How to use the @sentry/react-native.setExtraContext function in @sentry/react-native

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
// Don't contact Sentry if we're connected to a server with diagnostics disabled. Note that this will
        // still log if we're not connected to any server.
        if (config && config.EnableDiagnostics != null && config.EnableDiagnostics !== 'true') {
            return;
        }

        let hasUserContext = false;
        const userContext = getUserContext(state);
        if (Object.keys(userContext).length) {
            hasUserContext = true;
            Sentry.setUserContext(userContext);
        }

        const extraContext = getExtraContext(state);
        if (Object.keys(extraContext).length) {
            Sentry.setExtraContext(extraContext);
        }

        const buildTags = getBuildTags(state);
        if (Object.keys(buildTags).length) {
            Sentry.setTagsContext(buildTags);
        }

        if (hasUserContext) {
            console.warn('Capturing with Sentry at ' + getDsn() + '...'); // eslint-disable-line no-console

            captureFunc();
        } else {
            console.warn('No user context, skipping capture'); // eslint-disable-line no-console
        }
    } catch (e) {
        // Don't want this to get into an infinite loop again...