Skip to content

Commit 4650452

Browse files
committed
fix
1 parent f4b1f3b commit 4650452

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

apps/api/src/controllers/track.controller.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -334,21 +334,29 @@ async function handleGroup(
334334
const { id, type, name, properties = {} } = payload;
335335
const profileId = payload.profileId ?? context.deviceId;
336336

337-
await Promise.all([
337+
const promises: Promise<unknown>[] = [];
338+
promises.push(
338339
groupBuffer.add({
339340
id,
340341
projectId: context.projectId,
341342
type,
342343
name,
343344
properties,
344-
}),
345-
upsertProfile({
346-
id: profileId,
347-
projectId: context.projectId,
348-
isExternal: !!(payload.profileId ?? context.identity?.profileId),
349-
groups: [id],
350-
}),
351-
]);
345+
})
346+
);
347+
348+
if (profileId) {
349+
promises.push(
350+
upsertProfile({
351+
id: String(profileId),
352+
projectId: context.projectId,
353+
isExternal: !!(payload.profileId ?? context.identity?.profileId),
354+
groups: [id],
355+
})
356+
);
357+
}
358+
359+
await Promise.all(promises);
352360
}
353361

354362
export async function handler(

0 commit comments

Comments
 (0)