Skip to content

Commit

Permalink
making sure we clear our idMap when a node is removed lest we have a …
Browse files Browse the repository at this point in the history
…dangling reference that can break visualization when node is reused
  • Loading branch information
Sam Martin committed Jun 26, 2024
1 parent 72cff8e commit 4e7bd58
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.7.38",
"version": "0.7.39",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "clarity",
"private": true,
"version": "0.7.38",
"version": "0.7.39",
"repository": "https://github.com/microsoft/clarity.git",
"author": "Sarvesh Nagpal <[email protected]>",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/clarity-decode/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clarity-decode",
"version": "0.7.38",
"version": "0.7.39",
"description": "An analytics library that uses web page interactions to generate aggregated insights",
"author": "Microsoft Corp.",
"license": "MIT",
Expand All @@ -26,7 +26,7 @@
"url": "https://github.com/Microsoft/clarity/issues"
},
"dependencies": {
"clarity-js": "^0.7.38"
"clarity-js": "^0.7.39"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/clarity-devtools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clarity-devtools",
"version": "0.7.38",
"version": "0.7.39",
"private": true,
"description": "Adds Clarity debugging support to browser devtools",
"author": "Microsoft Corp.",
Expand All @@ -24,9 +24,9 @@
"url": "https://github.com/Microsoft/clarity/issues"
},
"dependencies": {
"clarity-decode": "^0.7.38",
"clarity-js": "^0.7.38",
"clarity-visualize": "^0.7.38"
"clarity-decode": "^0.7.39",
"clarity-js": "^0.7.39",
"clarity-visualize": "^0.7.39"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/clarity-devtools/static/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"manifest_version": 2,
"name": "Microsoft Clarity Developer Tools",
"description": "Clarity helps you understand how users are interacting with your website.",
"version": "0.7.38",
"version_name": "0.7.38",
"version": "0.7.39",
"version_name": "0.7.39",
"minimum_chrome_version": "50",
"devtools_page": "devtools.html",
"icons": {
Expand Down
2 changes: 1 addition & 1 deletion packages/clarity-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clarity-js",
"version": "0.7.38",
"version": "0.7.39",
"description": "An analytics library that uses web page interactions to generate aggregated insights",
"author": "Microsoft Corp.",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/clarity-js/src/core/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
let version = "0.7.38";
let version = "0.7.39";
export default version;
10 changes: 8 additions & 2 deletions packages/clarity-js/src/layout/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,14 @@ function remove(id: number, source: Source): void {
function removeNodeFromNodesMap(id: number) {
// Shadow dom roots shouldn't be deleted,
// we should keep listening to the mutations there even they're not rendered in the DOM.
if(nodesMap.get(id).nodeType === Node.DOCUMENT_FRAGMENT_NODE){
var node = nodesMap.get(id);
if(node.nodeType === Node.DOCUMENT_FRAGMENT_NODE){
return;
}
// need to ensure we delete references in our id map as well as nodes map, otherwise we can end
// up with inconsistent state which causes orphaned nodes to be dropped from visualization
nodesMap.delete(id);
idMap.delete(node);

let value = id in values ? values[id] : null;
if (value && value.children) {
Expand Down Expand Up @@ -382,5 +386,7 @@ function track(id: number, source: Source, changed: boolean = true, parentChange
if (uIndex >= 0 && source === Source.ChildListAdd && parentChanged) {
updateMap.splice(uIndex, 1);
updateMap.push(id);
} else if (uIndex === -1 && changed) { updateMap.push(id); }
} else if (uIndex === -1 && changed) {
updateMap.push(id);
}
}
4 changes: 2 additions & 2 deletions packages/clarity-visualize/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clarity-visualize",
"version": "0.7.38",
"version": "0.7.39",
"description": "An analytics library that uses web page interactions to generate aggregated insights",
"author": "Microsoft Corp.",
"license": "MIT",
Expand All @@ -27,7 +27,7 @@
"url": "https://github.com/Microsoft/clarity/issues"
},
"dependencies": {
"clarity-decode": "^0.7.38"
"clarity-decode": "^0.7.39"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.0",
Expand Down

0 comments on commit 4e7bd58

Please sign in to comment.