fix: set random groupId if events from a server without a profile id
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import { getClientIp } from '@/utils/get-client-ip';
|
||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||
|
||||
import { generateDeviceId } from '@openpanel/common/server';
|
||||
import { generateDeviceId, parseUserAgent } from '@openpanel/common/server';
|
||||
import { getSalts } from '@openpanel/db';
|
||||
import { eventsGroupQueue, eventsQueue } from '@openpanel/queue';
|
||||
import { getLock, getRedisCache } from '@openpanel/redis';
|
||||
import type { PostEventPayload } from '@openpanel/sdk';
|
||||
|
||||
import { checkDuplicatedEvent } from '@/utils/deduplicate';
|
||||
import { generateId } from '@openpanel/common';
|
||||
import { getGeoLocation } from '@openpanel/geo';
|
||||
import { getStringHeaders, getTimestamp } from './track.controller';
|
||||
|
||||
@@ -62,9 +63,12 @@ export async function postEvent(
|
||||
|
||||
const isGroupQueue = await getRedisCache().exists('group_queue');
|
||||
if (isGroupQueue) {
|
||||
const uaInfo = parseUserAgent(ua, request.body?.properties);
|
||||
const groupId = request.body?.profileId
|
||||
? `${projectId}:${request.body?.profileId}`
|
||||
: currentDeviceId;
|
||||
: uaInfo.isServer
|
||||
? `${projectId}:${generateId()}`
|
||||
: currentDeviceId;
|
||||
await eventsGroupQueue.add({
|
||||
orderMs: new Date(timestamp).getTime(),
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user