Skip to content

Commit ff01567

Browse files
authored
feat: Add analytics for Create Index Button Clicked CLOUDP-314818 (#6878)
* add analytics for Create Index Button Clicked * made it bit more readable * address pr comments
1 parent 8fb9db5 commit ff01567

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

packages/compass-indexes/src/modules/create-index.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,22 @@ export const createIndexFormSubmitted = (): IndexesThunkAction<
365365
void,
366366
ErrorEncounteredAction | CreateIndexFormSubmittedAction
367367
> => {
368-
return (dispatch, getState) => {
368+
return (dispatch, getState, { track, preferences }) => {
369+
// @experiment Early Journey Indexes Guidance & Awareness | Jira Epic: CLOUDP-239367
370+
const currentTab = getState().createIndex.currentTab;
371+
const { enableIndexesGuidanceExp, showIndexesGuidanceVariant } =
372+
preferences.getPreferences();
373+
374+
track('Create Index Button Clicked', {
375+
context: 'Create Index Modal',
376+
flow:
377+
enableIndexesGuidanceExp && showIndexesGuidanceVariant
378+
? currentTab === 'IndexFlow'
379+
? 'Start with Index'
380+
: 'Start with Query'
381+
: undefined,
382+
});
383+
369384
// Check for field errors.
370385
if (
371386
getState().createIndex.fields.some(

packages/compass-telemetry/src/telemetry-events.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -2678,6 +2678,16 @@ type ExperimentViewedEvent = CommonEvent<{
26782678
payload: { test_name: string };
26792679
}>;
26802680

2681+
export type CreateIndexModalContext = 'Create Index Modal';
2682+
2683+
type CreateIndexButtonClickedEvent = CommonEvent<{
2684+
name: 'Create Index Button Clicked';
2685+
payload: {
2686+
flow: 'Start with Query' | 'Start with Index' | undefined;
2687+
context: CreateIndexModalContext;
2688+
};
2689+
}>;
2690+
26812691
export type TelemetryEvent =
26822692
| AggregationCanceledEvent
26832693
| AggregationCopiedEvent
@@ -2799,4 +2809,5 @@ export type TelemetryEvent =
27992809
| FirstInputDelayEvent
28002810
| CumulativeLayoutShiftEvent
28012811
| TimeToFirstByteEvent
2802-
| ExperimentViewedEvent;
2812+
| ExperimentViewedEvent
2813+
| CreateIndexButtonClickedEvent;

0 commit comments

Comments
 (0)