aurea-tracking-sdk 1.3.0 → 1.3.2

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.mts CHANGED
@@ -9,6 +9,7 @@ interface EventCategoryConfig {
9
9
  value?: number;
10
10
  description?: string;
11
11
  trackOnce?: boolean;
12
+ color?: string;
12
13
  }
13
14
  interface AureaConfig {
14
15
  apiKey: string;
@@ -202,6 +203,7 @@ declare class AureaSDK {
202
203
  value?: number;
203
204
  advanceTo?: FunnelStage;
204
205
  description?: string;
206
+ color?: string;
205
207
  }): void;
206
208
  /**
207
209
  * Get current event category statistics
@@ -258,6 +260,12 @@ declare class AureaSDK {
258
260
  * Track checkout abandoned (user left without completing)
259
261
  */
260
262
  checkoutAbandoned(reason?: string): void;
263
+ /**
264
+ * Manually end the current session
265
+ * Useful before page navigation (e.g., checkout redirect)
266
+ * Sends session_end event with active/idle time metrics
267
+ */
268
+ endSession(): Promise<void>;
261
269
  /**
262
270
  * Get time spent in a specific stage (in seconds)
263
271
  */
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ interface EventCategoryConfig {
9
9
  value?: number;
10
10
  description?: string;
11
11
  trackOnce?: boolean;
12
+ color?: string;
12
13
  }
13
14
  interface AureaConfig {
14
15
  apiKey: string;
@@ -202,6 +203,7 @@ declare class AureaSDK {
202
203
  value?: number;
203
204
  advanceTo?: FunnelStage;
204
205
  description?: string;
206
+ color?: string;
205
207
  }): void;
206
208
  /**
207
209
  * Get current event category statistics
@@ -258,6 +260,12 @@ declare class AureaSDK {
258
260
  * Track checkout abandoned (user left without completing)
259
261
  */
260
262
  checkoutAbandoned(reason?: string): void;
263
+ /**
264
+ * Manually end the current session
265
+ * Useful before page navigation (e.g., checkout redirect)
266
+ * Sends session_end event with active/idle time metrics
267
+ */
268
+ endSession(): Promise<void>;
261
269
  /**
262
270
  * Get time spent in a specific stage (in seconds)
263
271
  */
package/dist/index.js CHANGED
@@ -252,6 +252,7 @@ var AureaSDK = class {
252
252
  const value = options?.value ?? categoryConfig?.value ?? 50;
253
253
  const advanceTo = options?.advanceTo || categoryConfig?.advanceTo;
254
254
  const description = options?.description || categoryConfig?.description;
255
+ const color = options?.color || categoryConfig?.color;
255
256
  const trackOnce = categoryConfig?.trackOnce ?? false;
256
257
  if (trackOnce) {
257
258
  if (this.trackedOnceEvents.has(eventName)) {
@@ -276,6 +277,8 @@ var AureaSDK = class {
276
277
  _category: category,
277
278
  _value: value,
278
279
  _description: description,
280
+ _color: color,
281
+ // Custom color (e.g., 'fuchsia' or full Tailwind classes)
279
282
  _currentStage: this.currentStage,
280
283
  _categoryStats: Object.fromEntries(this.eventCategoryStats),
281
284
  _trackedOnce: trackOnce
@@ -539,6 +542,40 @@ var AureaSDK = class {
539
542
  console.log("[Aurea SDK] Checkout abandoned:", reason);
540
543
  }
541
544
  }
545
+ /**
546
+ * Manually end the current session
547
+ * Useful before page navigation (e.g., checkout redirect)
548
+ * Sends session_end event with active/idle time metrics
549
+ */
550
+ async endSession() {
551
+ if (typeof window === "undefined") return;
552
+ const now = Date.now();
553
+ if (this.isInCheckout && this.currentStage === "checkout") {
554
+ this.checkoutAbandoned("session_end");
555
+ }
556
+ if (this.isPageVisible) {
557
+ this.activeTime += now - this.lastActiveTimestamp;
558
+ }
559
+ const totalDuration = Math.floor((now - this.sessionStartTime) / 1e3);
560
+ const activeTimeSeconds = Math.floor(this.activeTime / 1e3);
561
+ const idleTimeSeconds = totalDuration - activeTimeSeconds;
562
+ const engagementRate = totalDuration > 0 ? activeTimeSeconds / totalDuration * 100 : 0;
563
+ await this.trackEvent("session_end", {
564
+ duration: totalDuration,
565
+ activeTime: activeTimeSeconds,
566
+ idleTime: idleTimeSeconds,
567
+ engagementRate
568
+ });
569
+ await this.flushEvents();
570
+ if (this.config.debug) {
571
+ console.log("[Aurea SDK] Session manually ended", {
572
+ duration: totalDuration,
573
+ activeTime: activeTimeSeconds,
574
+ idleTime: idleTimeSeconds,
575
+ engagementRate: `${engagementRate.toFixed(1)}%`
576
+ });
577
+ }
578
+ }
542
579
  /**
543
580
  * Get time spent in a specific stage (in seconds)
544
581
  */
package/dist/index.mjs CHANGED
@@ -223,6 +223,7 @@ var AureaSDK = class {
223
223
  const value = options?.value ?? categoryConfig?.value ?? 50;
224
224
  const advanceTo = options?.advanceTo || categoryConfig?.advanceTo;
225
225
  const description = options?.description || categoryConfig?.description;
226
+ const color = options?.color || categoryConfig?.color;
226
227
  const trackOnce = categoryConfig?.trackOnce ?? false;
227
228
  if (trackOnce) {
228
229
  if (this.trackedOnceEvents.has(eventName)) {
@@ -247,6 +248,8 @@ var AureaSDK = class {
247
248
  _category: category,
248
249
  _value: value,
249
250
  _description: description,
251
+ _color: color,
252
+ // Custom color (e.g., 'fuchsia' or full Tailwind classes)
250
253
  _currentStage: this.currentStage,
251
254
  _categoryStats: Object.fromEntries(this.eventCategoryStats),
252
255
  _trackedOnce: trackOnce
@@ -510,6 +513,40 @@ var AureaSDK = class {
510
513
  console.log("[Aurea SDK] Checkout abandoned:", reason);
511
514
  }
512
515
  }
516
+ /**
517
+ * Manually end the current session
518
+ * Useful before page navigation (e.g., checkout redirect)
519
+ * Sends session_end event with active/idle time metrics
520
+ */
521
+ async endSession() {
522
+ if (typeof window === "undefined") return;
523
+ const now = Date.now();
524
+ if (this.isInCheckout && this.currentStage === "checkout") {
525
+ this.checkoutAbandoned("session_end");
526
+ }
527
+ if (this.isPageVisible) {
528
+ this.activeTime += now - this.lastActiveTimestamp;
529
+ }
530
+ const totalDuration = Math.floor((now - this.sessionStartTime) / 1e3);
531
+ const activeTimeSeconds = Math.floor(this.activeTime / 1e3);
532
+ const idleTimeSeconds = totalDuration - activeTimeSeconds;
533
+ const engagementRate = totalDuration > 0 ? activeTimeSeconds / totalDuration * 100 : 0;
534
+ await this.trackEvent("session_end", {
535
+ duration: totalDuration,
536
+ activeTime: activeTimeSeconds,
537
+ idleTime: idleTimeSeconds,
538
+ engagementRate
539
+ });
540
+ await this.flushEvents();
541
+ if (this.config.debug) {
542
+ console.log("[Aurea SDK] Session manually ended", {
543
+ duration: totalDuration,
544
+ activeTime: activeTimeSeconds,
545
+ idleTime: idleTimeSeconds,
546
+ engagementRate: `${engagementRate.toFixed(1)}%`
547
+ });
548
+ }
549
+ }
513
550
  /**
514
551
  * Get time spent in a specific stage (in seconds)
515
552
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aurea-tracking-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Standalone tracking SDK for Aurea CRM external funnels",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",