clarity-js 0.8.12 → 0.8.14

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.
Files changed (92) hide show
  1. package/build/clarity.extended.js +1 -1
  2. package/build/clarity.insight.js +1 -1
  3. package/build/clarity.js +4609 -4762
  4. package/build/clarity.min.js +1 -1
  5. package/build/clarity.module.js +4609 -4762
  6. package/build/clarity.performance.js +1 -1
  7. package/package.json +69 -76
  8. package/rollup.config.ts +88 -84
  9. package/src/clarity.ts +29 -35
  10. package/src/core/api.ts +1 -8
  11. package/src/core/config.ts +2 -2
  12. package/src/core/event.ts +32 -36
  13. package/src/core/hash.ts +6 -5
  14. package/src/core/history.ts +11 -10
  15. package/src/core/index.ts +11 -21
  16. package/src/core/measure.ts +5 -9
  17. package/src/core/report.ts +6 -10
  18. package/src/core/scrub.ts +27 -30
  19. package/src/core/task.ts +45 -73
  20. package/src/core/time.ts +3 -3
  21. package/src/core/timeout.ts +2 -2
  22. package/src/core/version.ts +1 -1
  23. package/src/data/baseline.ts +55 -60
  24. package/src/data/consent.ts +22 -4
  25. package/src/data/custom.ts +13 -8
  26. package/src/data/dimension.ts +7 -11
  27. package/src/data/encode.ts +38 -36
  28. package/src/data/envelope.ts +38 -38
  29. package/src/data/extract.ts +77 -86
  30. package/src/data/index.ts +9 -11
  31. package/src/data/limit.ts +1 -1
  32. package/src/data/metadata.ts +319 -305
  33. package/src/data/metric.ts +8 -18
  34. package/src/data/ping.ts +4 -8
  35. package/src/data/signal.ts +18 -18
  36. package/src/data/summary.ts +4 -6
  37. package/src/data/token.ts +8 -10
  38. package/src/data/upgrade.ts +3 -7
  39. package/src/data/upload.ts +49 -100
  40. package/src/data/variable.ts +20 -27
  41. package/src/diagnostic/encode.ts +2 -2
  42. package/src/diagnostic/fraud.ts +4 -3
  43. package/src/diagnostic/internal.ts +5 -11
  44. package/src/diagnostic/script.ts +8 -12
  45. package/src/global.ts +1 -1
  46. package/src/insight/blank.ts +4 -4
  47. package/src/insight/encode.ts +17 -23
  48. package/src/insight/snapshot.ts +37 -57
  49. package/src/interaction/change.ts +6 -9
  50. package/src/interaction/click.ts +28 -34
  51. package/src/interaction/clipboard.ts +2 -2
  52. package/src/interaction/encode.ts +31 -35
  53. package/src/interaction/input.ts +9 -11
  54. package/src/interaction/pointer.ts +30 -41
  55. package/src/interaction/resize.ts +5 -5
  56. package/src/interaction/scroll.ts +17 -20
  57. package/src/interaction/selection.ts +8 -12
  58. package/src/interaction/submit.ts +2 -2
  59. package/src/interaction/timeline.ts +9 -13
  60. package/src/interaction/unload.ts +1 -1
  61. package/src/interaction/visibility.ts +2 -2
  62. package/src/layout/animation.ts +41 -47
  63. package/src/layout/discover.ts +5 -5
  64. package/src/layout/document.ts +19 -31
  65. package/src/layout/dom.ts +91 -141
  66. package/src/layout/encode.ts +37 -52
  67. package/src/layout/mutation.ts +318 -321
  68. package/src/layout/node.ts +81 -104
  69. package/src/layout/offset.ts +6 -7
  70. package/src/layout/region.ts +43 -66
  71. package/src/layout/schema.ts +8 -15
  72. package/src/layout/selector.ts +25 -47
  73. package/src/layout/style.ts +37 -45
  74. package/src/layout/target.ts +10 -14
  75. package/src/layout/traverse.ts +11 -17
  76. package/src/performance/blank.ts +1 -1
  77. package/src/performance/encode.ts +4 -4
  78. package/src/performance/interaction.ts +70 -58
  79. package/src/performance/navigation.ts +2 -2
  80. package/src/performance/observer.ts +26 -59
  81. package/src/queue.ts +9 -16
  82. package/tsconfig.json +1 -1
  83. package/tslint.json +32 -25
  84. package/types/core.d.ts +13 -13
  85. package/types/data.d.ts +48 -32
  86. package/types/diagnostic.d.ts +1 -1
  87. package/types/index.d.ts +1 -0
  88. package/types/interaction.d.ts +4 -5
  89. package/types/layout.d.ts +21 -36
  90. package/types/performance.d.ts +5 -6
  91. package/.lintstagedrc.yml +0 -3
  92. package/biome.json +0 -43
@@ -1,4 +1,4 @@
1
- import { Code, Constant, Dimension, Metric, PerformanceEventTiming, Severity } from "@clarity-types/data";
1
+ import { Code, Constant, Dimension, Metric, Severity, PerformanceEventTiming } from "@clarity-types/data";
2
2
  import { FunctionNames } from "@clarity-types/performance";
3
3
  import config from "@src/core/config";
4
4
  import { bind } from "@src/core/event";
@@ -7,40 +7,27 @@ import { setTimeout } from "@src/core/timeout";
7
7
  import * as dimension from "@src/data/dimension";
8
8
  import * as metric from "@src/data/metric";
9
9
  import * as internal from "@src/diagnostic/internal";
10
- import * as interaction from "@src/performance/interaction";
11
10
  import * as navigation from "@src/performance/navigation";
11
+ import * as interaction from "@src/performance/interaction";
12
12
 
13
13
  let observer: PerformanceObserver;
14
- const types: string[] = [
15
- Constant.Navigation,
16
- Constant.Resource,
17
- Constant.LongTask,
18
- Constant.FID,
19
- Constant.CLS,
20
- Constant.LCP,
21
- Constant.PerformanceEventTiming,
22
- ];
14
+ const types: string[] = [Constant.Navigation, Constant.Resource, Constant.LongTask, Constant.FID, Constant.CLS, Constant.LCP, Constant.PerformanceEventTiming];
23
15
 
24
16
  export function start(): void {
25
17
  // Capture connection properties, if available
26
18
  if (navigator && "connection" in navigator) {
27
- // biome-ignore lint/complexity/useLiteralKeys: connection isn't on every browser, so effectiveType gives unncessary typescript error
28
- dimension.log(Dimension.ConnectionType, navigator.connection["effectiveType"]);
19
+ dimension.log(Dimension.ConnectionType, navigator["connection"]["effectiveType"]);
29
20
  }
30
21
 
31
22
  // Check the browser support performance observer as a pre-requisite for any performance measurement
32
- if (window.PerformanceObserver && PerformanceObserver.supportedEntryTypes) {
23
+ if (window["PerformanceObserver"] && PerformanceObserver.supportedEntryTypes) {
33
24
  // Start monitoring performance data after page has finished loading.
34
25
  // If the document.readyState is not yet complete, we intentionally call observe using a setTimeout.
35
26
  // This allows us to capture loadEventEnd on navigation timeline.
36
27
  if (document.readyState !== "complete") {
37
28
  bind(window, "load", setTimeout.bind(this, observe, 0));
38
- } else {
39
- observe();
40
- }
41
- } else {
42
- internal.log(Code.PerformanceObserver, Severity.Info);
43
- }
29
+ } else { observe(); }
30
+ } else { internal.log(Code.PerformanceObserver, Severity.Info); }
44
31
  }
45
32
 
46
33
  function observe(): void {
@@ -48,27 +35,21 @@ function observe(): void {
48
35
  // Some browsers will throw an error for unsupported entryType, e.g. "layout-shift"
49
36
  // In those cases, we log it as a warning and continue with rest of the Clarity processing
50
37
  try {
51
- if (observer) {
52
- observer.disconnect();
53
- }
38
+ if (observer) { observer.disconnect(); }
54
39
  observer = new PerformanceObserver(measure(handle) as PerformanceObserverCallback);
55
40
  // Reference: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/observe
56
41
  // "buffered" flag indicates whether buffered entries should be queued into the observer's buffer.
57
42
  // It must only be used only with the "type" option, and cannot be used with entryTypes.
58
43
  // This is why we need to individually "observe" each supported type
59
- for (const x of types) {
44
+ for (let x of types) {
60
45
  if (PerformanceObserver.supportedEntryTypes.indexOf(x) >= 0) {
61
46
  // Initialize CLS with a value of zero. It's possible (and recommended) for sites to not have any cumulative layout shift.
62
47
  // In those cases, we want to still initialize the metric in Clarity
63
- if (x === Constant.CLS) {
64
- metric.sum(Metric.CumulativeLayoutShift, 0);
65
- }
66
- observer.observe({ type: x, buffered: true });
48
+ if (x === Constant.CLS) { metric.sum(Metric.CumulativeLayoutShift, 0); }
49
+ observer.observe({type: x, buffered: true});
67
50
  }
68
51
  }
69
- } catch {
70
- internal.log(Code.PerformanceObserver, Severity.Warning);
71
- }
52
+ } catch { internal.log(Code.PerformanceObserver, Severity.Warning); }
72
53
  }
73
54
 
74
55
  function handle(entries: PerformanceObserverEntryList): void {
@@ -77,65 +58,51 @@ function handle(entries: PerformanceObserverEntryList): void {
77
58
  }
78
59
 
79
60
  function process(entries: PerformanceEntryList): void {
80
- const visible = "visibilityState" in document ? document.visibilityState === "visible" : true;
61
+ let visible = "visibilityState" in document ? document.visibilityState === "visible" : true;
81
62
  for (let i = 0; i < entries.length; i++) {
82
- const entry = entries[i];
63
+ let entry = entries[i];
83
64
  switch (entry.entryType) {
84
65
  case Constant.Navigation:
85
66
  navigation.compute(entry as PerformanceNavigationTiming);
86
67
  break;
87
- case Constant.Resource: {
88
- const name = entry.name;
68
+ case Constant.Resource:
69
+ let name = entry.name;
89
70
  dimension.log(Dimension.NetworkHosts, host(name));
90
- if (name === config.upload || name === config.fallback) {
91
- metric.max(Metric.UploadTime, entry.duration);
92
- }
71
+ if (name === config.upload || name === config.fallback) { metric.max(Metric.UploadTime, entry.duration); }
93
72
  break;
94
- }
95
73
  case Constant.LongTask:
96
74
  metric.count(Metric.LongTaskCount);
97
75
  break;
98
76
  case Constant.FID:
99
- // biome-ignore lint/suspicious/noExplicitAny: not all browsers support processingstart
100
- if (visible && (entry as any).processingStart) {
101
- // biome-ignore lint/suspicious/noExplicitAny: not all browsers support processingstart
102
- metric.max(Metric.FirstInputDelay, (entry as any).processingStart - entry.startTime);
103
- }
77
+ if (visible) { metric.max(Metric.FirstInputDelay, entry["processingStart"] - entry.startTime); }
104
78
  break;
105
79
  case Constant.PerformanceEventTiming:
106
- if (visible && "PerformanceEventTiming" in window && "interactionId" in PerformanceEventTiming.prototype) {
107
- interaction.processInteractionEntry(entry as PerformanceEventTiming);
80
+ if (visible && 'PerformanceEventTiming' in window && 'interactionId' in PerformanceEventTiming.prototype)
81
+ {
82
+ interaction.processInteractionEntry(entry as PerformanceEventTiming);
108
83
  // Logging it as dimension because we're always looking for the last value.
109
- dimension.log(Dimension.InteractionNextPaint, interaction.estimateP98LongestInteraction().toString());
84
+ dimension.log(Dimension.InteractionNextPaint, interaction.estimateP98LongestInteraction().toString());
110
85
  }
111
86
  break;
112
87
  case Constant.CLS:
113
88
  // Scale the value to avoid sending back floating point number
114
- // biome-ignore lint/suspicious/noExplicitAny: not all browsers support hadRecentInput
115
- if (visible && !(entry as any).hadRecentInput) {
116
- // biome-ignore lint/suspicious/noExplicitAny: not all browsers support layoutshift value
117
- metric.sum(Metric.CumulativeLayoutShift, (entry as any).value * 1000);
118
- }
89
+ if (visible && !entry["hadRecentInput"]) { metric.sum(Metric.CumulativeLayoutShift, entry["value"] * 1000); }
119
90
  break;
120
91
  case Constant.LCP:
121
- if (visible) {
122
- metric.max(Metric.LargestPaint, entry.startTime);
123
- }
92
+ if (visible) { metric.max(Metric.LargestPaint, entry.startTime); }
124
93
  break;
125
94
  }
126
95
  }
127
96
  }
128
97
 
129
98
  export function stop(): void {
130
- if (observer) {
131
- observer.disconnect();
132
- }
99
+ if (observer) { observer.disconnect(); }
133
100
  observer = null;
134
101
  interaction.resetInteractions();
135
102
  }
136
103
 
137
104
  function host(url: string): string {
138
- const a = document.createElement("a");
105
+ let a = document.createElement("a");
139
106
  a.href = url;
140
107
  return a.host;
141
108
  }
package/src/queue.ts CHANGED
@@ -1,19 +1,16 @@
1
1
  import { Constant } from "@clarity-types/data";
2
2
  import * as clarity from "@src/clarity";
3
3
 
4
- const w = window;
4
+ const w = window;
5
5
  const c = Constant.Clarity;
6
6
 
7
7
  export function setup() {
8
- // Start queuing up calls while Clarity is inactive and we are in a browser enviornment
8
+ // Start queuing up calls while Clarity is inactive and we are in a browser enviornment
9
9
  if (typeof w !== "undefined") {
10
- w[c] = (...args) => {
11
- if (!w[c].q) {
12
- w[c].q = [];
13
- }
14
- w[c].q.push(args);
10
+ w[c] = function() {
11
+ (w[c].q = w[c].q || []).push(arguments);
15
12
  // if the start function was called, don't queue it and instead process the queue
16
- args[0] === "start" && w[c].q.unshift(w[c].q.pop()) && process();
13
+ arguments[0] === "start" && w[c].q.unshift(w[c].q.pop()) && process();
17
14
  };
18
15
  }
19
16
  }
@@ -21,20 +18,16 @@ export function setup() {
21
18
  export function process() {
22
19
  if (typeof w !== "undefined") {
23
20
  // Do not execute or reset global "clarity" variable if a version of Clarity is already running on the page
24
- if (w[c]?.v) {
25
- return console.warn("Error CL001: Multiple Clarity tags detected.");
26
- }
21
+ if (w[c] && w[c].v) { return console.warn("Error CL001: Multiple Clarity tags detected."); }
27
22
 
28
23
  // Expose clarity in a browser environment
29
24
  // To be efficient about queuing up operations while Clarity is wiring up, we expose clarity.*(args) => clarity(*, args);
30
25
  // This allows us to reprocess any calls that we missed once Clarity is available on the page
31
26
  // Once Clarity script bundle is loaded on the page, we also initialize a "v" property that holds current version
32
27
  // We use the presence or absence of "v" to determine if we are attempting to run a duplicate instance
33
- const queue = w[c] ? w[c].q || [] : [];
34
- w[c] = (method: string, ...args): void => clarity[method](...args);
28
+ let queue = w[c] ? (w[c].q || []) : [];
29
+ w[c] = function(method: string, ...args: any[]): void { return clarity[method](...args); }
35
30
  w[c].v = clarity.version;
36
- while (queue.length > 0) {
37
- w[c](...queue.shift());
38
- }
31
+ while (queue.length > 0) { w[c](...queue.shift()); }
39
32
  }
40
33
  }
package/tsconfig.json CHANGED
@@ -16,6 +16,6 @@
16
16
  "@clarity-types/*": ["types/*"]
17
17
  }
18
18
  },
19
- "include": ["src/**/*.ts", "types/**/*.d.ts", "rollup.config.ts"],
19
+ "include":["src/**/*.ts","types/**/*.d.ts", "rollup.config.ts"],
20
20
  "exclude": ["test", "node_modules", "build"]
21
21
  }
package/tslint.json CHANGED
@@ -1,26 +1,33 @@
1
1
  {
2
- "extends": "tslint:recommended",
3
- "rules": {
4
- "max-line-length": [true, 140],
5
- "no-console": [false],
6
- "no-string-literal": false,
7
- "prefer-const": false,
8
- "prefer-for-of": false,
9
- "object-literal-sort-keys": false,
10
- "one-variable-per-declaration": false,
11
- "trailing-comma": [false],
12
- "variable-name": false,
13
- "interface-name": false,
14
- "interface-over-type-literal": false,
15
- "only-arrow-functions": false,
16
- "typedef": [
17
- true,
18
- "call-signature",
19
- "parameter",
20
- "property-declaration",
21
- "member-variable-declaration",
22
- "object-destructuring",
23
- "array-destructuring"
24
- ]
25
- }
26
- }
2
+ "extends": "tslint:recommended",
3
+ "rules": {
4
+ "max-line-length": [
5
+ true,
6
+ 140
7
+ ],
8
+ "no-console": [
9
+ false
10
+ ],
11
+ "no-string-literal": false,
12
+ "prefer-const": false,
13
+ "prefer-for-of": false,
14
+ "object-literal-sort-keys": false,
15
+ "one-variable-per-declaration": false,
16
+ "trailing-comma": [
17
+ false
18
+ ],
19
+ "variable-name": false,
20
+ "interface-name": false,
21
+ "interface-over-type-literal": false,
22
+ "only-arrow-functions": false,
23
+ "typedef": [
24
+ true,
25
+ "call-signature",
26
+ "parameter",
27
+ "property-declaration",
28
+ "member-variable-declaration",
29
+ "object-destructuring",
30
+ "array-destructuring"
31
+ ]
32
+ }
33
+ }
package/types/core.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type * as Data from "./data";
1
+ import * as Data from "./data";
2
2
 
3
3
  type TaskFunction = () => Promise<void>;
4
4
  type TaskResolve = () => void;
@@ -10,20 +10,20 @@ type Checksum = [number /* FraudId */, string /* Query Selector */];
10
10
 
11
11
  export const enum Priority {
12
12
  Normal = 0,
13
- High = 1,
13
+ High = 1
14
14
  }
15
15
 
16
16
  export const enum Time {
17
17
  Second = 1000,
18
18
  Minute = 60 * 1000,
19
19
  Hour = 60 * 60 * 1000,
20
- Day = 24 * 60 * 60 * 1000,
20
+ Day = 24 * 60 * 60 * 1000
21
21
  }
22
22
 
23
23
  export const enum Task {
24
24
  Wait = 0,
25
25
  Run = 1,
26
- Stop = 2,
26
+ Stop = 2
27
27
  }
28
28
 
29
29
  export const enum ExtractSource {
@@ -31,20 +31,20 @@ export const enum ExtractSource {
31
31
  Cookie = 1,
32
32
  Text = 2,
33
33
  Fragment = 3,
34
- Hash = 4,
34
+ Hash = 4
35
35
  }
36
36
 
37
37
  export const enum Type {
38
38
  Array = 1,
39
39
  Object = 2,
40
- Simple = 3,
40
+ Simple = 3
41
41
  }
42
42
 
43
43
  export type Syntax = {
44
- name: string;
45
- type: Type;
46
- condition: string;
47
- };
44
+ name: string,
45
+ type: Type,
46
+ condition: string
47
+ }
48
48
 
49
49
  export const enum Privacy {
50
50
  None = 0,
@@ -52,7 +52,7 @@ export const enum Privacy {
52
52
  Text = 2,
53
53
  TextImage = 3,
54
54
  Exclude = 4,
55
- Snapshot = 5,
55
+ Snapshot = 5
56
56
  }
57
57
 
58
58
  /* Helper Interfaces */
@@ -83,7 +83,7 @@ export interface RequestIdleCallbackOptions {
83
83
 
84
84
  export interface RequestIdleCallbackDeadline {
85
85
  didTimeout: boolean;
86
- timeRemaining: () => number;
86
+ timeRemaining: (() => number);
87
87
  }
88
88
 
89
89
  export interface AsyncTask {
@@ -146,5 +146,5 @@ export const enum Constant {
146
146
  Zone = "Zone",
147
147
  Symbol = "__symbol__",
148
148
  AddEventListener = "addEventListener",
149
- RemoveEventListener = "removeEventListener",
149
+ RemoveEventListener = "removeEventListener"
150
150
  }
package/types/data.d.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  import { Time } from "@clarity-types/core";
2
- export type Target = number | Node;
3
- export type Token = string | number | number[] | string[] | (string | number)[];
2
+ export type Target = (number | Node);
3
+ export type Token = (string | number | number[] | string[] | (string | number)[]);
4
+ export type DecodedToken = (any | any[]);
4
5
 
5
- export type MetadataCallback = (data: Metadata, playback: boolean) => void;
6
+ export type MetadataCallback = (data: Metadata, playback: boolean, consentStatus?: ConsentState) => void;
6
7
  export interface MetadataCallbackOptions {
7
- callback: MetadataCallback;
8
- wait: boolean;
9
- recall: boolean;
10
- called: boolean;
8
+ callback: MetadataCallback,
9
+ wait: boolean,
10
+ recall: boolean,
11
+ called: boolean,
12
+ consentInfo: boolean
11
13
  }
12
- export type SignalCallback = (data: ClaritySignal) => void;
14
+ export type SignalCallback = (data: ClaritySignal) => void
13
15
 
14
16
  /* Enum */
15
17
  export const enum Event {
@@ -70,6 +72,7 @@ export const enum Event {
70
72
  Animation = 44,
71
73
  StyleSheetAdoption = 45,
72
74
  StyleSheetUpdate = 46,
75
+ Consent = 47,
73
76
 
74
77
  // Apps specific events
75
78
  WebViewDiscover = 100,
@@ -79,7 +82,7 @@ export const enum Event {
79
82
  Keystrokes = 104,
80
83
  BackGesture = 105,
81
84
  WebViewStatus = 106,
82
- AppInstallReferrer = 107,
85
+ AppInstallReferrer = 107
83
86
  }
84
87
 
85
88
  export const enum Metric {
@@ -131,6 +134,7 @@ export const enum Metric {
131
134
  */
132
135
  InteractionNextPaint = 37,
133
136
  HistoryClear = 38,
137
+ AngularZone = 39,
134
138
  }
135
139
 
136
140
  export const enum Dimension {
@@ -171,7 +175,7 @@ export const enum Dimension {
171
175
  Timezone = 34,
172
176
  TimezoneOffset = 35,
173
177
  Consent = 36,
174
- InteractionNextPaint = 37,
178
+ InteractionNextPaint = 37
175
179
  }
176
180
 
177
181
  export const enum Check {
@@ -182,7 +186,7 @@ export const enum Check {
182
186
  Bytes = 4,
183
187
  Collection = 5,
184
188
  Server = 6,
185
- Page = 7,
189
+ Page = 7
186
190
  }
187
191
 
188
192
  export const enum Code {
@@ -200,48 +204,43 @@ export const enum Code {
200
204
  Config = 8,
201
205
  FunctionExecutionTime = 9,
202
206
  LeanLimit = 10,
203
- AngularZone = 11,
204
207
  }
205
208
 
206
209
  export const enum Severity {
207
210
  Info = 0,
208
211
  Warning = 1,
209
212
  Error = 2,
210
- Fatal = 3,
213
+ Fatal = 3
211
214
  }
212
215
 
213
216
  export const enum Upload {
214
217
  Async = 0,
215
- Beacon = 1,
218
+ Beacon = 1
216
219
  }
217
220
 
218
221
  export const enum BooleanFlag {
219
222
  False = 0,
220
- True = 1,
223
+ True = 1
221
224
  }
222
225
 
223
226
  export const enum IframeStatus {
224
227
  Unknown = 0,
225
228
  TopFrame = 1,
226
- Iframe = 2,
229
+ Iframe = 2
227
230
  }
228
231
 
229
232
  export const enum Setting {
230
233
  Expire = 365, // 1 Year
231
234
  SessionExpire = 1, // 1 Day
232
235
  CookieVersion = 2, // Increment this version every time there's a cookie schema change
233
- // biome-ignore lint/style/useLiteralEnumMembers: Time.Minute is a const enum, it is compiled to a number
234
236
  SessionTimeout = 30 * Time.Minute, // 30 minutes
235
237
  CookieInterval = 1, // 1 Day
236
- // biome-ignore lint/style/useLiteralEnumMembers: Time.Minute is a const enum, it is compiled to a number
237
238
  PingInterval = 1 * Time.Minute, // 1 Minute
238
- // biome-ignore lint/style/useLiteralEnumMembers: Time.Minute is a const enum, it is compiled to a number
239
239
  PingTimeout = 5 * Time.Minute, // 5 Minutes
240
240
  SummaryInterval = 100, // Same events within 100ms will be collapsed into single summary
241
241
  ClickText = 25, // Maximum number of characters to send as part of Click event's text field
242
242
  PayloadLimit = 128, // Do not allow more than specified payloads per page
243
243
  PageLimit = 128, // Do not allow more than 128 pages in a session
244
- // biome-ignore lint/style/useLiteralEnumMembers: Time.Hour is a const enum, it is compiled to a number
245
244
  ShutdownLimit = 2 * Time.Hour, // Shutdown instrumentation after specified time
246
245
  RetryLimit = 1, // Maximum number of attempts to upload a payload before giving up
247
246
  PlaybackBytesLimit = 10 * 1024 * 1024, // 10MB
@@ -260,7 +259,6 @@ export const enum Setting {
260
259
  MegaByte = 1024 * 1024, // 1MB
261
260
  UploadFactor = 3, // Slow down sequence by specified factor
262
261
  MinUploadDelay = 100, // Minimum time before we are ready to flush events to the server
263
- // biome-ignore lint/style/useLiteralEnumMembers: Time.Second is a const enum, it is compiled to a number
264
262
  MaxUploadDelay = 30 * Time.Second, // Do flush out payload once every 30s,
265
263
  ExtractLimit = 10000, // Do not extract more than 10000 characters
266
264
  ChecksumPrecision = 28, // n-bit integer to represent token hash
@@ -275,11 +273,11 @@ export const enum Character {
275
273
  Blank = 32,
276
274
  Tab = 9,
277
275
  NewLine = 10,
278
- Return = 13,
276
+ Return = 13
279
277
  }
280
278
 
281
279
  export const enum ApplicationPlatform {
282
- WebApp = 0,
280
+ WebApp = 0
283
281
  }
284
282
 
285
283
  export const enum Constant {
@@ -351,6 +349,8 @@ export const enum Constant {
351
349
  SHA256 = "SHA-256",
352
350
  Electron = "Electron",
353
351
  Caret = "^",
352
+ Granted = "granted",
353
+ Denied = "denied",
354
354
  }
355
355
 
356
356
  export const enum XMLReadyState {
@@ -358,21 +358,26 @@ export const enum XMLReadyState {
358
358
  Opened = 1,
359
359
  Headers_Recieved = 2,
360
360
  Loading = 3,
361
- Done = 4,
361
+ Done = 4
362
+ }
363
+
364
+ export const enum ConsentSource{
365
+ Implicit = 0,
366
+ API = 1
362
367
  }
363
368
 
364
369
  /* Helper Interfaces */
365
370
 
366
371
  export interface Payload {
367
- e: Token[] /* Envelope */;
368
- a: Token[][] /* Events that are used for data analysis */;
369
- p: Token[][] /* Events that are primarily used for session playback */;
372
+ e: Token[]; /* Envelope */
373
+ a: Token[][]; /* Events that are used for data analysis */
374
+ p: Token[][]; /* Events that are primarily used for session playback */
370
375
  }
371
376
 
372
377
  export interface EncodedPayload {
373
- e: string /* Envelope */;
374
- a: string /* Analytics Payload */;
375
- p: string /* Playback Payload */;
378
+ e: string; /* Envelope */
379
+ a: string; /* Analytics Payload */
380
+ p: string; /* Playback Payload */
376
381
  }
377
382
 
378
383
  export interface Metadata {
@@ -505,8 +510,8 @@ export interface UploadData {
505
510
  }
506
511
 
507
512
  export interface ClaritySignal {
508
- type: string;
509
- value?: number;
513
+ type: string
514
+ value?: number
510
515
  }
511
516
 
512
517
  export interface PerformanceEventTiming extends PerformanceEntry {
@@ -518,3 +523,14 @@ export interface Interaction {
518
523
  id: number;
519
524
  latency: number;
520
525
  }
526
+
527
+ export interface ConsentState {
528
+ ad_Storage?: string;
529
+ analytics_Storage?: string;
530
+ }
531
+
532
+ export interface ConsentData {
533
+ source: ConsentSource;
534
+ ad_Storage: BooleanFlag;
535
+ analytics_Storage: BooleanFlag;
536
+ }
@@ -1,4 +1,4 @@
1
- import type { Code, Severity } from "./data";
1
+ import { Code, Severity, Target } from "./data";
2
2
 
3
3
  /* Event Data */
4
4
  export interface ScriptErrorData {
package/types/index.d.ts CHANGED
@@ -12,6 +12,7 @@ interface Clarity {
12
12
  resume: () => void;
13
13
  upgrade: (key: string) => void;
14
14
  consent: () => void;
15
+ consentv2: () => void;
15
16
  event: (name: string, value: string) => void;
16
17
  set: (variable: string, value: string | string[]) => void;
17
18
  identify: (userId: string, sessionId?: string, pageId?: string, userHint?: string) => void;
@@ -1,6 +1,6 @@
1
- import type { BooleanFlag } from "@clarity-types/data";
1
+ import { BooleanFlag } from "@clarity-types/data";
2
2
  import { Time } from "./core";
3
- import type { Event, Target } from "./data";
3
+ import { Event, Target } from "./data";
4
4
 
5
5
  /* Enum */
6
6
 
@@ -8,7 +8,7 @@ export const enum BrowsingContext {
8
8
  Self = 0,
9
9
  Blank = 1,
10
10
  Parent = 2,
11
- Top = 3,
11
+ Top = 3
12
12
  }
13
13
 
14
14
  export const enum Setting {
@@ -18,14 +18,13 @@ export const enum Setting {
18
18
  ScrollInterval = 50, // 25 milliseconds
19
19
  PointerInterval = 25, // 25 milliseconds
20
20
  Throttle = 25, // 25 milliseconds
21
- // biome-ignore lint/style/useLiteralEnumMembers: Time.Second is a const enum, it is compiled to a number
22
21
  TimelineSpan = 2 * Time.Second, // 2 seconds
23
22
  }
24
23
 
25
24
  export const enum Clipboard {
26
25
  Cut = 0,
27
26
  Copy = 1,
28
- Paste = 2,
27
+ Paste = 2
29
28
  }
30
29
 
31
30
  /* Helper Interfaces */