Calling Sentry.setUserContext() from Another Component

In my App.js I have the typical setup…

// App.js

import Sentry from 'sentry-expo';
Sentry.enableInExpoDevelopment = true; // TODO: remove once setup correctly

Later, in my RootNavigation I have login logic and want to setUserContext so I do this…

// RootNavigation.js

import Sentry from 'sentry-expo';
createSession = ({ data }) => {
    const { jwt, fullName, email, id } = data.login;
    Sentry.setUserContext({ userId: id, email, fullName });
    this.setState({ authenticated: true, submitting: false });

My question is, is this the right way to go about this? The docs don’t specify, but I’m assuming that the Sentry object is a singleton. Not sure how to verify it, and the user data isn’t getting passed along with the errors as I’d expect if my assumption were true.

UPDATE: nevermind…this seems to be working now. Not sure if it has something to do with the upgrade to SDK v27.0.0 or the fact that I’ve uninstalled/reinstalled Expo, but all seems to be working as expected now.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.