Skip to content

Commit bb21f76

Browse files
committed
fix element serialization
eg. we were crashing when calling _paq.push(["addListener", element])
1 parent 4e427bd commit bb21f76

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

apps/debugger-extension/entrypoints/collector.content.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineContentScript } from '#imports';
22
import { InternalMessage, Message } from '@/lib/messaging';
3+
import { finder } from '@medv/finder';
34

45
// proxy object created when JSTC is loaded
56
type _QueueProxy = { push: (args: unknown[]) => void };
@@ -13,7 +14,15 @@ const sendMessage = (msg: Message | InternalMessage) => {
1314
};
1415

1516
function formatPushArgs(args: any[]) {
16-
return args.map((e) => (typeof e === 'function' ? e.toString() : e)) as any;
17+
return args.map((e) => {
18+
if (typeof e === 'function') {
19+
return e.toString();
20+
}
21+
if (e instanceof Element) {
22+
return `Element: ${finder(e)}`;
23+
}
24+
return e;
25+
}) as any;
1726
}
1827

1928
export default defineContentScript({

apps/debugger-extension/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"format:fix": "pnpm format --write"
1818
},
1919
"dependencies": {
20+
"@medv/finder": "^4.0.2",
2021
"@radix-ui/react-separator": "^1.1.6",
2122
"@radix-ui/react-slot": "^1.2.2",
2223
"@radix-ui/react-tooltip": "^1.2.6",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)