alphana-sdk 1.8.0 → 2.0.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.
@@ -64,15 +64,11 @@ interface TrackerConfig {
64
64
  */
65
65
  trackLogs?: boolean;
66
66
  /**
67
- * List of page paths for which heatmap data should be captured client-side.
68
- * Paths should match the dashboard "Heatmap pages" list (decoded Unicode is
69
- * fine the SDK normalizes percent-encoding vs `window.location` mismatches).
70
- *
71
- * If empty or undefined, the SDK may still collect moves locally, but the
72
- * backend only persists points when the app has at least one registered
73
- * heatmap page and the path matches.
74
- *
75
- * Example: `heatmapPages: ["/", "/pricing", "/dashboard"]`
67
+ * @deprecated Optional client-side path filter only. Heatmap pages are
68
+ * registered in the Alphana dashboard; the backend persists points only for
69
+ * those paths. Leave unset so the SDK collects on every page and the server
70
+ * filters — no SDK configuration is required when you add a page in the
71
+ * dashboard.
76
72
  */
77
73
  heatmapPages?: string[];
78
74
  /**
@@ -100,6 +96,12 @@ interface TrackerConfig {
100
96
  sessionReplayMaskTextClass?: string;
101
97
  /** CSS class name for DOM subtrees that rrweb should not capture. */
102
98
  sessionReplayBlockClass?: string;
99
+ /**
100
+ * Cookie consent mode.
101
+ * - `auto` (default): honor the dashboard cookie-consent widget when enabled.
102
+ * - `disabled`: never show the consent banner; track immediately.
103
+ */
104
+ consentMode?: "auto" | "disabled";
103
105
  /** Called synchronously for every emitted event. */
104
106
  onEvent?: (event: TrackerEvent) => void;
105
107
  }
@@ -162,11 +164,23 @@ interface HeatmapPoint {
162
164
  pw?: number;
163
165
  /** Page scrollHeight at the time of the event (used for accurate remapping) */
164
166
  ph?: number;
167
+ /** Viewport (innerWidth) at capture time — disambiguates responsive layouts. */
168
+ vw?: number;
165
169
  type: "move" | "click" | "scroll";
166
170
  path: string;
167
171
  timestamp: number;
168
172
  /** Text/label of the clicked element — only present on click events. */
169
173
  target?: string;
174
+ /**
175
+ * Stable CSS selector of the anchored element (clicks only). Lets the
176
+ * dashboard place the point relative to the element in the screenshot, so it
177
+ * stays accurate even when the visitor's layout differed from the capture.
178
+ */
179
+ selector?: string;
180
+ /** Click X as a fraction (0–1) of the anchored element's width (clicks only). */
181
+ relX?: number;
182
+ /** Click Y as a fraction (0–1) of the anchored element's height (clicks only). */
183
+ relY?: number;
170
184
  }
171
185
  interface RageClick {
172
186
  path: string;
@@ -429,6 +443,10 @@ declare class UserTracker {
429
443
  /** Public so consumers can call logCapture.capture() for manual log entries. */
430
444
  logCapture?: LogCapture;
431
445
  private initialized;
446
+ private trackingAllowed;
447
+ private trackingBlocked;
448
+ private visitorPersisted;
449
+ private elementBindings?;
432
450
  private readonly subscribers;
433
451
  /** In-memory queue of events waiting to be flushed. */
434
452
  private queue;
@@ -446,8 +464,17 @@ declare class UserTracker {
446
464
  * Attach event listeners and start tracking.
447
465
  * Safe to call during SSR — returns `this` immediately if `window` is
448
466
  * undefined so it can be chained: `const tracker = new UserTracker(cfg).init()`.
467
+ *
468
+ * When the dashboard cookie-consent widget is enabled, tracking waits until
469
+ * the visitor accepts (or resumes a prior decision for the same config version).
449
470
  */
450
471
  init(): this;
472
+ private bootstrapRuntime;
473
+ private applyElementBindings;
474
+ private persistVisitorIfNeeded;
475
+ /** Start plugins, network flush, and element listeners after consent is OK. */
476
+ private startTracking;
477
+ private blockTracking;
451
478
  /** Remove all event listeners, flush remaining queue, and reset state. */
452
479
  destroy(): void;
453
480
  private handleVisibilityChange;
@@ -567,6 +594,7 @@ declare class UserTracker {
567
594
  /** Heatmap points for all tracked paths. */
568
595
  getHeatmapData(): Record<string, HeatmapPoint[]>;
569
596
  private get collectUrl();
597
+ private fetchRuntimeConfig;
570
598
  private currentPath;
571
599
  /**
572
600
  * Immediately drain the event queue and POST pending events to `/batch`.
@@ -64,15 +64,11 @@ interface TrackerConfig {
64
64
  */
65
65
  trackLogs?: boolean;
66
66
  /**
67
- * List of page paths for which heatmap data should be captured client-side.
68
- * Paths should match the dashboard "Heatmap pages" list (decoded Unicode is
69
- * fine the SDK normalizes percent-encoding vs `window.location` mismatches).
70
- *
71
- * If empty or undefined, the SDK may still collect moves locally, but the
72
- * backend only persists points when the app has at least one registered
73
- * heatmap page and the path matches.
74
- *
75
- * Example: `heatmapPages: ["/", "/pricing", "/dashboard"]`
67
+ * @deprecated Optional client-side path filter only. Heatmap pages are
68
+ * registered in the Alphana dashboard; the backend persists points only for
69
+ * those paths. Leave unset so the SDK collects on every page and the server
70
+ * filters — no SDK configuration is required when you add a page in the
71
+ * dashboard.
76
72
  */
77
73
  heatmapPages?: string[];
78
74
  /**
@@ -100,6 +96,12 @@ interface TrackerConfig {
100
96
  sessionReplayMaskTextClass?: string;
101
97
  /** CSS class name for DOM subtrees that rrweb should not capture. */
102
98
  sessionReplayBlockClass?: string;
99
+ /**
100
+ * Cookie consent mode.
101
+ * - `auto` (default): honor the dashboard cookie-consent widget when enabled.
102
+ * - `disabled`: never show the consent banner; track immediately.
103
+ */
104
+ consentMode?: "auto" | "disabled";
103
105
  /** Called synchronously for every emitted event. */
104
106
  onEvent?: (event: TrackerEvent) => void;
105
107
  }
@@ -162,11 +164,23 @@ interface HeatmapPoint {
162
164
  pw?: number;
163
165
  /** Page scrollHeight at the time of the event (used for accurate remapping) */
164
166
  ph?: number;
167
+ /** Viewport (innerWidth) at capture time — disambiguates responsive layouts. */
168
+ vw?: number;
165
169
  type: "move" | "click" | "scroll";
166
170
  path: string;
167
171
  timestamp: number;
168
172
  /** Text/label of the clicked element — only present on click events. */
169
173
  target?: string;
174
+ /**
175
+ * Stable CSS selector of the anchored element (clicks only). Lets the
176
+ * dashboard place the point relative to the element in the screenshot, so it
177
+ * stays accurate even when the visitor's layout differed from the capture.
178
+ */
179
+ selector?: string;
180
+ /** Click X as a fraction (0–1) of the anchored element's width (clicks only). */
181
+ relX?: number;
182
+ /** Click Y as a fraction (0–1) of the anchored element's height (clicks only). */
183
+ relY?: number;
170
184
  }
171
185
  interface RageClick {
172
186
  path: string;
@@ -429,6 +443,10 @@ declare class UserTracker {
429
443
  /** Public so consumers can call logCapture.capture() for manual log entries. */
430
444
  logCapture?: LogCapture;
431
445
  private initialized;
446
+ private trackingAllowed;
447
+ private trackingBlocked;
448
+ private visitorPersisted;
449
+ private elementBindings?;
432
450
  private readonly subscribers;
433
451
  /** In-memory queue of events waiting to be flushed. */
434
452
  private queue;
@@ -446,8 +464,17 @@ declare class UserTracker {
446
464
  * Attach event listeners and start tracking.
447
465
  * Safe to call during SSR — returns `this` immediately if `window` is
448
466
  * undefined so it can be chained: `const tracker = new UserTracker(cfg).init()`.
467
+ *
468
+ * When the dashboard cookie-consent widget is enabled, tracking waits until
469
+ * the visitor accepts (or resumes a prior decision for the same config version).
449
470
  */
450
471
  init(): this;
472
+ private bootstrapRuntime;
473
+ private applyElementBindings;
474
+ private persistVisitorIfNeeded;
475
+ /** Start plugins, network flush, and element listeners after consent is OK. */
476
+ private startTracking;
477
+ private blockTracking;
451
478
  /** Remove all event listeners, flush remaining queue, and reset state. */
452
479
  destroy(): void;
453
480
  private handleVisibilityChange;
@@ -567,6 +594,7 @@ declare class UserTracker {
567
594
  /** Heatmap points for all tracked paths. */
568
595
  getHeatmapData(): Record<string, HeatmapPoint[]>;
569
596
  private get collectUrl();
597
+ private fetchRuntimeConfig;
570
598
  private currentPath;
571
599
  /**
572
600
  * Immediately drain the event queue and POST pending events to `/batch`.