Skip to content

feat: Add analytics for Create Index Button Clicked CLOUDP-314818 #6878

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

Merged
merged 3 commits into from
Apr 23, 2025

Conversation

rubydong
Copy link
Collaborator

@rubydong rubydong commented Apr 22, 2025

Description

Added tracking for when user clicks on the 'Create Index' button and the flow will be different based on whether they are not in the experiment / control, in the index flow, or in the query flow. To get this to work, i set the initial value of currentTab to null.

image
image
image



Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@rubydong rubydong added no release notes Fix or feature not for release notes feat labels Apr 22, 2025
@rubydong rubydong marked this pull request as ready for review April 22, 2025 16:07
@@ -83,6 +83,10 @@ function CreateIndexModal({
const enableInIndexesGuidanceExp = usePreference('enableIndexesGuidanceExp');
const showIndexesGuidanceVariant =
usePreference('showIndexesGuidanceVariant') && enableInIndexesGuidanceExp;
if (showIndexesGuidanceVariant && !currentTab) {
// If user is in the variant and there has not been a currentTab set, default it to IndexFlow
props.onTabClick('IndexFlow');
Copy link
Member

@Anemy Anemy Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid setting something like this in the react flow. We're only doing this for telemetry purposes right? Can we instead set that telemetry event metadata based on the preferences? And then we can go back to always having the currentTab set.

Comment on lines 86 to 89
if (showIndexesGuidanceVariant && !currentTab) {
// If user is in the variant and there has not been a currentTab set, default it to IndexFlow
props.onTabClick('IndexFlow');
}
Copy link
Collaborator

@gribnoysup gribnoysup Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dispatching actions from a render method is an antipattern, so is dispatching actions to set initial state. If you need your state to have three distinct values, you should be using redux ability to set initial state to define it (this is already done for the indexes plugin, you can see some initial state being passed to the createStore method in activateIndexesPlugin). Looking at the logic though, I think you only need to check the same preference flag when tracking the event instead of introducing a third state to the currentTab value and needing to account for this change everywhere

@rubydong rubydong requested review from Anemy and gribnoysup April 22, 2025 19:09
@rubydong rubydong merged commit ff01567 into main Apr 23, 2025
55 checks passed
@rubydong rubydong deleted the cloudp-314818 branch April 23, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat no release notes Fix or feature not for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants