-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmonitor.tsx
More file actions
47 lines (44 loc) · 1.37 KB
/
monitor.tsx
File metadata and controls
47 lines (44 loc) · 1.37 KB
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
40
41
42
43
44
45
46
47
import type { ReactNode } from 'react';
import { lazy, Suspense } from 'react';
import { MonitorContext } from './monitor.use-monitor';
import { ENV, getServerUrl } from '../config';
const SENTRY_DSN = 'todo: replace with sentry dsn';
const SentryLazy = lazy(() =>
import('@sentry/react').then((SentryReact) => {
SentryReact.init({
dsn: SENTRY_DSN,
environment: ENV,
integrations: [
SentryReact.browserTracingIntegration(),
SentryReact.replayIntegration(),
],
tracesSampleRate: 1.0,
tracePropagationTargets: ['localhost', getServerUrl()],
// limit replay sampling
replaysSessionSampleRate: ENV === 'prod' ? 0.1 : 0,
replaysOnErrorSampleRate: ENV === 'prod' ? 1.0 : 0,
});
console.log('monitor initialized');
const SentryProvider = ({ children }: { children: ReactNode }) => {
return (
<SentryReact.ErrorBoundary>
<MonitorContext.Provider
value={{ captureException: SentryReact.captureException }}
>
{children}
</MonitorContext.Provider>
</SentryReact.ErrorBoundary>
);
};
return {
default: SentryProvider,
};
}),
);
export const MonitorProvider = ({ children }: { children: ReactNode }) => {
return (
<Suspense fallback={<>{children}</>}>
<SentryLazy>{children}</SentryLazy>
</Suspense>
);
};