Skip to content

feat: add study user id to app launch analytics - #257

Merged
dz4va merged 1 commit into
developfrom
AJ-657
May 27, 2026
Merged

feat: add study user id to app launch analytics#257
dz4va merged 1 commit into
developfrom
AJ-657

Conversation

@dz4va

@dz4va dz4va commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Changes

  • Persist confirmed study_user_id after successful study enrollment
  • Store the study ID alongside the existing pseudoId using a dedicated preference key
  • Append study_user_id only to app_launch Firebase event parameters when available
  • Leave unenrolled app_launch events unchanged by omitting study_user_id
  • Add unit coverage for app_launch events with and without a persisted study_user_id
  • Restore the existing language_selected analytics test invocation so the test class passes

How to test

  • Using the unit tests that exist in the project and by sending the app_launch events and then checking them through BigQuery if being part of the study by accepting the study modal

Ref: AJ-657

Summary by CodeRabbit

  • Version Update

    • Released version 2.34.3
  • Improvements

    • Enhanced analytics to include study user identification for improved data tracking
  • Tests

    • Updated analytics tests to verify study user tracking behavior

Review Change Stack

- Persist confirmed study_user_id after successful study enrollment
- Store the study ID alongside the existing pseudoId using a dedicated preference key
- Append study_user_id only to app_launch Firebase event parameters when available
- Leave unenrolled app_launch events unchanged by omitting study_user_id
- Add unit coverage for app_launch events with and without a persisted study_user_id
- Restore the existing language_selected analytics test invocation so the test class passes
@dz4va
dz4va requested a review from amitsinghsutara May 26, 2026 20:52
@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f947a597-66d2-44b0-8cc2-fd37dbd6b497

📥 Commits

Reviewing files that changed from the base of the PR and between 79d5323 and e6ceccc.

📒 Files selected for processing (4)
  • app/build.gradle
  • app/src/main/java/org/curiouslearning/container/MainActivity.java
  • app/src/main/java/org/curiouslearning/container/firebase/AnalyticsUtils.java
  • app/src/test/java/org/curiouslearning/container/AnalyticsUtilsCustomEventsTest.java

📝 Walkthrough

Walkthrough

This PR adds persistent study user ID caching to analytics events. AnalyticsUtils introduces constants and a helper to inject cached study user IDs into app_launch events. MainActivity persists confirmed user IDs via the new constant. Tests validate caching behavior with and without cached IDs. App version is bumped to 2.34.3.

Changes

Study User ID Caching and Analytics Integration

Layer / File(s) Summary
Analytics study_user_id caching infrastructure
app/src/main/java/org/curiouslearning/container/firebase/AnalyticsUtils.java
AnalyticsUtils adds APP_CACHED_PREFS and STUDY_USER_ID constants, introduces addStudyUserIdForAppLaunch() private helper to read cached study user IDs and conditionally inject them into app_launch event bundles, and integrates the helper into the logEvent flow.
Study user ID persistence in ID confirmation
app/src/main/java/org/curiouslearning/container/MainActivity.java
MainActivity's ID-confirmation handler now persists the confirmed user ID to shared preferences under AnalyticsUtils.STUDY_USER_ID in addition to updating the existing pseudoId preference.
Test infrastructure and study_user_id caching validation
app/src/test/java/org/curiouslearning/container/AnalyticsUtilsCustomEventsTest.java
Test setup acquires and clears the cached preferences store to avoid state pollution. Tests seed and validate study_user_id injection for app_launch events, and a new test case verifies that study_user_id is omitted when not cached. The logLanguageSelectEvent invocation signature is updated to include an additional parameter.

App Version Bump

Layer / File(s) Summary
App version metadata update
app/build.gradle
Bumps defaultConfig.versionCode from 70 to 73 and versionName from 2.34.2 to 2.34.3.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Rajesh1041
  • miguelccodev

Poem

🐰 A study user ID now persists,
Through cached preferences it exists—
When app_launch fires, it's attached with care,
Analytics know who's using our app out there! 📊✨

🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Tests & Lint & Coverage ❓ Inconclusive Tests are properly added and code changes are valid, but project lacks explicit linting configuration and no evidence of 70% coverage verification in automated tooling or CI/CD pipeline. Clarify if project has automated linting and coverage checks. Android Gradle has lint and jacocoTestReport tasks but CI doesn't appear to execute them.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add study user id to app launch analytics' accurately and concisely describes the main change: persisting and appending study_user_id to app_launch Firebase events.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch AJ-657

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.

@dz4va
dz4va merged commit 49408bd into develop May 27, 2026
1 check passed
@amitsinghsutara
amitsinghsutara deleted the AJ-657 branch June 18, 2026 04:19
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.

2 participants