fix: prevent sentry from loading when telemetry is disabled (#10543)

Co-authored-by: forehalo <forehalo@gmail.com>
This commit is contained in:
hackerESQ
2025-03-05 06:09:38 -06:00
committed by GitHub
parent b247b8e26c
commit fed0e0add3
16 changed files with 122 additions and 200 deletions
+2 -1
View File
@@ -1,9 +1,10 @@
import { enableAutoTrack, makeTracker } from './auto';
import { mixpanel } from './mixpanel';
import { sentry } from './sentry';
export const track = makeTracker((event, props) => {
mixpanel.track(event, props);
});
export { enableAutoTrack, mixpanel };
export { enableAutoTrack, mixpanel, sentry };
export default track;
-1
View File
@@ -94,7 +94,6 @@ function createMixpanel() {
}
export const mixpanel = createMixpanel();
mixpanel.init();
function createProxyHandler() {
const handler = {
+50
View File
@@ -0,0 +1,50 @@
import * as Sentry from '@sentry/react';
import { useEffect } from 'react';
import {
createRoutesFromChildren,
matchRoutes,
useLocation,
useNavigationType,
} from 'react-router-dom';
function createSentry() {
let enabled = true;
const wrapped = {
init() {
// https://docs.sentry.io/platforms/javascript/guides/react/#configure
Sentry.init({
enabled: enabled,
dsn: process.env.SENTRY_DSN,
debug: BUILD_CONFIG.debug ?? false,
environment: process.env.BUILD_TYPE ?? 'development',
integrations: [
Sentry.reactRouterV6BrowserTracingIntegration({
useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes,
}),
],
beforeSend(event) {
return enabled ? event : null;
},
});
Sentry.setTags({
distribution: BUILD_CONFIG.distribution,
appVersion: BUILD_CONFIG.appVersion,
editorVersion: BUILD_CONFIG.editorVersion,
});
},
enable() {
enabled = true;
},
disable() {
enabled = false;
},
};
return wrapped;
}
export const sentry = createSentry();