OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
minor fixes in event.controller
Carl-Gerhard Lindesvärdfb5a0624a044
diff --git a/apps/sdk-api/src/controllers/event.controller.ts b/apps/sdk-api/src/controllers/event.controller.tsindex 9677a6b49..513e7f7ff 100644--- a/apps/sdk-api/src/controllers/event.controller.ts+++ b/apps/sdk-api/src/controllers/event.controller.ts@@ -72,7 +72,14 @@ export async function postEvent(const { projectId, body } = request;const properties = body.properties ?? {};const getProperty = (name: string): string | undefined => {- return (properties[name] as string | null | undefined) ?? undefined;+ // replace thing is just for older sdks when we didn't have `__`+ // remove when kiddokitchen app (24.09.02) is not used anymore+ return (+ ((properties[name] || properties[name.replace('__', '')]) as+ | string+ | null+ | undefined) ?? undefined+ );};const profileId = body.profileId ?? '';const createdAt = new Date(body.timestamp);@@ -93,7 +100,7 @@ export async function postEvent(ip,ua,});- const previousProfileId = generateDeviceId({+ const previousDeviceId = generateDeviceId({salt: salts.previous,origin,ip,@@ -174,7 +181,7 @@ export async function postEvent();const sessionEndJobPreviousDeviceId = findJobByPrefix(eventsJobs,- `sessionEnd:${projectId}:${previousProfileId}:`+ `sessionEnd:${projectId}:${previousDeviceId}:`);const createSessionStart =@@ -187,7 +194,7 @@ export async function postEvent(sessionEndJobCurrentDeviceId.changeDelay(diff + SESSION_END_TIMEOUT);} else if (!sessionEndJobCurrentDeviceId && sessionEndJobPreviousDeviceId) {console.log('found session previous');- deviceId = previousProfileId;+ deviceId = previousDeviceId;const diff = Date.now() - sessionEndJobPreviousDeviceId.timestamp;sessionEndJobPreviousDeviceId.changeDelay(diff + SESSION_END_TIMEOUT);} else {