clarity-js 0.8.40 → 0.8.42

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 (113) 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 +6027 -6027
  5. package/build/clarity.min.js +1 -1
  6. package/build/clarity.module.js +6027 -6027
  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/event.ts +53 -53
  15. package/src/core/hash.ts +19 -19
  16. package/src/core/history.ts +71 -71
  17. package/src/core/index.ts +81 -81
  18. package/src/core/measure.ts +19 -19
  19. package/src/core/report.ts +28 -28
  20. package/src/core/scrub.ts +202 -202
  21. package/src/core/task.ts +181 -181
  22. package/src/core/throttle.ts +46 -46
  23. package/src/core/time.ts +26 -26
  24. package/src/core/timeout.ts +10 -10
  25. package/src/core/version.ts +2 -2
  26. package/src/data/baseline.ts +162 -162
  27. package/src/data/compress.ts +31 -31
  28. package/src/data/consent.ts +77 -77
  29. package/src/data/custom.ts +23 -23
  30. package/src/data/dimension.ts +53 -53
  31. package/src/data/encode.ts +155 -155
  32. package/src/data/envelope.ts +53 -53
  33. package/src/data/extract.ts +211 -211
  34. package/src/data/index.ts +50 -50
  35. package/src/data/limit.ts +44 -44
  36. package/src/data/metadata.ts +408 -408
  37. package/src/data/metric.ts +51 -51
  38. package/src/data/ping.ts +36 -36
  39. package/src/data/signal.ts +30 -30
  40. package/src/data/summary.ts +34 -34
  41. package/src/data/token.ts +39 -39
  42. package/src/data/upgrade.ts +44 -44
  43. package/src/data/upload.ts +333 -333
  44. package/src/data/variable.ts +83 -83
  45. package/src/diagnostic/encode.ts +40 -40
  46. package/src/diagnostic/fraud.ts +36 -36
  47. package/src/diagnostic/index.ts +13 -13
  48. package/src/diagnostic/internal.ts +28 -28
  49. package/src/diagnostic/script.ts +35 -35
  50. package/src/dynamic/agent/blank.ts +2 -2
  51. package/src/dynamic/agent/crisp.ts +40 -40
  52. package/src/dynamic/agent/encode.ts +25 -25
  53. package/src/dynamic/agent/index.ts +8 -8
  54. package/src/dynamic/agent/livechat.ts +58 -58
  55. package/src/dynamic/agent/tidio.ts +44 -44
  56. package/src/global.ts +6 -6
  57. package/src/index.ts +9 -9
  58. package/src/insight/blank.ts +14 -14
  59. package/src/insight/encode.ts +60 -60
  60. package/src/insight/snapshot.ts +114 -114
  61. package/src/interaction/change.ts +38 -38
  62. package/src/interaction/click.ts +173 -173
  63. package/src/interaction/clipboard.ts +32 -32
  64. package/src/interaction/encode.ts +210 -210
  65. package/src/interaction/index.ts +60 -60
  66. package/src/interaction/input.ts +57 -57
  67. package/src/interaction/pointer.ts +137 -137
  68. package/src/interaction/resize.ts +50 -50
  69. package/src/interaction/scroll.ts +129 -129
  70. package/src/interaction/selection.ts +66 -66
  71. package/src/interaction/submit.ts +30 -30
  72. package/src/interaction/timeline.ts +69 -69
  73. package/src/interaction/unload.ts +26 -26
  74. package/src/interaction/visibility.ts +27 -27
  75. package/src/layout/animation.ts +133 -133
  76. package/src/layout/custom.ts +42 -42
  77. package/src/layout/discover.ts +31 -31
  78. package/src/layout/document.ts +46 -46
  79. package/src/layout/dom.ts +439 -439
  80. package/src/layout/encode.ts +154 -154
  81. package/src/layout/index.ts +42 -42
  82. package/src/layout/mutation.ts +411 -411
  83. package/src/layout/node.ts +294 -294
  84. package/src/layout/offset.ts +19 -19
  85. package/src/layout/region.ts +151 -151
  86. package/src/layout/schema.ts +63 -63
  87. package/src/layout/selector.ts +82 -82
  88. package/src/layout/style.ts +159 -159
  89. package/src/layout/target.ts +32 -32
  90. package/src/layout/traverse.ts +27 -27
  91. package/src/performance/blank.ts +9 -9
  92. package/src/performance/encode.ts +31 -31
  93. package/src/performance/index.ts +12 -12
  94. package/src/performance/interaction.ts +125 -125
  95. package/src/performance/navigation.ts +31 -31
  96. package/src/performance/observer.ts +112 -112
  97. package/src/queue.ts +33 -33
  98. package/test/core.test.ts +139 -139
  99. package/test/helper.ts +162 -162
  100. package/test/html/core.html +27 -27
  101. package/test/stub.test.ts +7 -7
  102. package/test/tsconfig.test.json +5 -5
  103. package/tsconfig.json +21 -21
  104. package/tslint.json +32 -32
  105. package/types/agent.d.ts +39 -39
  106. package/types/core.d.ts +150 -150
  107. package/types/data.d.ts +571 -571
  108. package/types/diagnostic.d.ts +24 -24
  109. package/types/global.d.ts +30 -30
  110. package/types/index.d.ts +40 -40
  111. package/types/interaction.d.ts +177 -177
  112. package/types/layout.d.ts +276 -276
  113. package/types/performance.d.ts +31 -31
@@ -1,160 +1,160 @@
1
- import { Event } from "@clarity-types/data";
2
- import { StyleSheetOperation, StyleSheetState } from "@clarity-types/layout";
3
- import { time } from "@src/core/time";
4
- import { shortid } from "@src/data/metadata";
5
- import encode from "@src/layout/encode";
6
- import { getId } from "@src/layout/dom";
7
- import * as core from "@src/core";
8
- import config from "@src/core/config";
9
- import { getCssRules } from "./node";
10
-
11
- export let sheetUpdateState: StyleSheetState[] = [];
12
- export let sheetAdoptionState: StyleSheetState[] = [];
13
- const styleSheetId = 'claritySheetId';
14
- let styleSheetMap = {};
15
- let styleTimeMap: {[key: string]: number} = {};
16
- let documentNodes = [];
17
- let createdSheetIds = [];
18
-
19
- function proxyStyleRules(win: any) {
20
- if ((config.lean && config.lite) || win === null || win === undefined) {
21
- return;
22
- }
23
-
24
- win.clarityOverrides = win.clarityOverrides || {};
25
-
26
- if (win['CSSStyleSheet'] && win.CSSStyleSheet.prototype) {
27
- if (win.clarityOverrides.replace === undefined) {
28
- win.clarityOverrides.replace = win.CSSStyleSheet.prototype.replace;
29
- win.CSSStyleSheet.prototype.replace = function(): Promise<CSSStyleSheet> {
30
- if (core.active()) {
31
- // if we haven't seen this stylesheet on this page yet, wait until the checkDocumentStyles has found it
32
- // and attached the sheet to a document. This way the timestamp of the style sheet creation will align
33
- // to when it is used in the document rather than potentially being misaligned during the traverse process.
34
- if (createdSheetIds.indexOf(this[styleSheetId]) > -1) {
35
- trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.Replace, arguments[0]);
36
- }
37
- }
38
- return win.clarityOverrides.replace.apply(this, arguments);
39
- };
40
- }
41
-
42
- if (win.clarityOverrides.replaceSync === undefined) {
43
- win.clarityOverrides.replaceSync = win.CSSStyleSheet.prototype.replaceSync;
44
- win.CSSStyleSheet.prototype.replaceSync = function(): void {
45
- if (core.active()) {
46
- // if we haven't seen this stylesheet on this page yet, wait until the checkDocumentStyles has found it
47
- // and attached the sheet to a document. This way the timestamp of the style sheet creation will align
48
- // to when it is used in the document rather than potentially being misaligned during the traverse process.
49
- if (createdSheetIds.indexOf(this[styleSheetId]) > -1) {
50
- trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.ReplaceSync, arguments[0]);
51
- }
52
- }
53
- return win.clarityOverrides.replaceSync.apply(this, arguments);
54
- };
55
- }
56
- }
57
- }
58
-
59
- export function start(): void {
60
- proxyStyleRules(window);
61
- }
62
-
63
- export function checkDocumentStyles(documentNode: Document, timestamp: number): void {
64
- if (config.lean && config.lite) { return; }
65
-
66
- if (documentNodes.indexOf(documentNode) === -1) {
67
- documentNodes.push(documentNode);
68
- if (documentNode.defaultView) {
69
- proxyStyleRules(documentNode.defaultView);
70
- }
71
- }
72
- timestamp = timestamp || time();
73
- if (!documentNode?.adoptedStyleSheets) {
74
- // if we don't have adoptedStyledSheets on the Node passed to us, we can short circuit.
75
- return;
76
- }
77
- let currentStyleSheets: string[] = [];
78
- for (var styleSheet of documentNode.adoptedStyleSheets) {
79
- // If we haven't seen this style sheet on this page yet, we create a reference to it for the visualizer.
80
- // For SPA or times in which Clarity restarts on a given page, our visualizer would lose context
81
- // on the previously created style sheet for page N-1.
82
- // Then we synthetically call replaceSync with its contents to bootstrap it
83
- if (!styleSheet[styleSheetId] || createdSheetIds.indexOf(styleSheet[styleSheetId]) === -1) {
84
- styleSheet[styleSheetId] = shortid();
85
- createdSheetIds.push(styleSheet[styleSheetId]);
86
- trackStyleChange(timestamp, styleSheet[styleSheetId], StyleSheetOperation.Create);
87
- trackStyleChange(timestamp, styleSheet[styleSheetId], StyleSheetOperation.ReplaceSync, getCssRules(styleSheet));
88
- }
89
-
90
- currentStyleSheets.push(styleSheet[styleSheetId]);
91
- }
92
-
93
- let documentId = getId(documentNode, true);
94
- if (!styleSheetMap[documentId]) {
95
- styleSheetMap[documentId] = [];
96
- }
97
- if (!arraysEqual(currentStyleSheets, styleSheetMap[documentId])) {
98
- // Using -1 to signify the root document node as we don't track that as part of our nodeMap
99
- trackStyleAdoption(timestamp, documentNode == document ? -1 : getId(documentNode), StyleSheetOperation.SetAdoptedStyles, currentStyleSheets);
100
- styleSheetMap[documentId] = currentStyleSheets;
101
- styleTimeMap[documentId] = timestamp;
102
- }
103
- }
104
-
105
- export function compute(): void {
106
- for (var documentNode of documentNodes) {
107
- var docId = documentNode == document ? -1 : getId(documentNode);
108
- let ts = docId in styleTimeMap ? styleTimeMap[docId] : null;
109
- checkDocumentStyles(documentNode, ts);
110
- }
111
- }
112
-
113
- export function reset(): void {
114
- sheetAdoptionState = [];
115
- sheetUpdateState = [];
116
- }
117
-
118
- export function stop(): void {
119
- styleSheetMap = {};
120
- styleTimeMap = {};
121
- documentNodes = [];
122
- createdSheetIds = [];
123
- reset();
124
- }
125
-
126
- function trackStyleChange(time: number, id: string, operation: StyleSheetOperation, cssRules?: string): void {
127
- sheetUpdateState.push({
128
- time,
129
- event: Event.StyleSheetUpdate,
130
- data: {
131
- id,
132
- operation,
133
- cssRules
134
- }
135
- });
136
-
137
- encode(Event.StyleSheetUpdate);
138
- }
139
-
140
- function trackStyleAdoption(time: number, id: number, operation: StyleSheetOperation, newIds: string[]): void {
141
- sheetAdoptionState.push({
142
- time,
143
- event: Event.StyleSheetAdoption,
144
- data: {
145
- id,
146
- operation,
147
- newIds
148
- }
149
- });
150
-
151
- encode(Event.StyleSheetAdoption);
152
- }
153
-
154
- function arraysEqual(a: string[], b: string[]): boolean {
155
- if (a.length !== b.length) {
156
- return false;
157
- }
158
-
159
- return a.every((value, index) => value === b[index]);
1
+ import { Event } from "@clarity-types/data";
2
+ import { StyleSheetOperation, StyleSheetState } from "@clarity-types/layout";
3
+ import { time } from "@src/core/time";
4
+ import { shortid } from "@src/data/metadata";
5
+ import encode from "@src/layout/encode";
6
+ import { getId } from "@src/layout/dom";
7
+ import * as core from "@src/core";
8
+ import config from "@src/core/config";
9
+ import { getCssRules } from "./node";
10
+
11
+ export let sheetUpdateState: StyleSheetState[] = [];
12
+ export let sheetAdoptionState: StyleSheetState[] = [];
13
+ const styleSheetId = 'claritySheetId';
14
+ let styleSheetMap = {};
15
+ let styleTimeMap: {[key: string]: number} = {};
16
+ let documentNodes = [];
17
+ let createdSheetIds = [];
18
+
19
+ function proxyStyleRules(win: any) {
20
+ if ((config.lean && config.lite) || win === null || win === undefined) {
21
+ return;
22
+ }
23
+
24
+ win.clarityOverrides = win.clarityOverrides || {};
25
+
26
+ if (win['CSSStyleSheet'] && win.CSSStyleSheet.prototype) {
27
+ if (win.clarityOverrides.replace === undefined) {
28
+ win.clarityOverrides.replace = win.CSSStyleSheet.prototype.replace;
29
+ win.CSSStyleSheet.prototype.replace = function(): Promise<CSSStyleSheet> {
30
+ if (core.active()) {
31
+ // if we haven't seen this stylesheet on this page yet, wait until the checkDocumentStyles has found it
32
+ // and attached the sheet to a document. This way the timestamp of the style sheet creation will align
33
+ // to when it is used in the document rather than potentially being misaligned during the traverse process.
34
+ if (createdSheetIds.indexOf(this[styleSheetId]) > -1) {
35
+ trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.Replace, arguments[0]);
36
+ }
37
+ }
38
+ return win.clarityOverrides.replace.apply(this, arguments);
39
+ };
40
+ }
41
+
42
+ if (win.clarityOverrides.replaceSync === undefined) {
43
+ win.clarityOverrides.replaceSync = win.CSSStyleSheet.prototype.replaceSync;
44
+ win.CSSStyleSheet.prototype.replaceSync = function(): void {
45
+ if (core.active()) {
46
+ // if we haven't seen this stylesheet on this page yet, wait until the checkDocumentStyles has found it
47
+ // and attached the sheet to a document. This way the timestamp of the style sheet creation will align
48
+ // to when it is used in the document rather than potentially being misaligned during the traverse process.
49
+ if (createdSheetIds.indexOf(this[styleSheetId]) > -1) {
50
+ trackStyleChange(time(), this[styleSheetId], StyleSheetOperation.ReplaceSync, arguments[0]);
51
+ }
52
+ }
53
+ return win.clarityOverrides.replaceSync.apply(this, arguments);
54
+ };
55
+ }
56
+ }
57
+ }
58
+
59
+ export function start(): void {
60
+ proxyStyleRules(window);
61
+ }
62
+
63
+ export function checkDocumentStyles(documentNode: Document, timestamp: number): void {
64
+ if (config.lean && config.lite) { return; }
65
+
66
+ if (documentNodes.indexOf(documentNode) === -1) {
67
+ documentNodes.push(documentNode);
68
+ if (documentNode.defaultView) {
69
+ proxyStyleRules(documentNode.defaultView);
70
+ }
71
+ }
72
+ timestamp = timestamp || time();
73
+ if (!documentNode?.adoptedStyleSheets) {
74
+ // if we don't have adoptedStyledSheets on the Node passed to us, we can short circuit.
75
+ return;
76
+ }
77
+ let currentStyleSheets: string[] = [];
78
+ for (var styleSheet of documentNode.adoptedStyleSheets) {
79
+ // If we haven't seen this style sheet on this page yet, we create a reference to it for the visualizer.
80
+ // For SPA or times in which Clarity restarts on a given page, our visualizer would lose context
81
+ // on the previously created style sheet for page N-1.
82
+ // Then we synthetically call replaceSync with its contents to bootstrap it
83
+ if (!styleSheet[styleSheetId] || createdSheetIds.indexOf(styleSheet[styleSheetId]) === -1) {
84
+ styleSheet[styleSheetId] = shortid();
85
+ createdSheetIds.push(styleSheet[styleSheetId]);
86
+ trackStyleChange(timestamp, styleSheet[styleSheetId], StyleSheetOperation.Create);
87
+ trackStyleChange(timestamp, styleSheet[styleSheetId], StyleSheetOperation.ReplaceSync, getCssRules(styleSheet));
88
+ }
89
+
90
+ currentStyleSheets.push(styleSheet[styleSheetId]);
91
+ }
92
+
93
+ let documentId = getId(documentNode, true);
94
+ if (!styleSheetMap[documentId]) {
95
+ styleSheetMap[documentId] = [];
96
+ }
97
+ if (!arraysEqual(currentStyleSheets, styleSheetMap[documentId])) {
98
+ // Using -1 to signify the root document node as we don't track that as part of our nodeMap
99
+ trackStyleAdoption(timestamp, documentNode == document ? -1 : getId(documentNode), StyleSheetOperation.SetAdoptedStyles, currentStyleSheets);
100
+ styleSheetMap[documentId] = currentStyleSheets;
101
+ styleTimeMap[documentId] = timestamp;
102
+ }
103
+ }
104
+
105
+ export function compute(): void {
106
+ for (var documentNode of documentNodes) {
107
+ var docId = documentNode == document ? -1 : getId(documentNode);
108
+ let ts = docId in styleTimeMap ? styleTimeMap[docId] : null;
109
+ checkDocumentStyles(documentNode, ts);
110
+ }
111
+ }
112
+
113
+ export function reset(): void {
114
+ sheetAdoptionState = [];
115
+ sheetUpdateState = [];
116
+ }
117
+
118
+ export function stop(): void {
119
+ styleSheetMap = {};
120
+ styleTimeMap = {};
121
+ documentNodes = [];
122
+ createdSheetIds = [];
123
+ reset();
124
+ }
125
+
126
+ function trackStyleChange(time: number, id: string, operation: StyleSheetOperation, cssRules?: string): void {
127
+ sheetUpdateState.push({
128
+ time,
129
+ event: Event.StyleSheetUpdate,
130
+ data: {
131
+ id,
132
+ operation,
133
+ cssRules
134
+ }
135
+ });
136
+
137
+ encode(Event.StyleSheetUpdate);
138
+ }
139
+
140
+ function trackStyleAdoption(time: number, id: number, operation: StyleSheetOperation, newIds: string[]): void {
141
+ sheetAdoptionState.push({
142
+ time,
143
+ event: Event.StyleSheetAdoption,
144
+ data: {
145
+ id,
146
+ operation,
147
+ newIds
148
+ }
149
+ });
150
+
151
+ encode(Event.StyleSheetAdoption);
152
+ }
153
+
154
+ function arraysEqual(a: string[], b: string[]): boolean {
155
+ if (a.length !== b.length) {
156
+ return false;
157
+ }
158
+
159
+ return a.every((value, index) => value === b[index]);
160
160
  }
@@ -1,32 +1,32 @@
1
- import { Privacy } from "@clarity-types/core";
2
- import { Event } from "@clarity-types/data";
3
- import { TargetMetadata } from "@clarity-types/layout";
4
- import * as fraud from "@src/diagnostic/fraud";
5
- import * as region from "@src/layout/region";
6
- import * as dom from "@src/layout/dom";
7
- import * as mutation from "@src/layout/mutation";
8
-
9
- export function target(evt: UIEvent): Node {
10
- let path = evt.composed && evt.composedPath ? evt.composedPath() : null;
11
- let node = (path && path.length > 0 ? path[0] : evt.target) as Node;
12
- mutation.active(); // Mark active periods of time so mutations can continue uninterrupted
13
- return node && node.nodeType === Node.DOCUMENT_NODE ? (node as Document).documentElement : node;
14
- }
15
-
16
- export function metadata(node: Node, event: Event, text: string = null): TargetMetadata {
17
- // If the node is null, we return a reserved value for id: 0. Valid assignment of id begins from 1+.
18
- let output: TargetMetadata = { id: 0, hash: null, privacy: Privacy.Text };
19
- if (node) {
20
- let value = dom.get(node);
21
- if (value !== null) {
22
- let metadata = value.metadata;
23
- output.id = value.id;
24
- output.hash = value.hash;
25
- output.privacy = metadata.privacy;
26
- if (value.region) { region.track(value.region, event); }
27
- if (metadata.fraud) { fraud.check(metadata.fraud, value.id, text || value.data.value); }
28
- }
29
- }
30
-
31
- return output;
32
- }
1
+ import { Privacy } from "@clarity-types/core";
2
+ import { Event } from "@clarity-types/data";
3
+ import { TargetMetadata } from "@clarity-types/layout";
4
+ import * as fraud from "@src/diagnostic/fraud";
5
+ import * as region from "@src/layout/region";
6
+ import * as dom from "@src/layout/dom";
7
+ import * as mutation from "@src/layout/mutation";
8
+
9
+ export function target(evt: UIEvent): Node {
10
+ let path = evt.composed && evt.composedPath ? evt.composedPath() : null;
11
+ let node = (path && path.length > 0 ? path[0] : evt.target) as Node;
12
+ mutation.active(); // Mark active periods of time so mutations can continue uninterrupted
13
+ return node && node.nodeType === Node.DOCUMENT_NODE ? (node as Document).documentElement : node;
14
+ }
15
+
16
+ export function metadata(node: Node, event: Event, text: string = null): TargetMetadata {
17
+ // If the node is null, we return a reserved value for id: 0. Valid assignment of id begins from 1+.
18
+ let output: TargetMetadata = { id: 0, hash: null, privacy: Privacy.Text };
19
+ if (node) {
20
+ let value = dom.get(node);
21
+ if (value !== null) {
22
+ let metadata = value.metadata;
23
+ output.id = value.id;
24
+ output.hash = value.hash;
25
+ output.privacy = metadata.privacy;
26
+ if (value.region) { region.track(value.region, event); }
27
+ if (metadata.fraud) { fraud.check(metadata.fraud, value.id, text || value.data.value); }
28
+ }
29
+ }
30
+
31
+ return output;
32
+ }
@@ -1,28 +1,28 @@
1
- import { Task, Timer } from "@clarity-types/core";
2
- import { Source } from "@clarity-types/layout";
3
- import * as task from "@src/core/task";
4
- import node from "@src/layout/node";
5
-
6
- export default async function(root: Node, timer: Timer, source: Source, timestamp: number): Promise<void> {
7
- let queue = [root];
8
- while (queue.length > 0) {
9
- let entry = queue.shift();
10
- let next = entry.firstChild;
11
-
12
- while (next) {
13
- queue.push(next);
14
- next = next.nextSibling;
15
- }
16
-
17
- // Check the status of current task to see if we should yield before continuing
18
- let state = task.state(timer);
19
- if (state === Task.Wait) { state = await task.suspend(timer); }
20
- if (state === Task.Stop) { break; }
21
-
22
- // Check if processing a node gives us a pointer to one of its sub nodes for traversal
23
- // E.g. an element node may give us a pointer to traverse shadowDom if shadowRoot property is set
24
- // Or, an iframe from the same origin could give a pointer to it's document for traversing contents of iframe.
25
- let subnode = node(entry, source, timestamp);
26
- if (subnode) { queue.push(subnode); }
27
- }
1
+ import { Task, Timer } from "@clarity-types/core";
2
+ import { Source } from "@clarity-types/layout";
3
+ import * as task from "@src/core/task";
4
+ import node from "@src/layout/node";
5
+
6
+ export default async function(root: Node, timer: Timer, source: Source, timestamp: number): Promise<void> {
7
+ let queue = [root];
8
+ while (queue.length > 0) {
9
+ let entry = queue.shift();
10
+ let next = entry.firstChild;
11
+
12
+ while (next) {
13
+ queue.push(next);
14
+ next = next.nextSibling;
15
+ }
16
+
17
+ // Check the status of current task to see if we should yield before continuing
18
+ let state = task.state(timer);
19
+ if (state === Task.Wait) { state = await task.suspend(timer); }
20
+ if (state === Task.Stop) { break; }
21
+
22
+ // Check if processing a node gives us a pointer to one of its sub nodes for traversal
23
+ // E.g. an element node may give us a pointer to traverse shadowDom if shadowRoot property is set
24
+ // Or, an iframe from the same origin could give a pointer to it's document for traversing contents of iframe.
25
+ let subnode = node(entry, source, timestamp);
26
+ if (subnode) { queue.push(subnode); }
27
+ }
28
28
  }
@@ -1,10 +1,10 @@
1
- export * from "@src/insight/blank";
2
-
3
- export let keys = [];
4
-
5
- /* Intentionally blank module with empty code */
6
- export function hashText(): void {}
7
- export function trigger(): void {}
8
- export function track(): void {}
9
- export function event(): void {}
1
+ export * from "@src/insight/blank";
2
+
3
+ export let keys = [];
4
+
5
+ /* Intentionally blank module with empty code */
6
+ export function hashText(): void {}
7
+ export function trigger(): void {}
8
+ export function track(): void {}
9
+ export function event(): void {}
10
10
  export function register(): void {}
@@ -1,31 +1,31 @@
1
- import {Event, Token} from "@clarity-types/data";
2
- import { time } from "@src/core/time";
3
- import { queue } from "@src/data/upload";
4
- import * as navigation from "@src/performance/navigation";
5
-
6
- export default async function(type: Event): Promise<void> {
7
- let t = time();
8
- let tokens: Token[] = [t, type];
9
- switch (type) {
10
- case Event.Navigation:
11
- tokens.push(navigation.data.fetchStart);
12
- tokens.push(navigation.data.connectStart);
13
- tokens.push(navigation.data.connectEnd);
14
- tokens.push(navigation.data.requestStart);
15
- tokens.push(navigation.data.responseStart);
16
- tokens.push(navigation.data.responseEnd);
17
- tokens.push(navigation.data.domInteractive);
18
- tokens.push(navigation.data.domComplete);
19
- tokens.push(navigation.data.loadEventStart);
20
- tokens.push(navigation.data.loadEventEnd);
21
- tokens.push(navigation.data.redirectCount);
22
- tokens.push(navigation.data.size);
23
- tokens.push(navigation.data.type);
24
- tokens.push(navigation.data.protocol);
25
- tokens.push(navigation.data.encodedSize);
26
- tokens.push(navigation.data.decodedSize);
27
- navigation.reset();
28
- queue(tokens);
29
- break;
30
- }
31
- }
1
+ import {Event, Token} from "@clarity-types/data";
2
+ import { time } from "@src/core/time";
3
+ import { queue } from "@src/data/upload";
4
+ import * as navigation from "@src/performance/navigation";
5
+
6
+ export default async function(type: Event): Promise<void> {
7
+ let t = time();
8
+ let tokens: Token[] = [t, type];
9
+ switch (type) {
10
+ case Event.Navigation:
11
+ tokens.push(navigation.data.fetchStart);
12
+ tokens.push(navigation.data.connectStart);
13
+ tokens.push(navigation.data.connectEnd);
14
+ tokens.push(navigation.data.requestStart);
15
+ tokens.push(navigation.data.responseStart);
16
+ tokens.push(navigation.data.responseEnd);
17
+ tokens.push(navigation.data.domInteractive);
18
+ tokens.push(navigation.data.domComplete);
19
+ tokens.push(navigation.data.loadEventStart);
20
+ tokens.push(navigation.data.loadEventEnd);
21
+ tokens.push(navigation.data.redirectCount);
22
+ tokens.push(navigation.data.size);
23
+ tokens.push(navigation.data.type);
24
+ tokens.push(navigation.data.protocol);
25
+ tokens.push(navigation.data.encodedSize);
26
+ tokens.push(navigation.data.decodedSize);
27
+ navigation.reset();
28
+ queue(tokens);
29
+ break;
30
+ }
31
+ }
@@ -1,12 +1,12 @@
1
- import * as navigation from "@src/performance/navigation";
2
- import * as observer from "@src/performance/observer";
3
-
4
- export function start(): void {
5
- navigation.reset();
6
- observer.start();
7
- }
8
-
9
- export function stop(): void {
10
- observer.stop();
11
- navigation.reset();
12
- }
1
+ import * as navigation from "@src/performance/navigation";
2
+ import * as observer from "@src/performance/observer";
3
+
4
+ export function start(): void {
5
+ navigation.reset();
6
+ observer.start();
7
+ }
8
+
9
+ export function stop(): void {
10
+ observer.stop();
11
+ navigation.reset();
12
+ }