-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathinit.js
39 lines (34 loc) · 950 Bytes
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as Sentry from '@sentry/browser';
window.Sentry = Sentry;
Sentry.init({
dsn: 'https://[email protected]/1337',
tracesSampleRate: 1.0,
release: '1.0.0',
autoSessionTracking: false,
});
window.timingSync = () => {
// Ensure we always have a wrapping span
return Sentry.startSpan({ name: 'manual span' }, () => {
return Sentry.metrics.timing('timingSync', () => {
sleepSync(200);
return 'sync done';
});
});
};
window.timingAsync = () => {
// Ensure we always have a wrapping span
return Sentry.startSpan({ name: 'manual span' }, () => {
return Sentry.metrics.timing('timingAsync', async () => {
await new Promise(resolve => setTimeout(resolve, 200));
return 'async done';
});
});
};
function sleepSync(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if (new Date().getTime() - start > milliseconds) {
break;
}
}
}