-
Notifications
You must be signed in to change notification settings - Fork 728
Fix event payload with empty key #2720
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
Conversation
WalkthroughThe changes primarily focus on enhancing event tracking and refining error handling across several Vue components related to member suggestions and filters. Key modifications include renaming event keys for member merging, adding default values for event keys in filter components, and refining the logic in search functions. New entries for event keys have also been introduced in the Changes
Possibly related PRs
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
🧹 Outside diff range and nitpick comments (4)
frontend/src/shared/modules/filters/components/FilterSearch.vue (1)
66-66: LGTM! Consider adding a comment for clarity.The change ensures that search events are always tracked, even when the route doesn't match specific cases, fixing the empty key issue. This is a good improvement to the event tracking system.
Consider adding a comment to explain the default case:
} else { + // Default to generic search event when no specific route matches key = FeatureEventKey.SEARCH; }frontend/src/modules/member/components/suggestions/filters/merge-suggestions-search.vue (1)
43-44: Consider using Vue's watch with debounceWhile the current implementation works, consider using Vue's built-in watch with debounce for better maintainability:
-const search = (val: string) => { - setTimeout(() => { - if (proxy.value === val) { - let key: FeatureEventKey | null = null; +const search = (val: string) => { + let key: FeatureEventKey | null = null; + const { name: routeName } = router.currentRoute.value; + + if (routeName === 'memberMergeSuggestions') { + key = FeatureEventKey.SEARCH_MEMBERS_MERGE_SUGGESTIONS; + } else if (routeName === 'organizationMergeSuggestions') { + key = FeatureEventKey.SEARCH_ORGANIZATIONS_MERGE_SUGGESTIONS; + } else { + key = FeatureEventKey.SEARCH; + } + + if (key) { + trackEvent({ + key, + type: EventType.FEATURE, + }); + } + + emit('update:modelValue', val); +}; + +watch( + () => proxy.value, + debounce((val: string) => { + search(val); + }, 300) +);frontend/src/modules/member/components/suggestions/filters/merge-suggestions-confidence-filter.vue (2)
96-97: Consider extracting confidence levels to constantsThe confidence levels and their ranges are hardcoded in the template. Consider extracting them to constants for better maintainability:
// Add at the top of the script const CONFIDENCE_LEVELS = { HIGH: { value: 'high', label: 'High', range: '90% - 100%', color: 'bg-green-600' }, MEDIUM: { value: 'medium', label: 'Medium', range: '70% - 89%', color: 'bg-primary-600' }, LOW: { value: 'low', label: 'Low', range: '<69%', color: 'bg-yellow-600' } } as const;Then update the template to use these constants.
Line range hint
96-110: Add type safety for event propertiesConsider adding type safety for the event properties to prevent potential runtime errors:
// Add at the top of the script interface ConfidenceFilterProperties { filter: { confidence: string[]; }; } // Update the trackEvent call trackEvent<ConfidenceFilterProperties>({ key, type: EventType.FEATURE, properties: { filter: { confidence: model.value, }, }, });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
frontend/src/modules/member/components/member-merge-suggestions.vue(1 hunks)frontend/src/modules/member/components/suggestions/filters/merge-suggestions-confidence-filter.vue(1 hunks)frontend/src/modules/member/components/suggestions/filters/merge-suggestions-projects-filter.vue(1 hunks)frontend/src/modules/member/components/suggestions/filters/merge-suggestions-search.vue(1 hunks)frontend/src/shared/modules/filters/components/Filter.vue(1 hunks)frontend/src/shared/modules/filters/components/FilterSearch.vue(1 hunks)frontend/src/shared/modules/monitoring/types/event.ts(1 hunks)
🔇 Additional comments (5)
frontend/src/shared/modules/filters/components/FilterSearch.vue (1)
66-66: Verify consistent event tracking implementation across components.
Since this change modifies the default event tracking behavior, we should ensure consistency across similar components.
✅ Verification successful
Let me try a different approach to verify the event tracking implementation.
Based on the search results, I can now provide a conclusive response:
Event tracking implementation is consistent across components
The codebase shows a consistent pattern where FeatureEventKey.SEARCH is used as a fallback when no specific search event type matches, while more specific event keys (like SEARCH_MEMBERS, SEARCH_ORGANIZATIONS, etc.) are used for their respective routes. This is the same pattern implemented in the changed file.
The event types are properly defined in frontend/src/shared/modules/monitoring/types/event.ts and are used consistently across the codebase, particularly in filter components.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for similar patterns in other filter components
echo "Checking other components for event tracking consistency..."
ast-grep --pattern 'key = FeatureEventKey.$_' frontend/src/shared/modules/filters/
# Check for potential inconsistencies in event tracking
echo "Checking for potential null key assignments in event tracking..."
ast-grep --pattern 'trackEvent({
key: $_,
type: EventType.FEATURE,
})' frontend/src/
Length of output: 443
Script:
#!/bin/bash
# Search for all usages of FeatureEventKey
echo "Checking all FeatureEventKey usages..."
rg "FeatureEventKey\." -A 2 frontend/src/
# Search for SEARCH constant specifically
echo "Checking SEARCH constant usage..."
rg "SEARCH.*=.*" frontend/src/ --type ts
# Look for event tracking related files
echo "Checking event tracking related files..."
fd "event" frontend/src/ --type file
Length of output: 42089
frontend/src/shared/modules/monitoring/types/event.ts (1)
138-139: Consider impact on analytics data quality
The addition of generic SEARCH and FILTER event keys might lead to loss of context in analytics compared to the specific keys like SEARCH_MEMBERS, FILTER_MEMBERS, etc. This could make it harder to track user behavior accurately.
Let's verify the usage of these generic keys:
Consider:
- Adding metadata to identify the context when using generic keys
- Logging a warning when falling back to generic keys
- Creating specific keys for new routes instead of using generic fallbacks
✅ Verification successful
Generic event keys are used appropriately as fallbacks with context
Based on the code analysis, the generic SEARCH and FILTER keys are only used as fallbacks after attempting to match specific route-based keys. The implementation properly:
- First tries to match specific routes and contexts (e.g.,
SEARCH_MEMBERS,FILTER_ORGANIZATIONS) - Only falls back to generic keys when no specific route matches
- Maintains context through the component hierarchy and route information
Key findings:
- In
FilterSearch.vue: GenericSEARCHis used only after checking for members, organizations, activities, and conversations contexts - In
Filter.vue: GenericFILTERis used only after checking for specific filtering contexts - In merge suggestions components: Proper context-specific keys are used with generic fallbacks
- All tracking events include additional properties with context information
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for usage of generic event keys to ensure they're only used as fallbacks
rg "FeatureEventKey\.(SEARCH|FILTER)" -A 5 -B 5
Length of output: 17065
frontend/src/modules/member/components/suggestions/filters/merge-suggestions-projects-filter.vue (1)
201-202: LGTM! Verify analytics tracking strategy.
The addition of a default case for event tracking is a good practice. However, please verify that using FeatureEventKey.FILTER as a fallback aligns with your analytics tracking strategy, ensuring that aggregated metrics will be meaningful.
✅ Verification successful
Based on the search results, I can now generate the final response:
Using FeatureEventKey.FILTER as fallback is consistent with the codebase's analytics strategy
The codebase shows a consistent pattern where specific filter events use specialized keys (e.g., FILTER_MEMBERS_MERGE_SUGGESTIONS, FILTER_ORGANIZATIONS_MERGE_SUGGESTIONS), with FeatureEventKey.FILTER serving as a generic fallback. This pattern is implemented across multiple filter components:
- In
merge-suggestions-projects-filter.vue - In
merge-suggestions-confidence-filter.vue - In
Filter.vue(shared component)
The fallback strategy aligns with the codebase's approach to analytics tracking, where generic events are used when more specific categorization is not applicable.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for consistency in event key usage across filter components
rg -A 2 "key = FeatureEventKey.FILTER" --type vue
Length of output: 79
Script:
#!/bin/bash
# Check for consistency in event key usage across filter components using ripgrep without file type restriction
rg -A 2 "key = FeatureEventKey.FILTER"
Length of output: 2972
Script:
#!/bin/bash
# Find all references to FeatureEventKey enum to understand the analytics tracking strategy
rg "FeatureEventKey\." -A 2
Length of output: 40692
Script:
#!/bin/bash
# Look for the definition of FeatureEventKey enum
fd -e ts -e js "FeatureEventKey" --exec cat {}
Length of output: 48
frontend/src/shared/modules/filters/components/Filter.vue (1)
168-168: LGTM! Consistent event tracking implementation.
The addition of the default case for event tracking maintains consistency with other filter components and ensures comprehensive analytics coverage.
frontend/src/modules/member/components/member-merge-suggestions.vue (1)
288-288: Verify analytics tracking continuity.
The event key has been renamed from MERGE_MEMBERS_MERGE_SUGGESTION to MERGE_MEMBER_MERGE_SUGGESTION. While this improves naming consistency, ensure that:
- Analytics systems are updated to handle the new event key
- Historical data tracking is not disrupted
Changes proposed ✍️
What
copilot:summary
copilot:poem
Why
How
copilot:walkthrough
Checklist ✅
Feature,Improvement, orBug.Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation