File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 batchedVitalsSchema ,
66} from "@databuddy/validation" ;
77import {
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 ( {
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments