Skip to content

Commit ee6132b

Browse files
authored
fix: add telemetry events for survey VSCODE-595 (#787)
1 parent d97770b commit ee6132b

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/mdbExtensionController.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ import launchMongoShell from './commands/launchMongoShell';
3333
import type SchemaTreeItem from './explorer/schemaTreeItem';
3434
import { StatusView } from './views';
3535
import { StorageController, StorageVariables } from './storage';
36-
import TelemetryService from './telemetry/telemetryService';
36+
import TelemetryService, {
37+
TelemetryEventTypes,
38+
} from './telemetry/telemetryService';
3739
import type PlaygroundsTreeItem from './explorer/playgroundsTreeItem';
3840
import PlaygroundResultProvider from './editors/playgroundResultProvider';
3941
import WebviewController from './views/webviewController';
@@ -823,7 +825,7 @@ export default class MDBExtensionController implements vscode.Disposable {
823825
this._storageController.get(StorageVariables.GLOBAL_SURVEY_SHOWN) ===
824826
surveyId;
825827

826-
// Show the overview page when it hasn't been show to the
828+
// Show the survey when it hasn't been show to the
827829
// user yet, and they have saved connections
828830
// -> they haven't just started using this extension
829831
if (
@@ -845,6 +847,13 @@ export default class MDBExtensionController implements vscode.Disposable {
845847
);
846848
if (result?.title === action) {
847849
void vscode.env.openExternal(vscode.Uri.parse(link));
850+
this._telemetryService.track(TelemetryEventTypes.SURVEY_CLICKED, {
851+
survey_id: surveyId,
852+
});
853+
} else {
854+
this._telemetryService.track(TelemetryEventTypes.SURVEY_DISMISSED, {
855+
survey_id: surveyId,
856+
});
848857
}
849858

850859
// whether action was taken or the prompt dismissed, we won't show this again

src/telemetry/telemetryService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ type ConnectionEditedTelemetryEventProperties = {
7777
success: boolean;
7878
};
7979

80+
type SurveyActionProperties = {
81+
survey_id: string;
82+
};
83+
8084
type SavedConnectionsLoadedProperties = {
8185
// Total number of connections saved on disk
8286
saved_connections: number;
@@ -102,7 +106,8 @@ export type TelemetryEventProperties =
102106
| PlaygroundSavedTelemetryEventProperties
103107
| PlaygroundLoadedTelemetryEventProperties
104108
| KeytarSecretsMigrationFailedProperties
105-
| SavedConnectionsLoadedProperties;
109+
| SavedConnectionsLoadedProperties
110+
| SurveyActionProperties;
106111

107112
export enum TelemetryEventTypes {
108113
PLAYGROUND_CODE_EXECUTED = 'Playground Code Executed',
@@ -120,6 +125,8 @@ export enum TelemetryEventTypes {
120125
PLAYGROUND_CREATED = 'Playground Created',
121126
KEYTAR_SECRETS_MIGRATION_FAILED = 'Keytar Secrets Migration Failed',
122127
SAVED_CONNECTIONS_LOADED = 'Saved Connections Loaded',
128+
SURVEY_CLICKED = 'Survey link clicked',
129+
SURVEY_DISMISSED = 'Survey prompt dismissed',
123130
}
124131

125132
/**

0 commit comments

Comments
 (0)