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.
- package/build/clarity.extended.js +1 -1
- package/build/clarity.insight.js +1 -1
- package/build/clarity.js +91 -43
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +91 -43
- package/build/clarity.performance.js +1 -1
- package/package.json +1 -1
- package/src/core/version.ts +1 -1
- package/src/interaction/click.ts +24 -1
- package/src/interaction/encode.ts +1 -0
- package/src/interaction/index.ts +3 -0
- package/src/interaction/pageshow.ts +35 -0
- package/types/data.d.ts +1 -0
- package/types/interaction.d.ts +9 -0
package/src/interaction/index.ts
CHANGED
|
@@ -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
package/types/interaction.d.ts
CHANGED
|
@@ -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 {
|