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.
package/dist/index.d.mts CHANGED
@@ -61,15 +61,11 @@ interface TrackerConfig {
61
61
  */
62
62
  trackLogs?: boolean;
63
63
  /**
64
- * List of page paths for which heatmap data should be captured client-side.
65
- * Paths should match the dashboard "Heatmap pages" list (decoded Unicode is
66
- * fine the SDK normalizes percent-encoding vs `window.location` mismatches).
67
- *
68
- * If empty or undefined, the SDK may still collect moves locally, but the
69
- * backend only persists points when the app has at least one registered
70
- * heatmap page and the path matches.
71
- *
72
- * Example: `heatmapPages: ["/", "/pricing", "/dashboard"]`
64
+ * @deprecated Optional client-side path filter only. Heatmap pages are
65
+ * registered in the Alphana dashboard; the backend persists points only for
66
+ * those paths. Leave unset so the SDK collects on every page and the server
67
+ * filters — no SDK configuration is required when you add a page in the
68
+ * dashboard.
73
69
  */
74
70
  heatmapPages?: string[];
75
71
  /**
@@ -97,6 +93,12 @@ interface TrackerConfig {
97
93
  sessionReplayMaskTextClass?: string;
98
94
  /** CSS class name for DOM subtrees that rrweb should not capture. */
99
95
  sessionReplayBlockClass?: string;
96
+ /**
97
+ * Cookie consent mode.
98
+ * - `auto` (default): honor the dashboard cookie-consent widget when enabled.
99
+ * - `disabled`: never show the consent banner; track immediately.
100
+ */
101
+ consentMode?: "auto" | "disabled";
100
102
  /** Called synchronously for every emitted event. */
101
103
  onEvent?: (event: TrackerEvent) => void;
102
104
  }
@@ -159,11 +161,23 @@ interface HeatmapPoint {
159
161
  pw?: number;
160
162
  /** Page scrollHeight at the time of the event (used for accurate remapping) */
161
163
  ph?: number;
164
+ /** Viewport (innerWidth) at capture time — disambiguates responsive layouts. */
165
+ vw?: number;
162
166
  type: "move" | "click" | "scroll";
163
167
  path: string;
164
168
  timestamp: number;
165
169
  /** Text/label of the clicked element — only present on click events. */
166
170
  target?: string;
171
+ /**
172
+ * Stable CSS selector of the anchored element (clicks only). Lets the
173
+ * dashboard place the point relative to the element in the screenshot, so it
174
+ * stays accurate even when the visitor's layout differed from the capture.
175
+ */
176
+ selector?: string;
177
+ /** Click X as a fraction (0–1) of the anchored element's width (clicks only). */
178
+ relX?: number;
179
+ /** Click Y as a fraction (0–1) of the anchored element's height (clicks only). */
180
+ relY?: number;
167
181
  }
168
182
  interface RageClick {
169
183
  path: string;
@@ -423,6 +437,10 @@ declare class UserTracker {
423
437
  /** Public so consumers can call logCapture.capture() for manual log entries. */
424
438
  logCapture?: LogCapture;
425
439
  private initialized;
440
+ private trackingAllowed;
441
+ private trackingBlocked;
442
+ private visitorPersisted;
443
+ private elementBindings?;
426
444
  private readonly subscribers;
427
445
  /** In-memory queue of events waiting to be flushed. */
428
446
  private queue;
@@ -440,8 +458,17 @@ declare class UserTracker {
440
458
  * Attach event listeners and start tracking.
441
459
  * Safe to call during SSR — returns `this` immediately if `window` is
442
460
  * undefined so it can be chained: `const tracker = new UserTracker(cfg).init()`.
461
+ *
462
+ * When the dashboard cookie-consent widget is enabled, tracking waits until
463
+ * the visitor accepts (or resumes a prior decision for the same config version).
443
464
  */
444
465
  init(): this;
466
+ private bootstrapRuntime;
467
+ private applyElementBindings;
468
+ private persistVisitorIfNeeded;
469
+ /** Start plugins, network flush, and element listeners after consent is OK. */
470
+ private startTracking;
471
+ private blockTracking;
445
472
  /** Remove all event listeners, flush remaining queue, and reset state. */
446
473
  destroy(): void;
447
474
  private handleVisibilityChange;
@@ -561,6 +588,7 @@ declare class UserTracker {
561
588
  /** Heatmap points for all tracked paths. */
562
589
  getHeatmapData(): Record<string, HeatmapPoint[]>;
563
590
  private get collectUrl();
591
+ private fetchRuntimeConfig;
564
592
  private currentPath;
565
593
  /**
566
594
  * Immediately drain the event queue and POST pending events to `/batch`.
@@ -598,7 +626,7 @@ declare class UserTracker {
598
626
  */
599
627
  declare function renderHeatmap(canvas: HTMLCanvasElement, points: HeatmapPoint[], options?: HeatmapRenderOptions): void;
600
628
 
601
- declare const ALPHANA_SDK_VERSION = "1.0.2";
629
+ declare const ALPHANA_SDK_VERSION = "2.0.2";
602
630
 
603
631
  /**
604
632
  * Canonical URL path (+ optional query) for analytics / heatmap matching.
package/dist/index.d.ts CHANGED
@@ -61,15 +61,11 @@ interface TrackerConfig {
61
61
  */
62
62
  trackLogs?: boolean;
63
63
  /**
64
- * List of page paths for which heatmap data should be captured client-side.
65
- * Paths should match the dashboard "Heatmap pages" list (decoded Unicode is
66
- * fine the SDK normalizes percent-encoding vs `window.location` mismatches).
67
- *
68
- * If empty or undefined, the SDK may still collect moves locally, but the
69
- * backend only persists points when the app has at least one registered
70
- * heatmap page and the path matches.
71
- *
72
- * Example: `heatmapPages: ["/", "/pricing", "/dashboard"]`
64
+ * @deprecated Optional client-side path filter only. Heatmap pages are
65
+ * registered in the Alphana dashboard; the backend persists points only for
66
+ * those paths. Leave unset so the SDK collects on every page and the server
67
+ * filters — no SDK configuration is required when you add a page in the
68
+ * dashboard.
73
69
  */
74
70
  heatmapPages?: string[];
75
71
  /**
@@ -97,6 +93,12 @@ interface TrackerConfig {
97
93
  sessionReplayMaskTextClass?: string;
98
94
  /** CSS class name for DOM subtrees that rrweb should not capture. */
99
95
  sessionReplayBlockClass?: string;
96
+ /**
97
+ * Cookie consent mode.
98
+ * - `auto` (default): honor the dashboard cookie-consent widget when enabled.
99
+ * - `disabled`: never show the consent banner; track immediately.
100
+ */
101
+ consentMode?: "auto" | "disabled";
100
102
  /** Called synchronously for every emitted event. */
101
103
  onEvent?: (event: TrackerEvent) => void;
102
104
  }
@@ -159,11 +161,23 @@ interface HeatmapPoint {
159
161
  pw?: number;
160
162
  /** Page scrollHeight at the time of the event (used for accurate remapping) */
161
163
  ph?: number;
164
+ /** Viewport (innerWidth) at capture time — disambiguates responsive layouts. */
165
+ vw?: number;
162
166
  type: "move" | "click" | "scroll";
163
167
  path: string;
164
168
  timestamp: number;
165
169
  /** Text/label of the clicked element — only present on click events. */
166
170
  target?: string;
171
+ /**
172
+ * Stable CSS selector of the anchored element (clicks only). Lets the
173
+ * dashboard place the point relative to the element in the screenshot, so it
174
+ * stays accurate even when the visitor's layout differed from the capture.
175
+ */
176
+ selector?: string;
177
+ /** Click X as a fraction (0–1) of the anchored element's width (clicks only). */
178
+ relX?: number;
179
+ /** Click Y as a fraction (0–1) of the anchored element's height (clicks only). */
180
+ relY?: number;
167
181
  }
168
182
  interface RageClick {
169
183
  path: string;
@@ -423,6 +437,10 @@ declare class UserTracker {
423
437
  /** Public so consumers can call logCapture.capture() for manual log entries. */
424
438
  logCapture?: LogCapture;
425
439
  private initialized;
440
+ private trackingAllowed;
441
+ private trackingBlocked;
442
+ private visitorPersisted;
443
+ private elementBindings?;
426
444
  private readonly subscribers;
427
445
  /** In-memory queue of events waiting to be flushed. */
428
446
  private queue;
@@ -440,8 +458,17 @@ declare class UserTracker {
440
458
  * Attach event listeners and start tracking.
441
459
  * Safe to call during SSR — returns `this` immediately if `window` is
442
460
  * undefined so it can be chained: `const tracker = new UserTracker(cfg).init()`.
461
+ *
462
+ * When the dashboard cookie-consent widget is enabled, tracking waits until
463
+ * the visitor accepts (or resumes a prior decision for the same config version).
443
464
  */
444
465
  init(): this;
466
+ private bootstrapRuntime;
467
+ private applyElementBindings;
468
+ private persistVisitorIfNeeded;
469
+ /** Start plugins, network flush, and element listeners after consent is OK. */
470
+ private startTracking;
471
+ private blockTracking;
445
472
  /** Remove all event listeners, flush remaining queue, and reset state. */
446
473
  destroy(): void;
447
474
  private handleVisibilityChange;
@@ -561,6 +588,7 @@ declare class UserTracker {
561
588
  /** Heatmap points for all tracked paths. */
562
589
  getHeatmapData(): Record<string, HeatmapPoint[]>;
563
590
  private get collectUrl();
591
+ private fetchRuntimeConfig;
564
592
  private currentPath;
565
593
  /**
566
594
  * Immediately drain the event queue and POST pending events to `/batch`.
@@ -598,7 +626,7 @@ declare class UserTracker {
598
626
  */
599
627
  declare function renderHeatmap(canvas: HTMLCanvasElement, points: HeatmapPoint[], options?: HeatmapRenderOptions): void;
600
628
 
601
- declare const ALPHANA_SDK_VERSION = "1.0.2";
629
+ declare const ALPHANA_SDK_VERSION = "2.0.2";
602
630
 
603
631
  /**
604
632
  * Canonical URL path (+ optional query) for analytics / heatmap matching.