Skip to content

Commit

Permalink
Remove survey bits
Browse files Browse the repository at this point in the history
  • Loading branch information
gagik committed Dec 6, 2024
1 parent 081be7c commit 7fb0a1c
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 255 deletions.
57 changes: 0 additions & 57 deletions src/mdbExtensionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default class MDBExtensionController implements vscode.Disposable {
_editDocumentCodeLensProvider: EditDocumentCodeLensProvider;
_exportToLanguageCodeLensProvider: ExportToLanguageCodeLensProvider;
_participantController: ParticipantController;
_startupNotificationShown = false;

constructor(
context: vscode.ExtensionContext,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -968,59 +964,6 @@ export default class MDBExtensionController implements vscode.Disposable {
}
}

async showCopilotIntroductionForEstablishedUsers(): Promise<void> {
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<void> {
await this.deactivate();
}
Expand Down
2 changes: 0 additions & 2 deletions src/storage/storageController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/telemetry/telemetryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}

/**
Expand Down Expand Up @@ -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);
}
}
184 changes: 0 additions & 184 deletions src/test/suite/mdbExtensionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 7fb0a1c

Please sign in to comment.