expo / sentry-expo

MIT License
202 stars 83 forks source link

Sentry not working with expo (go)? #361

Closed Chriko2502 closed 1 year ago

Chriko2502 commented 1 year ago

Summary

I am trying to setup sentry with expo. Unfortunately I can't mange to get it working.

I followed the steps as described here: https://docs.expo.dev/guides/using-sentry/

When using the expo go app I always get the following warnings/messages

Sentry Logger [log]: Failed to get modules from native: SentryError: Native is disabled

WARN  Sentry Logger [warn]: [SdkInfo] Native SDK Info retrieval failed...something could be wrong with your Sentry installation:
WARN  Sentry Logger [warn]: [SentryError: Native is disabled]
WARN  Sentry Logger [warn]: Event was skipped as native SDK is not enabled.
import * as Sentry from 'sentry-expo'

Sentry.init({
  dsn: "dsn",
  enableInExpoDevelopment: true,
  debug: true, 
});

const App = () => {
  try {
   throw new Error("BROKEN!")
  } catch (error) {
    //console.error(error)
    Sentry.Native.captureException(error)
  }
  return null
}

export default App
//export default Sentry.Native.wrap(App)

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android, iOS

SDK Version (managed workflow only)

48

Environment

expo-env-info 1.0.5 environment info: System: OS: Linux 5.15 Debian GNU/Linux 10 (buster) 10 (buster) Shell: 5.0.3 - /bin/bash Binaries: Node: 16.19.1 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.6.0 - /usr/local/bin/npm npmPackages: expo: ^48.0.9 => 48.0.11 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.71.7 => 0.71.7 react-native-web: ~0.18.11 => 0.18.12 npmGlobalPackages: eas-cli: 3.7.2 expo-cli: 6.3.2 Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

import * as Sentry from 'sentry-expo'

Sentry.init({
  dsn: "dsn",
  enableInExpoDevelopment: true,
  debug: true, 
});

const App = () => {
  try {
   throw new Error("BROKEN!")
  } catch (error) {
    //console.error(error)
    Sentry.Native.captureException(error)
  }
  return null
}

export default App
//export default Sentry.Native.wrap(App)
phollaki commented 1 year ago

Same for me. Tried to downgrade sentry-expo to a lower version but still not working. And if I add enableNative: true to the initialization config options then my app loads forever.

jparksecurity commented 1 year ago

I saw somewhere that it doesn't work on Expo Go because Expo Go doesn't have sentry SDK in native level. We need to install the Sentry SDK in native level somehow.

One way to do that is to build an app via eas build.

I had to spend long time to figure it out. It works for me now as I use expo-dev-client with eas build.

kbrandwijk commented 1 year ago

As per the docs, native events are not available in Expo Go. So the behavior is as expected. Like mentioned above, it works fine in a development build as well as production builds.