clarity-visualize 0.8.67-beta → 0.8.68

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.
@@ -1300,19 +1300,24 @@ class LayoutHelper {
1300
1300
  this.hashMapBeta = {};
1301
1301
  this.primaryHtmlNodeId = null;
1302
1302
  };
1303
- this.get = (hash) => {
1303
+ this.get = (hash, silent = false) => {
1304
1304
  if (hash in this.hashMapBeta && this.hashMapBeta[hash].isConnected) {
1305
1305
  return this.hashMapBeta[hash];
1306
1306
  }
1307
1307
  else if (hash in this.hashMapAlpha && this.hashMapAlpha[hash].isConnected) {
1308
+ // Beta lookup missed but the Alpha (fallback) selector resolved the element.
1309
+ // Surface this so we can measure how often Alpha is still required before retiring it.
1310
+ if (!silent && this.state.options.onalphaFallback) {
1311
+ this.state.options.onalphaFallback(hash);
1312
+ }
1308
1313
  return this.hashMapAlpha[hash];
1309
1314
  }
1310
1315
  return null;
1311
1316
  };
1312
1317
  this.addToHashMap = (data, parent) => {
1313
1318
  // In case of selector collision, prefer the first inserted node
1314
- this.hashMapAlpha[data.hashAlpha] = this.get(data.hashAlpha) || parent;
1315
- this.hashMapBeta[data.hashBeta] = this.get(data.hashBeta) || parent;
1319
+ this.hashMapAlpha[data.hashAlpha] = this.get(data.hashAlpha, true) || parent;
1320
+ this.hashMapBeta[data.hashBeta] = this.get(data.hashBeta, true) || parent;
1316
1321
  };
1317
1322
  this.resize = (el, width, height) => {
1318
1323
  if (el && el.nodeType === 1 /* NodeType.ELEMENT_NODE */ && width && height) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarity-visualize",
3
- "version": "0.8.67-beta",
3
+ "version": "0.8.68",
4
4
  "description": "An analytics library that uses web page interactions to generate aggregated insights",
5
5
  "author": "Microsoft Corp.",
6
6
  "license": "MIT",
@@ -27,7 +27,7 @@
27
27
  "url": "https://github.com/Microsoft/clarity/issues"
28
28
  },
29
29
  "dependencies": {
30
- "clarity-decode": "^0.8.67-beta"
30
+ "clarity-decode": "^0.8.68"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@rollup/plugin-commonjs": "^24.0.0",
package/src/layout.ts CHANGED
@@ -142,10 +142,13 @@ export class LayoutHelper {
142
142
  this.primaryHtmlNodeId = null;
143
143
  }
144
144
 
145
- public get = (hash) => {
145
+ public get = (hash: string, silent: boolean = false): HTMLElement => {
146
146
  if (hash in this.hashMapBeta && this.hashMapBeta[hash].isConnected) {
147
147
  return this.hashMapBeta[hash];
148
148
  } else if (hash in this.hashMapAlpha && this.hashMapAlpha[hash].isConnected) {
149
+ // Beta lookup missed but the Alpha (fallback) selector resolved the element.
150
+ // Surface this so we can measure how often Alpha is still required before retiring it.
151
+ if (!silent && this.state.options.onalphaFallback) { this.state.options.onalphaFallback(hash); }
149
152
  return this.hashMapAlpha[hash];
150
153
  }
151
154
  return null;
@@ -153,8 +156,8 @@ export class LayoutHelper {
153
156
 
154
157
  private addToHashMap = (data: DecodedLayout.DomData, parent: Node) => {
155
158
  // In case of selector collision, prefer the first inserted node
156
- this.hashMapAlpha[data.hashAlpha] = this.get(data.hashAlpha) || parent;
157
- this.hashMapBeta[data.hashBeta] = this.get(data.hashBeta) || parent;
159
+ this.hashMapAlpha[data.hashAlpha] = this.get(data.hashAlpha, true) || parent;
160
+ this.hashMapBeta[data.hashBeta] = this.get(data.hashBeta, true) || parent;
158
161
  }
159
162
 
160
163
  private resize = (el: HTMLElement, width: number, height: number): void => {
@@ -35,6 +35,9 @@ export type ResizeHandler = (width: number, height: number) => void;
35
35
  export type ErrorLogger = (error: Error) => void;
36
36
  export type LinkHandler = (link: string, id: string, linkType: string) => string;
37
37
  export type ClickLogger = (args: IClickLoggerArgs) => void;
38
+ // Fired when a hash resolves via the Alpha (fallback) selector map after the Beta lookup missed.
39
+ // Used to measure how often the Alpha selector is still required.
40
+ export type AlphaFallbackLogger = (hash: string) => void;
38
41
 
39
42
  export interface IClickLoggerArgs {
40
43
  time: number;
@@ -62,6 +65,7 @@ export interface Options {
62
65
  logerror?: ErrorLogger;
63
66
  useproxy?: LinkHandler;
64
67
  onclickMismatch?: ClickLogger;
68
+ onalphaFallback?: AlphaFallbackLogger;
65
69
  metadata?: HTMLElement;
66
70
  pointer?: boolean;
67
71
  canvas?: boolean;