Skip to content

Commit f419fab

Browse files
committed
Fix tests
1 parent 42ece80 commit f419fab

File tree

1 file changed

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

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@ import * as Sentry from '@sentry/browser';
22

33
window.Sentry = Sentry;
44

5+
const originalRandom = Math.random;
6+
57
// Force this so that the initial sampleRand is consistent
68
Math.random = () => 0.45;
79

10+
// polyfill for crypto.randomUUID if not available (e.g. in non-secure contexts)
11+
window.crypto = window.crypto || {};
12+
window.crypto.randomUUID =
13+
window.crypto.randomUUID ||
14+
(() => {
15+
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, c =>
16+
// eslint-disable-next-line no-bitwise
17+
(c ^ (((originalRandom() * 16) & 15) >> (c / 4))).toString(16),
18+
);
19+
});
20+
821
Sentry.init({
922
dsn: 'https://[email protected]/1337',
1023
integrations: [Sentry.browserTracingIntegration()],

0 commit comments

Comments
 (0)