From 7fb0a1c3df11caecc8eff9b7c716eb43943da8e4 Mon Sep 17 00:00:00 2001 From: gagik Date: Fri, 6 Dec 2024 10:15:21 +0100 Subject: [PATCH] Remove survey bits --- src/mdbExtensionController.ts | 57 ------ src/storage/storageController.ts | 2 - src/telemetry/telemetryService.ts | 13 +- src/test/suite/mdbExtensionController.test.ts | 184 ------------------ 4 files changed, 1 insertion(+), 255 deletions(-) diff --git a/src/mdbExtensionController.ts b/src/mdbExtensionController.ts index 17ea0315f..7a46bce16 100644 --- a/src/mdbExtensionController.ts +++ b/src/mdbExtensionController.ts @@ -76,7 +76,6 @@ export default class MDBExtensionController implements vscode.Disposable { _editDocumentCodeLensProvider: EditDocumentCodeLensProvider; _exportToLanguageCodeLensProvider: ExportToLanguageCodeLensProvider; _participantController: ParticipantController; - _startupNotificationShown = false; constructor( context: vscode.ExtensionContext, @@ -174,9 +173,6 @@ export default class MDBExtensionController implements vscode.Disposable { this.registerCommands(); this.showOverviewPageIfRecentlyInstalled(); - // ------ In-app notifications ------ // - void this.showCopilotIntroductionForEstablishedUsers(); - const copilot = vscode.extensions.getExtension('GitHub.copilot'); void vscode.commands.executeCommand( 'setContext', @@ -968,59 +964,6 @@ export default class MDBExtensionController implements vscode.Disposable { } } - async showCopilotIntroductionForEstablishedUsers(): Promise { - const copilotIntroductionShown = - this._storageController.get( - StorageVariables.GLOBAL_COPILOT_INTRODUCTION_SHOWN - ) === true; - - // 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 || - copilotIntroductionShown || - !this._connectionStorage.hasSavedConnections() - ) { - return; - } - - this._startupNotificationShown = true; - - const action = 'Chat with @MongoDB'; - const text = - 'Generate queries, interact with documentation, and explore your database schema using the MongoDB Copilot extension. Give it a try!'; - const result = await vscode.window.showInformationMessage( - text, - {}, - { - title: action, - } - ); - - const copilot = vscode.extensions.getExtension(COPILOT_CHAT_EXTENSION_ID); - if (result?.title === action) { - await this._participantController.sendMessageToParticipant({ - message: '', - isNewChat: true, - isPartialQuery: true, - }); - this._telemetryService.trackCopilotIntroductionClicked({ - is_copilot_active: !!copilot?.isActive, - }); - } else { - this._telemetryService.trackCopilotIntroductionDismissed({ - is_copilot_active: !!copilot?.isActive, - }); - } - - // Whether action was taken or the prompt dismissed, we won't show this again. - void this._storageController.update( - StorageVariables.GLOBAL_COPILOT_INTRODUCTION_SHOWN, - true - ); - } - async dispose(): Promise { await this.deactivate(); } diff --git a/src/storage/storageController.ts b/src/storage/storageController.ts index f5a395f72..7a2ba780b 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_COPILOT_INTRODUCTION_SHOWN = 'GLOBAL_COPILOT_INTRODUCTION_SHOWN', GLOBAL_SAVED_CONNECTIONS = 'GLOBAL_SAVED_CONNECTIONS', // Analytics user identify. GLOBAL_USER_ID = 'GLOBAL_USER_ID', @@ -52,7 +51,6 @@ interface StorageVariableContents { [StorageVariables.GLOBAL_USER_ID]: string; [StorageVariables.GLOBAL_ANONYMOUS_ID]: string; [StorageVariables.GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW]: boolean; - [StorageVariables.GLOBAL_COPILOT_INTRODUCTION_SHOWN]: boolean; [StorageVariables.GLOBAL_SAVED_CONNECTIONS]: ConnectionsFromStorage; [StorageVariables.WORKSPACE_SAVED_CONNECTIONS]: ConnectionsFromStorage; [StorageVariables.COPILOT_HAS_BEEN_SHOWN_WELCOME_MESSAGE]: boolean; diff --git a/src/telemetry/telemetryService.ts b/src/telemetry/telemetryService.ts index 6044d3e8c..808ae1265 100644 --- a/src/telemetry/telemetryService.ts +++ b/src/telemetry/telemetryService.ts @@ -212,8 +212,7 @@ export enum TelemetryEventTypes { /** Tracks after a participant interacts with the input box we open to let the user write the prompt for participant. */ PARTICIPANT_INPUT_BOX_SUBMITTED = 'Participant Inbox Box Submitted', PARTICIPANT_RESPONSE_GENERATED = 'Participant Response Generated', - COPILOT_INTRODUCTION_CLICKED = 'Copilot Introduction Clicked', - COPILOT_INTRODUCTION_DISMISSED = 'Copilot Introduction Dismissed', + PARTICIPANT_SUBMITTED_FROM_INPUT_BOX = 'Participant Submitted From Input Box', } /** @@ -527,14 +526,4 @@ export default class TelemetryService { trackParticipantResponse(props: ParticipantResponseProperties): void { this.track(TelemetryEventTypes.PARTICIPANT_RESPONSE_GENERATED, props); } - - trackCopilotIntroductionClicked(props: CopilotIntroductionProperties): void { - this.track(TelemetryEventTypes.COPILOT_INTRODUCTION_CLICKED, props); - } - - trackCopilotIntroductionDismissed( - props: CopilotIntroductionProperties - ): void { - this.track(TelemetryEventTypes.COPILOT_INTRODUCTION_DISMISSED, props); - } } diff --git a/src/test/suite/mdbExtensionController.test.ts b/src/test/suite/mdbExtensionController.test.ts index 9642055e8..440a83262 100644 --- a/src/test/suite/mdbExtensionController.test.ts +++ b/src/test/suite/mdbExtensionController.test.ts @@ -1712,190 +1712,6 @@ suite('MDBExtensionController Test Suite', function () { }); }); }); - - suite('copilot introduction 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 copilot introduction prompt', () => { - assert(showInformationMessageStub.notCalled); - }); - } - ); - - suite( - "when a user hasn't been shown the copilot introduction prompt yet, and they have connections saved", - () => { - [ - { - description: 'clicked the button', - value: { title: 'Chat with @MongoDB' }, - }, - { description: 'dismissed', value: undefined }, - ].forEach((reaction) => { - suite(`user ${reaction.description}`, () => { - let connectionsUpdateStub: SinonStub; - let executeCommandStub: SinonStub; - beforeEach(async () => { - sandbox - .stub( - mdbTestExtension.testExtensionController, - '_startupNotificationShown' - ) - .set(function setterFn() {}) - .get(function getterFn() { - return false; - }); - showInformationMessageStub.resolves(reaction.value); - executeCommandStub = sandbox.stub( - vscode.commands, - 'executeCommand' - ); - 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' - ); - connectionsUpdateStub.resolves(undefined); - await mdbTestExtension.testExtensionController.showCopilotIntroductionForEstablishedUsers(); - }); - - afterEach(() => { - sandbox.restore(); - }); - - test('they are shown the copilot introduction prompt', () => { - assert(showInformationMessageStub.called); - assert.strictEqual( - showInformationMessageStub.firstCall.args[0], - 'Generate queries, interact with documentation, and explore your database schema using the MongoDB Copilot extension. Give it a try!' - ); - }); - - test('the link was open if and only if they click the button', () => { - if (reaction.value === undefined) { - assert(executeCommandStub.notCalled); - } - if (reaction.value) { - assert(executeCommandStub.called); - assert.strictEqual( - executeCommandStub.firstCall.args[0], - 'workbench.action.chat.newChat' - ); - } - }); - - test("it sets that they've been shown the copilot introduction", () => { - assert(connectionsUpdateStub.called); - assert.strictEqual( - connectionsUpdateStub.firstCall.args[0], - StorageVariables.GLOBAL_COPILOT_INTRODUCTION_SHOWN - ); - assert.strictEqual( - connectionsUpdateStub.firstCall.args[1], - true - ); - }); - }); - }); - } - ); - - suite( - 'when a user has been shown the copilot introduction 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(true) // copilot introduction 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.showCopilotIntroductionForEstablishedUsers(); - }); - - test('they are not shown the copilot introduction 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.showCopilotIntroductionForEstablishedUsers(); - }); - - test('they are not shown the copilot introduction prompt', () => { - assert(showInformationMessageStub.notCalled); - }); - }); - }); }); test('mdb.participantViewRawSchemaOutput command opens a json document with the output', async () => {