How to use @sentry/react-native - 10 common examples

To help you get started, we’ve selected a few @sentry/react-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mattermost / mattermost-mobile / app / utils / sentry / index.js View on Github external
export function initializeSentry() {
    if (!Config.SentryEnabled) {
        return;
    }

    const dsn = getDsn();

    if (!dsn) {
        console.warn('Sentry is enabled, but not configured on this platform'); // eslint-disable-line no-console
        return;
    }

    Sentry.init({dsn, ...Config.SentryOptions});
}
github guardian / editions / projects / Apps / editionsSrc / src / services / errors.ts View on Github external
private handleConsentUpdate(hasConsent: GdprSwitchSetting) {
        this.hasConsent = hasConsent
        if (hasConsent === false || hasConsent === null) return

        if (!this.hasConfigured) {
            Sentry.init({ dsn: SENTRY_DSN_URL })

            Sentry.setTag(
                'environment',
                __DEV__ ? 'DEV' : isInBeta() ? 'BETA' : 'RELEASE',
            )
            Sentry.setExtra('react', true)
            this.hasConfigured = true
        }

        while (this.pendingQueue.length > 0) {
            const err = this.pendingQueue.pop()
            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
            Sentry.captureException(err!)
        }
    }
github guardian / editions / projects / Mallard / src / services / errors.ts View on Github external
private handleConsentUpdate(hasConsent: GdprSwitchSetting) {
        this.hasConsent = hasConsent
        if (hasConsent === false || hasConsent === null) return

        if (!this.hasConfigured) {
            Sentry.init({ dsn: SENTRY_DSN_URL })

            Sentry.setTag(
                'environment',
                __DEV__ ? 'DEV' : isInBeta() ? 'BETA' : 'RELEASE',
            )
            Sentry.setExtra('react', true)
            this.hasConfigured = true
        }

        while (this.pendingQueue.length > 0) {
            const err = this.pendingQueue.pop()
            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
            Sentry.captureException(err!)
        }
    }
github jolocom / smartwallet-app / src / lib / errors.ts View on Github external
export function initErrorReporting() {
  Sentry.init({
    dsn: sentryDSN,
    release: `${VersionNumber.bundleIdentifier}@${VersionNumber.appVersion}`,

    // disable automatic reporting of errors/rejections without user consent
    integrations: defaultIntegrations =>
      defaultIntegrations.filter(i => i.name !== 'ReactNativeErrorHandlers'),

    /**
     * @param event
     * @dev TODO Decide if event.contexts.app should be stripped
     */

    beforeSend: event => {
      const { extra, contexts } = event

      if (extra && contexts) {
github guardian / editions / projects / Mallard / src / services / errors.ts View on Github external
private handleConsentUpdate(hasConsent: GdprSwitchSetting) {
        this.hasConsent = hasConsent
        if (hasConsent === false || hasConsent === null) return

        if (!this.hasConfigured) {
            Sentry.init({ dsn: SENTRY_DSN_URL })

            Sentry.setTag(
                'environment',
                __DEV__ ? 'DEV' : isInBeta() ? 'BETA' : 'RELEASE',
            )
            Sentry.setExtra('react', true)
            this.hasConfigured = true
        }

        while (this.pendingQueue.length > 0) {
            const err = this.pendingQueue.pop()
            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
            Sentry.captureException(err!)
        }
    }
github guardian / editions / projects / Apps / editionsSrc / src / services / errors.ts View on Github external
private handleConsentUpdate(hasConsent: GdprSwitchSetting) {
        this.hasConsent = hasConsent
        if (hasConsent === false || hasConsent === null) return

        if (!this.hasConfigured) {
            Sentry.init({ dsn: SENTRY_DSN_URL })

            Sentry.setTag(
                'environment',
                __DEV__ ? 'DEV' : isInBeta() ? 'BETA' : 'RELEASE',
            )
            Sentry.setExtra('react', true)
            this.hasConfigured = true
        }

        while (this.pendingQueue.length > 0) {
            const err = this.pendingQueue.pop()
            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
            Sentry.captureException(err!)
        }
    }
github mattermost / mattermost-mobile / app / utils / sentry / index.js View on Github external
}

    if (obj.status_code) {
        breadcrumb.data.status_code = obj.status_code;
    }

    if (obj.url) {
        const match = (/^(?:https?:\/\/)[^/]+(\/.*)$/);

        if (match && match.length >= 2) {
            breadcrumb.data.url = match[1];
        }
    }

    try {
        Sentry.addBreadcrumb(breadcrumb);
    } catch (e) {
        // Do nothing since this is only here to make sure we don't crash when handling an exception
        console.warn('Failed to capture breadcrumb of non-error', e); // eslint-disable-line no-console
    }
}
github rastapasta / foodsharing / src / sagas / sentry.tsx View on Github external
if (Platform.OS !== 'ios')
    return

  while (true) {
    // Wait until we get ANY event
    const { type, payload } = yield take()

    if (type.startsWith('rrf') || type.startsWith('@'))
      continue

    if (filter[type])
      filter[type].forEach(path =>
        recursiveReplacer(path.split(/\./), payload)
      )

    Sentry.addBreadcrumb({
      category: 'redux',
      message: type,
      level: type.match(/ERROR/) ? Sentry.Severity.Warning : Sentry.Severity.Info,
      ...(payload ?
        {data: typeof payload === 'object' ? payload : {payload}} :
        {}
      )
    })
  }
}
github mapswipe / mapswipe / src / shared / common / SatImage.js View on Github external
onError = (evt) => {
        const { source } = this.state;
        const { nativeEvent: { error } } = evt;
        Sentry.addBreadcrumb({
            message: 'Image not loading',
            data: {
                url: source.uri,
                error,
            },
        });
        Sentry.captureMessage('Cannot load sat imagery', 'warning');
        console.log(error);
        // eslint-disable-next-line global-require
        this.setState({ source: require('../../../assets/noImageAvailable.png') });
    }
github guardian / editions / projects / Apps / editionsSrc / src / services / errors.ts View on Github external
private handleConsentUpdate(hasConsent: GdprSwitchSetting) {
        this.hasConsent = hasConsent
        if (hasConsent === false || hasConsent === null) return

        if (!this.hasConfigured) {
            Sentry.init({ dsn: SENTRY_DSN_URL })

            Sentry.setTag(
                'environment',
                __DEV__ ? 'DEV' : isInBeta() ? 'BETA' : 'RELEASE',
            )
            Sentry.setExtra('react', true)
            this.hasConfigured = true
        }

        while (this.pendingQueue.length > 0) {
            const err = this.pendingQueue.pop()
            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
            Sentry.captureException(err!)
        }
    }