clarity-js 0.8.22 → 0.8.24

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.
@@ -1,6 +1,5 @@
1
1
  import { Event, Setting } from "@clarity-types/data";
2
2
  import { ScriptErrorData } from "@clarity-types/diagnostic";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import { bind } from "@src/core/event";
5
4
  import encode from "./encode";
6
5
 
@@ -13,7 +12,6 @@ export function start(): void {
13
12
  }
14
13
 
15
14
  function handler(error: ErrorEvent): boolean {
16
- handler.dn = FunctionNames.ScriptHandler;
17
15
  let e = error["error"] || error;
18
16
  // While rare, it's possible for code to fail repeatedly during the lifetime of the same page
19
17
  // In those cases, we only want to log the failure first few times and not spam logs with redundant information.
@@ -1,6 +1,5 @@
1
1
  import { Constant, Event, Setting } from "@clarity-types/data";
2
2
  import { ChangeState } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import config from "@src/core/config";
5
4
  import { bind } from "@src/core/event";
6
5
  import hash from "@src/core/hash";
@@ -21,7 +20,6 @@ export function observe(root: Node): void {
21
20
  }
22
21
 
23
22
  function recompute(evt: UIEvent): void {
24
- recompute.dn = FunctionNames.ChangeRecompute;
25
23
  let element = target(evt) as HTMLInputElement;
26
24
  if (element) {
27
25
  let value = element.value;
@@ -1,7 +1,6 @@
1
1
  import { BooleanFlag, Constant, Event, Setting } from "@clarity-types/data";
2
2
  import { BrowsingContext, ClickState, TextInfo } from "@clarity-types/interaction";
3
3
  import { Box } from "@clarity-types/layout";
4
- import { FunctionNames } from "@clarity-types/performance";
5
4
  import { bind } from "@src/core/event";
6
5
  import { schedule } from "@src/core/task";
7
6
  import { time } from "@src/core/time";
@@ -23,7 +22,6 @@ export function observe(root: Node): void {
23
22
  }
24
23
 
25
24
  function handler(event: Event, root: Node, evt: MouseEvent): void {
26
- handler.dn = FunctionNames.ClickHandler;
27
25
  let frame = iframe(root);
28
26
  let d = frame && frame.contentDocument ? frame.contentDocument.documentElement : document.documentElement;
29
27
  let x = "pageX" in evt ? Math.round(evt.pageX) : ("clientX" in evt ? Math.round(evt["clientX"] + d.scrollLeft) : null);
@@ -1,6 +1,5 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { Clipboard, ClipboardState } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import { bind } from "@src/core/event";
5
4
  import { schedule } from "@src/core/task";
6
5
  import { time } from "@src/core/time";
@@ -20,7 +19,6 @@ export function observe(root: Node): void {
20
19
  }
21
20
 
22
21
  function recompute(action: Clipboard, evt: UIEvent): void {
23
- recompute.dn = FunctionNames.ClipboardRecompute;
24
22
  state.push({ time: time(evt), event: Event.Clipboard, data: { target: target(evt), action } });
25
23
  schedule(encode.bind(this, Event.Clipboard));
26
24
  }
@@ -109,6 +109,7 @@ export default async function (type: Event, ts: number = null): Promise<void> {
109
109
  tokens = [entry.time, entry.event];
110
110
  tokens.push(iTarget.id);
111
111
  tokens.push(scrub.text(entry.data.value, "input", iTarget.privacy, false, entry.data.type));
112
+ tokens.push(entry.data.trust);
112
113
  queue(tokens);
113
114
  }
114
115
  input.reset();
@@ -1,4 +1,3 @@
1
- import { FunctionNames } from "@clarity-types/performance";
2
1
  import * as change from "@src/interaction/change";
3
2
  import * as click from "@src/interaction/click";
4
3
  import * as clipboard from "@src/interaction/clipboard";
@@ -13,7 +12,6 @@ import * as unload from "@src/interaction/unload";
13
12
  import * as visibility from "@src/interaction/visibility";
14
13
 
15
14
  export function start(): void {
16
- start.dn = FunctionNames.InteractionStart;
17
15
  timeline.start();
18
16
  click.start();
19
17
  clipboard.start();
@@ -1,6 +1,5 @@
1
- import { Event } from "@clarity-types/data";
1
+ import { BooleanFlag, Event } from "@clarity-types/data";
2
2
  import { InputData, InputState, Setting } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import { bind } from "@src/core/event";
5
4
  import { schedule } from "@src/core/task";
6
5
  import { time } from "@src/core/time";
@@ -21,7 +20,6 @@ export function observe(root: Node): void {
21
20
  }
22
21
 
23
22
  function recompute(evt: UIEvent): void {
24
- recompute.dn = FunctionNames.InputRecompute;
25
23
  let input = target(evt) as HTMLInputElement;
26
24
  let value = get(input);
27
25
  if (input && input.type && value) {
@@ -34,7 +32,7 @@ function recompute(evt: UIEvent): void {
34
32
  break;
35
33
  }
36
34
 
37
- let data: InputData = { target: input, value: v, type: t };
35
+ let data: InputData = { target: input, value: v, type: t, trust: evt.isTrusted ? BooleanFlag.True : BooleanFlag.False };
38
36
 
39
37
  // If last entry in the queue is for the same target node as the current one, remove it so we can later swap it with current data.
40
38
  if (state.length > 0 && (state[state.length - 1].data.target === data.target)) { state.pop(); }
@@ -1,6 +1,5 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { PointerState, Setting } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import { bind } from "@src/core/event";
5
4
  import { schedule } from "@src/core/task";
6
5
  import { time } from "@src/core/time";
@@ -33,7 +32,6 @@ export function observe(root: Node): void {
33
32
  }
34
33
 
35
34
  function mouse(event: Event, root: Node, evt: MouseEvent): void {
36
- mouse.dn = FunctionNames.PointerMouse;
37
35
  let frame = iframe(root);
38
36
  let d = frame && frame.contentDocument ? frame.contentDocument.documentElement : document.documentElement;
39
37
  let x = "pageX" in evt ? Math.round(evt.pageX) : ("clientX" in evt ? Math.round(evt["clientX"] + d.scrollLeft) : null);
@@ -50,7 +48,6 @@ function mouse(event: Event, root: Node, evt: MouseEvent): void {
50
48
  }
51
49
 
52
50
  function touch(event: Event, root: Node, evt: TouchEvent): void {
53
- touch.dn = FunctionNames.PointerTouch;
54
51
  let frame = iframe(root);
55
52
  let d = frame && frame.contentDocument ? frame.contentDocument.documentElement : document.documentElement;
56
53
  let touches = evt.changedTouches;
@@ -1,6 +1,5 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { ResizeData, Setting } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import { clearTimeout, setTimeout } from "@src/core/timeout";
5
4
  import { bind } from "@src/core/event";
6
5
  import throttle from "@src/core/throttle";
@@ -20,7 +19,6 @@ export function start(): void {
20
19
  }
21
20
 
22
21
  function recompute(): void {
23
- recompute.dn = FunctionNames.ResizeRecompute;
24
22
  let de = document.documentElement;
25
23
  // window.innerWidth includes width of the scrollbar and is not a true representation of the viewport width.
26
24
  // Therefore, when possible, use documentElement's clientWidth property.
@@ -1,6 +1,5 @@
1
1
  import { Constant, Dimension, Event } from "@clarity-types/data";
2
2
  import { ScrollState, Setting } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import { bind } from "@src/core/event";
5
4
  import { schedule } from "@src/core/task";
6
5
  import { time } from "@src/core/time";
@@ -28,7 +27,6 @@ export function observe(root: Node): void {
28
27
  }
29
28
 
30
29
  function recompute(event: UIEvent = null): void {
31
- recompute.dn = FunctionNames.ScrollRecompute;
32
30
  let w = window as Window;
33
31
  let de = document.documentElement;
34
32
  let element = event ? target(event) : de;
@@ -112,7 +110,6 @@ function similar(last: ScrollState, current: ScrollState): boolean {
112
110
  }
113
111
 
114
112
  export function compute(): void {
115
- compute.dn = FunctionNames.ScrollCompute;
116
113
  if (initialTop) {
117
114
  const top = metadata(initialTop, null);
118
115
  dimension.log(Dimension.InitialScrollTop, top?.hash?.join(Constant.Dot));
@@ -1,6 +1,5 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { SelectionData, Setting } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import { bind } from "@src/core/event";
5
4
  import { schedule } from "@src/core/task";
6
5
  import { clearTimeout, setTimeout } from "@src/core/timeout";
@@ -20,7 +19,6 @@ export function observe(root: Node): void {
20
19
  }
21
20
 
22
21
  function recompute(root: Node): void {
23
- recompute.dn = FunctionNames.SelectionRecompute;
24
22
  let doc = root.nodeType === Node.DOCUMENT_NODE ? root as Document : document;
25
23
  let current = doc.getSelection();
26
24
 
@@ -1,6 +1,5 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { SubmitState } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import { bind } from "@src/core/event";
5
4
  import { schedule } from "@src/core/task";
6
5
  import { time } from "@src/core/time";
@@ -18,7 +17,6 @@ export function observe(root: Node): void {
18
17
  }
19
18
 
20
19
  function recompute(evt: UIEvent): void {
21
- recompute.dn = FunctionNames.SubmitRecompute;
22
20
  state.push({ time: time(evt), event: Event.Submit, data: { target: target(evt) } });
23
21
  schedule(encode.bind(this, Event.Submit));
24
22
  }
@@ -1,6 +1,5 @@
1
1
  import { BooleanFlag, Event } from "@clarity-types/data";
2
2
  import { UnloadData } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import * as clarity from "@src/clarity";
5
4
  import { bind } from "@src/core/event";
6
5
  import { time } from "@src/core/time";
@@ -13,7 +12,6 @@ export function start(): void {
13
12
  }
14
13
 
15
14
  function recompute(evt: PageTransitionEvent): void {
16
- recompute.dn = FunctionNames.UnloadRecompute;
17
15
  data = { name: evt.type, persisted: evt.persisted ? BooleanFlag.True : BooleanFlag.False };
18
16
  encode(Event.Unload, time(evt));
19
17
  clarity.stop();
@@ -1,6 +1,5 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { VisibilityData } from "@clarity-types/interaction";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import { bind } from "@src/core/event";
5
4
  import { time } from "@src/core/time";
6
5
  import encode from "./encode";
@@ -13,7 +12,6 @@ export function start(): void {
13
12
  }
14
13
 
15
14
  function recompute(evt: UIEvent = null): void {
16
- recompute.dn = FunctionNames.VisibilityRecompute;
17
15
  data = { visible: "visibilityState" in document ? document.visibilityState : "default" };
18
16
  encode(Event.Visibility, time(evt));
19
17
  }
@@ -1,6 +1,5 @@
1
1
  import { Event } from "@clarity-types/data";
2
2
  import { DocumentData } from "@clarity-types/layout";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import encode from "@src/layout/encode";
5
4
 
6
5
  export let data: DocumentData;
@@ -15,7 +14,6 @@ export function start(): void {
15
14
  }
16
15
 
17
16
  export function compute(): void {
18
- compute.dn = FunctionNames.DocumentCompute;
19
17
  let body = document.body;
20
18
  let d = document.documentElement;
21
19
  let bodyClientWidth = body ? body.clientWidth : null;
@@ -1,4 +1,3 @@
1
- import { FunctionNames } from "@clarity-types/performance";
2
1
  import * as discover from "@src/layout/discover";
3
2
  import * as doc from "@src/layout/document";
4
3
  import * as dom from "@src/layout/dom";
@@ -12,7 +11,6 @@ import config from "@src/core/config";
12
11
  export { hashText } from "@src/layout/dom";
13
12
 
14
13
  export function start(): void {
15
- start.dn = FunctionNames.LayoutStart;
16
14
  // The order below is important
17
15
  // and is determined by interdependencies of modules
18
16
  doc.start();
@@ -1,7 +1,6 @@
1
1
  import { Priority, Task, Timer } from "@clarity-types/core";
2
2
  import { Code, Event, Metric, Severity } from "@clarity-types/data";
3
3
  import { Constant, MutationHistory, MutationRecordWithTime, MutationQueue, Setting, Source } from "@clarity-types/layout";
4
- import { FunctionNames } from "@clarity-types/performance";
5
4
  import api from "@src/core/api";
6
5
  import * as core from "@src/core";
7
6
  import * as event from "@src/core/event";
@@ -35,7 +34,6 @@ let observedNodes: WeakMap<Node, MutationObserver> = new WeakMap<Node, MutationO
35
34
  const IGNORED_ATTRIBUTES = ["data-google-query-id", "data-load-complete", "data-google-container-id"];
36
35
 
37
36
  export function start(): void {
38
- start.dn = FunctionNames.MutationStart;
39
37
  observers = new Set();
40
38
  queue = [];
41
39
  timeout = null;
@@ -107,7 +105,6 @@ export function disconnect(n: Node): void {
107
105
  }
108
106
 
109
107
  function handle(m: MutationRecord[]): void {
110
- handle.dn = FunctionNames.MutationHandle;
111
108
  // Queue up mutation records for asynchronous processing
112
109
  let now = time();
113
110
  summary.track(Event.Mutation, now);
@@ -328,7 +325,6 @@ function trigger(): void {
328
325
  }
329
326
 
330
327
  function generate(target: Node, type: MutationRecordType): void {
331
- generate.dn = FunctionNames.MutationGenerate;
332
328
  measure(handle)([
333
329
  {
334
330
  addedNodes: [target],
@@ -1,6 +1,5 @@
1
1
  import { Event, Setting } from "@clarity-types/data";
2
2
  import { InteractionState, RegionData, RegionState, RegionQueue, RegionVisibility } from "@clarity-types/layout";
3
- import { FunctionNames } from "@clarity-types/performance";
4
3
  import { time } from "@src/core/time";
5
4
  import * as dom from "@src/layout/dom";
6
5
  import encode from "@src/layout/encode";
@@ -60,7 +59,6 @@ export function track(id: number, event: Event): void {
60
59
  }
61
60
 
62
61
  export function compute(): void {
63
- compute.dn = FunctionNames.RegionCompute;
64
62
  // Process any regions where we couldn't resolve an "id" for at the time of last intersection observer event
65
63
  // This could happen in cases where elements are not yet processed by Clarity's virtual DOM but browser reports a change, regardless.
66
64
  // For those cases we add them to the queue and re-process them below
@@ -1,9 +1,7 @@
1
- import { FunctionNames } from "@clarity-types/performance";
2
1
  import * as navigation from "@src/performance/navigation";
3
2
  import * as observer from "@src/performance/observer";
4
3
 
5
4
  export function start(): void {
6
- start.dn = FunctionNames.PerformanceStart;
7
5
  navigation.reset();
8
6
  observer.start();
9
7
  }
@@ -1,5 +1,4 @@
1
1
  import { Code, Constant, Dimension, Metric, Severity, PerformanceEventTiming } from "@clarity-types/data";
2
- import { FunctionNames } from "@clarity-types/performance";
3
2
  import config from "@src/core/config";
4
3
  import { bind } from "@src/core/event";
5
4
  import measure from "@src/core/measure";
@@ -31,7 +30,6 @@ export function start(): void {
31
30
  }
32
31
 
33
32
  function observe(): void {
34
- observe.dn = FunctionNames.ObserverObserve;
35
33
  // Some browsers will throw an error for unsupported entryType, e.g. "layout-shift"
36
34
  // In those cases, we log it as a warning and continue with rest of the Clarity processing
37
35
  try {
@@ -53,7 +51,6 @@ function observe(): void {
53
51
  }
54
52
 
55
53
  function handle(entries: PerformanceObserverEntryList): void {
56
- handle.dn = FunctionNames.ObserverHandle;
57
54
  process(entries.getEntries());
58
55
  }
59
56
 
package/types/data.d.ts CHANGED
@@ -353,7 +353,6 @@ export const enum Constant {
353
353
  Caret = "^",
354
354
  Granted = "granted",
355
355
  Denied = "denied",
356
- BeaconError = "BeaconError",
357
356
  }
358
357
 
359
358
  export const enum XMLReadyState {
@@ -97,6 +97,7 @@ export interface InputData {
97
97
  target: Target;
98
98
  value: string;
99
99
  type?: string;
100
+ trust: BooleanFlag;
100
101
  }
101
102
 
102
103
  export interface SubmitData {
@@ -1,5 +1,3 @@
1
- import { BooleanFlag, Target } from "./data";
2
-
3
1
  /* Helper Interface */
4
2
 
5
3
 
@@ -31,35 +29,3 @@ export interface NavigationData {
31
29
  encodedSize: number;
32
30
  decodedSize: number;
33
31
  }
34
-
35
- export const enum FunctionNames {
36
- HistoryCompute = 1,
37
- Restart = 2,
38
- DiagnosticStart = 3,
39
- ScriptHandler = 4,
40
- ChangeRecompute = 5,
41
- ClickHandler = 6,
42
- ClipboardRecompute = 7,
43
- InteractionStart = 8,
44
- InputRecompute = 9,
45
- PointerMouse = 10,
46
- PointerTouch = 11,
47
- ResizeRecompute = 12,
48
- ScrollRecompute = 13,
49
- ScrollCompute = 14,
50
- SelectionRecompute = 15,
51
- SubmitRecompute = 16,
52
- UnloadRecompute = 17,
53
- VisibilityRecompute = 18,
54
- DocumentCompute = 19,
55
- LayoutStart = 20,
56
- MutationStart = 21,
57
- MutationHandle = 22,
58
- MutationGenerate = 23,
59
- RegionCompute = 24,
60
- PerformanceStart = 25,
61
- ObserverObserve = 26,
62
- ObserverHandle = 27
63
- }
64
-
65
- declare global { interface Function { dn?: FunctionNames; } }