react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

[🐛] setUserProperties does not display on Debug View only Android

Open tranhuuthinhit opened this issue 2 years ago • 11 comments

A pretty simple one, I have a call to use the setUserProperties method, but I don't see the user property show and update on Debug View, only on Android. But all events still display on Debug view.

The user property only updates when I kill and restart the app again.

Tux, the Linux mascot

JS Handle

async setUserProperties(isReset = false) {
    const { language } = store.getState().app
    const { account } = store.getState().account

    const params = {
      ui_language: language,
      membership: `${CONFIGS.TENANT_ID}-anonymous`,
      build_type: CONFIGS.BUILD_TYPE
    }

    if (account && account.profile !== undefined) {
      const subscriptionPlanInfo = account.profile.subscription_plan_info
      params.membership = `${CONFIGS.TENANT_ID}-free`

      if (subscriptionPlanInfo && subscriptionPlanInfo.slug) {
        params.membership = `${CONFIGS.TENANT_ID}-${subscriptionPlanInfo.slug}`
      }
    }

    try {
      console.log('setUserProperties', params)
      firebase.analytics().setUserProperties(params)

      if (isReset) {
        firebase.analytics().resetAnalyticsData()
        firebase.analytics().setUserProperties(params)
      }
    } catch (error) {
      console.log('setUserProperties error', error)
    }
  }

package.json:

  "@react-native-firebase/admob": "11.5.0",
  "@react-native-firebase/analytics": "11.5.0",
  "@react-native-firebase/app": "11.5.0",
  "@react-native-firebase/crashlytics": "11.5.0",
  "@react-native-firebase/perf": "11.5.0",
  "react": "17.0.1",
  "react-native": "0.64.2",

firebase.json for react-native-firebase v6:

{
  "react-native": {
    "analytics_auto_collection_enabled": false
  }
}

I'm using autolinking on Android.

tranhuuthinhit avatar Mar 21 '22 10:03 tranhuuthinhit

Hi there! These versions are incredibly old, we can't spend time working on them for troubleshooting:

 "@react-native-firebase/admob": "11.5.0",
  "@react-native-firebase/analytics": "11.5.0",
  "@react-native-firebase/app": "11.5.0",
  "@react-native-firebase/crashlytics": "11.5.0",
  "@react-native-firebase/perf": "11.5.0",

I understand you are likely on those versions because it was the last version with admob. Have no fear! We have a valid + living admob replacement package now, so you should switch to https://github.com/invertase/react-native-google-mobile-ads, then you can get everything here up to date, and if you can still reproduce, please let us know

mikehardy avatar Mar 21 '22 12:03 mikehardy

For the changes needed here while updating across major versions (they should be small?) you can read how we handle versioning and how to upgrade here https://invertase.io/blog/react-native-firebase-versioning

mikehardy avatar Mar 21 '22 12:03 mikehardy

For the changes needed here while updating across major versions (they should be small?) you can read how we handle versioning and how to upgrade here https://invertase.io/blog/react-native-firebase-versioning

Thank you!

tranhuuthinhit avatar Mar 21 '22 15:03 tranhuuthinhit

Hi @mikehardy, I'm trying to update the latest version and this issue is still reproduced. The event is still displayed, but I don't see the user property display on debug view (only on android)

I have added an event after set the user property, and then this event is displayed on debug view.

I using this command to enable debug view on Android

adb shell setprop debug.firebase.analytics.app <package>

https://i.ibb.co/hCSGNQD/Screen-Shot-2022-03-21-at-23-56-04.png

JS Code

async setUserProperties(isReset = false) {
    const { language } = store.getState().app
    const { account } = store.getState().account

    const params = {
      ui_language: language,
      membership: `${CONFIGS.TENANT_ID}-anonymous`,
      build_type: CONFIGS.BUILD_TYPE
    }

    if (account && account.profile !== undefined) {
      const subscriptionPlanInfo = account.profile.subscription_plan_info
      params.membership = `${CONFIGS.TENANT_ID}-free`

      if (subscriptionPlanInfo && subscriptionPlanInfo.slug) {
        params.membership = `${CONFIGS.TENANT_ID}-${subscriptionPlanInfo.slug}`
      }
    }

    try {
      console.log('setUserProperties', params)
      firebase.analytics().setUserProperties(params)

      if (isReset) {
        firebase.analytics().resetAnalyticsData()
        firebase.analytics().setUserProperties(params)
      }
    } catch (error) {
      console.log('setUserProperties error', error)
    }
  }

    "@react-native-firebase/analytics": "14.5.1",
    "@react-native-firebase/app": "14.5.1",
    "@react-native-firebase/crashlytics": "14.5.1",
    "@react-native-firebase/perf": "14.5.1",

tranhuuthinhit avatar Mar 21 '22 17:03 tranhuuthinhit

Okay - thanks for checking that out, shame it still shows up with current versions. Have you checked the issues list here for older + closed issues? This seems familiar to me and I think there may be a different in DebugView vs production view - do you see the user properties show up in the final data (after a delay, I know DebugView is more useful for realtime investigation?). If this is familiar and has been seen before, the symptom was that something happening in the back-end on google analytics wasn't showing things in DebugView but we were transmitting correctly and so unfortunately it was not actionable here

mikehardy avatar Mar 21 '22 18:03 mikehardy

Hi @mikehardy ,

I have the same thoughts as you about debug view, but when I try to integrate firebase with android native (JAVA) and then test update the user property and event, it works perfectly and updates on the User Property table at the right bottom.

And for React Native (iOS) with this lib, it still works perfectly.

https://i.ibb.co/KFvFmDx/Screen-Shot-2022-03-22-at-10-24-30.png

https://i.ibb.co/C2K2P5n/Screen-Shot-2022-03-22-at-10-26-50.png

But on React Native (Android), just the event had been updated realtime, and I need to kill the app and re-open the app again, and then the user property had been updated.

I think there may be a difference between iOS and Android implemented.

Can you help me re-produce it on Android? Thank you

tranhuuthinhit avatar Mar 22 '22 03:03 tranhuuthinhit

That is really great information - if I understand correctly you either used the firebase-android-sdk analytics quickstart or some other mechanism to bind directly at the java native level against the firebase-android-sdk analytics SDKs and tested the setUserPorperty, and it worked in debug view?

Assuming I understand that right, it sounds like we have a real problem here and this needs more triage on our side. Can you confirm I am understanding you?

mikehardy avatar Mar 22 '22 14:03 mikehardy

Hi @mikehardy,

That right!

The setUserPorperty method worked in debug view mode, and it works perfectly on iOS. This problem is only encountered on Android.

On Android, I need to kill the app and open the app again after setUserPorperty. And then I saw the user property updated on debug view. But actually, it needs to be displayed and updated without having to kill the app and open the app again.

Thank you!

tranhuuthinhit avatar Mar 22 '22 14:03 tranhuuthinhit

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 the community's attention?

This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 28 '22 01:04 stale[bot]

@mikehardy Any updates? I also use setUserProperties / setUserProperty and I am not able to see any of these properties in firebase console DebugView after I configure them in my app.

Update 1 I noticed that these properties are getting displayed in USER PROPERTIES ACTIVE NOW (DebugView panel) only after I remove the app from background and reopen it.

Update 2 I also noticed that these properties are getting displayed in USER PROPERTIES ACTIVE NOW (DebugView panel) after user_engagement event is fired or after I call logScreenView few times

Tested on Android device with the latest version of analytics and react native, basic setup, nothing special.

I also enabled debug mode running adb shell setprop debug.firebase.analytics.app my.app.package

mydesweb avatar May 08 '22 12:05 mydesweb

There are no secret updates, what is in this thread is what exists

mikehardy avatar May 08 '22 22:05 mikehardy

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.

github-actions[bot] avatar Dec 05 '22 19:12 github-actions[bot]

Hi guys,

I'm in a similar spot. I am setting some user properties in my application code with the hope of using them in remote config. However, I cannot find the properties anywhere on the analytics dashboard, not even in the debug view. It's been over an hour now, does it take longer than that to reflect?

sleekLancelot avatar Mar 26 '24 02:03 sleekLancelot