From e93006a105314b4e1cd02ff9e5fed1215426525b Mon Sep 17 00:00:00 2001 From: Alena Khineika <alena.khineika@mongodb.com> Date: Wed, 27 Nov 2024 17:24:13 +0100 Subject: [PATCH] chore: remove closed survey VSCODE-659 (#888) --- src/mdbExtensionController.ts | 55 +----- src/storage/storageController.ts | 2 - src/telemetry/telemetryService.ts | 7 - src/test/suite/mdbExtensionController.test.ts | 182 ------------------ 4 files changed, 3 insertions(+), 243 deletions(-) diff --git a/src/mdbExtensionController.ts b/src/mdbExtensionController.ts index 7026ca8aa..6487d951c 100644 --- a/src/mdbExtensionController.ts +++ b/src/mdbExtensionController.ts @@ -33,9 +33,7 @@ import launchMongoShell from './commands/launchMongoShell'; import type SchemaTreeItem from './explorer/schemaTreeItem'; import { StatusView } from './views'; import { StorageController, StorageVariables } from './storage'; -import TelemetryService, { - TelemetryEventTypes, -} from './telemetry/telemetryService'; +import TelemetryService from './telemetry/telemetryService'; import type PlaygroundsTreeItem from './explorer/playgroundsTreeItem'; import PlaygroundResultProvider from './editors/playgroundResultProvider'; import WebviewController from './views/webviewController'; @@ -166,7 +164,8 @@ export default class MDBExtensionController implements vscode.Disposable { this.registerCommands(); this.showOverviewPageIfRecentlyInstalled(); - void this.showSurveyForEstablishedUsers(); + + // ------ In-app notifications ------ // void this.showCopilotIntroductionForEstablishedUsers(); const copilot = vscode.extensions.getExtension('GitHub.copilot'); @@ -974,54 +973,6 @@ export default class MDBExtensionController implements vscode.Disposable { ); } - async showSurveyForEstablishedUsers(): Promise<void> { - const surveyId = '9viN9wcbsC3zvHyg7'; - - const hasBeenShownSurveyAlready = - this._storageController.get(StorageVariables.GLOBAL_SURVEY_SHOWN) === - surveyId; - - // Show the toast when startup notifications have not been shown - // to the user yet and they have saved connections - // -> they haven't just started using this extension - if ( - this._startupNotificationShown || - hasBeenShownSurveyAlready || - !this._connectionStorage.hasSavedConnections() - ) { - return; - } - - this._startupNotificationShown = true; - - const action = 'Share your thoughts'; - const text = 'How can we make the MongoDB extension better for you?'; - const link = 'https://forms.gle/9viN9wcbsC3zvHyg7'; - const result = await vscode.window.showInformationMessage( - text, - {}, - { - title: action, - } - ); - if (result?.title === action) { - void vscode.env.openExternal(vscode.Uri.parse(link)); - this._telemetryService.track(TelemetryEventTypes.SURVEY_CLICKED, { - survey_id: surveyId, - }); - } else { - this._telemetryService.track(TelemetryEventTypes.SURVEY_DISMISSED, { - survey_id: surveyId, - }); - } - - // whether action was taken or the prompt dismissed, we won't show this again - void this._storageController.update( - StorageVariables.GLOBAL_SURVEY_SHOWN, - surveyId - ); - } - async dispose(): Promise<void> { await this.deactivate(); } diff --git a/src/storage/storageController.ts b/src/storage/storageController.ts index 9bce41701..f5a395f72 100644 --- a/src/storage/storageController.ts +++ b/src/storage/storageController.ts @@ -6,7 +6,6 @@ import type { StoreConnectionInfo } from './connectionStorage'; export enum StorageVariables { // Only exists on globalState. GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW = 'GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW', - GLOBAL_SURVEY_SHOWN = 'GLOBAL_SURVEY_SHOWN', GLOBAL_COPILOT_INTRODUCTION_SHOWN = 'GLOBAL_COPILOT_INTRODUCTION_SHOWN', GLOBAL_SAVED_CONNECTIONS = 'GLOBAL_SAVED_CONNECTIONS', // Analytics user identify. @@ -53,7 +52,6 @@ interface StorageVariableContents { [StorageVariables.GLOBAL_USER_ID]: string; [StorageVariables.GLOBAL_ANONYMOUS_ID]: string; [StorageVariables.GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW]: boolean; - [StorageVariables.GLOBAL_SURVEY_SHOWN]: string; [StorageVariables.GLOBAL_COPILOT_INTRODUCTION_SHOWN]: boolean; [StorageVariables.GLOBAL_SAVED_CONNECTIONS]: ConnectionsFromStorage; [StorageVariables.WORKSPACE_SAVED_CONNECTIONS]: ConnectionsFromStorage; diff --git a/src/telemetry/telemetryService.ts b/src/telemetry/telemetryService.ts index 1d4238e66..54d3c3039 100644 --- a/src/telemetry/telemetryService.ts +++ b/src/telemetry/telemetryService.ts @@ -77,10 +77,6 @@ type ConnectionEditedTelemetryEventProperties = { success: boolean; }; -type SurveyActionProperties = { - survey_id: string; -}; - type SavedConnectionsLoadedProperties = { // Total number of connections saved on disk saved_connections: number; @@ -157,7 +153,6 @@ type TelemetryEventProperties = | PlaygroundLoadedTelemetryEventProperties | KeytarSecretsMigrationFailedProperties | SavedConnectionsLoadedProperties - | SurveyActionProperties | ParticipantFeedbackProperties | ParticipantResponseFailedProperties | ParticipantPromptProperties @@ -179,8 +174,6 @@ export enum TelemetryEventTypes { PLAYGROUND_CREATED = 'Playground Created', KEYTAR_SECRETS_MIGRATION_FAILED = 'Keytar Secrets Migration Failed', SAVED_CONNECTIONS_LOADED = 'Saved Connections Loaded', - SURVEY_CLICKED = 'Survey link clicked', - SURVEY_DISMISSED = 'Survey prompt dismissed', PARTICIPANT_FEEDBACK = 'Participant Feedback', PARTICIPANT_WELCOME_SHOWN = 'Participant Welcome Shown', PARTICIPANT_RESPONSE_FAILED = 'Participant Response Failed', diff --git a/src/test/suite/mdbExtensionController.test.ts b/src/test/suite/mdbExtensionController.test.ts index dac0bb16a..9642055e8 100644 --- a/src/test/suite/mdbExtensionController.test.ts +++ b/src/test/suite/mdbExtensionController.test.ts @@ -175,14 +175,12 @@ suite('MDBExtensionController Test Suite', function () { let fakeActiveConnectionId: SinonSpy; let showErrorMessageStub: SinonStub; let fakeCreatePlaygroundFileWithContent: SinonSpy; - let openExternalStub: SinonStub; beforeEach(() => { showInformationMessageStub = sandbox.stub( vscode.window, 'showInformationMessage' ); - openExternalStub = sandbox.stub(vscode.env, 'openExternal'); openTextDocumentStub = sandbox.stub(vscode.workspace, 'openTextDocument'); fakeActiveConnectionId = sandbox.fake.returns('tasty_sandwich'); sandbox.replace( @@ -1715,186 +1713,6 @@ suite('MDBExtensionController Test Suite', function () { }); }); - suite('survey prompt', function () { - suite( - 'when a user has been shown the startup notification already', - function () { - beforeEach(() => { - sandbox - .stub( - mdbTestExtension.testExtensionController, - '_startupNotificationShown' - ) - .get(function getterFn() { - return true; - }); - }); - - test('they are not shown the survey prompt', () => { - assert(showInformationMessageStub.notCalled); - }); - } - ); - - suite( - "when a user hasn't been shown the survey prompt yet, and they have connections saved", - () => { - [ - { - description: 'clicked the button', - value: { title: 'Share your thoughts' }, - }, - { description: 'dismissed', value: undefined }, - ].forEach((reaction) => { - suite(`user ${reaction.description}`, () => { - let connectionsUpdateStub: SinonStub; - let uriParseStub: SinonStub; - beforeEach(async () => { - sandbox - .stub( - mdbTestExtension.testExtensionController, - '_startupNotificationShown' - ) - .set(function setterFn() {}) - .get(function getterFn() { - return false; - }); - showInformationMessageStub.resolves(reaction.value); - openExternalStub.resolves(undefined); - sandbox.replace( - mdbTestExtension.testExtensionController._storageController, - 'get', - sandbox.fake.returns(undefined) - ); - sandbox.replace( - mdbTestExtension.testExtensionController._connectionStorage, - 'hasSavedConnections', - sandbox.fake.returns(true) - ); - connectionsUpdateStub = sandbox.stub( - mdbTestExtension.testExtensionController._storageController, - 'update' - ); - uriParseStub = sandbox.stub(vscode.Uri, 'parse'); - connectionsUpdateStub.resolves(undefined); - await mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); - }); - - afterEach(() => { - sandbox.restore(); - }); - - test('they are shown the survey prompt', () => { - assert(showInformationMessageStub.called); - assert.strictEqual( - showInformationMessageStub.firstCall.args[0], - 'How can we make the MongoDB extension better for you?' - ); - }); - - test('the link was open if and only if they click the button', () => { - if (reaction.value === undefined) { - assert(openExternalStub.notCalled); - } - if (reaction.value) { - assert(openExternalStub.called); - assert(uriParseStub.called); - assert.strictEqual( - uriParseStub.firstCall.args[0], - 'https://forms.gle/9viN9wcbsC3zvHyg7' - ); - } - }); - - test("it sets that they've been shown the survey", () => { - assert(connectionsUpdateStub.called); - assert.strictEqual( - connectionsUpdateStub.firstCall.args[0], - StorageVariables.GLOBAL_SURVEY_SHOWN - ); - assert.strictEqual( - connectionsUpdateStub.firstCall.args[1], - '9viN9wcbsC3zvHyg7' - ); - }); - }); - }); - } - ); - - suite('when a user has been shown the survey prompt already', () => { - let connectionsUpdateStub: SinonStub; - beforeEach(() => { - sandbox - .stub( - mdbTestExtension.testExtensionController, - '_startupNotificationShown' - ) - .set(function setterFn() {}) - .get(function getterFn() { - return false; - }); - sandbox.replace( - mdbTestExtension.testExtensionController._storageController, - 'get', - sandbox.fake.returns('9viN9wcbsC3zvHyg7') // survey has been shown - ); - sandbox.replace( - mdbTestExtension.testExtensionController._connectionStorage, - 'hasSavedConnections', - sandbox.fake.returns(true) - ); - connectionsUpdateStub = sandbox.stub( - mdbTestExtension.testExtensionController._storageController, - 'update' - ); - connectionsUpdateStub.resolves(undefined); - - void mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); - }); - - test('they are not shown the survey prompt', () => { - assert(showInformationMessageStub.notCalled); - }); - }); - - suite('when a has no connections saved', () => { - let connectionsUpdateStub: SinonStub; - beforeEach(() => { - sandbox - .stub( - mdbTestExtension.testExtensionController, - '_startupNotificationShown' - ) - .set(function setterFn() {}) - .get(function getterFn() { - return false; - }); - sandbox.replace( - mdbTestExtension.testExtensionController._storageController, - 'get', - sandbox.fake.returns(undefined) - ); - sandbox.replace( - mdbTestExtension.testExtensionController._connectionStorage, - 'hasSavedConnections', - sandbox.fake.returns(false) // no connections yet - this might be the first install - ); - connectionsUpdateStub = sandbox.stub( - mdbTestExtension.testExtensionController._storageController, - 'update' - ); - connectionsUpdateStub.resolves(undefined); - - void mdbTestExtension.testExtensionController.showSurveyForEstablishedUsers(); - }); - - test('they are not shown the survey prompt', () => { - assert(showInformationMessageStub.notCalled); - }); - }); - }); - suite('copilot introduction prompt', function () { suite( 'when a user has been shown the startup notification already',