fix: always use currentDeviceId on client request to make sure they arrive in same group
This commit is contained in:
@@ -64,11 +64,11 @@ export async function postEvent(
|
|||||||
const isGroupQueue = await getRedisCache().exists('group_queue');
|
const isGroupQueue = await getRedisCache().exists('group_queue');
|
||||||
if (isGroupQueue) {
|
if (isGroupQueue) {
|
||||||
const uaInfo = parseUserAgent(ua, request.body?.properties);
|
const uaInfo = parseUserAgent(ua, request.body?.properties);
|
||||||
const groupId = request.body?.profileId
|
const groupId = uaInfo.isServer
|
||||||
? `${projectId}:${request.body?.profileId}`
|
? request.body?.profileId
|
||||||
: uaInfo.isServer
|
? `${projectId}:${request.body?.profileId}`
|
||||||
? `${projectId}:${generateId()}`
|
: `${projectId}:${generateId()}`
|
||||||
: currentDeviceId;
|
: currentDeviceId;
|
||||||
await eventsGroupQueue.add({
|
await eventsGroupQueue.add({
|
||||||
orderMs: new Date(timestamp).getTime(),
|
orderMs: new Date(timestamp).getTime(),
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { FastifyReply, FastifyRequest } from 'fastify';
|
|||||||
import { path, assocPath, pathOr, pick } from 'ramda';
|
import { path, assocPath, pathOr, pick } from 'ramda';
|
||||||
|
|
||||||
import { checkDuplicatedEvent } from '@/utils/deduplicate';
|
import { checkDuplicatedEvent } from '@/utils/deduplicate';
|
||||||
|
import { logger } from '@/utils/logger';
|
||||||
import { generateId } from '@openpanel/common';
|
import { generateId } from '@openpanel/common';
|
||||||
import { generateDeviceId, parseUserAgent } from '@openpanel/common/server';
|
import { generateDeviceId, parseUserAgent } from '@openpanel/common/server';
|
||||||
import { getProfileById, getSalts, upsertProfile } from '@openpanel/db';
|
import { getProfileById, getSalts, upsertProfile } from '@openpanel/db';
|
||||||
@@ -284,11 +285,11 @@ async function track({
|
|||||||
const isGroupQueue = await getRedisCache().exists('group_queue');
|
const isGroupQueue = await getRedisCache().exists('group_queue');
|
||||||
if (isGroupQueue) {
|
if (isGroupQueue) {
|
||||||
const uaInfo = parseUserAgent(headers['user-agent'], payload.properties);
|
const uaInfo = parseUserAgent(headers['user-agent'], payload.properties);
|
||||||
const groupId = payload.profileId
|
const groupId = uaInfo.isServer
|
||||||
? `${projectId}:${payload.profileId}`
|
? payload.profileId
|
||||||
: uaInfo.isServer
|
? `${projectId}:${payload.profileId}`
|
||||||
? `${projectId}:${generateId()}`
|
: `${projectId}:${generateId()}`
|
||||||
: currentDeviceId;
|
: currentDeviceId;
|
||||||
await eventsGroupQueue.add({
|
await eventsGroupQueue.add({
|
||||||
orderMs: new Date(timestamp).getTime(),
|
orderMs: new Date(timestamp).getTime(),
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
Reference in New Issue
Block a user