clarity-js 0.8.49 → 0.8.50-beta

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.
@@ -11,6 +11,7 @@ import * as timeline from "@src/interaction/timeline";
11
11
  import * as unload from "@src/interaction/unload";
12
12
  import * as visibility from "@src/interaction/visibility";
13
13
  import * as focus from "@src/interaction/focus";
14
+ import * as pageshow from "@src/interaction/pageshow";
14
15
 
15
16
  export function start(): void {
16
17
  timeline.start();
@@ -21,6 +22,7 @@ export function start(): void {
21
22
  resize.start();
22
23
  visibility.start();
23
24
  focus.start();
25
+ pageshow.start();
24
26
  scroll.start();
25
27
  selection.start();
26
28
  change.start();
@@ -37,6 +39,7 @@ export function stop(): void {
37
39
  resize.stop();
38
40
  visibility.stop();
39
41
  focus.stop();
42
+ pageshow.stop();
40
43
  scroll.stop();
41
44
  selection.stop();
42
45
  change.stop();
@@ -0,0 +1,35 @@
1
+ import { Constant } from "@clarity-types/core";
2
+ import { Code, Severity } from "@clarity-types/data";
3
+ import * as clarity from "@src/clarity";
4
+ import api from "@src/core/api";
5
+ import measure from "@src/core/measure";
6
+ import * as internal from "@src/diagnostic/internal";
7
+
8
+ let bound = false;
9
+
10
+ export function start(): void {
11
+ // Only bind once - this listener must persist even when Clarity stops
12
+ // to detect when the page is restored from bfcache
13
+ if (!bound) {
14
+ try {
15
+ window[api(Constant.AddEventListener)]("pageshow", measure(handler) as EventListener, { capture: false, passive: true });
16
+ bound = true;
17
+ } catch {
18
+ /* do nothing */
19
+ }
20
+ }
21
+ }
22
+
23
+ function handler(evt: PageTransitionEvent): void {
24
+ // The persisted property indicates if the page was loaded from bfcache
25
+ if (evt && evt.persisted) {
26
+ // Restart Clarity since it was stopped when the page entered bfcache
27
+ clarity.start();
28
+ internal.log(Code.BFCache, Severity.Info);
29
+ }
30
+ }
31
+
32
+ export function stop(): void {
33
+ // Intentionally don't remove the listener or reset 'bound' flag
34
+ // We need the listener to persist to detect bfcache restoration
35
+ }
package/types/data.d.ts CHANGED
@@ -212,6 +212,7 @@ export const enum Code {
212
212
  Config = 8,
213
213
  FunctionExecutionTime = 9,
214
214
  LeanLimit = 10,
215
+ BFCache = 11,
215
216
  }
216
217
 
217
218
  export const enum Severity {
@@ -11,6 +11,14 @@ export const enum BrowsingContext {
11
11
  Top = 3
12
12
  }
13
13
 
14
+ export const enum ClickSource {
15
+ Undefined = 0,
16
+ FirstParty = 1,
17
+ ThirdParty = 2,
18
+ Eval = 3,
19
+ Unknown = 4
20
+ }
21
+
14
22
  export const enum Setting {
15
23
  LookAhead = 500, // 500ms
16
24
  InputLookAhead = 1000, // 1s
@@ -131,6 +139,7 @@ export interface ClickData {
131
139
  tag: string;
132
140
  class: string;
133
141
  id: string;
142
+ source: ClickSource;
134
143
  }
135
144
 
136
145
  export interface TextInfo {