Skip to content

Conversation

@conroy-ricketts
Copy link
Contributor

@conroy-ricketts conroy-ricketts commented Dec 9, 2025

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 FirebaseAnalytics instance) as soon as we get the flag from server and the PersonalIdSessionData is first created. The FirebaseAnalytics instance 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.

Reported a new Firebase analytics event when a demo user phone number is used at the very start of the Personal ID setup flow.
@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

📝 Walkthrough

Walkthrough

The pull request adds analytics tracking for demo-number usage in the Personal ID flow. It introduces a new analytics event constant DEMO_NUMBER_USED_FOR_PERSONAL_ID_SESSION in the CCAnalyticsEvent class, creates a new reporting method reportDemoNumberUsedForPersonalIDSession() in FirebaseAnalyticsUtil that sets a user property and logs the event, and integrates this analytics call into PersonalIdPhoneFragment to fire when a PersonalId session is successfully returned with the demoUser flag set to true.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5–10 minutes

  • Straightforward addition of a new constant, method, and single call with no complex logic
  • Limited scope: three files with consistent, self-contained changes

Possibly related PRs

Suggested labels

skip-integration-tests, QA Note

Suggested reviewers

  • OrangeAndGreen
  • shubham1g5
  • Jignesh-dimagi

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ⚠️ Warning The PR description provides technical context, implementation rationale, and safety verification, but lacks structured sections matching the repository template. Add Product Description, Feature Flag, Automated test coverage, QA Plan sections, and labels checklist from the template to ensure complete documentation.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding analytics categorization for demo users (Phase 2), which aligns with the PR objective to report demo user identification earlier in the Personal ID setup flow.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/CI-423-categorize-demo-users-in-analytics

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7f663d2 and 768e219.

📒 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 good

The new DEMO_NUMBER_USED_FOR_PERSONAL_ID_SESSION constant 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 appropriate

Using 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.

Refactored code so that we reuse an existing Firebase analytics event to report a demo user phone number used before account creation/recovery.
…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
@conroy-ricketts
Copy link
Contributor Author

@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.

@conroy-ricketts
Copy link
Contributor Author

@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 👍

Copy link
Contributor

@OrangeAndGreen OrangeAndGreen left a 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();
Copy link
Contributor

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

Copy link
Contributor Author

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
OrangeAndGreen
OrangeAndGreen previously approved these changes Dec 16, 2025
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
@conroy-ricketts conroy-ricketts merged commit 2be438e into master Dec 17, 2025
7 checks passed
@conroy-ricketts conroy-ricketts deleted the bug/CI-423-categorize-demo-users-in-analytics branch December 17, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants