@databuddy/sdk 2.3.27 → 2.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.mjs +1 -1
- package/dist/node/index.d.mts +4 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.mjs +29 -11
- package/dist/react/index.mjs +1 -1
- package/dist/shared/@databuddy/{sdk.ClnhxS25.mjs → sdk.urY7MmVr.mjs} +1 -1
- package/dist/vue/index.mjs +1 -1
- package/package.json +1 -1
package/dist/core/index.mjs
CHANGED
package/dist/node/index.d.mts
CHANGED
|
@@ -234,6 +234,10 @@ declare class Databuddy {
|
|
|
234
234
|
* ```
|
|
235
235
|
*/
|
|
236
236
|
track(event: CustomEventInput): Promise<EventResponse>;
|
|
237
|
+
/**
|
|
238
|
+
* Convert BatchEventInput to CustomEventSpan format expected by /events endpoint
|
|
239
|
+
*/
|
|
240
|
+
private toCustomEventSpan;
|
|
237
241
|
private send;
|
|
238
242
|
private scheduleFlush;
|
|
239
243
|
/**
|
package/dist/node/index.d.ts
CHANGED
|
@@ -234,6 +234,10 @@ declare class Databuddy {
|
|
|
234
234
|
* ```
|
|
235
235
|
*/
|
|
236
236
|
track(event: CustomEventInput): Promise<EventResponse>;
|
|
237
|
+
/**
|
|
238
|
+
* Convert BatchEventInput to CustomEventSpan format expected by /events endpoint
|
|
239
|
+
*/
|
|
240
|
+
private toCustomEventSpan;
|
|
237
241
|
private send;
|
|
238
242
|
private scheduleFlush;
|
|
239
243
|
/**
|
package/dist/node/index.mjs
CHANGED
|
@@ -419,20 +419,35 @@ class Databuddy {
|
|
|
419
419
|
}
|
|
420
420
|
return { success: true };
|
|
421
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Convert BatchEventInput to CustomEventSpan format expected by /events endpoint
|
|
424
|
+
*/
|
|
425
|
+
toCustomEventSpan(event) {
|
|
426
|
+
const timestamp = event.timestamp ? Math.floor(event.timestamp) : Date.now();
|
|
427
|
+
return {
|
|
428
|
+
timestamp,
|
|
429
|
+
path: "",
|
|
430
|
+
eventName: event.name,
|
|
431
|
+
anonymousId: event.anonymousId ?? null,
|
|
432
|
+
sessionId: event.sessionId ?? null,
|
|
433
|
+
properties: event.properties ?? null
|
|
434
|
+
};
|
|
435
|
+
}
|
|
422
436
|
async send(event) {
|
|
423
437
|
try {
|
|
424
|
-
const url = `${this.apiUrl}
|
|
438
|
+
const url = `${this.apiUrl}/events?client_id=${encodeURIComponent(this.clientId)}`;
|
|
439
|
+
const customEventSpan = this.toCustomEventSpan(event);
|
|
425
440
|
this.logger.info("\u{1F4E4} SENDING SINGLE EVENT:", {
|
|
426
|
-
|
|
427
|
-
properties: JSON.stringify(
|
|
428
|
-
propertiesCount: Object.keys(
|
|
441
|
+
eventName: customEventSpan.eventName,
|
|
442
|
+
properties: JSON.stringify(customEventSpan.properties, null, 2),
|
|
443
|
+
propertiesCount: Object.keys(customEventSpan.properties || {}).length
|
|
429
444
|
});
|
|
430
445
|
const response = await fetch(url, {
|
|
431
446
|
method: "POST",
|
|
432
447
|
headers: {
|
|
433
448
|
"Content-Type": "application/json"
|
|
434
449
|
},
|
|
435
|
-
body: JSON.stringify(
|
|
450
|
+
body: JSON.stringify([customEventSpan])
|
|
436
451
|
});
|
|
437
452
|
if (!response.ok) {
|
|
438
453
|
const errorText = await response.text().catch(() => "Unknown error");
|
|
@@ -578,17 +593,20 @@ class Databuddy {
|
|
|
578
593
|
};
|
|
579
594
|
}
|
|
580
595
|
try {
|
|
581
|
-
const url = `${this.apiUrl}/
|
|
596
|
+
const url = `${this.apiUrl}/events?client_id=${encodeURIComponent(this.clientId)}`;
|
|
597
|
+
const customEventSpans = processedEvents.map(
|
|
598
|
+
(event) => this.toCustomEventSpan(event)
|
|
599
|
+
);
|
|
582
600
|
this.logger.info("\u{1F4E6} SENDING BATCH EVENTS:", {
|
|
583
|
-
count:
|
|
584
|
-
firstEventName:
|
|
601
|
+
count: customEventSpans.length,
|
|
602
|
+
firstEventName: customEventSpans[0]?.eventName,
|
|
585
603
|
firstEventProperties: JSON.stringify(
|
|
586
|
-
|
|
604
|
+
customEventSpans[0]?.properties,
|
|
587
605
|
null,
|
|
588
606
|
2
|
|
589
607
|
),
|
|
590
608
|
firstEventPropertiesCount: Object.keys(
|
|
591
|
-
|
|
609
|
+
customEventSpans[0]?.properties || {}
|
|
592
610
|
).length
|
|
593
611
|
});
|
|
594
612
|
const response = await fetch(url, {
|
|
@@ -596,7 +614,7 @@ class Databuddy {
|
|
|
596
614
|
headers: {
|
|
597
615
|
"Content-Type": "application/json"
|
|
598
616
|
},
|
|
599
|
-
body: JSON.stringify(
|
|
617
|
+
body: JSON.stringify(customEventSpans)
|
|
600
618
|
});
|
|
601
619
|
if (!response.ok) {
|
|
602
620
|
const errorText = await response.text().catch(() => "Unknown error");
|
package/dist/react/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { detectClientId } from '../core/index.mjs';
|
|
4
4
|
export { clear, flush, getAnonymousId, getSessionId, getTracker, getTrackingIds, getTrackingParams, isTrackerAvailable, track, trackError } from '../core/index.mjs';
|
|
5
|
-
import { i as isScriptInjected, c as createScript } from '../shared/@databuddy/sdk.
|
|
5
|
+
import { i as isScriptInjected, c as createScript } from '../shared/@databuddy/sdk.urY7MmVr.mjs';
|
|
6
6
|
import React, { useRef, useMemo, useEffect, useSyncExternalStore, createContext, useContext } from 'react';
|
|
7
7
|
import { B as BrowserFlagStorage, C as CoreFlagsManager } from '../shared/@databuddy/sdk.DE24-JrU.mjs';
|
|
8
8
|
import { l as logger } from '../shared/@databuddy/sdk.CALvx07o.mjs';
|
package/dist/vue/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, ref, onMounted, onUnmounted, watch, reactive, watchEffect, computed } from 'vue';
|
|
2
|
-
import { i as isScriptInjected, c as createScript } from '../shared/@databuddy/sdk.
|
|
2
|
+
import { i as isScriptInjected, c as createScript } from '../shared/@databuddy/sdk.urY7MmVr.mjs';
|
|
3
3
|
import { B as BrowserFlagStorage, C as CoreFlagsManager } from '../shared/@databuddy/sdk.DE24-JrU.mjs';
|
|
4
4
|
import '../shared/@databuddy/sdk.CALvx07o.mjs';
|
|
5
5
|
|