-
-
Notifications
You must be signed in to change notification settings - Fork 45
CI-423 Categorize Demo Users In Analytics (Phase 2) #3457
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
CI-423 Categorize Demo Users In Analytics (Phase 2) #3457
Conversation
Reported a new Firebase analytics event when a demo user phone number is used at the very start of the Personal ID setup flow.
📝 WalkthroughWalkthroughThe pull request adds analytics tracking for demo-number usage in the Personal ID flow. It introduces a new analytics event constant Estimated code review effort🎯 2 (Simple) | ⏱️ ~5–10 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
app/src/org/commcare/fragments/personalId/PersonalIdPhoneFragment.java(1 hunks)app/src/org/commcare/google/services/analytics/CCAnalyticsEvent.java(1 hunks)app/src/org/commcare/google/services/analytics/FirebaseAnalyticsUtil.java(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: shubham1g5
Repo: dimagi/commcare-android PR: 0
File: :0-0
Timestamp: 2025-05-08T11:08:18.530Z
Learning: PR #3048 "Phase 4 Connect PR" introduces a substantial feature called "Connect" to the CommCare Android app, which includes messaging, job management, delivery tracking, payment processing, authentication flows, and learning modules. It follows a modern architecture using Navigation Components with three navigation graphs, segregated business logic in Manager classes, and proper database persistence.
🧬 Code graph analysis (1)
app/src/org/commcare/fragments/personalId/PersonalIdPhoneFragment.java (1)
app/src/org/commcare/google/services/analytics/FirebaseAnalyticsUtil.java (1)
FirebaseAnalyticsUtil(43-610)
🔇 Additional comments (2)
app/src/org/commcare/google/services/analytics/CCAnalyticsEvent.java (1)
63-63: Event constant naming and placement look goodThe new
DEMO_NUMBER_USED_FOR_PERSONAL_ID_SESSIONconstant is consistent with existing naming and usage patterns; no changes needed.app/src/org/commcare/fragments/personalId/PersonalIdPhoneFragment.java (1)
431-438: Demo-user detection and event placement are appropriateUsing
Boolean.TRUE.equals(sessionData.getDemoUser())is null-safe and keeps the event scoped to genuine demo sessions; firing it right after setting the session data aligns with the intended funnel analytics behavior.
app/src/org/commcare/google/services/analytics/FirebaseAnalyticsUtil.java
Outdated
Show resolved
Hide resolved
app/src/org/commcare/google/services/analytics/FirebaseAnalyticsUtil.java
Outdated
Show resolved
Hide resolved
Refactored code so that we reuse an existing Firebase analytics event to report a demo user phone number used before account creation/recovery.
Fixed a comment typo.
…nto bug/CI-423-categorize-demo-users-in-analytics
Specified Personal ID in naming regarding demo users.
Refactored the code to follow a much simpler approach to flagging Personal ID demo users.
Reverted changes to FirebaseAnalyticsUtil
|
@OrangeAndGreen I updated my changes based on our discussion in Slack. I'm still waiting for the testing on my emulator to show up on BigQuery. I will verify that it's being flagged as a demo user properly before I merge these changes in. |
|
@OrangeAndGreen Just confirmed (on an emulator rather than my normal test device) that the latest changes work and we can see the property in BigQuery 👍 |
OrangeAndGreen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This looks good, just requesting a small change.
| personalIdSessionDataViewModel.getPersonalIdSessionData().setPhoneNumber(phone); | ||
|
|
||
| boolean isDemoUser = Boolean.TRUE.equals(sessionData.getDemoUser()); | ||
| FirebaseAnalytics analyticsInstance = CommCareApplication.instance().getAnalyticsInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create a helper in FirebaseAnalyticsUtil to wrap this, that class generally holds the references to CCAnalyticsParams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I also did a very small refactor in FirebaseAnalyticsUtil so that we always use the helper function when it makes sense. Let me know what you think!
Refactored logic to utilize a helper function in FirebaseAnalyticsUtil for flagging PersonalID demo users.
…nto bug/CI-423-categorize-demo-users-in-analytics
app/src/org/commcare/google/services/analytics/FirebaseAnalyticsUtil.java
Outdated
Show resolved
Hide resolved
app/src/org/commcare/fragments/personalId/PersonalIdPhoneFragment.java
Outdated
Show resolved
Hide resolved
app/src/org/commcare/google/services/analytics/FirebaseAnalyticsUtil.java
Show resolved
Hide resolved
Refactored wrapper function for flagging demo users to take nullable boolean.
Moved function call for the flagPersonalIDDemoUser() wrapper function.
…nto bug/CI-423-categorize-demo-users-in-analytics
CI-423
Technical Summary
After discussion with @OrangeAndGreen, we decided that more code changes are needed to reach the desired outcome for this ticket.
For context, in #3454 we added changes to report if a demo user is currently logged-in with Personal ID for all Firebase analytics events. The problem is that the user funnel tracks certain events leading up to account creation or recovery, and currently we are only flagging demo users once they've completed the configuration workflow.
So, in other words, we also need a way of knowing if someone has entered a demo phone number as early as possible in the Personal ID setup flow - ideally as soon as they enter the phone number on the phone page and we create a new
PersonalIdSessionData.Edit: So we decided that the easiest way to achieve this is to flag demo users (with our
FirebaseAnalyticsinstance) as soon as we get the flag from server and thePersonalIdSessionDatais first created. TheFirebaseAnalyticsinstance is used for all analytics events in our app, so the flag will be recorded with the next analytics event.Safety Assurance
Safety story
I verified that we are correctly identifying and reporting users that are using a demo phone number with these changes by actually using both a demo phone number and a real phone number.