clarity-js 0.8.6 → 0.8.8

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 (103) 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 +5544 -5553
  5. package/build/clarity.min.js +1 -1
  6. package/build/clarity.module.js +5544 -5553
  7. package/build/clarity.performance.js +1 -1
  8. package/package.json +70 -70
  9. package/rollup.config.ts +98 -98
  10. package/src/clarity.ts +60 -60
  11. package/src/core/api.ts +8 -8
  12. package/src/core/config.ts +29 -33
  13. package/src/core/copy.ts +3 -3
  14. package/src/core/event.ts +53 -53
  15. package/src/core/hash.ts +19 -19
  16. package/src/core/history.ts +73 -73
  17. package/src/core/index.ts +83 -83
  18. package/src/core/measure.ts +19 -19
  19. package/src/core/report.ts +28 -28
  20. package/src/core/scrub.ts +196 -196
  21. package/src/core/task.ts +181 -181
  22. package/src/core/time.ts +19 -19
  23. package/src/core/timeout.ts +10 -10
  24. package/src/core/version.ts +2 -2
  25. package/src/data/baseline.ts +155 -155
  26. package/src/data/compress.ts +31 -31
  27. package/src/data/consent.ts +20 -20
  28. package/src/data/custom.ts +23 -23
  29. package/src/data/dimension.ts +53 -53
  30. package/src/data/encode.ts +140 -140
  31. package/src/data/envelope.ts +53 -53
  32. package/src/data/extract.ts +211 -211
  33. package/src/data/index.ts +46 -46
  34. package/src/data/limit.ts +44 -44
  35. package/src/data/metadata.ts +344 -344
  36. package/src/data/metric.ts +51 -51
  37. package/src/data/ping.ts +36 -36
  38. package/src/data/signal.ts +30 -30
  39. package/src/data/summary.ts +34 -34
  40. package/src/data/token.ts +39 -39
  41. package/src/data/upgrade.ts +44 -44
  42. package/src/data/upload.ts +283 -283
  43. package/src/data/variable.ts +83 -83
  44. package/src/diagnostic/encode.ts +40 -40
  45. package/src/diagnostic/fraud.ts +36 -36
  46. package/src/diagnostic/index.ts +15 -15
  47. package/src/diagnostic/internal.ts +28 -28
  48. package/src/diagnostic/script.ts +37 -37
  49. package/src/global.ts +6 -6
  50. package/src/index.ts +9 -9
  51. package/src/insight/blank.ts +14 -14
  52. package/src/insight/encode.ts +60 -60
  53. package/src/insight/snapshot.ts +114 -114
  54. package/src/interaction/change.ts +40 -40
  55. package/src/interaction/click.ts +162 -162
  56. package/src/interaction/clipboard.ts +34 -34
  57. package/src/interaction/encode.ts +193 -193
  58. package/src/interaction/index.ts +59 -59
  59. package/src/interaction/input.ts +59 -59
  60. package/src/interaction/pointer.ts +139 -139
  61. package/src/interaction/resize.ts +47 -47
  62. package/src/interaction/scroll.ts +124 -124
  63. package/src/interaction/selection.ts +68 -68
  64. package/src/interaction/submit.ts +32 -32
  65. package/src/interaction/timeline.ts +65 -65
  66. package/src/interaction/unload.ts +28 -28
  67. package/src/interaction/visibility.ts +26 -26
  68. package/src/layout/animation.ts +133 -133
  69. package/src/layout/discover.ts +31 -31
  70. package/src/layout/document.ts +48 -48
  71. package/src/layout/dom.ts +439 -439
  72. package/src/layout/encode.ts +147 -147
  73. package/src/layout/index.ts +41 -41
  74. package/src/layout/mutation.ts +415 -417
  75. package/src/layout/node.ts +292 -292
  76. package/src/layout/offset.ts +19 -19
  77. package/src/layout/region.ts +153 -153
  78. package/src/layout/schema.ts +63 -63
  79. package/src/layout/selector.ts +82 -82
  80. package/src/layout/style.ts +160 -164
  81. package/src/layout/target.ts +32 -32
  82. package/src/layout/traverse.ts +27 -27
  83. package/src/performance/blank.ts +7 -7
  84. package/src/performance/encode.ts +31 -31
  85. package/src/performance/index.ts +14 -14
  86. package/src/performance/interaction.ts +125 -125
  87. package/src/performance/navigation.ts +31 -31
  88. package/src/performance/observer.ts +108 -108
  89. package/src/queue.ts +33 -33
  90. package/test/core.test.ts +139 -139
  91. package/test/helper.ts +162 -162
  92. package/test/html/core.html +27 -27
  93. package/test/stub.test.ts +7 -7
  94. package/test/tsconfig.test.json +5 -5
  95. package/tsconfig.json +21 -21
  96. package/tslint.json +32 -32
  97. package/types/core.d.ts +150 -154
  98. package/types/data.d.ts +514 -511
  99. package/types/diagnostic.d.ts +24 -24
  100. package/types/index.d.ts +39 -39
  101. package/types/interaction.d.ts +165 -165
  102. package/types/layout.d.ts +272 -272
  103. package/types/performance.d.ts +64 -64
@@ -1,68 +1,68 @@
1
- import { Event } from "@clarity-types/data";
2
- import { SelectionData, Setting } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
- import { bind } from "@src/core/event";
5
- import { schedule } from "@src/core/task";
6
- import { clearTimeout, setTimeout } from "@src/core/timeout";
7
- import encode from "./encode";
8
-
9
- export let data: SelectionData = null;
10
- let previous: Selection = null;
11
- let timeout: number = null;
12
-
13
- export function start(): void {
14
- reset();
15
- }
16
-
17
- export function observe(root: Node): void {
18
- bind(root, "selectstart", recompute.bind(this, root), true);
19
- bind(root, "selectionchange", recompute.bind(this, root), true);
20
- }
21
-
22
- function recompute(root: Node): void {
23
- recompute.dn = FunctionNames.SelectionRecompute;
24
- let doc = root.nodeType === Node.DOCUMENT_NODE ? root as Document : document;
25
- let current = doc.getSelection();
26
-
27
- // Bail out if we don't have a valid selection
28
- if (current === null) { return; }
29
-
30
- // Bail out if we got a valid selection but not valid nodes
31
- // In Edge, selectionchange gets fired even on interactions like right clicks and
32
- // can result in null anchorNode and focusNode if there was no previous selection on page
33
- // Also, ignore any selections that start and end at the exact same point
34
- if ((current.anchorNode === null && current.focusNode === null) ||
35
- (current.anchorNode === current.focusNode && current.anchorOffset === current.focusOffset)) {
36
- return;
37
- }
38
- let startNode = data.start ? data.start : null;
39
- if (previous !== null && data.start !== null && startNode !== current.anchorNode) {
40
- clearTimeout(timeout);
41
- process(Event.Selection);
42
- }
43
-
44
- data = {
45
- start: current.anchorNode,
46
- startOffset: current.anchorOffset,
47
- end: current.focusNode,
48
- endOffset: current.focusOffset
49
- };
50
- previous = current;
51
-
52
- clearTimeout(timeout);
53
- timeout = setTimeout(process, Setting.LookAhead, Event.Selection);
54
- }
55
-
56
- function process(event: Event): void {
57
- schedule(encode.bind(this, event));
58
- }
59
-
60
- export function reset(): void {
61
- previous = null;
62
- data = { start: 0, startOffset: 0, end: 0, endOffset: 0 };
63
- }
64
-
65
- export function stop(): void {
66
- reset();
67
- clearTimeout(timeout);
68
- }
1
+ import { Event } from "@clarity-types/data";
2
+ import { SelectionData, Setting } from "@clarity-types/interaction";
3
+ import { FunctionNames } from "@clarity-types/performance";
4
+ import { bind } from "@src/core/event";
5
+ import { schedule } from "@src/core/task";
6
+ import { clearTimeout, setTimeout } from "@src/core/timeout";
7
+ import encode from "./encode";
8
+
9
+ export let data: SelectionData = null;
10
+ let previous: Selection = null;
11
+ let timeout: number = null;
12
+
13
+ export function start(): void {
14
+ reset();
15
+ }
16
+
17
+ export function observe(root: Node): void {
18
+ bind(root, "selectstart", recompute.bind(this, root), true);
19
+ bind(root, "selectionchange", recompute.bind(this, root), true);
20
+ }
21
+
22
+ function recompute(root: Node): void {
23
+ recompute.dn = FunctionNames.SelectionRecompute;
24
+ let doc = root.nodeType === Node.DOCUMENT_NODE ? root as Document : document;
25
+ let current = doc.getSelection();
26
+
27
+ // Bail out if we don't have a valid selection
28
+ if (current === null) { return; }
29
+
30
+ // Bail out if we got a valid selection but not valid nodes
31
+ // In Edge, selectionchange gets fired even on interactions like right clicks and
32
+ // can result in null anchorNode and focusNode if there was no previous selection on page
33
+ // Also, ignore any selections that start and end at the exact same point
34
+ if ((current.anchorNode === null && current.focusNode === null) ||
35
+ (current.anchorNode === current.focusNode && current.anchorOffset === current.focusOffset)) {
36
+ return;
37
+ }
38
+ let startNode = data.start ? data.start : null;
39
+ if (previous !== null && data.start !== null && startNode !== current.anchorNode) {
40
+ clearTimeout(timeout);
41
+ process(Event.Selection);
42
+ }
43
+
44
+ data = {
45
+ start: current.anchorNode,
46
+ startOffset: current.anchorOffset,
47
+ end: current.focusNode,
48
+ endOffset: current.focusOffset
49
+ };
50
+ previous = current;
51
+
52
+ clearTimeout(timeout);
53
+ timeout = setTimeout(process, Setting.LookAhead, Event.Selection);
54
+ }
55
+
56
+ function process(event: Event): void {
57
+ schedule(encode.bind(this, event));
58
+ }
59
+
60
+ export function reset(): void {
61
+ previous = null;
62
+ data = { start: 0, startOffset: 0, end: 0, endOffset: 0 };
63
+ }
64
+
65
+ export function stop(): void {
66
+ reset();
67
+ clearTimeout(timeout);
68
+ }
@@ -1,32 +1,32 @@
1
- import { Event } from "@clarity-types/data";
2
- import { SubmitState } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
- import { bind } from "@src/core/event";
5
- import { schedule } from "@src/core/task";
6
- import { time } from "@src/core/time";
7
- import encode from "./encode";
8
- import { target } from "@src/layout/target";
9
-
10
- export let state: SubmitState[] = [];
11
-
12
- export function start(): void {
13
- reset();
14
- }
15
-
16
- export function observe(root: Node): void {
17
- bind(root, "submit", recompute, true);
18
- }
19
-
20
- function recompute(evt: UIEvent): void {
21
- recompute.dn = FunctionNames.SubmitRecompute;
22
- state.push({ time: time(evt), event: Event.Submit, data: { target: target(evt) } });
23
- schedule(encode.bind(this, Event.Submit));
24
- }
25
-
26
- export function reset(): void {
27
- state = [];
28
- }
29
-
30
- export function stop(): void {
31
- reset();
32
- }
1
+ import { Event } from "@clarity-types/data";
2
+ import { SubmitState } from "@clarity-types/interaction";
3
+ import { FunctionNames } from "@clarity-types/performance";
4
+ import { bind } from "@src/core/event";
5
+ import { schedule } from "@src/core/task";
6
+ import { time } from "@src/core/time";
7
+ import encode from "./encode";
8
+ import { target } from "@src/layout/target";
9
+
10
+ export let state: SubmitState[] = [];
11
+
12
+ export function start(): void {
13
+ reset();
14
+ }
15
+
16
+ export function observe(root: Node): void {
17
+ bind(root, "submit", recompute, true);
18
+ }
19
+
20
+ function recompute(evt: UIEvent): void {
21
+ recompute.dn = FunctionNames.SubmitRecompute;
22
+ state.push({ time: time(evt), event: Event.Submit, data: { target: target(evt) } });
23
+ schedule(encode.bind(this, Event.Submit));
24
+ }
25
+
26
+ export function reset(): void {
27
+ state = [];
28
+ }
29
+
30
+ export function stop(): void {
31
+ reset();
32
+ }
@@ -1,65 +1,65 @@
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
- const temp = [];
47
- updates = [];
48
- let max = envelope.data.start + envelope.data.duration;
49
- let min = Math.max(max - Setting.TimelineSpan, 0);
50
-
51
- for (let s of state) {
52
- if (s.time >= min) {
53
- if (s.time <= max) { updates.push(s); }
54
- temp.push(s);
55
- }
56
- }
57
-
58
- state = temp; // Drop events less than the min time
59
- encode(Event.Timeline);
60
- }
61
-
62
- export function stop(): void {
63
- state = [];
64
- reset();
65
- }
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
+ const temp = [];
47
+ updates = [];
48
+ let max = envelope.data.start + envelope.data.duration;
49
+ let min = Math.max(max - Setting.TimelineSpan, 0);
50
+
51
+ for (let s of state) {
52
+ if (s.time >= min) {
53
+ if (s.time <= max) { updates.push(s); }
54
+ temp.push(s);
55
+ }
56
+ }
57
+
58
+ state = temp; // Drop events less than the min time
59
+ encode(Event.Timeline);
60
+ }
61
+
62
+ export function stop(): void {
63
+ state = [];
64
+ reset();
65
+ }
@@ -1,28 +1,28 @@
1
- import { BooleanFlag, Event } from "@clarity-types/data";
2
- import { UnloadData } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
- import * as clarity from "@src/clarity";
5
- import { bind } from "@src/core/event";
6
- import { time } from "@src/core/time";
7
- import encode from "./encode";
8
-
9
- export let data: UnloadData;
10
-
11
- export function start(): void {
12
- bind(window, "pagehide", recompute);
13
- }
14
-
15
- function recompute(evt: PageTransitionEvent): void {
16
- recompute.dn = FunctionNames.UnloadRecompute;
17
- data = { name: evt.type, persisted: evt.persisted ? BooleanFlag.True : BooleanFlag.False };
18
- encode(Event.Unload, time(evt));
19
- clarity.stop();
20
- }
21
-
22
- export function reset(): void {
23
- data = null;
24
- }
25
-
26
- export function stop(): void {
27
- reset();
28
- }
1
+ import { BooleanFlag, Event } from "@clarity-types/data";
2
+ import { UnloadData } from "@clarity-types/interaction";
3
+ import { FunctionNames } from "@clarity-types/performance";
4
+ import * as clarity from "@src/clarity";
5
+ import { bind } from "@src/core/event";
6
+ import { time } from "@src/core/time";
7
+ import encode from "./encode";
8
+
9
+ export let data: UnloadData;
10
+
11
+ export function start(): void {
12
+ bind(window, "pagehide", recompute);
13
+ }
14
+
15
+ function recompute(evt: PageTransitionEvent): void {
16
+ recompute.dn = FunctionNames.UnloadRecompute;
17
+ data = { name: evt.type, persisted: evt.persisted ? BooleanFlag.True : BooleanFlag.False };
18
+ encode(Event.Unload, time(evt));
19
+ clarity.stop();
20
+ }
21
+
22
+ export function reset(): void {
23
+ data = null;
24
+ }
25
+
26
+ export function stop(): void {
27
+ reset();
28
+ }
@@ -1,27 +1,27 @@
1
- import { Event } from "@clarity-types/data";
2
- import { VisibilityData } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
- import { bind } from "@src/core/event";
5
- import { time } from "@src/core/time";
6
- import encode from "./encode";
7
-
8
- export let data: VisibilityData;
9
-
10
- export function start(): void {
11
- bind(document, "visibilitychange", recompute);
12
- recompute();
13
- }
14
-
15
- function recompute(evt: UIEvent = null): void {
16
- recompute.dn = FunctionNames.VisibilityRecompute;
17
- data = { visible: "visibilityState" in document ? document.visibilityState : "default" };
18
- encode(Event.Visibility, time(evt));
19
- }
20
-
21
- export function reset(): void {
22
- data = null;
23
- }
24
-
25
- export function stop(): void {
26
- reset();
1
+ import { Event } from "@clarity-types/data";
2
+ import { VisibilityData } from "@clarity-types/interaction";
3
+ import { FunctionNames } from "@clarity-types/performance";
4
+ import { bind } from "@src/core/event";
5
+ import { time } from "@src/core/time";
6
+ import encode from "./encode";
7
+
8
+ export let data: VisibilityData;
9
+
10
+ export function start(): void {
11
+ bind(document, "visibilitychange", recompute);
12
+ recompute();
13
+ }
14
+
15
+ function recompute(evt: UIEvent = null): void {
16
+ recompute.dn = FunctionNames.VisibilityRecompute;
17
+ data = { visible: "visibilityState" in document ? document.visibilityState : "default" };
18
+ encode(Event.Visibility, time(evt));
19
+ }
20
+
21
+ export function reset(): void {
22
+ data = null;
23
+ }
24
+
25
+ export function stop(): void {
26
+ reset();
27
27
  }