Skip to content

feat: joined study additions - #259

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

feat: joined study additions#259
dz4va merged 1 commit into
developfrom
AJ-656-joined_study

Conversation

@dz4va

@dz4va dz4va commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Changes

  • Added AnalyticsUtils.logJoinedStudyEvent(...).
  • Replaced the old cr_user_id_confirmed analytics call in MainActivity with joined_study.
  • Included all required event parameters:
    cr_language, app_info.version, cr_user_id, source, campaign_id, study_user_id, study_consent.
  • Read source and campaign_id from the same InstallReferrerPrefs storage previously used for analytics user
    properties.
  • Sanitized cr_user_id and study_user_id so only numeric characters are submitted.
  • Used the confirmed study ID as both cr_user_id and study_user_id.
  • Used the existing study_consent query parameter as study_consent.
  • Used the app version from MainActivity, falling back to AppUtils.getAppVersionName(...) if needed.
  • Updated docs/joined_study_plan.md to reflect that cr_user_id_confirmed is replaced on this enrollment path.
  • Added unit test coverage in AnalyticsUtilsCustomEventsTest for:
    successful joined_study payload,
    numeric-only ID sanitization,
    inclusion of cached attribution values.

How to test

  • Through the local build or the internal testing version

Ref: AJ-656

Summary by CodeRabbit

Release Notes

  • Chores
    • Improved study enrollment analytics tracking to reliably capture app version, language, and consent data.

Review Change Stack

@dz4va
dz4va merged commit 4d49905 into develop May 27, 2026
1 check was pending
@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fa693dbd-19bb-474b-85ea-7526b5027b15

📥 Commits

Reviewing files that changed from the base of the PR and between 7fe4900 and d362665.

📒 Files selected for processing (3)
  • 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 a new Firebase Analytics event joined_study that logs when users confirm their identity during the study enrollment flow. The implementation includes user ID sanitization, attribution field retrieval, and comprehensive test coverage for both standard and malformed identifier inputs.

Changes

Joined Study Event Analytics

Layer / File(s) Summary
Analytics event implementation with sanitization
app/src/main/java/org/curiouslearning/container/firebase/AnalyticsUtils.java, app/src/test/java/org/curiouslearning/container/AnalyticsUtilsCustomEventsTest.java
logJoinedStudyEvent method builds an analytics Bundle with language, app version, sanitized user IDs, study consent, and attribution fields (source, campaign_id), then logs the joined_study event. Helper sanitizeStudyUserId removes non-digit characters from user identifiers. Two tests verify event bundle contents and sanitization of malformed IDs.
MainActivity ID confirmation flow update
app/src/main/java/org/curiouslearning/container/MainActivity.java
When users confirm their pseudoId in showConfirmIdDialog, the code now computes joinedStudyAppVersion (with fallback to AppUtils.getAppVersionName) and logs the new joined-study event instead of the previous cr_user_id_confirmed event.

Sequence Diagram

sequenceDiagram
  participant MainActivity
  participant AnalyticsUtils
  participant FirebaseAnalytics
  MainActivity->>AnalyticsUtils: logJoinedStudyEvent(crUserId, language, appVersion, studyUserId, studyConsent)
  AnalyticsUtils->>AnalyticsUtils: sanitizeStudyUserId(studyUserId)
  AnalyticsUtils->>FirebaseAnalytics: setUserProperty(source, campaign_id)
  AnalyticsUtils->>FirebaseAnalytics: logEvent(joined_study, Bundle)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • curiouslearning/CRcontainer#254: Both PRs modify the ID confirmation analytics logging in MainActivity, where this PR switches from cr_user_id_confirmed to the new logJoinedStudyEvent/joined_study event.

Suggested reviewers

  • amitsinghsutara

Poem

🐰 A curious event, newly born so bright,
Tracking when users join the study's light,
With IDs sanitized and properties set,
Firebase logs what the data hath met,
Clean analytics bloom in the night!

✨ 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-656-joined_study

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.

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.

1 participant