getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.57k stars 336 forks source link

How to disable Sentry when in development using Expo? #3603

Closed rayronvictor closed 7 months ago

rayronvictor commented 7 months ago

Description

import * as Sentry from '@sentry/react-native';

Sentry.init({
  dsn: 'YOUR DSN HERE',
  enabled: !__DEV__, // this is not working
});

function App() {
  // ...
}

registerRootComponent(Sentry.wrap(App) as Parameters<typeof registerRootComponent>[0]);

My work around is not call Sentry.init and Sentry.wrap when in development:

if (!__DEV__) {
  Sentry.init({
    dsn: 'https://040a334b75ade0c9916d03a14d229a17@sentry.nadic.ifrn.edu.br/6',
  });
}

function App() {
  // ...
}

const RootComponent = __DEV__
  ? App
  : (Sentry.wrap(App) as Parameters<typeof registerRootComponent>[0]);

registerRootComponent(RootComponent);
krystofwoldrich commented 7 months ago

Hi @rayronvictor, thank you for reporting this bug.

Your workaround looks good.