Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry.clearContext() blocks #51

Closed
messense opened this issue May 12, 2017 · 7 comments
Closed

Sentry.clearContext() blocks #51

messense opened this issue May 12, 2017 · 7 comments
Assignees
Labels

Comments

@messense
Copy link
Contributor

messense commented May 12, 2017

Logout saga (I am using redux-saga):

export function * logout() {
  API.setHeader('X-Token', '');
  yield call(AsyncStorage.removeItem, 'currentUser');
  Sentry.clearContext();
  alert('test clear');
}

The alert('test clear') never gets executed, remove the Sentry.clearContext(); then it pops up an alert.

OS: iOS & Android
RN version: 0.44
react-native-sentry version: 0.8.1

@messense
Copy link
Contributor Author

The setUserContext method on raven-js supports call setUserContext() with no argument to clear user context, but react-native-sentry seems not supporting that so I have to call clearContext().

@HazAT HazAT self-assigned this May 12, 2017
@messense
Copy link
Contributor Author

messense commented May 13, 2017

   static clearContext(clearContext) {
        if (Sentry.isNativeClientAvailable()) Sentry._nativeClient.clearContext();
        // Sentry._ravenClient.clearContext();
    }

The problem seems not related to nativeClient but ravenClient, comment out Sentry._ravenClient.clearContext(); works fine.

@messense
Copy link
Contributor Author

messense commented May 13, 2017

BTW, the setUserContext of raven-js documentation seems advice us to pass user id as id while react-native-sentry requires userID.

https://docs.sentry.io/clients/javascript/usage/#tracking-users

@HazAT HazAT added the js label Jun 7, 2017
@jordanmkoncz
Copy link

I was planning to use clearContext() from within a logout saga just like you, so this will also be an issue for me. Hopefully it's fixed soon.

@HazAT HazAT closed this as completed in d916f8e Jun 26, 2017
@jordanmkoncz
Copy link

@HazAT, just confirming that Sentry.clearContext() appears to be working fine for me in 0.14.0, thanks for the fix.

@antoinerousseau
Copy link

antoinerousseau commented Sep 12, 2017

Yeah but how do we clear the user context without other context infos?
With Raven it was Raven.setUserContext() but with Sentry it crashes because it takes an object:

java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.facebook.react.bridge.ReadableMap.hasKey(java.lang.String)' on a null object reference

at io.sentry.RNSentryModule.getUserBuilder(RNSentryModule.java:263)
at io.sentry.RNSentryModule.setUser(RNSentryModule.java:158)

Should we call Sentry.setUserContext({})?

@HazAT
Copy link
Member

HazAT commented Sep 12, 2017

@antoinerousseau If it works like that, yes use Sentry.setUserContext({})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants