Commit 3baa4fa6 authored by tom's avatar tom

Refactor Sentry initialization

parent 0969496a
import type * as Sentry from '@sentry/react';
import * as Sentry from '@sentry/react';
import { BrowserTracing } from '@sentry/tracing';
import appConfig from 'configs/app';
......@@ -90,3 +90,12 @@ export function configureScope(scope: Sentry.Scope) {
}
scope.setTag('app_instance', feature.instance);
}
export function init() {
if (!config) {
return;
}
Sentry.init(config);
Sentry.configureScope(configureScope);
}
import * as Sentry from '@sentry/react';
import React from 'react';
import { config, configureScope } from './config';
export default function useConfigSentry() {
React.useEffect(() => {
if (!config) {
return;
}
// gotta init sentry in browser
Sentry.init(config);
Sentry.configureScope(configureScope);
}, []);
}
......@@ -7,18 +7,19 @@ import useAdblockDetect from 'lib/hooks/useAdblockDetect';
import useGetCsrfToken from 'lib/hooks/useGetCsrfToken';
import * as metadata from 'lib/metadata';
import * as mixpanel from 'lib/mixpanel';
import useConfigSentry from 'lib/sentry/useConfigSentry';
import { init as initSentry } from 'lib/sentry/config';
type Props = Route & {
children: React.ReactNode;
}
initSentry();
const PageNextJs = (props: Props) => {
const { title, description, opengraph } = metadata.generate(props);
useGetCsrfToken();
useAdblockDetect();
useConfigSentry();
const isMixpanelInited = mixpanel.useInit();
mixpanel.useLogPageView(isMixpanelInited);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment