Skip to content

Commit ec917eb

Browse files
JimmyChoiMDBJimmy Choi
andauthored
feat(compass-indexes): Add segment event tracking for search index support on views COMPASS-9964 (#7592)
* initial commit * fix category --------- Co-authored-by: Jimmy Choi <[email protected]>
1 parent d4e8ccb commit ec917eb

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { indexViewChanged } from '../../modules/index-view';
2828
import type { CollectionStats } from '../../modules/collection-stats';
2929
import type { Document } from 'mongodb';
3030
import { VIEW_PIPELINE_UTILS } from '@mongodb-js/mongodb-constants';
31+
import { useTelemetry } from '@mongodb-js/compass-telemetry/provider';
3132

3233
const toolbarButtonsContainer = css({
3334
display: 'flex',
@@ -321,6 +322,8 @@ export const CreateIndexButton: React.FunctionComponent<
321322
indexView,
322323
isViewPipelineSearchQueryable,
323324
}) => {
325+
const track = useTelemetry();
326+
324327
const onActionDispatch = useCallback(
325328
(action: CreateIndexActions) => {
326329
switch (action) {
@@ -338,7 +341,12 @@ export const CreateIndexButton: React.FunctionComponent<
338341
return (
339342
<Button
340343
disabled={!isWritable || !isViewPipelineSearchQueryable}
341-
onClick={onCreateSearchIndexClick}
344+
onClick={() => {
345+
onCreateSearchIndexClick();
346+
track('Create Search Index for View Clicked', {
347+
context: 'Indexes Tab',
348+
});
349+
}}
342350
variant="primary"
343351
size="small"
344352
>

packages/compass-indexes/src/components/indexes/indexes.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ const AtlasIndexesBanner = ({
134134
onDismissClick: () => void;
135135
}) => {
136136
const { atlasMetadata } = useConnectionInfo();
137+
const track = useTelemetry();
137138

138139
if (!atlasMetadata || dismissed) {
139140
return null;
@@ -151,6 +152,11 @@ const AtlasIndexesBanner = ({
151152
clusterName: atlasMetadata.clusterName,
152153
namespace,
153154
})}
155+
onClick={() => {
156+
track('Atlas Search Indexes for View Link Clicked', {
157+
context: 'Indexes Tab',
158+
});
159+
}}
154160
hideExternalIcon
155161
>
156162
{linkTitle}

packages/compass-indexes/src/components/search-indexes-table/search-indexes-table.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { useConnectionInfo } from '@mongodb-js/compass-connections/provider';
4141
import { useWorkspaceTabId } from '@mongodb-js/compass-workspaces/provider';
4242
import type { CollectionStats } from '../../modules/collection-stats';
4343
import { VIEW_PIPELINE_UTILS } from '@mongodb-js/mongodb-constants';
44+
import { useTelemetry } from '@mongodb-js/compass-telemetry/provider';
4445

4546
type SearchIndexesTableProps = {
4647
namespace: string;
@@ -71,6 +72,8 @@ function ZeroState({
7172
onOpenCreateModalClick: () => void;
7273
isViewPipelineSearchQueryable: boolean;
7374
}) {
75+
const track = useTelemetry();
76+
7477
return (
7578
<EmptyContent
7679
icon={ZeroGraphic}
@@ -83,7 +86,12 @@ function ZeroState({
8386
justify="middle"
8487
trigger={
8588
<Button
86-
onClick={onOpenCreateModalClick}
89+
onClick={() => {
90+
onOpenCreateModalClick();
91+
track('Create Search Index for View Clicked', {
92+
context: 'Indexes Tab',
93+
});
94+
}}
8795
data-testid="create-atlas-search-index-button"
8896
variant="primary"
8997
size="small"

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,6 +3240,36 @@ type MockDataScriptCopiedEvent = CommonEvent<{
32403240
};
32413241
}>;
32423242

3243+
/**
3244+
* This event is fired when a user clicks the link to Atlas Search in the Indexes tab for a view.
3245+
*
3246+
* @category Indexes
3247+
*/
3248+
type AtlasSearchIndexesForViewLinkClickedEvent = CommonEvent<{
3249+
name: 'Atlas Search Indexes for View Link Clicked';
3250+
payload: {
3251+
/**
3252+
* The context/screen from which the link was clicked.
3253+
*/
3254+
context: 'Indexes Tab';
3255+
};
3256+
}>;
3257+
3258+
/**
3259+
* This event is fired when a user clicks the button to create a search index for a view.
3260+
*
3261+
* @category Indexes
3262+
*/
3263+
type CreateSearchIndexForViewClickedEvent = CommonEvent<{
3264+
name: 'Create Search Index for View Clicked';
3265+
payload: {
3266+
/**
3267+
* The context/screen from which the link was clicked.
3268+
*/
3269+
context: 'Indexes Tab';
3270+
};
3271+
}>;
3272+
32433273
export type TelemetryEvent =
32443274
| AggregationCanceledEvent
32453275
| AggregationCopiedEvent
@@ -3270,6 +3300,7 @@ export type TelemetryEvent =
32703300
| AiResponseGeneratedEvent
32713301
| ApplicationLaunchedEvent
32723302
| AtlasLinkClickedEvent
3303+
| AtlasSearchIndexesForViewLinkClickedEvent
32733304
| AtlasSkillsCtaClickedEvent
32743305
| AtlasSkillsCtaDismissedEvent
32753306
| AtlasSignInErrorEvent
@@ -3293,6 +3324,7 @@ export type TelemetryEvent =
32933324
| ConnectionFailedEvent
32943325
| ConnectionImportedEvent
32953326
| ConnectionRemovedEvent
3327+
| CreateSearchIndexForViewClickedEvent
32963328
| CurrentOpShowOperationDetailsEvent
32973329
| DatabaseCreatedEvent
32983330
| DataModelingDiagramCollectionAdded

0 commit comments

Comments
 (0)