mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import * as Sentry from '@sentry/react';
|
|
import { useEffect } from 'react';
|
|
import {
|
|
createRoutesFromChildren,
|
|
matchRoutes,
|
|
useLocation,
|
|
useNavigationType,
|
|
} from 'react-router-dom';
|
|
|
|
function createSentry() {
|
|
let client: Sentry.BrowserClient | undefined;
|
|
const wrapped = {
|
|
init() {
|
|
if (!globalThis.SENTRY_RELEASE) {
|
|
// https://docs.sentry.io/platforms/javascript/guides/react/#configure
|
|
client = Sentry.init({
|
|
dsn: process.env.SENTRY_DSN,
|
|
debug: BUILD_CONFIG.debug ?? false,
|
|
environment: process.env.BUILD_TYPE ?? 'development',
|
|
integrations: [
|
|
Sentry.reactRouterV6BrowserTracingIntegration({
|
|
useEffect,
|
|
useLocation,
|
|
useNavigationType,
|
|
createRoutesFromChildren,
|
|
matchRoutes,
|
|
}),
|
|
],
|
|
}) as Sentry.BrowserClient;
|
|
|
|
Sentry.setTags({
|
|
distribution: BUILD_CONFIG.distribution,
|
|
appVersion: BUILD_CONFIG.appVersion,
|
|
editorVersion: BUILD_CONFIG.editorVersion,
|
|
});
|
|
}
|
|
},
|
|
enable() {
|
|
if (client) {
|
|
client.getOptions().enabled = true;
|
|
}
|
|
},
|
|
disable() {
|
|
if (client) {
|
|
client.getOptions().enabled = false;
|
|
}
|
|
},
|
|
};
|
|
|
|
return wrapped;
|
|
}
|
|
|
|
export const sentry = createSentry();
|