clarity-js 0.8.37 → 0.8.38-beta

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.
@@ -70,6 +70,9 @@ function handler(event: Event, root: Node, evt: MouseEvent): void {
70
70
  hash: null,
71
71
  trust: evt.isTrusted ? BooleanFlag.True : BooleanFlag.False,
72
72
  isFullText: textInfo.isFullText,
73
+ tag: getElementAttribute(t, "tagName").substring(0, Setting.ClickTag),
74
+ class: getElementAttribute(t, "className").substring(0, Setting.ClickClass),
75
+ id: getElementAttribute(t, "id").substring(0, Setting.ClickId),
73
76
  }
74
77
  });
75
78
  schedule(encode.bind(this, event));
@@ -109,15 +112,23 @@ function text(element: Node): TextInfo {
109
112
  }
110
113
 
111
114
  function reaction(element: Node): BooleanFlag {
112
- if (element.nodeType === Node.ELEMENT_NODE) {
113
- let tag = (element as HTMLElement).tagName.toLowerCase();
114
- if (UserInputTags.indexOf(tag) >= 0) {
115
- return BooleanFlag.False;
116
- }
115
+ const tagName = getElementAttribute(element, "tagName");
116
+
117
+ if (UserInputTags.indexOf(tagName) >= 0) {
118
+ return BooleanFlag.False;
117
119
  }
118
120
  return BooleanFlag.True;
119
121
  }
120
122
 
123
+ function getElementAttribute(element: Node, attribute: "tagName" | "className" | "id"): string {
124
+ if (element.nodeType === Node.ELEMENT_NODE) {
125
+ const attr = (element as HTMLElement)?.[attribute];
126
+ const value = typeof attr === "string" ? attr?.toLowerCase() : "";
127
+ return value;
128
+ }
129
+ return "";
130
+ }
131
+
121
132
  function layout(element: Element): Box {
122
133
  let box: Box = null;
123
134
  let de = document.documentElement;
@@ -72,6 +72,9 @@ export default async function (type: Event, ts: number = null): Promise<void> {
72
72
  tokens.push(cHash);
73
73
  tokens.push(entry.data.trust);
74
74
  tokens.push(entry.data.isFullText);
75
+ tokens.push(entry.data.tag);
76
+ tokens.push(entry.data.class);
77
+ tokens.push(entry.data.id);
75
78
  queue(tokens);
76
79
  timeline.track(entry.time, entry.event, cHash, entry.data.x, entry.data.y, entry.data.reaction, entry.data.context);
77
80
  }
@@ -6,3 +6,5 @@ export let keys = [];
6
6
  export function hashText(): void {}
7
7
  export function trigger(): void {}
8
8
  export function track(): void {}
9
+ export function event(): void {}
10
+ export function register(): void {}
package/types/data.d.ts CHANGED
@@ -253,6 +253,9 @@ export const enum Setting {
253
253
  PingTimeout = 5 * Time.Minute, // 5 Minutes
254
254
  SummaryInterval = 100, // Same events within 100ms will be collapsed into single summary
255
255
  ClickText = 25, // Maximum number of characters to send as part of Click event's text field
256
+ ClickClass = 50, // Maximum number of characters to send as part of Click event's class name
257
+ ClickTag = 10, // Maximum number of characters to send as part of Click event's tag
258
+ ClickId = 25, // Maximum number of characters to send as part of Click event's id
256
259
  PayloadLimit = 128, // Do not allow more than specified payloads per page
257
260
  PageLimit = 128, // Do not allow more than 128 pages in a session
258
261
  ShutdownLimit = 2 * Time.Hour, // Shutdown instrumentation after specified time
@@ -473,6 +476,7 @@ export interface BaselineData {
473
476
  pointerPrevX?: number;
474
477
  pointerPrevY?: number;
475
478
  pointerPrevTime?: number;
479
+ modules: number[];
476
480
  }
477
481
 
478
482
  export interface IdentityData {
package/types/global.d.ts CHANGED
@@ -14,6 +14,11 @@ declare global {
14
14
  tidioChatApi?: {
15
15
  on: (eventName: string, callback: (data: any) => void) => void;
16
16
  };
17
+ $crisp?: {
18
+ push: (
19
+ args: [action: string, eventName: string, callback: (data: any) => void]
20
+ ) => void;
21
+ };
17
22
  }
18
23
 
19
24
  interface Function {
@@ -126,6 +126,9 @@ export interface ClickData {
126
126
  hash: string;
127
127
  trust: number;
128
128
  isFullText: BooleanFlag;
129
+ tag: string;
130
+ class: string;
131
+ id: string;
129
132
  }
130
133
 
131
134
  export interface TextInfo {