Sentry-react-native: React native sentry isn't working for new react native projects

Created on 28 Aug 2018  ·  4Comments  ·  Source: getsentry/sentry-react-native

OS:

  • [ ] Windows
  • [X] MacOS
  • [ ] Linux

_Platform:_

  • [X] iOS
  • [ ] Android

Output of node -v && npm -v && npm ls --prod --depth=0

v10.7.0
6.4.0
[email protected] /Users/kevin/projects/avo-native
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── UNMET PEER DEPENDENCY [email protected]
├── [email protected]
└── [email protected]

npm ERR! peer dep missing: react-native-vector-icons@^4.2.0, required by [email protected]

I have following issue:

I am trying to add react-native-sentry to a new create react native project. It says it installs successfully, but I can't figure out how to send a test exception.

Steps to reproduce:

The linking ran successfully.

Successfully set up android for react-native
Successfully set up ios for react-native

🎉  Successfully set up Sentry for your project 🎉

When I tried to trigger an error in my code throw "hello world", it would just display a yellow warning notification in react native ios simulator, but I did not see it logged in sentry.

Reading the documentation, I see it says

we will automatically update your index.ios.js / index.android.js with the following changes
source

But react native does not use index.ios.js or index.android.js as the default now. See here.

The linking wizard did not update index.js and when I try to add these lines to index.js:

import { Sentry } from 'react-native-sentry';
Sentry.config('https://[email protected]/xxxx').install();

Actual result:
I get this error:

2018-08-28 22:54:48.819061+0700 AvoNative[61873:1547512] Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Metro Bundler has encountered an internal error, please check your terminal error output for more details (null))
2018-08-28 23:01:19.115728+0700 AvoNative[61873:1535721] [Touch] unexpected nil window in __dispatchSystemChangeDigitizerEvent, touchesEvent:<UITouchesEvent: 0x60c0001107d0> timestamp: 92310.6 touches: {(
    <UITouch: 0x7fb31781b3d0> phase: Stationary tap count: 1 force: 0.933 window: <RCTRedBoxWindow: 0x7fb317875c20; baseClass = UIWindow; frame = (0 0; 375 667); gestureRecognizers = <NSArray: 0x60c000440180>; layer = <UIWindowLayer: 0x60c000035de0>> view: <UITableViewCellContentView: 0x7fb314417cd0; frame = (0 0; 375 155); gestureRecognizers = <NSArray: 0x608000454760>; layer = <CALayer: 0x608000226640>> location in window: {26, 48.5} previous location in window: {21.5, 48.5} location in view: {26, 28.5} previous location in view: {21.5, 28.5}
)}

Expected result:
I think (according to the documentation) the linking wizard should update index.js and the app should not have that error.

🦔react-native-sentry

Most helpful comment

I finally figured it out.

You have to add this to your App.js file.

import {
  Sentry,
  SentryLog
} from 'react-native-sentry';

// disable stacktrace merging
Sentry.config("https://[email protected]/xxxx", {
  deactivateStacktraceMerging: false, // default: true | Deactivates the stacktrace merging feature
  logLevel: SentryLog.None, // default SentryLog.None | Possible values:  .None, .Error, .Debug, .Verbose
  disableNativeIntegration: false, // default: false | Deactivates the native integration and only uses raven-js
  handlePromiseRejection: true // default: true | Handle unhandled promise rejections
  // sampleRate: 0.5 // default: 1.0 | Only set this if you don't want to send every event so e.g.: 0.5 will send 50% of all events
  // These two options will only be considered if stacktrace merging is active
  // Here you can add modules that should be ignored or exclude modules
  // that should no longer be ignored from stacktrace merging
  // ignoreModulesExclude: ["I18nManager"], // default: [] | Exclude is always stronger than include
  // ignoreModulesInclude: ["RNSentry"], // default: [] | Include modules that should be ignored too
  // ---------------------------------
}).install();

All 4 comments

Instead of updating index.js with the sentry config, I updated App.js and it doesn't crash, but I still can't get it to report an error.

I finally figured it out.

You have to add this to your App.js file.

import {
  Sentry,
  SentryLog
} from 'react-native-sentry';

// disable stacktrace merging
Sentry.config("https://[email protected]/xxxx", {
  deactivateStacktraceMerging: false, // default: true | Deactivates the stacktrace merging feature
  logLevel: SentryLog.None, // default SentryLog.None | Possible values:  .None, .Error, .Debug, .Verbose
  disableNativeIntegration: false, // default: false | Deactivates the native integration and only uses raven-js
  handlePromiseRejection: true // default: true | Handle unhandled promise rejections
  // sampleRate: 0.5 // default: 1.0 | Only set this if you don't want to send every event so e.g.: 0.5 will send 50% of all events
  // These two options will only be considered if stacktrace merging is active
  // Here you can add modules that should be ignored or exclude modules
  // that should no longer be ignored from stacktrace merging
  // ignoreModulesExclude: ["I18nManager"], // default: [] | Exclude is always stronger than include
  // ignoreModulesInclude: ["RNSentry"], // default: [] | Include modules that should be ignored too
  // ---------------------------------
}).install();

Also the docs here: https://docs.sentry.io/clients/react-native/config/

generate a deprecated DSN.

I am closing all old issues, please if this is still a problem feel free to revive it.
Also, consider moving to our new SDK @sentry/react-native if it still happens there please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings