Skip to content

Commit

Permalink
chore: remove closed survey VSCODE-659 (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
alenakhineika authored Nov 27, 2024
1 parent b489a80 commit e93006a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 243 deletions.
55 changes: 3 additions & 52 deletions src/mdbExtensionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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();
}
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_SURVEY_SHOWN = 'GLOBAL_SURVEY_SHOWN',
GLOBAL_COPILOT_INTRODUCTION_SHOWN = 'GLOBAL_COPILOT_INTRODUCTION_SHOWN',
GLOBAL_SAVED_CONNECTIONS = 'GLOBAL_SAVED_CONNECTIONS',
// Analytics user identify.
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions src/telemetry/telemetryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -157,7 +153,6 @@ type TelemetryEventProperties =
| PlaygroundLoadedTelemetryEventProperties
| KeytarSecretsMigrationFailedProperties
| SavedConnectionsLoadedProperties
| SurveyActionProperties
| ParticipantFeedbackProperties
| ParticipantResponseFailedProperties
| ParticipantPromptProperties
Expand All @@ -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',
Expand Down
182 changes: 0 additions & 182 deletions src/test/suite/mdbExtensionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit e93006a

Please sign in to comment.