@bentolabs/sdk 0.2.0 → 0.3.0
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/index.d.ts +6 -0
- package/dist/index.js +20 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -86,6 +86,12 @@ export declare class BentoLabsSDK {
|
|
|
86
86
|
* Manually trigger a batch send
|
|
87
87
|
*/
|
|
88
88
|
flushEvents(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Track a custom event with custom data
|
|
91
|
+
* @param eventName - Name of the custom event
|
|
92
|
+
* @param data - Custom event data (will be JSON stringified)
|
|
93
|
+
*/
|
|
94
|
+
trackCustomEvent(eventName: string, data?: Record<string, any>): void;
|
|
89
95
|
}
|
|
90
96
|
declare const _default: BentoLabsSDK;
|
|
91
97
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -329,6 +329,26 @@ class BentoLabsSDK {
|
|
|
329
329
|
async flushEvents() {
|
|
330
330
|
await this.sendBatch();
|
|
331
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Track a custom event with custom data
|
|
334
|
+
* @param eventName - Name of the custom event
|
|
335
|
+
* @param data - Custom event data (will be JSON stringified)
|
|
336
|
+
*/
|
|
337
|
+
trackCustomEvent(eventName, data) {
|
|
338
|
+
if (!this.sessionId) {
|
|
339
|
+
console.warn('[BentoLabsSDK] Cannot track event: SDK not initialized');
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
this.addEvent({
|
|
343
|
+
timestamp: Date.now(),
|
|
344
|
+
type: `custom:${eventName}`,
|
|
345
|
+
data: data || {},
|
|
346
|
+
sessionId: this.sessionId,
|
|
347
|
+
});
|
|
348
|
+
if (this.config.debug) {
|
|
349
|
+
console.log(`[BentoLabsSDK] Custom event tracked: ${eventName}`, data);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
332
352
|
}
|
|
333
353
|
exports.BentoLabsSDK = BentoLabsSDK;
|
|
334
354
|
// Export a default instance for convenience
|