Sentry-react-native: undefined is not an object (evaluating 'j.default.captureException')

Created on 21 Dec 2018  Β·  2Comments  Β·  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

β”œβ”€β”€ @types/[email protected]
β”œβ”€β”€ @types/[email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected] invalid
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
└── [email protected]

npm ERR! invalid: [email protected] /Users/hyuckjunlee/Development/MCTExchange/node_modules/react-native-languages
npm ERR! invalid: [email protected] /Users/hyuckjunlee/Development/MCTExchange/node_modules/@sentry/wizard/node_modules/xcode

Config:

export const SentryUrl = 'πŸ”‘';
Sentry.config(SentryUrl).install();

I have following issue:

on root index.js

/** @format */

import { AppRegistry, YellowBox } from 'react-native';
import App from './src/index';
import { name as appName } from './app.json';
import Sentry from 'react-native-sentry';
import { SentryUrl } from './src/config/urls';
import CodePush from 'react-native-code-push';

Sentry.config(SentryUrl).install();
CodePush.getUpdateMetadata().then((update) => {
  if (update) {
    Sentry.setVersion(update.appVersion + '-codepush:' + update.label);
  }
});

YellowBox.ignoreWarnings(['You should only render ...', 'Remote debugger']);

AppRegistry.registerComponent(appName, () => App);

and actual capturing exception codes Login.tsx

  import Sentry from 'react-native-sentry';
  ...
  ... 
  @action
  public submit = async () => {
    try {
      this.isLoading = true;
      await this.props.login(this.emailAddr, this.pswd);
      this.props.navigation.navigate('MainTab');
    } catch (e) {
      console.log(e);
      Alert.alert('Hello');
      !__DEV__ && Sentry.captureException(e); // Sentry is undefined!!!!!!!!!!!!!!!!!!!!!!!!
      if (!e.response || e.response.status === 404) {
        Alert.alert('였λ₯˜', 'μ„œλ²„λ‘œλΆ€ν„° 응닡이 μ—†μŠ΅λ‹ˆλ‹€.');
      } else if (e.response.status === 400) {
        Alert.alert('', '이메일 ν˜Ήμ€ λΉ„λ°€λ²ˆν˜Έκ°€ μ˜¬λ°”λ₯΄μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.');
      } else if (e.response.status === 401) {
        Alert.alert('였λ₯˜', 'μ‚¬μš©μž 정보λ₯Ό λ°›μ•„ 올 수 μ—†μŠ΅λ‹ˆλ‹€.');
      } else {
        Alert.alert('였λ₯˜', 'μ•Œ 수 μ—†λŠ” 였λ₯˜μž…λ‹ˆλ‹€.');
      }
    } finally {
      this.isLoading = false;
    }
  };

On this code, Sentry.captureException(e) doesn't work.
err

||Version|
|---|---|
|react-native|0.57.8|
|react-native-sentry|0.42.2|

Most helpful comment

I made a fool mistake.
I modify import Sentry from 'react-native-sentry' to import { Sentry } from 'react-native-sentry, it works

All 2 comments

Hi there, I just edited this for you. Try not to post your DSN on GitHub.

I made a fool mistake.
I modify import Sentry from 'react-native-sentry' to import { Sentry } from 'react-native-sentry, it works

Was this page helpful?
0 / 5 - 0 ratings