Skip to content

Commit b58687a

Browse files
committed
Try and polyfill crypto.randomUUID
1 parent b30322a commit b58687a

File tree

1 file changed

+9
-0
lines changed
  • dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/startNewTraceSampling

1 file changed

+9
-0
lines changed

dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/startNewTraceSampling/init.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ window.Sentry = Sentry;
55
// Force this so that the initial sampleRand is consistent
66
Math.random = () => 0.45;
77

8+
// Polyfill crypto.randomUUID
9+
crypto.randomUUID = function randomUUID() {
10+
return (
11+
[1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,
12+
// eslint-disable-next-line no-bitwise
13+
c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
14+
);
15+
};
16+
817
Sentry.init({
918
dsn: 'https://[email protected]/1337',
1019
integrations: [Sentry.browserTracingIntegration()],

0 commit comments

Comments
 (0)