invertase / react-native-firebase

πŸ”₯ A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.7k stars 2.22k forks source link

[πŸ›][πŸ”₯]Not Able to reset UserId and setUserId(null) does not work #6583

Closed sandeep-aample closed 1 year ago

sandeep-aample commented 2 years ago

Issue

I'm trying to mock login and logout functionality to test userId feature of google analytics. I have three screens: 1) Login 2) Profile 1 3) Profile 2

Login Profile1 Profile2

I'm using react-navigation library to navigate through screens. I'm using react-native-paper to design inputs and buttons.

1) In Login screen, when the user types a username and presses submit button, I'm setting the username as userId using setUserId(username) and navigating him to Profile 1 screen. 2) In Profile 1 Screen, on press of submit button I'm logging an event and navigating him to Profile 2 screeen. 3) In Profile 2 Screen , on press of submit button, I'm logging an event and on press of logout button I'm setting user id to null using setUserId(null) and navigating him back to Login screen.

I'm using google analytics debugView to track events in near-realtime.

The issue is when a user logs into the app initially, I'm able to see the userId being set in debugVIew and when the user logs out of the app after navigating through screens and logs in back with a different username, the userId is not being reset with the new username in debugView and also setUserId(null) is not being reflected in debugView.

After tesing it for several hours, I found out that the userId resets only in some situations i.e, 1) When the user puts the app in the background for a few seconds and brings back the app to foreground and tries to login again with a different username. 2) When the user clears the app from memory and opens it afresh and logs in again with a different username.

I'm not sure if this is a bug in debugView or in react-native-firebase analytics.

For your reference, I'm attaching the logs that I have captured using commands provided by firebase :

Login Screen logs (on press of submit button in login screen)

09-30 18:45:34.145 V/FA      (13263): Connecting to remote service
09-30 18:45:34.273 V/FA      (13263): Connection attempt already in progress
09-30 18:45:34.273 D/FA      (13263): Connected to remote service
09-30 18:45:34.273 V/FA      (13263): Processing queued up service tasks: 2
09-30 18:45:34.346 V/FA-SVC  (31716): EES config found for: com.analytics
09-30 18:45:34.347 V/FA-SVC  (31716): EES was not applied to event: loginEvent
09-30 18:45:34.352 V/FA-SVC  (31716): Logging event: origin=app,name=loginEvent,params=Bundle[{ga_event_origin(_o)=app, ga_screen_class(_sc)=MainActivity, ga_screen_id(_si)=6352328087458408729, item=bob}]
09-30 18:45:34.383 V/FA-SVC  (31716): Upload scheduled in approximately ms: 500
09-30 18:45:34.383 V/FA-SVC  (31716): Unscheduling upload
09-30 18:45:34.386 V/FA-SVC  (31716): Scheduling upload, millis: 500
09-30 18:45:34.387 V/FA-SVC  (31716): Background event processing time, ms: 36
09-30 18:45:34.396 V/FA-SVC  (31716): Setting user property: user_id(_id), bob
09-30 18:45:34.887 V/FA-SVC  (31716): Unscheduling upload
09-30 18:45:34.892 V/FA-SVC  (31716): Starting upload from DelayedRunnable
09-30 18:45:34.900 V/FA-SVC  (31716): Checking account type status for ad personalization signals
09-30 18:45:34.909 V/FA-SVC  (31716): Saving bundle, size: 516
09-30 18:45:34.911 D/FA-SVC  (31716): Uploading events. Elapsed time since last upload attempt (ms): 512
09-30 18:45:34.915 V/FA-SVC  (31716): Uploading data. app, uncompressed size, data: com.analytics, 568,
09-30 18:45:34.915 V/FA-SVC  (31716): batch {
09-30 18:45:34.915 V/FA-SVC  (31716):   bundle {
09-30 18:45:34.915 V/FA-SVC  (31716):     protocol_version: 1
09-30 18:45:34.915 V/FA-SVC  (31716):     platform: android
09-30 18:45:34.915 V/FA-SVC  (31716):     gmp_version: 73000
09-30 18:45:34.915 V/FA-SVC  (31716):     uploading_gmp_version: 223316
09-30 18:45:34.915 V/FA-SVC  (31716):     dynamite_version: 83
09-30 18:45:34.915 V/FA-SVC  (31716):     config_version: 1664255876114418
09-30 18:45:34.915 V/FA-SVC  (31716):     gmp_app_id: 1:827535169290:android:ad0b579bef1f1161a2ccf3
09-30 18:45:34.915 V/FA-SVC  (31716):     admob_app_id:
09-30 18:45:34.915 V/FA-SVC  (31716):     app_id: com.analytics
09-30 18:45:34.915 V/FA-SVC  (31716):     app_version: 1.0
09-30 18:45:34.915 V/FA-SVC  (31716):     app_version_major: 1
09-30 18:45:34.915 V/FA-SVC  (31716):     firebase_instance_id: fwvf5i7xQh-8Y6KMfPozL_
09-30 18:45:34.915 V/FA-SVC  (31716):     dev_cert_hash: 6674964906916451472
09-30 18:45:34.915 V/FA-SVC  (31716):     app_store: manual_install
09-30 18:45:34.915 V/FA-SVC  (31716):     upload_timestamp_millis: 1664543734894
09-30 18:45:34.915 V/FA-SVC  (31716):     start_timestamp_millis: 1664543733963
09-30 18:45:34.915 V/FA-SVC  (31716):     end_timestamp_millis: 1664543733963
09-30 18:45:34.915 V/FA-SVC  (31716):     previous_bundle_start_timestamp_millis: 1664543723266
09-30 18:45:34.915 V/FA-SVC  (31716):     previous_bundle_end_timestamp_millis: 1664543723266
09-30 18:45:34.915 V/FA-SVC  (31716):     app_instance_id: fd63ec30b5ab27b044265fca3d997afe
09-30 18:45:34.915 V/FA-SVC  (31716):     resettable_device_id: a8bcd6a1-0e64-4565-9e76-2b4c2911d270
09-30 18:45:34.915 V/FA-SVC  (31716):     ds_id:
09-30 18:45:34.915 V/FA-SVC  (31716):     limited_ad_tracking: false
09-30 18:45:34.915 V/FA-SVC  (31716):     os_version: 9
09-30 18:45:34.915 V/FA-SVC  (31716):     device_model: AOSP on IA Emulator
09-30 18:45:34.915 V/FA-SVC  (31716):     user_default_language: en-us
09-30 18:45:34.915 V/FA-SVC  (31716):     time_zone_offset_minutes: 330
09-30 18:45:34.915 V/FA-SVC  (31716):     bundle_sequential_index: 549
09-30 18:45:34.915 V/FA-SVC  (31716):     service_upload: true
09-30 18:45:34.915 V/FA-SVC  (31716):     health_monitor:
09-30 18:45:34.915 V/FA-SVC  (31716):     consent_signals: G1--
09-30 18:45:34.915 V/FA-SVC  (31716):     user_property {
09-30 18:45:34.915 V/FA-SVC  (31716):       set_timestamp_millis: 1664356684929
09-30 18:45:34.915 V/FA-SVC  (31716):       name: non_personalized_ads(_npa)
09-30 18:45:34.915 V/FA-SVC  (31716):       string_value:
09-30 18:45:34.915 V/FA-SVC  (31716):       int_value: 0
09-30 18:45:34.915 V/FA-SVC  (31716):     }
09-30 18:45:34.915 V/FA-SVC  (31716):     user_property {
09-30 18:45:34.915 V/FA-SVC  (31716):       set_timestamp_millis: 1664356684929
09-30 18:45:34.915 V/FA-SVC  (31716):       name: first_open_time(_fot)
09-30 18:45:34.915 V/FA-SVC  (31716):       string_value:
09-30 18:45:34.915 V/FA-SVC  (31716):       int_value: 1664359200000
09-30 18:45:34.915 V/FA-SVC  (31716):     }
09-30 18:45:34.915 V/FA-SVC  (31716):     user_property {
09-30 18:45:34.915 V/FA-SVC  (31716):       set_timestamp_millis: 1664356684929
09-30 18:45:34.915 V/FA-SVC  (31716):       name: first_open_after_install(_fi)
09-30 18:45:34.915 V/FA-SVC  (31716):       string_value:
09-30 18:45:34.915 V/FA-SVC  (31716):       int_value: 1
09-30 18:45:34.915 V/FA-SVC  (31716):     }
09-30 18:45:34.915 V/FA-SVC  (31716):     user_property {
09-30 18:45:34.915 V/FA-SVC  (31716):       set_timestamp_millis: 1664516529221
09-30 18:45:34.915 V/FA-SVC  (31716):       name: ga_session_number(_sno)
09-30 18:45:34.915 V/FA-SVC  (31716):       string_value:
09-30 18:45:34.915 V/FA-SVC  (31716):       int_value: 3
09-30 18:45:34.915 V/FA-SVC  (31716):     }
09-30 18:45:34.915 V/FA-SVC  (31716):     user_property {
09-30 18:45:34.915 V/FA-SVC  (31716):       set_timestamp_millis: 1664516529221
09-30 18:45:34.915 V/FA-SVC  (31716):       name: ga_session_id(_sid)
09-30 18:45:34.915 V/FA-SVC  (31716):       string_value:
09-30 18:45:34.915 V/FA-SVC  (31716):       int_value: 1664516529
09-30 18:45:34.915 V/FA-SVC  (31716):     }
09-30 18:45:34.915 V/FA-SVC  (31716):     user_property {
09-30 18:45:34.915 V/FA-SVC  (31716):       set_timestamp_millis: 1664543734899
09-30 18:45:34.915 V/FA-SVC  (31716):       name: lifetime_user_engagement(_lte)
09-30 18:45:34.915 V/FA-SVC  (31716):       string_value:
09-30 18:45:34.915 V/FA-SVC  (31716):       int_value: 60108731
09-30 18:45:34.915 V/FA-SVC  (31716):     }
09-30 18:45:34.915 V/FA-SVC  (31716):     user_property {
09-30 18:45:34.915 V/FA-SVC  (31716):       set_timestamp_millis: 1664543734900
09-30 18:45:34.915 V/FA-SVC  (31716):       name: session_user_engagement(_se)
09-30 18:45:34.915 V/FA-SVC  (31716):       string_value:
09-30 18:45:34.915 V/FA-SVC  (31716):       int_value: 24885286
09-30 18:45:34.915 V/FA-SVC  (31716):     }
09-30 18:45:34.915 V/FA-SVC  (31716):     event {
09-30 18:45:34.915 V/FA-SVC  (31716):       name: loginEvent
09-30 18:45:34.915 V/FA-SVC  (31716):       timestamp_millis: 1664543733963
09-30 18:45:34.915 V/FA-SVC  (31716):       previous_timestamp_millis: 1664543719469
09-30 18:45:34.915 V/FA-SVC  (31716):       param {
09-30 18:45:34.915 V/FA-SVC  (31716):         name: ga_event_origin(_o)
09-30 18:45:34.915 V/FA-SVC  (31716):         string_value: app
09-30 18:45:34.915 V/FA-SVC  (31716):       }
09-30 18:45:34.915 V/FA-SVC  (31716):       param {
09-30 18:45:34.915 V/FA-SVC  (31716):         name: _r
09-30 18:45:34.915 V/FA-SVC  (31716):         int_value: 1
09-30 18:45:34.915 V/FA-SVC  (31716):       }
09-30 18:45:34.915 V/FA-SVC  (31716):       param {
09-30 18:45:34.915 V/FA-SVC  (31716):         name: ga_screen_class(_sc)
09-30 18:45:34.915 V/FA-SVC  (31716):         string_value: MainActivity
09-30 18:45:34.915 V/FA-SVC  (31716):       }
09-30 18:45:34.915 V/FA-SVC  (31716):       param {
09-30 18:45:34.915 V/FA-SVC  (31716):         name: ga_screen_id(_si)
09-30 18:45:34.915 V/FA-SVC  (31716):         int_value: 6352328087458408729
09-30 18:45:34.915 V/FA-SVC  (31716):       }
09-30 18:45:34.915 V/FA-SVC  (31716):       param {
09-30 18:45:34.915 V/FA-SVC  (31716):         name: _dbg
09-30 18:45:34.915 V/FA-SVC  (31716):         int_value: 1
09-30 18:45:34.915 V/FA-SVC  (31716):       }
09-30 18:45:34.915 V/FA-SVC  (31716):       param {
09-30 18:45:34.915 V/FA-SVC  (31716):         name: item
09-30 18:45:34.915 V/FA-SVC  (31716):         string_value: bob
09-30 18:45:34.915 V/FA-SVC  (31716):       }
09-30 18:45:34.915 V/FA-SVC  (31716):     }
09-30 18:45:34.915 V/FA-SVC  (31716):   }
09-30 18:45:34.915 V/FA-SVC  (31716): }
09-30 18:45:34.915 V/FA-SVC  (31716): Not stopping services. fetch, network, upload: false, true, false
09-30 18:45:34.917 V/FA-SVC  (31716): Uploading data. size: 529
09-30 18:45:35.110 V/FA-SVC  (31716): Upload scheduled in approximately ms: 3599995
09-30 18:45:35.110 V/FA-SVC  (31716): Unscheduling upload
09-30 18:45:35.115 V/FA-SVC  (31716): Scheduling upload, millis: 3599995
09-30 18:45:35.121 V/FA-SVC  (31716): Successful upload. Got network response. code, size: 204, 0
09-30 18:45:35.130 V/FA-SVC  (31716): Nothing to upload or uploading impossible
09-30 18:45:35.130 V/FA-SVC  (31716): Unscheduling upload
09-30 18:45:35.138 V/FA-SVC  (31716): Stopping uploading service(s)
09-30 18:45:39.390 V/FA      (13263): Inactivity, disconnecting from the service

Profile Screen 1 logs (on press of submit button in Profile Screen 1)

09-30 18:49:18.240 V/FA      (13263): Connecting to remote service
09-30 18:49:18.268 D/FA      (13263): Connected to remote service
09-30 18:49:18.268 V/FA      (13263): Processing queued up service tasks: 1
09-30 18:49:18.305 V/FA-SVC  (31716): EES config found for: com.analytics
09-30 18:49:18.307 V/FA-SVC  (31716): EES was not applied to event: screen1
09-30 18:49:18.309 V/FA-SVC  (31716): Logging event: origin=app,name=screen1,params=Bundle[{ga_event_origin(_o)=app, ga_screen_class(_sc)=MainActivity, ga_screen_id(_si)=6352328087458408729, item=profileScreen1}]
09-30 18:49:18.356 V/FA-SVC  (31716): Upload scheduled in approximately ms: 500
09-30 18:49:18.356 V/FA-SVC  (31716): Unscheduling upload
09-30 18:49:18.359 V/FA-SVC  (31716): Scheduling upload, millis: 500
09-30 18:49:18.360 V/FA-SVC  (31716): Background event processing time, ms: 51
09-30 18:49:18.861 V/FA-SVC  (31716): Unscheduling upload
09-30 18:49:18.864 V/FA-SVC  (31716): Starting upload from DelayedRunnable
09-30 18:49:18.872 V/FA-SVC  (31716): Checking account type status for ad personalization signals
09-30 18:49:18.916 V/FA-SVC  (31716): Saving bundle, size: 530
09-30 18:49:18.919 D/FA-SVC  (31716): Uploading events. Elapsed time since last upload attempt (ms): 510
09-30 18:49:18.922 V/FA-SVC  (31716): Uploading data. app, uncompressed size, data: com.analytics, 595,
09-30 18:49:18.922 V/FA-SVC  (31716): batch {
09-30 18:49:18.922 V/FA-SVC  (31716):   bundle {
09-30 18:49:18.922 V/FA-SVC  (31716):     protocol_version: 1
09-30 18:49:18.922 V/FA-SVC  (31716):     platform: android
09-30 18:49:18.922 V/FA-SVC  (31716):     gmp_version: 73000
09-30 18:49:18.922 V/FA-SVC  (31716):     uploading_gmp_version: 223316
09-30 18:49:18.922 V/FA-SVC  (31716):     dynamite_version: 83
09-30 18:49:18.922 V/FA-SVC  (31716):     config_version: 1664255876114418
09-30 18:49:18.922 V/FA-SVC  (31716):     gmp_app_id: 1:827535169290:android:ad0b579bef1f1161a2ccf3
09-30 18:49:18.922 V/FA-SVC  (31716):     admob_app_id:
09-30 18:49:18.922 V/FA-SVC  (31716):     app_id: com.analytics
09-30 18:49:18.922 V/FA-SVC  (31716):     app_version: 1.0
09-30 18:49:18.922 V/FA-SVC  (31716):     app_version_major: 1
09-30 18:49:18.922 V/FA-SVC  (31716):     firebase_instance_id: fwvf5i7xQh-8Y6KMfPozL_
09-30 18:49:18.922 V/FA-SVC  (31716):     dev_cert_hash: 6674964906916451472
09-30 18:49:18.922 V/FA-SVC  (31716):     app_store: manual_install
09-30 18:49:18.922 V/FA-SVC  (31716):     upload_timestamp_millis: 1664543958866
09-30 18:49:18.922 V/FA-SVC  (31716):     start_timestamp_millis: 1664543958198
09-30 18:49:18.922 V/FA-SVC  (31716):     end_timestamp_millis: 1664543958198
09-30 18:49:18.922 V/FA-SVC  (31716):     previous_bundle_start_timestamp_millis: 1664543733963
09-30 18:49:18.922 V/FA-SVC  (31716):     previous_bundle_end_timestamp_millis: 1664543733963
09-30 18:49:18.922 V/FA-SVC  (31716):     app_instance_id: fd63ec30b5ab27b044265fca3d997afe
09-30 18:49:18.922 V/FA-SVC  (31716):     resettable_device_id: a8bcd6a1-0e64-4565-9e76-2b4c2911d270
09-30 18:49:18.922 V/FA-SVC  (31716):     ds_id:
09-30 18:49:18.922 V/FA-SVC  (31716):     limited_ad_tracking: false
09-30 18:49:18.922 V/FA-SVC  (31716):     os_version: 9
09-30 18:49:18.922 V/FA-SVC  (31716):     device_model: AOSP on IA Emulator
09-30 18:49:18.922 V/FA-SVC  (31716):     user_default_language: en-us
09-30 18:49:18.922 V/FA-SVC  (31716):     time_zone_offset_minutes: 330
09-30 18:49:18.922 V/FA-SVC  (31716):     bundle_sequential_index: 550
09-30 18:49:18.922 V/FA-SVC  (31716):     service_upload: true
09-30 18:49:18.922 V/FA-SVC  (31716):     health_monitor:
09-30 18:49:18.922 V/FA-SVC  (31716):     consent_signals: G1--
09-30 18:49:18.922 V/FA-SVC  (31716):     user_property {
09-30 18:49:18.922 V/FA-SVC  (31716):       set_timestamp_millis: 1664356684929
09-30 18:49:18.922 V/FA-SVC  (31716):       name: non_personalized_ads(_npa)
09-30 18:49:18.922 V/FA-SVC  (31716):       string_value:
09-30 18:49:18.922 V/FA-SVC  (31716):       int_value: 0
09-30 18:49:18.922 V/FA-SVC  (31716):     }
09-30 18:49:18.922 V/FA-SVC  (31716):     user_property {
09-30 18:49:18.922 V/FA-SVC  (31716):       set_timestamp_millis: 1664356684929
09-30 18:49:18.922 V/FA-SVC  (31716):       name: first_open_time(_fot)
09-30 18:49:18.922 V/FA-SVC  (31716):       string_value:
09-30 18:49:18.922 V/FA-SVC  (31716):       int_value: 1664359200000
09-30 18:49:18.922 V/FA-SVC  (31716):     }
09-30 18:49:18.922 V/FA-SVC  (31716):     user_property {
09-30 18:49:18.922 V/FA-SVC  (31716):       set_timestamp_millis: 1664356684929
09-30 18:49:18.922 V/FA-SVC  (31716):       name: first_open_after_install(_fi)
09-30 18:49:18.922 V/FA-SVC  (31716):       string_value:
09-30 18:49:18.922 V/FA-SVC  (31716):       int_value: 1
09-30 18:49:18.922 V/FA-SVC  (31716):     }
09-30 18:49:18.922 V/FA-SVC  (31716):     user_property {
09-30 18:49:18.922 V/FA-SVC  (31716):       set_timestamp_millis: 1664516529221
09-30 18:49:18.922 V/FA-SVC  (31716):       name: ga_session_number(_sno)
09-30 18:49:18.922 V/FA-SVC  (31716):       string_value:
09-30 18:49:18.922 V/FA-SVC  (31716):       int_value: 3
09-30 18:49:18.922 V/FA-SVC  (31716):     }
09-30 18:49:18.922 V/FA-SVC  (31716):     user_property {
09-30 18:49:18.922 V/FA-SVC  (31716):       set_timestamp_millis: 1664516529221
09-30 18:49:18.922 V/FA-SVC  (31716):       name: ga_session_id(_sid)
09-30 18:49:18.922 V/FA-SVC  (31716):       string_value:
09-30 18:49:18.922 V/FA-SVC  (31716):       int_value: 1664516529
09-30 18:49:18.922 V/FA-SVC  (31716):     }
09-30 18:49:18.922 V/FA-SVC  (31716):     user_property {
09-30 18:49:18.922 V/FA-SVC  (31716):       set_timestamp_millis: 1664543958870
09-30 18:49:18.922 V/FA-SVC  (31716):       name: lifetime_user_engagement(_lte)
09-30 18:49:18.922 V/FA-SVC  (31716):       string_value:
09-30 18:49:18.922 V/FA-SVC  (31716):       int_value: 60108731
09-30 18:49:18.922 V/FA-SVC  (31716):     }
09-30 18:49:18.922 V/FA-SVC  (31716):     user_property {
09-30 18:49:18.922 V/FA-SVC  (31716):       set_timestamp_millis: 1664543958872
09-30 18:49:18.922 V/FA-SVC  (31716):       name: session_user_engagement(_se)
09-30 18:49:18.922 V/FA-SVC  (31716):       string_value:
09-30 18:49:18.922 V/FA-SVC  (31716):       int_value: 24885286
09-30 18:49:18.922 V/FA-SVC  (31716):     }
09-30 18:49:18.922 V/FA-SVC  (31716):     user_property {
09-30 18:49:18.922 V/FA-SVC  (31716):       set_timestamp_millis: 1664543733967
09-30 18:49:18.922 V/FA-SVC  (31716):       name: user_id(_id)
09-30 18:49:18.922 V/FA-SVC  (31716):       string_value: bob
09-30 18:49:18.922 V/FA-SVC  (31716):     }
09-30 18:49:18.922 V/FA-SVC  (31716):     event {
09-30 18:49:18.922 V/FA-SVC  (31716):       name: screen1
09-30 18:49:18.922 V/FA-SVC  (31716):       timestamp_millis: 1664543958198
09-30 18:49:18.922 V/FA-SVC  (31716):       previous_timestamp_millis: 1664543721088
09-30 18:49:18.922 V/FA-SVC  (31716):       param {
09-30 18:49:18.922 V/FA-SVC  (31716):         name: ga_event_origin(_o)
09-30 18:49:18.922 V/FA-SVC  (31716):         string_value: app
09-30 18:49:18.922 V/FA-SVC  (31716):       }
09-30 18:49:18.922 V/FA-SVC  (31716):       param {
09-30 18:49:18.922 V/FA-SVC  (31716):         name: _r
09-30 18:49:18.922 V/FA-SVC  (31716):         int_value: 1
09-30 18:49:18.922 V/FA-SVC  (31716):       }
09-30 18:49:18.922 V/FA-SVC  (31716):       param {
09-30 18:49:18.922 V/FA-SVC  (31716):         name: ga_screen_class(_sc)
09-30 18:49:18.922 V/FA-SVC  (31716):         string_value: MainActivity
09-30 18:49:18.922 V/FA-SVC  (31716):       }
09-30 18:49:18.922 V/FA-SVC  (31716):       param {
09-30 18:49:18.922 V/FA-SVC  (31716):         name: ga_screen_id(_si)
09-30 18:49:18.922 V/FA-SVC  (31716):         int_value: 6352328087458408729
09-30 18:49:18.922 V/FA-SVC  (31716):       }
09-30 18:49:18.922 V/FA-SVC  (31716):       param {
09-30 18:49:18.922 V/FA-SVC  (31716):         name: _dbg
09-30 18:49:18.922 V/FA-SVC  (31716):         int_value: 1
09-30 18:49:18.922 V/FA-SVC  (31716):       }
09-30 18:49:18.922 V/FA-SVC  (31716):       param {
09-30 18:49:18.922 V/FA-SVC  (31716):         name: item
09-30 18:49:18.922 V/FA-SVC  (31716):         string_value: profileScreen1
09-30 18:49:18.922 V/FA-SVC  (31716):       }
09-30 18:49:18.922 V/FA-SVC  (31716):     }
09-30 18:49:18.922 V/FA-SVC  (31716):   }
09-30 18:49:18.922 V/FA-SVC  (31716): }
09-30 18:49:18.923 V/FA-SVC  (31716): Not stopping services. fetch, network, upload: false, true, false
09-30 18:49:18.924 V/FA-SVC  (31716): Uploading data. size: 542
09-30 18:49:19.115 V/FA-SVC  (31716): Upload scheduled in approximately ms: 3599998
09-30 18:49:19.115 V/FA-SVC  (31716): Unscheduling upload
09-30 18:49:19.121 V/FA-SVC  (31716): Scheduling upload, millis: 3599998
09-30 18:49:19.124 V/FA-SVC  (31716): Successful upload. Got network response. code, size: 204, 0
09-30 18:49:19.138 V/FA-SVC  (31716): Nothing to upload or uploading impossible
09-30 18:49:19.138 V/FA-SVC  (31716): Unscheduling upload
09-30 18:49:19.158 V/FA-SVC  (31716): Stopping uploading service(s)
09-30 18:49:23.309 V/FA      (13263): Inactivity, disconnecting from the service

Profile Screen 2 logs (on press of logout button in Profile screen 2)

09-30 18:53:37.996 D/FA      (13263): Resetting session stitching token to not null
09-30 18:53:38.035 V/FA      (13263): Connecting to remote service
09-30 18:53:38.090 V/FA      (13263): Connection attempt already in progress
09-30 18:53:38.090 D/FA      (13263): Connected to remote service
09-30 18:53:38.090 V/FA      (13263): Processing queued up service tasks: 2
09-30 18:53:38.127 D/FA-SVC  (31716): Removing user property: user_id(_id)
09-30 18:53:38.159 D/FA-SVC  (31716): User property removed: user_id(_id)
09-30 18:53:38.159 D/FA-SVC  (31716): Removing user property: username
09-30 18:53:38.160 D/FA-SVC  (31716): User property removed: username
09-30 18:53:43.151 V/FA      (13263): Inactivity, disconnecting from the service

Main issues observed in debugView.

1) UserId resets only when the app is put to background or cleared from memory and reopened. 2) setUserId(null) not working.


Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "name": "analytics", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@react-native-firebase/analytics": "^15.6.0", "@react-native-firebase/app": "^15.6.0", "@react-navigation/native": "^6.0.13", "@react-navigation/native-stack": "^6.9.0", "react": "18.1.0", "react-native": "0.70.1", "react-native-paper": "^5.0.0-rc.5", "react-native-restart": "^0.0.24", "react-native-safe-area-context": "^4.3.4", "react-native-screens": "^3.17.0", "react-native-vector-icons": "^9.2.0" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", "babel-jest": "^26.6.3", "eslint": "^7.32.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.72.1", "react-test-renderer": "18.1.0", "standard": "^17.0.0" }, "jest": { "preset": "react-native" } } ``` #### `App.js` ``` import { NavigationContainer } from '@react-navigation/native' import { createNativeStackNavigator } from '@react-navigation/native-stack' import React from 'react' import { StatusBar } from 'react-native' import Login from './screens/Login' import Profile1 from './screens/Profile1' import Profile2 from './screens/Profile2' const Stack = createNativeStackNavigator() const App = () => { return ( ) } export default App ``` #### `Login.js` ``` import React, { useState } from 'react' import { StyleSheet, View } from 'react-native' import { Button, Text, TextInput } from 'react-native-paper' import analytics from '@react-native-firebase/analytics' const Login = ({ navigation }) => { const [state, setState] = useState({ username: '', password: '' }) const { username, password } = state const handleStateChange = (key, value) => { setState({ ...state, [key]: value }) } const handleLogin = async () => { try { await analytics().logEvent('loginEvent', { item: username }) await analytics().setUserId(username) navigation.navigate('Home') } catch (err) { alert(err) } } return ( LOGIN SCREEN handleStateChange('username', input)} /> handleStateChange('password', input)} /> ) } const styles = StyleSheet.create({ root: { flex: 1, justifyContent: 'center', backgroundColor: 'white' }, heading: { textAlign: 'center', margin: 30 }, textInput: { margin: 20 }, button: { margin: 20 } }) export default Login ``` #### `Profile1.js` ``` import React from 'react' import { StyleSheet, View } from 'react-native' import { Button, TextInput } from 'react-native-paper' import analytics from '@react-native-firebase/analytics' const Profile1 = ({ navigation }) => { const handleAnalytics = async () => { try { await analytics().logEvent('screen1', { item: 'profileScreen1' }) navigation.navigate('Profile') } catch (err) { alert(err) } } return ( ) } const styles = StyleSheet.create({ root: { flex: 1, backgroundColor: 'white' }, heading: { textAlign: 'center', margin: 30 }, textInput: { margin: 20 }, button: { margin: 20 } }) export default Profile1 ``` #### `Profile2.js` ``` import React from 'react' import { StyleSheet, View } from 'react-native' import { Button, TextInput } from 'react-native-paper' import analytics from '@react-native-firebase/analytics' const Profile2 = ({ navigation }) => { const handleAnalytics = async () => { try { await analytics().logEvent('screen2', { item: 'ProfileScreen2' }) } catch (err) { alert(err) } } const handleLogout = async () => { try { await analytics().setUserId(null) navigation.navigate('Login') } catch (err) { alert(err) } } return ( ) } const styles = StyleSheet.create({ root: { flex: 1, backgroundColor: 'white' }, heading: { textAlign: 'center', margin: 30 }, textInput: { margin: 20 }, button: { margin: 20 } }) export default Profile2 ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [ ] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "31.0.0" minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 31 if (System.properties['os.arch'] == "aarch64") { // For M1 Users we need to use the NDK 24 which added support for aarch64 ndkVersion = "24.0.8215888" } else { // Otherwise we default to the side-by-side NDK version from AGP. ndkVersion = "21.4.7075529" } } repositories { google() mavenCentral() } dependencies { classpath 'com.google.gms:google-services:4.3.14' classpath("com.android.tools.build:gradle:7.2.1") classpath("com.facebook.react:react-native-gradle-plugin") classpath("de.undercouch:gradle-download-task:5.0.1") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } mavenCentral { // We don't want to fetch react-native from Maven Central as there are // older versions over there. content { excludeGroup "com.facebook.react" } } google() maven { url 'https://www.jitpack.io' } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' import com.android.build.OutputFile import org.apache.tools.ant.taskdefs.condition.Os /** * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle * bundleAssetName: "index.android.bundle", * * // the entry file for bundle generation. If none specified and * // "index.android.js" exists, it will be used. Otherwise "index.js" is * // default. Can be overridden with ENTRY_FILE environment variable. * entryFile: "index.android.js", * * // https://reactnative.dev/docs/performance#enable-the-ram-format * bundleCommand: "ram-bundle", * * // whether to bundle JS and assets in debug mode * bundleInDebug: false, * * // whether to bundle JS and assets in release mode * bundleInRelease: true, * * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats * // 'bundleIn${productFlavor}${buildType}' * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", * * // where to put the JS bundle asset in debug mode * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", * * // where to put the JS bundle asset in release mode * jsBundleDirRelease: "$buildDir/intermediates/assets/release", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in debug mode * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in release mode * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", * * // by default the gradle tasks are skipped if none of the JS files or assets change; this means * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to * // date; if you have any other folders that you want to ignore for performance reasons (gradle * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] */ project.ext.react = [ enableHermes: true, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and that value will be read here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", false); /** * Architectures to build native code for. */ def reactNativeArchitectures() { def value = project.getProperties().get("reactNativeArchitectures") return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] } android { ndkVersion rootProject.ext.ndkVersion compileSdkVersion rootProject.ext.compileSdkVersion defaultConfig { applicationId "com.analytics" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() if (isNewArchitectureEnabled()) { // We configure the CMake build only if you decide to opt-in for the New Architecture. externalNativeBuild { cmake { arguments "-DPROJECT_BUILD_DIR=$buildDir", "-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid", "-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build", "-DNODE_MODULES_DIR=$rootDir/../node_modules", "-DANDROID_STL=c++_shared" } } if (!enableSeparateBuildPerCPUArchitecture) { ndk { abiFilters (*reactNativeArchitectures()) } } } } if (isNewArchitectureEnabled()) { // We configure the NDK build only if you decide to opt-in for the New Architecture. externalNativeBuild { cmake { path "$projectDir/src/main/jni/CMakeLists.txt" } } def reactAndroidProjectDir = project(':ReactAndroid').projectDir def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) { dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck") from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") into("$buildDir/react-ndk/exported") } def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) { dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck") from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib") into("$buildDir/react-ndk/exported") } afterEvaluate { // If you wish to add a custom TurboModule or component locally, // you should uncomment this line. // preBuild.dependsOn("generateCodegenArtifactsFromSchema") preDebugBuild.dependsOn(packageReactNdkDebugLibs) preReleaseBuild.dependsOn(packageReactNdkReleaseLibs) // Due to a bug inside AGP, we have to explicitly set a dependency // between configureCMakeDebug* tasks and the preBuild tasks. // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732 configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild) configureCMakeDebug.dependsOn(preDebugBuild) reactNativeArchitectures().each { architecture -> tasks.findByName("configureCMakeDebug[${architecture}]")?.configure { dependsOn("preDebugBuild") } tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure { dependsOn("preReleaseBuild") } } } } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include (*reactNativeArchitectures()) } } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.debug minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = defaultConfig.versionCode * 1000 + versionCodes.get(abi) } } } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } if (enableHermes) { //noinspection GradleDynamicVersion implementation("com.facebook.react:hermes-engine:+") { // From node_modules exclude group:'com.facebook.fbjni' } } else { implementation jscFlavor } } if (isNewArchitectureEnabled()) { // If new architecture is enabled, we let you build RN from source // Otherwise we fallback to a prebuilt .aar bundled in the NPM package. // This will be applied to all the imported transtitive dependency. configurations.all { resolutionStrategy.dependencySubstitution { substitute(module("com.facebook.react:react-native")) .using(project(":ReactAndroid")) .because("On New Architecture we're building React Native from source") substitute(module("com.facebook.react:hermes-engine")) .using(project(":ReactAndroid:hermes-engine")) .because("On New Architecture we're building Hermes from source") } } } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.implementation into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) def isNewArchitectureEnabled() { // To opt-in for the New Architecture, you can either: // - Set `newArchEnabled` to true inside the `gradle.properties` file // - Invoke gradle with `-newArchEnabled=true` // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" } ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'analytics' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' includeBuild('../node_modules/react-native-gradle-plugin') if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { include(":ReactAndroid") project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid') include(":ReactAndroid:hermes-engine") project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine') } ``` #### `MainApplication.java`: ```java package com.analytics; import android.app.Application; import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.config.ReactFeatureFlags; import com.facebook.soloader.SoLoader; import com.analytics.newarchitecture.MainApplicationReactNativeHost; import java.lang.reflect.InvocationTargetException; import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); return packages; } @Override protected String getJSMainModuleName() { return "index"; } }; private final ReactNativeHost mNewArchitectureNativeHost = new MainApplicationReactNativeHost(this); @Override public ReactNativeHost getReactNativeHost() { if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { return mNewArchitectureNativeHost; } else { return mReactNativeHost; } } @Override public void onCreate() { super.onCreate(); // If you opted-in for the New Architecture, we enable the TurboModule system ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } /** * Loads Flipper in React Native templates. Call this in the onCreate method with something like * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); * * @param context * @param reactInstanceManager */ private static void initializeFlipper( Context context, ReactInstanceManager reactInstanceManager) { if (BuildConfig.DEBUG) { try { /* We use reflection here to pick up the class that initializes Flipper, since Flipper library is not available in release mode */ Class aClass = Class.forName("com.analytics.ReactNativeFlipper"); aClass .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) .invoke(null, context, reactInstanceManager); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: Windows 10 10.0.19044 CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz Memory: 691.69 MB / 7.83 GB Binaries: Node: 16.13.1 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: Not Found IDEs: Android Studio: AI-212.5712.43.2112.8609683 Visual Studio: Not Found Languages: Java: 11.0.16 npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.1 => 0.70.1 react-native-windows: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [x] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `v6` - **`Firebase` module(s) you're using that has the issue:** - `Analytics` - **Are you using `TypeScript`?** - `N`


mikehardy commented 2 years ago

I think this is underlying issue: https://github.com/firebase/firebase-android-sdk/issues/3602 - I asked for updates.

Salakar commented 1 year ago

Hello πŸ‘‹, to help manage issues we automatically close stale issues.\n\nThis issue has been automatically marked as stale because it has not had activity for quite some time.\nHas this issue been fixed, or does it still require attention?\n\n> This issue will be closed in 15 days if no further activity occurs.\n\nThank you for your contributions.

mikehardy commented 1 year ago

I asked for status over there again

sandeep-aample commented 1 year ago

@mikehardy Did they reply?

mikehardy commented 1 year ago

@sandeep-aample the link to the issue is included above ☝️

github-actions[bot] commented 1 year ago

Hello πŸ‘‹, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.