Skip to content

Conversation

@shubham1g5
Copy link
Contributor

@shubham1g5 shubham1g5 commented Feb 7, 2025

Summary

Makes following changes to Analytics -

  • Send Start and Logut button clicks as part of home_button_click event
  • Adds form xmlns to form related analytics events (same ashttps://github.com/Small modifications to Form analytics  #2951 but for master)
  • Adds following new events
    1. form_finish_attempt: Logs a form save attempt with the save result and method (user_triggered save vs system_triggered) event params
    2. menu_screen_item_click: Whenever a menu/form is selected from the menu screen with menu id as item_id event param
    3. form_upload_attempt : Whenever we do a form upload process to the server with result and value as 2 event params representing the result of the form upload process and # of forms uploaded as part of the form upload attempt.

Feature Flag

Product Description

PR Checklist

  • If I think the PR is high risk, "High Risk" label is set
  • I have confidence that this PR will not introduce a regression for the reasons below
  • Do we need to enhance manual QA test coverage ? If yes, "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, "Release Note" label is set and a "Release Note" is specified in PR description.

Automated test coverage

N/A

Safety story

Analytics only, instrumentation tests should catch any errors given all events are in instrumented workflows

@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2025

📝 Walkthrough

Walkthrough

This pull request enhances the application’s analytics reporting by introducing additional parameters and new methods across several classes. In FormEntryActivity and FormEntryActivityUIController, the analytics methods now receive the current form’s XML namespace via a new method (getCurrentFormXmlnsFailSafe), ensuring that user interactions like form quitting and navigation include this context. Updates also extend FirebaseAnalyticsUtil with methods for reporting form entry, finish, and upload attempts. Additionally, changes in HomeButtons and MenuList introduce analytics calls for button and menu item clicks, respectively. Other updates include the addition of new constants in AnalyticsParamValue, CCAnalyticsEvent, and CCAnalyticsParam, and modifications in FormSubmissionHelper and FormUploadResult to report the form upload outcome more comprehensively by capturing both the worst result and the number of successful submissions.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant FE as FormEntryActivity
    participant FEC as FormEntryActivityUIController
    participant FA as FirebaseAnalyticsUtil
    U->>FE: Initiate quit/navigation action (e.g., back press)
    FE->>FE: Call getCurrentFormXmlnsFailSafe()
    FE->>FA: reportFormQuitAttempt/reportFormNav(XMLNS)
    Note over FA: Analytics event logged

    U->>FEC: Button click (Start/Logout)
    FEC->>FA: reportButtonClick (using corresponding AnalyticsParamValue)
    Note over FA: Button click event recorded
Loading
sequenceDiagram
    participant FS as FormSubmissionHelper
    participant FR as FormUploadResult
    participant FA as FirebaseAnalyticsUtil
    FS->>FR: Process submission results via getWorstResultWithSuccessCount
    FR-->>FS: Return worst result and success count
    FS->>FA: reportFormUploadAttempt(worstResult, successCount)
    Note over FA: Form upload event logged
Loading

Possibly related PRs

Suggested labels

Release Note, QA Note, product/invisible

Suggested reviewers

  • OrangeAndGreen
  • pm-dimagi
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 0

🧹 Nitpick comments (3)
app/src/org/commcare/google/services/analytics/CCAnalyticsEvent.java (1)

31-31: Consider grouping with other navigation-related constants.

The constant correctly implements the menu click tracking requirement and follows the naming convention. However, consider moving it closer to other navigation-related constants like ENTITY_DETAIL_NAVIGATION for better organization.

app/src/org/commcare/google/services/analytics/FirebaseAnalyticsUtil.java (2)

181-187: Consider adjusting rate limiting percentage.

The method correctly implements form navigation tracking with rate limiting, but 10% sampling might be too low for critical navigation patterns.

Consider increasing the sampling rate:

-        if (rateLimitReporting(.1)) {
+        if (rateLimitReporting(.25)) {

365-369: Improve parameter naming for form upload analytics.

The parameter names 'first' and 'second' are not descriptive enough.

Consider using more descriptive parameter names:

-    public static void reportFormUploadAttempt(FormUploadResult first, Integer second) {
+    public static void reportFormUploadAttempt(FormUploadResult uploadResult, Integer successCount) {
         reportEvent(CCAnalyticsEvent.FORM_UPLOAD_ATTEMPT,
                 new String[]{CCAnalyticsParam.RESULT, FirebaseAnalytics.Param.VALUE},
-                new String[]{String.valueOf(first), String.valueOf(second)});
+                new String[]{String.valueOf(uploadResult), String.valueOf(successCount)});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a031f9 and 5e843f1.

📒 Files selected for processing (10)
  • app/src/org/commcare/activities/FormEntryActivity.java (7 hunks)
  • app/src/org/commcare/activities/FormEntryActivityUIController.java (3 hunks)
  • app/src/org/commcare/activities/HomeButtons.java (2 hunks)
  • app/src/org/commcare/activities/components/MenuList.java (2 hunks)
  • app/src/org/commcare/google/services/analytics/AnalyticsParamValue.java (2 hunks)
  • app/src/org/commcare/google/services/analytics/CCAnalyticsEvent.java (2 hunks)
  • app/src/org/commcare/google/services/analytics/CCAnalyticsParam.java (1 hunks)
  • app/src/org/commcare/google/services/analytics/FirebaseAnalyticsUtil.java (3 hunks)
  • app/src/org/commcare/sync/FormSubmissionHelper.java (2 hunks)
  • app/src/org/commcare/utils/FormUploadResult.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Lint Code Base
🔇 Additional comments (22)
app/src/org/commcare/google/services/analytics/CCAnalyticsParam.java (1)

21-24: LGTM! Constants align well with PR objectives.

The new constants RESULT and FORM_ID are well-designed for the new analytics events:

  • RESULT will support tracking outcomes for form save and upload attempts
  • FORM_ID enables form-specific analytics tracking

The implementation maintains consistent naming and access level patterns with existing constants.

app/src/org/commcare/google/services/analytics/CCAnalyticsEvent.java (2)

16-16: LGTM! New form entry tracking constant.

The constant follows the established naming convention and aligns with the PR objective to enhance form analytics tracking.


18-19: LGTM! Form completion tracking constants.

These constants implement the PR requirements for tracking form save and upload attempts. They follow the established naming pattern and are appropriately placed with other form-related constants.

app/src/org/commcare/utils/FormUploadResult.java (2)

118-120: LGTM! Clean refactor to use the new method.

The modification maintains the existing behavior while leveraging the new functionality.


122-134: LGTM! Well-implemented method for enhanced analytics.

The method effectively tracks both the worst result and success count, maintaining the existing ordering logic while adding new capabilities.

app/src/org/commcare/activities/components/MenuList.java (1)

94-94: LGTM! Analytics tracking added at the right location.

The analytics call is correctly placed after validation but before navigation, following the established pattern.

app/src/org/commcare/google/services/analytics/AnalyticsParamValue.java (2)

89-90: LGTM! New button constants follow the established pattern.

Constants are logically grouped with other button values and follow the naming convention.


144-148: LGTM! Form submission event constants are well organized.

New section is properly separated and constants follow the established naming pattern.

app/src/org/commcare/activities/HomeButtons.java (2)

148-152: LGTM! Analytics tracking added for start button.

The implementation follows the established pattern of tracking before action.


191-195: LGTM! Analytics tracking added for logout button.

The implementation is consistent with other button handlers.

app/src/org/commcare/google/services/analytics/FirebaseAnalyticsUtil.java (3)

175-179: LGTM: Form entry analytics implementation.

The implementation correctly tracks form entry attempts with the form ID parameter.


195-201: LGTM: Form finish attempt analytics implementation.

The implementation properly captures:

  • Form ID
  • Save result
  • Method (user vs system triggered)

359-363: LGTM: Menu item click analytics implementation.

The implementation correctly tracks menu item clicks with the command ID.

app/src/org/commcare/sync/FormSubmissionHelper.java (1)

163-168: LGTM: Form upload analytics integration.

The implementation correctly:

  • Gets worst result and success count
  • Reports analytics with appropriate parameters
  • Maintains existing error handling flow
app/src/org/commcare/activities/FormEntryActivity.java (5)

1684-1691: LGTM! Well-implemented fail-safe method.

The method has proper error handling and logging, making it robust for analytics usage.


1137-1137: LGTM! Appropriate analytics tracking.

The form entry event is now enriched with XML namespace data.


1432-1434: LGTM! Consistent analytics implementation.

Form navigation events are consistently tracked with XML namespace data for both forward and backward navigation.

Also applies to: 1442-1444


597-598: LGTM! Consistent quit tracking.

Form quit attempts are consistently tracked with XML namespace data for both back button and navigation button presses.

Also applies to: 1218-1219


1297-1297: LGTM! Appropriate finish tracking.

Form finish attempts are properly tracked with XML namespace data.

app/src/org/commcare/activities/FormEntryActivityUIController.java (3)

112-115: LGTM! Consistent next button tracking.

Form navigation via next button is properly tracked with XML namespace data.


122-125: LGTM! Consistent previous button tracking.

Form navigation and quit attempts via previous button are properly tracked with XML namespace data.

Also applies to: 128-129


136-139: LGTM! Consistent finish button tracking.

Form navigation via finish button is properly tracked with XML namespace data.

@OrangeAndGreen OrangeAndGreen merged commit ca71661 into master Feb 7, 2025
5 of 7 checks passed
@OrangeAndGreen OrangeAndGreen deleted the analytics_event branch February 7, 2025 20:04
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.

3 participants