-
Notifications
You must be signed in to change notification settings - Fork 244
feat(compass-collection): gate experiment feature behind redux state check instead of hook call - CLOUDP-344022 #7298
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
eda194e
c23b7d7
f7a0f35
6548018
b1daccc
ebe4412
47f2247
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,14 +12,10 @@ import React from 'react'; | |
| import { usePreferences } from 'compass-preferences-model/provider'; | ||
| import toNS from 'mongodb-ns'; | ||
| import { wrapField } from '@mongodb-js/mongodb-constants'; | ||
| import { | ||
| useTelemetry, | ||
| useAssignment, | ||
| ExperimentTestName, | ||
| ExperimentTestGroup, | ||
| } from '@mongodb-js/compass-telemetry/provider'; | ||
| import { useTelemetry } from '@mongodb-js/compass-telemetry/provider'; | ||
| import { | ||
| SCHEMA_ANALYSIS_STATE_ANALYZING, | ||
| SCHEMA_ANALYSIS_STATE_COMPLETE, | ||
| type SchemaAnalysisStatus, | ||
| } from '../../schema-analysis-types'; | ||
|
|
||
|
|
@@ -82,21 +78,13 @@ const CollectionHeaderActions: React.FunctionComponent< | |
| usePreferences(['readOnly', 'enableShell']); | ||
| const track = useTelemetry(); | ||
|
|
||
| // Get experiment assignment for Mock Data Generator | ||
| const mockDataGeneratorAssignment = useAssignment( | ||
| ExperimentTestName.mockDataGenerator, | ||
| true // trackIsInSample - this will fire the "Experiment Viewed" event | ||
| ); | ||
|
|
||
| const { database, collection } = toNS(namespace); | ||
|
|
||
| // Check if user is in treatment group for Mock Data Generator experiment | ||
| const isInMockDataTreatmentVariant = | ||
| mockDataGeneratorAssignment?.assignment?.assignmentData?.variant === | ||
| ExperimentTestGroup.mockDataGeneratorVariant; | ||
|
|
||
| // Show Mock Data Generator button if schema analysis has bee initiated (indicating user is in treatment variant) | ||
| // Schema analysis only runs for users in the treatment variant | ||
| const shouldShowMockDataButton = | ||
| isInMockDataTreatmentVariant && | ||
| (schemaAnalysisStatus === SCHEMA_ANALYSIS_STATE_ANALYZING || | ||
| schemaAnalysisStatus === SCHEMA_ANALYSIS_STATE_COMPLETE) && | ||
|
Comment on lines
85
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change means that even when the experiment related code is removed, the button now will always jump in the view because the analysis doesn't start immediately: first render happens before that. This also makes the button pop out if the analysis has failed. Not sure if this is an intended change in the behavior here. Feels like checking the assignment status is a clearer way of dealing with this UI: when experiment code is removed, this button will always be visible if other conditions are met, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My thinking was that this will actually reduce the latency for which the button pops in, since before this change, it'd have to wait for the True that currently this PR has the button pop out on failed analysis, but I think that's okay, as that's an unexpected error state. Alternatively, we could keep the button displayed but disabled. Yes, when we remove experiment code, we can remove this. I can add a note to do so here if in the future we do remove the experiment gate. If you feel this PR is better left unmerged, happy to skip it. Maybe we can keep it unmerged for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, If the plan is to remove the button if we failed to analyze instead of surfacing the error somehow, then indeed it's probably better to not show the button at all and limit the state checks even more than you have here to only showing it when analysis is completed successfully, otherwise in the current version the button shows up hen analysis starts, it's disabled because analysis is in progress, then it just disappears with no notice on error, this doesn't make much sense as a behavior 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, sounds good. For now, I'll leave this PR and we can revisit/reconsider it once higher priority work is done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! Do you mind switching it to draft so that it doesn't look like ready for review? |
||
| atlasMetadata && // Only show in Atlas | ||
| !isReadonly && // Don't show for readonly collections (views) | ||
| !sourceName; // sourceName indicates it's a view | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.