@gemx-dev/clarity-js 0.8.39 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemx-dev/clarity-js",
3
- "version": "0.8.39",
3
+ "version": "0.8.42",
4
4
  "description": "Clarity js",
5
5
  "author": "Microsoft Corp.",
6
6
  "license": "MIT",
@@ -39,8 +39,7 @@
39
39
  "build:clean": "del-cli build/*",
40
40
  "test": "ts-mocha -p test/tsconfig.test.json test/stub.test.ts",
41
41
  "tslint": "tslint --project ./",
42
- "tslint:fix": "tslint --fix --project ./ --force",
43
- "release": "npm publish --access public"
42
+ "tslint:fix": "tslint --fix --project ./ --force"
44
43
  },
45
44
  "husky": {
46
45
  "hooks": {
@@ -1,2 +1,2 @@
1
- let version = "0.8.39";
1
+ let version = "0.8.42";
2
2
  export default version;
@@ -2,6 +2,7 @@ import { ConsentData, ConsentSource, ConsentState, ConsentType, Constant, Dimens
2
2
  import * as dimension from "@src/data/dimension";
3
3
  import encode from "./encode";
4
4
  import { consentv2 } from "./metadata";
5
+ import coreConfig from "@src/core/config";
5
6
 
6
7
  export let data: ConsentData = null;
7
8
  let updateConsent: boolean = true;
@@ -67,9 +68,11 @@ export function compute(): void {
67
68
  if (updateConsent) {
68
69
  encode(Event.Consent);
69
70
  updateConsent = false;
70
- const ics = window.google_tag_data?.ics;
71
- if (ics?.usedUpdate) {
72
- processConsent();
71
+ if (!coreConfig.track) {
72
+ const ics = window.google_tag_data?.ics;
73
+ if (ics?.usedUpdate) {
74
+ processConsent();
75
+ }
73
76
  }
74
77
  }
75
78
  }
@@ -71,7 +71,10 @@ function handler(event: Event, root: Node, evt: MouseEvent): void {
71
71
  trust: evt.isTrusted ? BooleanFlag.True : BooleanFlag.False,
72
72
  isFullText: textInfo.isFullText,
73
73
  w: l ? l.w : 0,
74
- h: l ? l.h : 0
74
+ h: l ? l.h : 0,
75
+ tag: getElementAttribute(t, "tagName").substring(0, Setting.ClickTag),
76
+ class: getElementAttribute(t, "className").substring(0, Setting.ClickClass),
77
+ id: getElementAttribute(t, "id").substring(0, Setting.ClickId),
75
78
  }
76
79
  });
77
80
  schedule(encode.bind(this, event));
@@ -111,15 +114,22 @@ function text(element: Node): TextInfo {
111
114
  }
112
115
 
113
116
  function reaction(element: Node): BooleanFlag {
114
- if (element.nodeType === Node.ELEMENT_NODE) {
115
- let tag = (element as HTMLElement).tagName.toLowerCase();
116
- if (UserInputTags.indexOf(tag) >= 0) {
117
- return BooleanFlag.False;
118
- }
117
+ const tag = getElementAttribute(element, "tagName");
118
+ if (UserInputTags.indexOf(tag) >= 0) {
119
+ return BooleanFlag.False;
119
120
  }
120
121
  return BooleanFlag.True;
121
122
  }
122
123
 
124
+ function getElementAttribute(element: Node, attribute: "tagName" | "className" | "id"): string {
125
+ if (element.nodeType === Node.ELEMENT_NODE) {
126
+ const attr = (element as HTMLElement)?.[attribute];
127
+ const value = typeof attr === "string" ? attr?.toLowerCase() : "";
128
+ return value;
129
+ }
130
+ return "";
131
+ }
132
+
123
133
  function layout(element: Element): Box {
124
134
  let box: Box = null;
125
135
  let de = document.documentElement;
@@ -74,6 +74,9 @@ export default async function (type: Event, ts: number = null): Promise<void> {
74
74
  tokens.push(entry.data.isFullText);
75
75
  tokens.push(entry.data.w);
76
76
  tokens.push(entry.data.h);
77
+ tokens.push(entry.data.tag);
78
+ tokens.push(entry.data.class);
79
+ tokens.push(entry.data.id);
77
80
  queue(tokens);
78
81
  timeline.track(entry.time, entry.event, cHash, entry.data.x, entry.data.y, entry.data.reaction, entry.data.context);
79
82
  }
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
@@ -128,6 +128,9 @@ export interface ClickData {
128
128
  isFullText: BooleanFlag;
129
129
  w: number;
130
130
  h: number;
131
+ tag: string;
132
+ class: string;
133
+ id: string;
131
134
  }
132
135
 
133
136
  export interface TextInfo {