Skip to content

Commit cfdaadb

Browse files
committed
fix: backwards compatibility
1 parent b5b936a commit cfdaadb

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

apps/basket/src/routes/basket.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
batchedVitalsSchema,
66
} from "@databuddy/validation";
77
import {
8-
insertCustomEventSpans,
8+
insertCustomEvents,
99
insertErrorSpans,
1010
insertIndividualVitals,
1111
insertOutgoingLink,
@@ -325,7 +325,20 @@ const app = new Elysia()
325325
return validation.error;
326326
}
327327

328-
const { clientId, userAgent } = validation;
328+
const { clientId, userAgent, ownerId } = validation;
329+
330+
if (!ownerId) {
331+
return new Response(
332+
JSON.stringify({
333+
status: "error",
334+
message: "Website missing organization",
335+
}),
336+
{
337+
status: 400,
338+
headers: { "Content-Type": "application/json" },
339+
}
340+
);
341+
}
329342

330343
const parseResult = batchedCustomEventSpansSchema.safeParse(body);
331344

@@ -344,7 +357,17 @@ const app = new Elysia()
344357
return botError.error;
345358
}
346359

347-
await insertCustomEventSpans(parseResult.data, clientId);
360+
const events = parseResult.data.map((event) => ({
361+
owner_id: ownerId,
362+
website_id: clientId,
363+
timestamp: event.timestamp,
364+
event_name: event.eventName,
365+
properties: event.properties as Record<string, unknown> | undefined,
366+
anonymous_id: event.anonymousId ?? undefined,
367+
session_id: event.sessionId ?? undefined,
368+
}));
369+
370+
await insertCustomEvents(events);
348371

349372
return new Response(
350373
JSON.stringify({

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@databuddy/sdk",
3-
"version": "2.3.28",
3+
"version": "2.3.29",
44
"description": "Official Databuddy Analytics SDK",
55
"main": "./dist/core/index.mjs",
66
"types": "./dist/core/index.d.ts",

0 commit comments

Comments
 (0)