forked from input-output-hk/lace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsentry.js
36 lines (34 loc) · 1.46 KB
/
sentry.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
import * as Sentry from '@sentry/react';
import { v4 as uuidv4 } from 'uuid';
import { storage } from 'webextension-polyfill';
Sentry.init({
environment: process.env.SENTRY_ENVIRONMENT,
dsn: process.env.SENTRY_DSN,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.browserProfilingIntegration(),
Sentry.replayIntegration(),
// TODO: re-enable once we've reviewed provider logging
Sentry.captureConsoleIntegration({ levels: process.env.SENTRY_ENVIRONMENT === 'production' ? [] : ['error'] })
],
// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
tracePropagationTargets: ['localhost', 'chrome-extension://gafhhkghbfjjkeiendhlofajokpaflmk'],
// .5%
tracesSampleRate: 0.05,
profilesSampleRate: 0.05,
// Since profilesSampleRate is relative to tracesSampleRate,
// the final profiling rate can be computed as tracesSampleRate * profilesSampleRate
// A tracesSampleRate of 0.05 and profilesSampleRate of 0.05 results in 2.5% of
// transactions being profiled (0.05*0.05=0.0025)
// Capture Replay for 0.05% of all sessions,
replaysSessionSampleRate: 0.005,
// ...plus for 100% of sessions with an error
replaysOnErrorSampleRate: 1.0
});
storage.local.get('SENTRY-UUID').then((storageVar) => {
let sentryUuid = storageVar?.['SENTRY-UUID'] ?? uuidv4();
if (!storageVar?.['SENTRY-UUID']) {
storage.local.set({ 'SENTRY-UUID': sentryUuid });
}
Sentry.setUser({ id: sentryUuid });
});