clarity-js 0.8.42 → 0.8.44

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 (116) hide show
  1. package/README.md +26 -26
  2. package/build/clarity.extended.js +1 -1
  3. package/build/clarity.insight.js +1 -1
  4. package/build/clarity.js +6101 -6071
  5. package/build/clarity.min.js +1 -1
  6. package/build/clarity.module.js +6101 -6071
  7. package/build/clarity.performance.js +1 -1
  8. package/package.json +70 -70
  9. package/rollup.config.ts +161 -161
  10. package/src/clarity.ts +65 -65
  11. package/src/core/api.ts +8 -8
  12. package/src/core/config.ts +29 -29
  13. package/src/core/copy.ts +3 -3
  14. package/src/core/dynamic.ts +13 -7
  15. package/src/core/event.ts +53 -53
  16. package/src/core/hash.ts +19 -19
  17. package/src/core/history.ts +71 -71
  18. package/src/core/index.ts +81 -81
  19. package/src/core/measure.ts +19 -19
  20. package/src/core/report.ts +28 -28
  21. package/src/core/scrub.ts +204 -202
  22. package/src/core/task.ts +181 -181
  23. package/src/core/throttle.ts +46 -46
  24. package/src/core/time.ts +26 -26
  25. package/src/core/timeout.ts +10 -10
  26. package/src/core/version.ts +2 -2
  27. package/src/data/baseline.ts +162 -162
  28. package/src/data/compress.ts +31 -31
  29. package/src/data/consent.ts +77 -77
  30. package/src/data/cookie.ts +90 -0
  31. package/src/data/custom.ts +23 -23
  32. package/src/data/dimension.ts +53 -53
  33. package/src/data/encode.ts +155 -155
  34. package/src/data/envelope.ts +53 -53
  35. package/src/data/extract.ts +211 -211
  36. package/src/data/index.ts +51 -50
  37. package/src/data/limit.ts +44 -44
  38. package/src/data/metadata.ts +321 -408
  39. package/src/data/metric.ts +51 -51
  40. package/src/data/ping.ts +36 -36
  41. package/src/data/signal.ts +30 -30
  42. package/src/data/summary.ts +34 -34
  43. package/src/data/token.ts +39 -39
  44. package/src/data/upgrade.ts +44 -44
  45. package/src/data/upload.ts +333 -333
  46. package/src/data/util.ts +18 -0
  47. package/src/data/variable.ts +83 -83
  48. package/src/diagnostic/encode.ts +40 -40
  49. package/src/diagnostic/fraud.ts +36 -36
  50. package/src/diagnostic/index.ts +13 -13
  51. package/src/diagnostic/internal.ts +28 -28
  52. package/src/diagnostic/script.ts +35 -35
  53. package/src/dynamic/agent/blank.ts +2 -2
  54. package/src/dynamic/agent/crisp.ts +40 -40
  55. package/src/dynamic/agent/encode.ts +25 -25
  56. package/src/dynamic/agent/index.ts +8 -8
  57. package/src/dynamic/agent/livechat.ts +58 -58
  58. package/src/dynamic/agent/tidio.ts +44 -44
  59. package/src/global.ts +6 -6
  60. package/src/index.ts +9 -9
  61. package/src/insight/blank.ts +14 -14
  62. package/src/insight/encode.ts +60 -60
  63. package/src/insight/snapshot.ts +114 -114
  64. package/src/interaction/change.ts +38 -38
  65. package/src/interaction/click.ts +173 -173
  66. package/src/interaction/clipboard.ts +32 -32
  67. package/src/interaction/encode.ts +210 -210
  68. package/src/interaction/index.ts +60 -60
  69. package/src/interaction/input.ts +57 -57
  70. package/src/interaction/pointer.ts +137 -137
  71. package/src/interaction/resize.ts +50 -50
  72. package/src/interaction/scroll.ts +129 -129
  73. package/src/interaction/selection.ts +66 -66
  74. package/src/interaction/submit.ts +30 -30
  75. package/src/interaction/timeline.ts +69 -69
  76. package/src/interaction/unload.ts +26 -26
  77. package/src/interaction/visibility.ts +27 -27
  78. package/src/layout/animation.ts +133 -133
  79. package/src/layout/custom.ts +42 -42
  80. package/src/layout/discover.ts +31 -31
  81. package/src/layout/document.ts +46 -46
  82. package/src/layout/dom.ts +439 -439
  83. package/src/layout/encode.ts +154 -154
  84. package/src/layout/index.ts +42 -42
  85. package/src/layout/mutation.ts +411 -411
  86. package/src/layout/node.ts +294 -294
  87. package/src/layout/offset.ts +19 -19
  88. package/src/layout/region.ts +151 -151
  89. package/src/layout/schema.ts +63 -63
  90. package/src/layout/selector.ts +82 -82
  91. package/src/layout/style.ts +159 -159
  92. package/src/layout/target.ts +32 -32
  93. package/src/layout/traverse.ts +27 -27
  94. package/src/performance/blank.ts +9 -9
  95. package/src/performance/encode.ts +31 -31
  96. package/src/performance/index.ts +12 -12
  97. package/src/performance/interaction.ts +125 -125
  98. package/src/performance/navigation.ts +31 -31
  99. package/src/performance/observer.ts +112 -112
  100. package/src/queue.ts +33 -33
  101. package/test/core.test.ts +139 -139
  102. package/test/helper.ts +162 -162
  103. package/test/html/core.html +27 -27
  104. package/test/stub.test.ts +7 -7
  105. package/test/tsconfig.test.json +5 -5
  106. package/tsconfig.json +21 -21
  107. package/tslint.json +32 -32
  108. package/types/agent.d.ts +39 -39
  109. package/types/core.d.ts +150 -150
  110. package/types/data.d.ts +572 -571
  111. package/types/diagnostic.d.ts +24 -24
  112. package/types/global.d.ts +30 -30
  113. package/types/index.d.ts +40 -40
  114. package/types/interaction.d.ts +177 -177
  115. package/types/layout.d.ts +276 -276
  116. package/types/performance.d.ts +31 -31
@@ -1,66 +1,66 @@
1
- import { Event } from "@clarity-types/data";
2
- import { SelectionData, Setting } from "@clarity-types/interaction";
3
- import { bind } from "@src/core/event";
4
- import { schedule } from "@src/core/task";
5
- import { clearTimeout, setTimeout } from "@src/core/timeout";
6
- import encode from "./encode";
7
-
8
- export let data: SelectionData = null;
9
- let previous: Selection = null;
10
- let timeout: number = null;
11
-
12
- export function start(): void {
13
- reset();
14
- }
15
-
16
- export function observe(root: Node): void {
17
- bind(root, "selectstart", recompute.bind(this, root), true);
18
- bind(root, "selectionchange", recompute.bind(this, root), true);
19
- }
20
-
21
- function recompute(root: Node): void {
22
- let doc = root.nodeType === Node.DOCUMENT_NODE ? root as Document : document;
23
- let current = doc.getSelection();
24
-
25
- // Bail out if we don't have a valid selection
26
- if (current === null) { return; }
27
-
28
- // Bail out if we got a valid selection but not valid nodes
29
- // In Edge, selectionchange gets fired even on interactions like right clicks and
30
- // can result in null anchorNode and focusNode if there was no previous selection on page
31
- // Also, ignore any selections that start and end at the exact same point
32
- if ((current.anchorNode === null && current.focusNode === null) ||
33
- (current.anchorNode === current.focusNode && current.anchorOffset === current.focusOffset)) {
34
- return;
35
- }
36
- let startNode = data.start ? data.start : null;
37
- if (previous !== null && data.start !== null && startNode !== current.anchorNode) {
38
- clearTimeout(timeout);
39
- process(Event.Selection);
40
- }
41
-
42
- data = {
43
- start: current.anchorNode,
44
- startOffset: current.anchorOffset,
45
- end: current.focusNode,
46
- endOffset: current.focusOffset
47
- };
48
- previous = current;
49
-
50
- clearTimeout(timeout);
51
- timeout = setTimeout(process, Setting.LookAhead, Event.Selection);
52
- }
53
-
54
- function process(event: Event): void {
55
- schedule(encode.bind(this, event));
56
- }
57
-
58
- export function reset(): void {
59
- previous = null;
60
- data = { start: 0, startOffset: 0, end: 0, endOffset: 0 };
61
- }
62
-
63
- export function stop(): void {
64
- reset();
65
- clearTimeout(timeout);
66
- }
1
+ import { Event } from "@clarity-types/data";
2
+ import { SelectionData, Setting } from "@clarity-types/interaction";
3
+ import { bind } from "@src/core/event";
4
+ import { schedule } from "@src/core/task";
5
+ import { clearTimeout, setTimeout } from "@src/core/timeout";
6
+ import encode from "./encode";
7
+
8
+ export let data: SelectionData = null;
9
+ let previous: Selection = null;
10
+ let timeout: number = null;
11
+
12
+ export function start(): void {
13
+ reset();
14
+ }
15
+
16
+ export function observe(root: Node): void {
17
+ bind(root, "selectstart", recompute.bind(this, root), true);
18
+ bind(root, "selectionchange", recompute.bind(this, root), true);
19
+ }
20
+
21
+ function recompute(root: Node): void {
22
+ let doc = root.nodeType === Node.DOCUMENT_NODE ? root as Document : document;
23
+ let current = doc.getSelection();
24
+
25
+ // Bail out if we don't have a valid selection
26
+ if (current === null) { return; }
27
+
28
+ // Bail out if we got a valid selection but not valid nodes
29
+ // In Edge, selectionchange gets fired even on interactions like right clicks and
30
+ // can result in null anchorNode and focusNode if there was no previous selection on page
31
+ // Also, ignore any selections that start and end at the exact same point
32
+ if ((current.anchorNode === null && current.focusNode === null) ||
33
+ (current.anchorNode === current.focusNode && current.anchorOffset === current.focusOffset)) {
34
+ return;
35
+ }
36
+ let startNode = data.start ? data.start : null;
37
+ if (previous !== null && data.start !== null && startNode !== current.anchorNode) {
38
+ clearTimeout(timeout);
39
+ process(Event.Selection);
40
+ }
41
+
42
+ data = {
43
+ start: current.anchorNode,
44
+ startOffset: current.anchorOffset,
45
+ end: current.focusNode,
46
+ endOffset: current.focusOffset
47
+ };
48
+ previous = current;
49
+
50
+ clearTimeout(timeout);
51
+ timeout = setTimeout(process, Setting.LookAhead, Event.Selection);
52
+ }
53
+
54
+ function process(event: Event): void {
55
+ schedule(encode.bind(this, event));
56
+ }
57
+
58
+ export function reset(): void {
59
+ previous = null;
60
+ data = { start: 0, startOffset: 0, end: 0, endOffset: 0 };
61
+ }
62
+
63
+ export function stop(): void {
64
+ reset();
65
+ clearTimeout(timeout);
66
+ }
@@ -1,30 +1,30 @@
1
- import { Event } from "@clarity-types/data";
2
- import { SubmitState } from "@clarity-types/interaction";
3
- import { bind } from "@src/core/event";
4
- import { schedule } from "@src/core/task";
5
- import { time } from "@src/core/time";
6
- import encode from "./encode";
7
- import { target } from "@src/layout/target";
8
-
9
- export let state: SubmitState[] = [];
10
-
11
- export function start(): void {
12
- reset();
13
- }
14
-
15
- export function observe(root: Node): void {
16
- bind(root, "submit", recompute, true);
17
- }
18
-
19
- function recompute(evt: UIEvent): void {
20
- state.push({ time: time(evt), event: Event.Submit, data: { target: target(evt) } });
21
- schedule(encode.bind(this, Event.Submit));
22
- }
23
-
24
- export function reset(): void {
25
- state = [];
26
- }
27
-
28
- export function stop(): void {
29
- reset();
30
- }
1
+ import { Event } from "@clarity-types/data";
2
+ import { SubmitState } from "@clarity-types/interaction";
3
+ import { bind } from "@src/core/event";
4
+ import { schedule } from "@src/core/task";
5
+ import { time } from "@src/core/time";
6
+ import encode from "./encode";
7
+ import { target } from "@src/layout/target";
8
+
9
+ export let state: SubmitState[] = [];
10
+
11
+ export function start(): void {
12
+ reset();
13
+ }
14
+
15
+ export function observe(root: Node): void {
16
+ bind(root, "submit", recompute, true);
17
+ }
18
+
19
+ function recompute(evt: UIEvent): void {
20
+ state.push({ time: time(evt), event: Event.Submit, data: { target: target(evt) } });
21
+ schedule(encode.bind(this, Event.Submit));
22
+ }
23
+
24
+ export function reset(): void {
25
+ state = [];
26
+ }
27
+
28
+ export function stop(): void {
29
+ reset();
30
+ }
@@ -1,69 +1,69 @@
1
- import { BooleanFlag, Event } from "@clarity-types/data";
2
- import { BrowsingContext, Setting, TimelineState } from "@clarity-types/interaction";
3
- import * as baseline from "@src/data/baseline";
4
- import * as envelope from "@src/data/envelope";
5
- import encode from "@src/interaction/encode";
6
-
7
- let state: TimelineState[] = [];
8
- export let updates: TimelineState[] = [];
9
-
10
- export function start(): void {
11
- state = [];
12
- reset();
13
- }
14
-
15
- export function reset(): void {
16
- updates = [];
17
- }
18
-
19
- export function track(time: number,
20
- event: Event,
21
- hash: string,
22
- x: number,
23
- y: number,
24
- reaction: number = BooleanFlag.True,
25
- context: number = BrowsingContext.Self): void {
26
- state.push({
27
- time,
28
- event: Event.Timeline,
29
- data: {
30
- type: event,
31
- hash,
32
- x,
33
- y,
34
- reaction,
35
- context
36
- }
37
- });
38
-
39
- // Since timeline only keeps the data for configured time, we still want to continue tracking these values
40
- // as part of the baseline. For instance, in a scenario where last scroll happened 5s ago.
41
- // We would still need to capture the last scroll position as part of the baseline event, even when timeline will be empty.
42
- baseline.track(event, x, y, time);
43
- }
44
-
45
- export function compute(): void {
46
- if (!envelope.data) {
47
- return;
48
- }
49
-
50
- const temp = [];
51
- updates = [];
52
- let max = (envelope.data.start || 0) + (envelope.data.duration || 0);
53
- let min = Math.max(max - Setting.TimelineSpan, 0);
54
-
55
- for (let s of state) {
56
- if (s.time >= min) {
57
- if (s.time <= max) { updates.push(s); }
58
- temp.push(s);
59
- }
60
- }
61
-
62
- state = temp; // Drop events less than the min time
63
- encode(Event.Timeline);
64
- }
65
-
66
- export function stop(): void {
67
- state = [];
68
- reset();
69
- }
1
+ import { BooleanFlag, Event } from "@clarity-types/data";
2
+ import { BrowsingContext, Setting, TimelineState } from "@clarity-types/interaction";
3
+ import * as baseline from "@src/data/baseline";
4
+ import * as envelope from "@src/data/envelope";
5
+ import encode from "@src/interaction/encode";
6
+
7
+ let state: TimelineState[] = [];
8
+ export let updates: TimelineState[] = [];
9
+
10
+ export function start(): void {
11
+ state = [];
12
+ reset();
13
+ }
14
+
15
+ export function reset(): void {
16
+ updates = [];
17
+ }
18
+
19
+ export function track(time: number,
20
+ event: Event,
21
+ hash: string,
22
+ x: number,
23
+ y: number,
24
+ reaction: number = BooleanFlag.True,
25
+ context: number = BrowsingContext.Self): void {
26
+ state.push({
27
+ time,
28
+ event: Event.Timeline,
29
+ data: {
30
+ type: event,
31
+ hash,
32
+ x,
33
+ y,
34
+ reaction,
35
+ context
36
+ }
37
+ });
38
+
39
+ // Since timeline only keeps the data for configured time, we still want to continue tracking these values
40
+ // as part of the baseline. For instance, in a scenario where last scroll happened 5s ago.
41
+ // We would still need to capture the last scroll position as part of the baseline event, even when timeline will be empty.
42
+ baseline.track(event, x, y, time);
43
+ }
44
+
45
+ export function compute(): void {
46
+ if (!envelope.data) {
47
+ return;
48
+ }
49
+
50
+ const temp = [];
51
+ updates = [];
52
+ let max = (envelope.data.start || 0) + (envelope.data.duration || 0);
53
+ let min = Math.max(max - Setting.TimelineSpan, 0);
54
+
55
+ for (let s of state) {
56
+ if (s.time >= min) {
57
+ if (s.time <= max) { updates.push(s); }
58
+ temp.push(s);
59
+ }
60
+ }
61
+
62
+ state = temp; // Drop events less than the min time
63
+ encode(Event.Timeline);
64
+ }
65
+
66
+ export function stop(): void {
67
+ state = [];
68
+ reset();
69
+ }
@@ -1,26 +1,26 @@
1
- import { BooleanFlag, Event } from "@clarity-types/data";
2
- import { UnloadData } from "@clarity-types/interaction";
3
- import * as clarity from "@src/clarity";
4
- import { bind } from "@src/core/event";
5
- import { time } from "@src/core/time";
6
- import encode from "./encode";
7
-
8
- export let data: UnloadData;
9
-
10
- export function start(): void {
11
- bind(window, "pagehide", recompute);
12
- }
13
-
14
- function recompute(evt: PageTransitionEvent): void {
15
- data = { name: evt.type, persisted: evt.persisted ? BooleanFlag.True : BooleanFlag.False };
16
- encode(Event.Unload, time(evt));
17
- clarity.stop();
18
- }
19
-
20
- export function reset(): void {
21
- data = null;
22
- }
23
-
24
- export function stop(): void {
25
- reset();
26
- }
1
+ import { BooleanFlag, Event } from "@clarity-types/data";
2
+ import { UnloadData } from "@clarity-types/interaction";
3
+ import * as clarity from "@src/clarity";
4
+ import { bind } from "@src/core/event";
5
+ import { time } from "@src/core/time";
6
+ import encode from "./encode";
7
+
8
+ export let data: UnloadData;
9
+
10
+ export function start(): void {
11
+ bind(window, "pagehide", recompute);
12
+ }
13
+
14
+ function recompute(evt: PageTransitionEvent): void {
15
+ data = { name: evt.type, persisted: evt.persisted ? BooleanFlag.True : BooleanFlag.False };
16
+ encode(Event.Unload, time(evt));
17
+ clarity.stop();
18
+ }
19
+
20
+ export function reset(): void {
21
+ data = null;
22
+ }
23
+
24
+ export function stop(): void {
25
+ reset();
26
+ }
@@ -1,28 +1,28 @@
1
- import { BooleanFlag, Event } from "@clarity-types/data";
2
- import { VisibilityData } from "@clarity-types/interaction";
3
- import { bind } from "@src/core/event";
4
- import { time } from "@src/core/time";
5
- import encode from "./encode";
6
-
7
- export let data: VisibilityData;
8
-
9
- export function start(): void {
10
- bind(document, "visibilitychange", recompute);
11
- recompute();
12
- }
13
-
14
- function recompute(evt: UIEvent = null): void {
15
- if ("visibilityState" in document) {
16
- const visible = document.visibilityState === "visible" ? BooleanFlag.True : BooleanFlag.False;
17
- data = { visible };
18
- encode(Event.Visibility, time(evt));
19
- }
20
- }
21
-
22
- export function reset(): void {
23
- data = null;
24
- }
25
-
26
- export function stop(): void {
27
- reset();
1
+ import { BooleanFlag, Event } from "@clarity-types/data";
2
+ import { VisibilityData } from "@clarity-types/interaction";
3
+ import { bind } from "@src/core/event";
4
+ import { time } from "@src/core/time";
5
+ import encode from "./encode";
6
+
7
+ export let data: VisibilityData;
8
+
9
+ export function start(): void {
10
+ bind(document, "visibilitychange", recompute);
11
+ recompute();
12
+ }
13
+
14
+ function recompute(evt: UIEvent = null): void {
15
+ if ("visibilityState" in document) {
16
+ const visible = document.visibilityState === "visible" ? BooleanFlag.True : BooleanFlag.False;
17
+ data = { visible };
18
+ encode(Event.Visibility, time(evt));
19
+ }
20
+ }
21
+
22
+ export function reset(): void {
23
+ data = null;
24
+ }
25
+
26
+ export function stop(): void {
27
+ reset();
28
28
  }