clarity-js 0.8.41 → 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.
- package/README.md +26 -26
- package/build/clarity.extended.js +1 -1
- package/build/clarity.insight.js +1 -1
- package/build/clarity.js +6027 -6027
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +6027 -6027
- package/build/clarity.performance.js +1 -1
- package/package.json +70 -70
- package/rollup.config.ts +161 -161
- package/src/clarity.ts +65 -65
- package/src/core/api.ts +8 -8
- package/src/core/config.ts +29 -29
- package/src/core/copy.ts +3 -3
- package/src/core/event.ts +53 -53
- package/src/core/hash.ts +19 -19
- package/src/core/history.ts +71 -71
- package/src/core/index.ts +81 -81
- package/src/core/measure.ts +19 -19
- package/src/core/report.ts +28 -28
- package/src/core/scrub.ts +202 -202
- package/src/core/task.ts +181 -181
- package/src/core/throttle.ts +46 -46
- package/src/core/time.ts +26 -26
- package/src/core/timeout.ts +10 -10
- package/src/core/version.ts +2 -2
- package/src/data/baseline.ts +162 -162
- package/src/data/compress.ts +31 -31
- package/src/data/consent.ts +77 -77
- package/src/data/custom.ts +23 -23
- package/src/data/dimension.ts +53 -53
- package/src/data/encode.ts +155 -155
- package/src/data/envelope.ts +53 -53
- package/src/data/extract.ts +211 -211
- package/src/data/index.ts +50 -50
- package/src/data/limit.ts +44 -44
- package/src/data/metadata.ts +408 -408
- package/src/data/metric.ts +51 -51
- package/src/data/ping.ts +36 -36
- package/src/data/signal.ts +30 -30
- package/src/data/summary.ts +34 -34
- package/src/data/token.ts +39 -39
- package/src/data/upgrade.ts +44 -44
- package/src/data/upload.ts +333 -333
- package/src/data/variable.ts +83 -83
- package/src/diagnostic/encode.ts +40 -40
- package/src/diagnostic/fraud.ts +36 -36
- package/src/diagnostic/index.ts +13 -13
- package/src/diagnostic/internal.ts +28 -28
- package/src/diagnostic/script.ts +35 -35
- package/src/dynamic/agent/blank.ts +2 -2
- package/src/dynamic/agent/crisp.ts +40 -40
- package/src/dynamic/agent/encode.ts +25 -25
- package/src/dynamic/agent/index.ts +8 -8
- package/src/dynamic/agent/livechat.ts +58 -58
- package/src/dynamic/agent/tidio.ts +44 -44
- package/src/global.ts +6 -6
- package/src/index.ts +9 -9
- package/src/insight/blank.ts +14 -14
- package/src/insight/encode.ts +60 -60
- package/src/insight/snapshot.ts +114 -114
- package/src/interaction/change.ts +38 -38
- package/src/interaction/click.ts +173 -173
- package/src/interaction/clipboard.ts +32 -32
- package/src/interaction/encode.ts +210 -210
- package/src/interaction/index.ts +60 -60
- package/src/interaction/input.ts +57 -57
- package/src/interaction/pointer.ts +137 -137
- package/src/interaction/resize.ts +50 -50
- package/src/interaction/scroll.ts +129 -129
- package/src/interaction/selection.ts +66 -66
- package/src/interaction/submit.ts +30 -30
- package/src/interaction/timeline.ts +69 -69
- package/src/interaction/unload.ts +26 -26
- package/src/interaction/visibility.ts +27 -27
- package/src/layout/animation.ts +133 -133
- package/src/layout/custom.ts +42 -42
- package/src/layout/discover.ts +31 -31
- package/src/layout/document.ts +46 -46
- package/src/layout/dom.ts +439 -439
- package/src/layout/encode.ts +154 -154
- package/src/layout/index.ts +42 -42
- package/src/layout/mutation.ts +411 -411
- package/src/layout/node.ts +294 -294
- package/src/layout/offset.ts +19 -19
- package/src/layout/region.ts +151 -151
- package/src/layout/schema.ts +63 -63
- package/src/layout/selector.ts +82 -82
- package/src/layout/style.ts +159 -159
- package/src/layout/target.ts +32 -32
- package/src/layout/traverse.ts +27 -27
- package/src/performance/blank.ts +9 -9
- package/src/performance/encode.ts +31 -31
- package/src/performance/index.ts +12 -12
- package/src/performance/interaction.ts +125 -125
- package/src/performance/navigation.ts +31 -31
- package/src/performance/observer.ts +112 -112
- package/src/queue.ts +33 -33
- package/test/core.test.ts +139 -139
- package/test/helper.ts +162 -162
- package/test/html/core.html +27 -27
- package/test/stub.test.ts +7 -7
- package/test/tsconfig.test.json +5 -5
- package/tsconfig.json +21 -21
- package/tslint.json +32 -32
- package/types/agent.d.ts +39 -39
- package/types/core.d.ts +150 -150
- package/types/data.d.ts +571 -571
- package/types/diagnostic.d.ts +24 -24
- package/types/global.d.ts +30 -30
- package/types/index.d.ts +40 -40
- package/types/interaction.d.ts +177 -177
- package/types/layout.d.ts +276 -276
- package/types/performance.d.ts +31 -31
package/src/core/index.ts
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { Config } from "@clarity-types/core";
|
|
2
|
-
import { Constant } from "@clarity-types/data";
|
|
3
|
-
import configuration from "@src/core/config";
|
|
4
|
-
import * as event from "@src/core/event";
|
|
5
|
-
import * as history from "@src/core/history";
|
|
6
|
-
import * as report from "@src/core/report";
|
|
7
|
-
import * as task from "@src/core/task";
|
|
8
|
-
import * as time from "@src/core/time";
|
|
9
|
-
import * as clarity from "@src/clarity";
|
|
10
|
-
import * as custom from "@src/data/custom";
|
|
11
|
-
|
|
12
|
-
let status = false;
|
|
13
|
-
|
|
14
|
-
export function start(): void {
|
|
15
|
-
status = true;
|
|
16
|
-
time.start();
|
|
17
|
-
task.reset();
|
|
18
|
-
event.reset();
|
|
19
|
-
report.reset();
|
|
20
|
-
history.start();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function stop(): void {
|
|
24
|
-
history.stop();
|
|
25
|
-
report.reset();
|
|
26
|
-
event.reset();
|
|
27
|
-
task.reset();
|
|
28
|
-
time.stop();
|
|
29
|
-
status = false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function active(): boolean {
|
|
33
|
-
return status;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function check(): boolean {
|
|
37
|
-
try {
|
|
38
|
-
let globalPrivacyControlSet = navigator && "globalPrivacyControl" in navigator && navigator['globalPrivacyControl'] == true;
|
|
39
|
-
return status === false &&
|
|
40
|
-
typeof Promise !== "undefined" &&
|
|
41
|
-
window["MutationObserver"] &&
|
|
42
|
-
document["createTreeWalker"] &&
|
|
43
|
-
"now" in Date &&
|
|
44
|
-
"now" in performance &&
|
|
45
|
-
typeof WeakMap !== "undefined" &&
|
|
46
|
-
!globalPrivacyControlSet
|
|
47
|
-
} catch (ex) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function config(override: Config): boolean {
|
|
53
|
-
// Process custom configuration overrides, if available
|
|
54
|
-
if (override === null || status) { return false; }
|
|
55
|
-
for (let key in override) {
|
|
56
|
-
if (key in configuration) { configuration[key] = override[key]; }
|
|
57
|
-
}
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Suspend ends the current Clarity instance after a configured timeout period
|
|
62
|
-
// The way it differs from the "end" call is that it starts listening to
|
|
63
|
-
// user interaction events as soon as it terminates existing clarity instance.
|
|
64
|
-
// On the next interaction, it automatically starts another instance under a different page id
|
|
65
|
-
// E.g. if configured timeout is 10m, and user stays inactive for an hour.
|
|
66
|
-
// In this case, we will suspend clarity after 10m of inactivity and after another 50m when user interacts again
|
|
67
|
-
// Clarity will restart and start another instance seamlessly. Effectively not missing any active time, but also
|
|
68
|
-
// not holding the session during inactive time periods.
|
|
69
|
-
export function suspend(): void {
|
|
70
|
-
if (status) {
|
|
71
|
-
custom.event(Constant.Clarity, Constant.Suspend);
|
|
72
|
-
clarity.stop();
|
|
73
|
-
["mousemove", "touchstart"].forEach(x => event.bind(document, x, restart));
|
|
74
|
-
["resize", "scroll", "pageshow"].forEach(x => event.bind(window, x, restart));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function restart(): void {
|
|
79
|
-
clarity.start();
|
|
80
|
-
custom.event(Constant.Clarity, Constant.Restart);
|
|
81
|
-
}
|
|
1
|
+
import { Config } from "@clarity-types/core";
|
|
2
|
+
import { Constant } from "@clarity-types/data";
|
|
3
|
+
import configuration from "@src/core/config";
|
|
4
|
+
import * as event from "@src/core/event";
|
|
5
|
+
import * as history from "@src/core/history";
|
|
6
|
+
import * as report from "@src/core/report";
|
|
7
|
+
import * as task from "@src/core/task";
|
|
8
|
+
import * as time from "@src/core/time";
|
|
9
|
+
import * as clarity from "@src/clarity";
|
|
10
|
+
import * as custom from "@src/data/custom";
|
|
11
|
+
|
|
12
|
+
let status = false;
|
|
13
|
+
|
|
14
|
+
export function start(): void {
|
|
15
|
+
status = true;
|
|
16
|
+
time.start();
|
|
17
|
+
task.reset();
|
|
18
|
+
event.reset();
|
|
19
|
+
report.reset();
|
|
20
|
+
history.start();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function stop(): void {
|
|
24
|
+
history.stop();
|
|
25
|
+
report.reset();
|
|
26
|
+
event.reset();
|
|
27
|
+
task.reset();
|
|
28
|
+
time.stop();
|
|
29
|
+
status = false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function active(): boolean {
|
|
33
|
+
return status;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function check(): boolean {
|
|
37
|
+
try {
|
|
38
|
+
let globalPrivacyControlSet = navigator && "globalPrivacyControl" in navigator && navigator['globalPrivacyControl'] == true;
|
|
39
|
+
return status === false &&
|
|
40
|
+
typeof Promise !== "undefined" &&
|
|
41
|
+
window["MutationObserver"] &&
|
|
42
|
+
document["createTreeWalker"] &&
|
|
43
|
+
"now" in Date &&
|
|
44
|
+
"now" in performance &&
|
|
45
|
+
typeof WeakMap !== "undefined" &&
|
|
46
|
+
!globalPrivacyControlSet
|
|
47
|
+
} catch (ex) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function config(override: Config): boolean {
|
|
53
|
+
// Process custom configuration overrides, if available
|
|
54
|
+
if (override === null || status) { return false; }
|
|
55
|
+
for (let key in override) {
|
|
56
|
+
if (key in configuration) { configuration[key] = override[key]; }
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Suspend ends the current Clarity instance after a configured timeout period
|
|
62
|
+
// The way it differs from the "end" call is that it starts listening to
|
|
63
|
+
// user interaction events as soon as it terminates existing clarity instance.
|
|
64
|
+
// On the next interaction, it automatically starts another instance under a different page id
|
|
65
|
+
// E.g. if configured timeout is 10m, and user stays inactive for an hour.
|
|
66
|
+
// In this case, we will suspend clarity after 10m of inactivity and after another 50m when user interacts again
|
|
67
|
+
// Clarity will restart and start another instance seamlessly. Effectively not missing any active time, but also
|
|
68
|
+
// not holding the session during inactive time periods.
|
|
69
|
+
export function suspend(): void {
|
|
70
|
+
if (status) {
|
|
71
|
+
custom.event(Constant.Clarity, Constant.Suspend);
|
|
72
|
+
clarity.stop();
|
|
73
|
+
["mousemove", "touchstart"].forEach(x => event.bind(document, x, restart));
|
|
74
|
+
["resize", "scroll", "pageshow"].forEach(x => event.bind(window, x, restart));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function restart(): void {
|
|
79
|
+
clarity.start();
|
|
80
|
+
custom.event(Constant.Clarity, Constant.Restart);
|
|
81
|
+
}
|
package/src/core/measure.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Code, Metric, Setting, Severity } from "@clarity-types/data";
|
|
2
|
-
import { report } from "@src/core/report";
|
|
3
|
-
import * as metric from "@src/data/metric";
|
|
4
|
-
import * as internal from "@src/diagnostic/internal";
|
|
5
|
-
|
|
6
|
-
// tslint:disable-next-line: ban-types
|
|
7
|
-
export default function (method: Function): Function {
|
|
8
|
-
return function (): void {
|
|
9
|
-
let start = performance.now();
|
|
10
|
-
try { method.apply(this, arguments); } catch (ex) { throw report(ex); }
|
|
11
|
-
let duration = performance.now() - start;
|
|
12
|
-
metric.sum(Metric.TotalCost, duration);
|
|
13
|
-
if (duration > Setting.LongTask) {
|
|
14
|
-
metric.count(Metric.LongTaskCount);
|
|
15
|
-
metric.max(Metric.ThreadBlockedTime, duration);
|
|
16
|
-
method.dn && internal.log(Code.FunctionExecutionTime, Severity.Info, `${method.dn}-${duration}`);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
}
|
|
1
|
+
import { Code, Metric, Setting, Severity } from "@clarity-types/data";
|
|
2
|
+
import { report } from "@src/core/report";
|
|
3
|
+
import * as metric from "@src/data/metric";
|
|
4
|
+
import * as internal from "@src/diagnostic/internal";
|
|
5
|
+
|
|
6
|
+
// tslint:disable-next-line: ban-types
|
|
7
|
+
export default function (method: Function): Function {
|
|
8
|
+
return function (): void {
|
|
9
|
+
let start = performance.now();
|
|
10
|
+
try { method.apply(this, arguments); } catch (ex) { throw report(ex); }
|
|
11
|
+
let duration = performance.now() - start;
|
|
12
|
+
metric.sum(Metric.TotalCost, duration);
|
|
13
|
+
if (duration > Setting.LongTask) {
|
|
14
|
+
metric.count(Metric.LongTaskCount);
|
|
15
|
+
metric.max(Metric.ThreadBlockedTime, duration);
|
|
16
|
+
method.dn && internal.log(Code.FunctionExecutionTime, Severity.Info, `${method.dn}-${duration}`);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
package/src/core/report.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { Report } from "@clarity-types/core";
|
|
2
|
-
import config from "@src/core/config";
|
|
3
|
-
import { data } from "@src/data/envelope";
|
|
4
|
-
|
|
5
|
-
let history: string[];
|
|
6
|
-
|
|
7
|
-
export function reset(): void {
|
|
8
|
-
history = [];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function report(e: Error): Error {
|
|
12
|
-
// Do not report the same message twice for the same page
|
|
13
|
-
if (history && history.indexOf(e.message) === -1) {
|
|
14
|
-
const url = config.report;
|
|
15
|
-
if (url && url.length > 0 && data) {
|
|
16
|
-
let payload: Report = {v: data.version, p: data.projectId, u: data.userId, s: data.sessionId, n: data.pageNum};
|
|
17
|
-
if (e.message) { payload.m = e.message; }
|
|
18
|
-
if (e.stack) { payload.e = e.stack; }
|
|
19
|
-
// Using POST request instead of a GET request (img-src) to not violate existing CSP rules
|
|
20
|
-
// Since, Clarity already uses XHR to upload data, we stick with similar POST mechanism for reporting too
|
|
21
|
-
let xhr = new XMLHttpRequest();
|
|
22
|
-
xhr.open("POST", url, true);
|
|
23
|
-
xhr.send(JSON.stringify(payload));
|
|
24
|
-
history.push(e.message);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return e;
|
|
28
|
-
}
|
|
1
|
+
import { Report } from "@clarity-types/core";
|
|
2
|
+
import config from "@src/core/config";
|
|
3
|
+
import { data } from "@src/data/envelope";
|
|
4
|
+
|
|
5
|
+
let history: string[];
|
|
6
|
+
|
|
7
|
+
export function reset(): void {
|
|
8
|
+
history = [];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function report(e: Error): Error {
|
|
12
|
+
// Do not report the same message twice for the same page
|
|
13
|
+
if (history && history.indexOf(e.message) === -1) {
|
|
14
|
+
const url = config.report;
|
|
15
|
+
if (url && url.length > 0 && data) {
|
|
16
|
+
let payload: Report = {v: data.version, p: data.projectId, u: data.userId, s: data.sessionId, n: data.pageNum};
|
|
17
|
+
if (e.message) { payload.m = e.message; }
|
|
18
|
+
if (e.stack) { payload.e = e.stack; }
|
|
19
|
+
// Using POST request instead of a GET request (img-src) to not violate existing CSP rules
|
|
20
|
+
// Since, Clarity already uses XHR to upload data, we stick with similar POST mechanism for reporting too
|
|
21
|
+
let xhr = new XMLHttpRequest();
|
|
22
|
+
xhr.open("POST", url, true);
|
|
23
|
+
xhr.send(JSON.stringify(payload));
|
|
24
|
+
history.push(e.message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return e;
|
|
28
|
+
}
|