firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

FirebaseAnalytics.setUserProperty() Not working.

Open nikesh4770 opened this issue 4 years ago • 5 comments

Step 1: Describe your environment

Android Studio version: 4.1.2

Build #AI-201.8743.12.41.7042882, built on December 20, 2020
Runtime version: 1.8.0_242-release-1644-b3-6915495 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.16
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 12
Registry: ide.new.welcome.screen.force=true, external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin

Firebase Component: Cloud Messaging

Component version: com.google.firebase:firebase-messaging:20.2.4

Step 2: Describe the problem

Steps to reproduce:

Problem: User properties are not getting updated. Notifications based on User properties are receiving for wrong users.

Please follow below steps:

1. Create a project with firebase cloud messaging.

2. Make sure that you are receiving notifications from firebase console after device registration.

3. Consider a login/logout feature for your app. (Or create a button with Login / Logout).

4. Now once you tap login set some user properties. (say "user_membership": "premium").

val firebaseInstance = FirebaseAnalytics.getInstance(getAppContext()) firebaseInstance.setUserProperty("user_membership", "premium")

Note: wait for few hours to replicate user properties as per guidelines.

5. Create a Notification Campaign with user property who have premium access as below.

Screenshot 2021-02-24 at 10 43 50 AM Screenshot 2021-02-24 at 10 45 22 AM

6. Send Notification and make sure you received notification.

7. Now tap on Logout.

8. Since we have logged out make user properties to empty value or null. (say "user_membership": "" or null).

val firebaseInstance = FirebaseAnalytics.getInstance(getAppContext()) firebaseInstance.setUserProperty("user_membership", "")

Note: wait for few hours to replicate user properties as per guidelines.

9. Do step 5 again.

10. Send notification but this time Notifications are still receiving even though we have updated user properties.

Expected: Notification should not receive after user properties have been updated.

nikesh4770 avatar Feb 24 '21 05:02 nikesh4770

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Feb 24 '21 05:02 google-oss-bot

Even on the firebase guidelines says that setting value to null removes properties but the description says the value persists throughout app lifecycle. Setting values to null also not working and able to receive notification.

https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics#public-void-setuserproperty-string-name,-string-value

nikesh4770 avatar Mar 02 '21 13:03 nikesh4770

Hi @nikesh4770, thanks for the report! Setting the value to null should remove the property like you described in step 5. I've added the analytics label to this issue to help diagnose what could be going on here.

ciarand avatar Mar 22 '21 16:03 ciarand

Thank you @ciarand. Funny thing is I'm able to see firebase log saying property removed but it is not. 03-02 15:29:39.636 D/FA-SVC ( 1614): Removing user property: ****.

I also tried to update value to "n/a" but still the same not updating. Once set it doesn't update.

nikesh4770 avatar Apr 08 '21 05:04 nikesh4770

same issue only resetAnalyticsData clear all props

olitynskyi-mtb avatar Dec 08 '25 17:12 olitynskyi-mtb