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

setUserId(null) not working #1247

Closed
EatSafeClaudia opened this issue Jun 25, 2018 · 13 comments
Closed

setUserId(null) not working #1247

EatSafeClaudia opened this issue Jun 25, 2018 · 13 comments
Labels
platform: android plugin: analytics Google Analytics for Firebase

Comments

@EatSafeClaudia
Copy link

Issue

setUserId(null) doesn't seem to work.

Once a user logs in, I send their id. When they log out, I want to reset their userId. Currently I do a setUserId(null), but looking on firebase, events continue being tracked under the previous user id.

Environment

Android

  1. Application Target Platform:

Android

  1. React Native version:

0.54.1

  1. RNFirebase Version:

4.2.0

  1. Firebase Module:
    Analytics
@Salakar
Copy link
Contributor

Salakar commented Jun 26, 2018

@EatSafeClaudia any chance you could provide a code example of your usage, e.g. how you're setting the null and how you're sending events after changing it, are the events immediately after setting to null showing as the old user id and then it changes to null eventually? Or does it consistently always stay on the old user id and never gradually change to null.

@Salakar Salakar added platform: android Workflow: Waiting for User Response Blocked waiting for user response. plugin: analytics Google Analytics for Firebase labels Jun 26, 2018
@Salakar Salakar removed the Workflow: Waiting for User Response Blocked waiting for user response. label Jul 21, 2018
@Salakar
Copy link
Contributor

Salakar commented Jul 21, 2018

Closing due to no response and unable to reproduce locally. Will re-open on request if this is still an issue.

Thanks


Loving react-native-firebase and the support we provide? Please consider supporting us with any of the below:

@Salakar Salakar closed this as completed Jul 21, 2018
@lukasgjetting
Copy link

lukasgjetting commented Sep 4, 2018

@Salakar I'm having this issue aswell. I'm currently running it in a Redux middleware.
I am simply doing firebaseTracker.setUserId(null); where firebaseTracker = firebase.analytics();
When looking in Firebase Debug Mode, I see the following (after running the above function).

From Firebase, nothing changed

I have verified that the function is actually running with a console.warn.
I have tried doing firebaseTracker.setUserId('null');, but that gives me the following:

From Firebase, user_id is the string 'null'

I mean, it could work.. but I would prefer actually setting it to null.

Platform: Android
RN: 0.55.4
RNFB: 4.2.0

Thanks in advance for your help!

EDIT:
I just noticed I'm also having issues actually setting the user id (not sure how it worked before with 'null'?). When the user logs in, I run the following code:

firebaseTracker.setUserId(id.toString());
firebaseTracker.logEvent('login', { sign_up_method: 'facebook' });

In Firebase I see the 'login' event, but I don't see the actual setting of the user id.

@EatSafeClaudia
Copy link
Author

Still having this issue, your description of use, @lukasgjetting, is exactly mine. I am having the issue after upgrade to RN 0.56.0 and RNFB 4.3.8.

@tjjjwxzq
Copy link

tjjjwxzq commented Feb 26, 2019

I get the same issue - trying to call setUserId(null) or setUserId(undefined) both do not work. I still see the old user id showing up in the Firebase DebugVIew. Only when I call setUserId on another string does the previous one get replaced (eg. setUserId('dummy')

RN version: 0.57.7
RNFB version: tested on both 4.2.0 and 5.2.2 on iOS simulator

@Salakar
Copy link
Contributor

Salakar commented Feb 26, 2019

@lukasgjetting @EatSafeClaudia @tjjjwxzq not sure what to suggest here, we call the native method directly with the value provided to it from JS, so if you send a null it calls FirebaseAnalytics.getInstance(getContext()).setUserId(null); on Android. This might be a bug with the Firebase Android SDK.

Analytics re-write for v6 is complete and it has some minor changes; all the methods return Promises now so this removes the chance that this could be a race condition (e.g. RN bridge batches method calls, so setting a user id may be being sent along with other method calls, e.g. logEvent at the same time, with a promise now you can ensure that it has set the user before the next analytics method is called).

See https://github.com/invertase/react-native-firebase/blob/master/CHANGELOG.md for details on the v6 release and upgrading notes / caveats - if you wish to try it out early.

@ptrkstr
Copy link

ptrkstr commented May 20, 2019

This issue is happening on iOS on the following versions:
pod 'Firebase/Core', '5.20.2'
pod 'Fabric', '1.9.0'
pod 'Crashlytics', '3.12.0'
We're able to set the userId, but setting it to nil still retains the old value.

@mikeborozdin
Copy link

Why has this been closed?

It's still an issue in 5.5.3.

@mikehardy
Copy link
Collaborator

seems to be an underlying sdk issue. I believe the suggested workaround was to set to empty string

@mikehardy
Copy link
Collaborator

can't find the related issue now but it's in the tracker somewhere just not linked here, it was from a separate issue tho

@btilford
Copy link

Pretty sure this still exists in v7.

Assuming there is no way to unset this wouldn't setting it to a new UUID each time be better than an empty string so that you don't merge a bunch of users under the "empty" id?

@mikehardy
Copy link
Collaborator

This is more than a year old, if you still have a problem please post a new issue with full details and an App.js that reproduces please

@anuragraina
Copy link

The issue still exists. Setting userId to null doesn't work, it keeps the same old id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: android plugin: analytics Google Analytics for Firebase
Projects
None yet
Development

No branches or pull requests

9 participants