aurea-tracking-sdk 1.3.0 → 1.3.1

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
@@ -258,6 +258,12 @@ declare class AureaSDK {
258
258
  * Track checkout abandoned (user left without completing)
259
259
  */
260
260
  checkoutAbandoned(reason?: string): void;
261
+ /**
262
+ * Manually end the current session
263
+ * Useful before page navigation (e.g., checkout redirect)
264
+ * Sends session_end event with active/idle time metrics
265
+ */
266
+ endSession(): Promise<void>;
261
267
  /**
262
268
  * Get time spent in a specific stage (in seconds)
263
269
  */
package/dist/index.d.ts CHANGED
@@ -258,6 +258,12 @@ declare class AureaSDK {
258
258
  * Track checkout abandoned (user left without completing)
259
259
  */
260
260
  checkoutAbandoned(reason?: string): void;
261
+ /**
262
+ * Manually end the current session
263
+ * Useful before page navigation (e.g., checkout redirect)
264
+ * Sends session_end event with active/idle time metrics
265
+ */
266
+ endSession(): Promise<void>;
261
267
  /**
262
268
  * Get time spent in a specific stage (in seconds)
263
269
  */
package/dist/index.js CHANGED
@@ -539,6 +539,40 @@ var AureaSDK = class {
539
539
  console.log("[Aurea SDK] Checkout abandoned:", reason);
540
540
  }
541
541
  }
542
+ /**
543
+ * Manually end the current session
544
+ * Useful before page navigation (e.g., checkout redirect)
545
+ * Sends session_end event with active/idle time metrics
546
+ */
547
+ async endSession() {
548
+ if (typeof window === "undefined") return;
549
+ const now = Date.now();
550
+ if (this.isInCheckout && this.currentStage === "checkout") {
551
+ this.checkoutAbandoned("session_end");
552
+ }
553
+ if (this.isPageVisible) {
554
+ this.activeTime += now - this.lastActiveTimestamp;
555
+ }
556
+ const totalDuration = Math.floor((now - this.sessionStartTime) / 1e3);
557
+ const activeTimeSeconds = Math.floor(this.activeTime / 1e3);
558
+ const idleTimeSeconds = totalDuration - activeTimeSeconds;
559
+ const engagementRate = totalDuration > 0 ? activeTimeSeconds / totalDuration * 100 : 0;
560
+ await this.trackEvent("session_end", {
561
+ duration: totalDuration,
562
+ activeTime: activeTimeSeconds,
563
+ idleTime: idleTimeSeconds,
564
+ engagementRate
565
+ });
566
+ await this.flushEvents();
567
+ if (this.config.debug) {
568
+ console.log("[Aurea SDK] Session manually ended", {
569
+ duration: totalDuration,
570
+ activeTime: activeTimeSeconds,
571
+ idleTime: idleTimeSeconds,
572
+ engagementRate: `${engagementRate.toFixed(1)}%`
573
+ });
574
+ }
575
+ }
542
576
  /**
543
577
  * Get time spent in a specific stage (in seconds)
544
578
  */
package/dist/index.mjs CHANGED
@@ -510,6 +510,40 @@ var AureaSDK = class {
510
510
  console.log("[Aurea SDK] Checkout abandoned:", reason);
511
511
  }
512
512
  }
513
+ /**
514
+ * Manually end the current session
515
+ * Useful before page navigation (e.g., checkout redirect)
516
+ * Sends session_end event with active/idle time metrics
517
+ */
518
+ async endSession() {
519
+ if (typeof window === "undefined") return;
520
+ const now = Date.now();
521
+ if (this.isInCheckout && this.currentStage === "checkout") {
522
+ this.checkoutAbandoned("session_end");
523
+ }
524
+ if (this.isPageVisible) {
525
+ this.activeTime += now - this.lastActiveTimestamp;
526
+ }
527
+ const totalDuration = Math.floor((now - this.sessionStartTime) / 1e3);
528
+ const activeTimeSeconds = Math.floor(this.activeTime / 1e3);
529
+ const idleTimeSeconds = totalDuration - activeTimeSeconds;
530
+ const engagementRate = totalDuration > 0 ? activeTimeSeconds / totalDuration * 100 : 0;
531
+ await this.trackEvent("session_end", {
532
+ duration: totalDuration,
533
+ activeTime: activeTimeSeconds,
534
+ idleTime: idleTimeSeconds,
535
+ engagementRate
536
+ });
537
+ await this.flushEvents();
538
+ if (this.config.debug) {
539
+ console.log("[Aurea SDK] Session manually ended", {
540
+ duration: totalDuration,
541
+ activeTime: activeTimeSeconds,
542
+ idleTime: idleTimeSeconds,
543
+ engagementRate: `${engagementRate.toFixed(1)}%`
544
+ });
545
+ }
546
+ }
513
547
  /**
514
548
  * Get time spent in a specific stage (in seconds)
515
549
  */
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.1",
4
4
  "description": "Standalone tracking SDK for Aurea CRM external funnels",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",