You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a user logs out it is currently not possible to unset the user id.
Steps to reproduce:
In code
Initialize a firebase app
Initialize an analytics instance
Try to set the user id to null using setUserId(analytics, null)
Type error
Relevant Code:
To reproduce
import{setUserId}from'firebase/analytics'// initialize app constanalytics=getAnalytics(app)setUserId(analytics,null)// Argument of type 'null' is not assignable to parameter of type 'string'.ts
The function signature differs from other places, for example
The param type is wrong. The internal implementation of this function does allow for string | null and the public-facing wrapper function should as well. We can fix this.
Setting it to null may not actually do anything in Android (perhaps due to a bug) and you're wondering if it's the same on web. There's 2 ways to find out. The easiest way might be to just use a @ts-ignore on that line really quick to ignore the type check error and just see if it actually sets it. Another way is to set it by calling gtag() directly (gtag('config', YOUR_MEASUREMENT_ID, {'user_id': null}). (If you do this, it may not show up in your Firebase Analytics dashboard and you may have to check your Google Analytics dashboard for it.)
If I have time I can try it out, but if you want to speed things up, you can try both of those things and let me know what happens. They may possibly get different results because they're not exactly identical calls.
Describe your environment
Describe the problem
When a user logs out it is currently not possible to unset the user id.
Steps to reproduce:
In code
setUserId(analytics, null)
Relevant Code:
To reproduce
The function signature differs from other places, for example
firebase-js-sdk/packages/analytics/src/functions.ts
Line 96 in 1d3a34d
Here it seems perfectly possible to set the user id to
null
.Here
null
is not allowedfirebase-js-sdk/packages/analytics-types/index.d.ts
Line 465 in 11d37ed
firebase-js-sdk/packages/analytics/src/api.ts
Line 180 in 1d3a34d
Here in the documentation for Firebase analytics for android it even states explicitly that
null
should be allowed for compliant implementations. Same thing here for iOSHere's a similar issue for Firebase React Native invertase/react-native-firebase#4931 and here is another issue in the same repository that says that the documentation says that it's allowed but that the implementation actually doesn't set the userId to null - firebase/firebase-android-sdk#3602.
The text was updated successfully, but these errors were encountered: