From e6d0b6544b74df0c0bd28cbfd159a307b68c1bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Fri, 6 Mar 2026 14:25:14 +0100 Subject: [PATCH] fix --- apps/api/src/controllers/track.controller.ts | 26 +++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/apps/api/src/controllers/track.controller.ts b/apps/api/src/controllers/track.controller.ts index 12e38a69..e1e1161d 100644 --- a/apps/api/src/controllers/track.controller.ts +++ b/apps/api/src/controllers/track.controller.ts @@ -343,21 +343,29 @@ async function handleGroup( const { id, type, name, properties = {} } = payload; const profileId = payload.profileId ?? context.deviceId; - await Promise.all([ + const promises: Promise[] = []; + promises.push( groupBuffer.add({ id, projectId: context.projectId, type, name, properties, - }), - upsertProfile({ - id: profileId, - projectId: context.projectId, - isExternal: !!(payload.profileId ?? context.identity?.profileId), - groups: [id], - }), - ]); + }) + ); + + if (profileId) { + promises.push( + upsertProfile({ + id: String(profileId), + projectId: context.projectId, + isExternal: !!(payload.profileId ?? context.identity?.profileId), + groups: [id], + }) + ); + } + + await Promise.all(promises); } export async function handler(