-
-
Notifications
You must be signed in to change notification settings - Fork 45
Adds New Analytics event #2952
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
Adds New Analytics event #2952
Conversation
… with form upload
📝 WalkthroughWalkthroughThis 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
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
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 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_NAVIGATIONfor 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
📒 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
RESULTandFORM_IDare well-designed for the new analytics events:
RESULTwill support tracking outcomes for form save and upload attemptsFORM_IDenables form-specific analytics trackingThe 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.
Summary
Makes following changes to Analytics -
home_button_clickeventmaster)form_finish_attempt: Logs a form save attempt with the saveresultandmethod(user_triggered save vs system_triggered) event paramsmenu_screen_item_click: Whenever a menu/form is selected from the menu screen with menu id asitem_idevent paramform_upload_attempt: Whenever we do a form upload process to the server withresultandvalueas 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
Automated test coverage
N/A
Safety story
Analytics only, instrumentation tests should catch any errors given all events are in instrumented workflows