Skip to content

Add telemetry for switch to Pylance acceptance #13526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
04e0b34
Fix path
May 6, 2020
9297d96
Merge branch 'master' of https://github.com/Microsoft/vscode-python
May 6, 2020
9f3d5ac
Merge branch 'master' of https://github.com/Microsoft/vscode-python
May 11, 2020
607bf98
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jun 1, 2020
e566214
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jun 11, 2020
4477900
Actually fix settings
Jun 18, 2020
d0d50de
Add news
Jun 18, 2020
03aa5f9
Add test
Jun 18, 2020
e4a032f
Format
Jun 18, 2020
27eeec7
Suppress 'jediEnabled' removal
Jun 18, 2020
89f432e
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jun 23, 2020
3ed655b
Drop survey first launch threshold
Jun 26, 2020
64ac38a
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jun 29, 2020
52a4325
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jun 30, 2020
67d7cb8
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jul 8, 2020
0ce6d91
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jul 22, 2020
571115e
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jul 30, 2020
41fbcbb
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Aug 4, 2020
8fee970
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Aug 10, 2020
67ea545
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Aug 17, 2020
09f2567
Initial
Aug 18, 2020
b8733af
Add test
Aug 19, 2020
f7aa66b
PR feedback
Aug 20, 2020
d73986c
Rename property
Aug 20, 2020
7d694f0
Rename constant
Aug 20, 2020
e37bef9
Define property
Aug 20, 2020
58f82e8
Moar rename
Aug 20, 2020
e70e9ad
casing
Aug 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/client/languageServices/proposeLanguageServerBanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
IPythonExtensionBanner
} from '../common/types';
import { Common, Pylance } from '../common/utils/localize';
import { sendTelemetryEvent } from '../telemetry';
import { EventName } from '../telemetry/constants';

export function getPylanceExtensionUri(appEnv: IApplicationEnvironment): string {
return `${appEnv.uriScheme}:extension/${PYLANCE_EXTENSION_ID}`;
Expand Down Expand Up @@ -74,11 +76,14 @@ export class ProposePylanceBanner implements IPythonExtensionBanner {

if (response === Pylance.tryItNow()) {
this.appShell.openUrl(getPylanceExtensionUri(this.appEnv));
sendTelemetryEvent(EventName.PYTHON_LANGUAGE_SERVER_TRY_PYLANCE, undefined, { useraction: 'yes' });
await this.disable();
} else if (response === Common.bannerLabelNo()) {
await this.disable();
sendTelemetryEvent(EventName.PYTHON_LANGUAGE_SERVER_TRY_PYLANCE, undefined, { useraction: 'no' });
} else {
this.disabledInCurrentSession = true;
sendTelemetryEvent(EventName.PYTHON_LANGUAGE_SERVER_TRY_PYLANCE, undefined, { useraction: 'later' });
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/client/telemetry/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export enum EventName {
PYTHON_LANGUAGE_SERVER_TELEMETRY = 'PYTHON_LANGUAGE_SERVER.EVENT',
PYTHON_LANGUAGE_SERVER_REQUEST = 'PYTHON_LANGUAGE_SERVER.REQUEST',

PYTHON_LANGUAGE_SERVER_TRY_PYLANCE = 'PYTHON_LANGUAGE_SERVER.TRY_PYLANCE',

LANGUAGE_SERVER_ENABLED = 'LANGUAGE_SERVER.ENABLED',
LANGUAGE_SERVER_STARTUP = 'LANGUAGE_SERVER.STARTUP',
LANGUAGE_SERVER_READY = 'LANGUAGE_SERVER.READY',
Expand Down
4 changes: 4 additions & 0 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,10 @@ export interface IEventNamePropertyMapping {
* Telemetry sent when the client makes a request to the language server
*/
[EventName.PYTHON_LANGUAGE_SERVER_REQUEST]: any;
/**
* Telemetry sent on user response to 'Try Pylance' prompt.
*/
[EventName.PYTHON_LANGUAGE_SERVER_TRY_PYLANCE]: any;
/**
* Telemetry event sent with details when inExperiment() API is called
*/
Expand Down
1 change: 0 additions & 1 deletion src/test/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"python.linting.banditEnabled": false,
"python.formatting.provider": "yapf",
"python.linting.pylintUseMinimalCheckers": false,
"python.pythonPath": "python",
// Do not set this to "Microsoft", else it will result in LS being downloaded on CI
// and that slows down tests significantly. We have other tests on CI for testing
// downloading of LS with this setting enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the MIT License.

'use strict';

import { expect } from 'chai';
import { assert, expect } from 'chai';
import * as sinon from 'sinon';
import * as typemoq from 'typemoq';
import { Extension } from 'vscode';
import { LanguageServerType } from '../../../client/activation/types';
Expand All @@ -24,6 +24,8 @@ import {
ProposeLSStateKeys,
ProposePylanceBanner
} from '../../../client/languageServices/proposeLanguageServerBanner';
import * as Telemetry from '../../../client/telemetry';
import { EventName } from '../../../client/telemetry/constants';

interface IExperimentLsCombination {
inExperiment: boolean;
Expand All @@ -46,6 +48,8 @@ suite('Propose Pylance Banner', () => {
let appShell: typemoq.IMock<IApplicationShell>;
let appEnv: typemoq.IMock<IApplicationEnvironment>;
let settings: typemoq.IMock<IPythonSettings>;
let sendTelemetryStub: sinon.SinonStub;
let telemetryEvent: { eventName: EventName; properties: { useraction: string } } | undefined;

const message = Pylance.proposePylanceMessage();
const yes = Pylance.tryItNow();
Expand All @@ -59,7 +63,23 @@ suite('Propose Pylance Banner', () => {
appShell = typemoq.Mock.ofType<IApplicationShell>();
appEnv = typemoq.Mock.ofType<IApplicationEnvironment>();
appEnv.setup((x) => x.uriScheme).returns(() => 'scheme');

sendTelemetryStub = sinon
.stub(Telemetry, 'sendTelemetryEvent')
.callsFake((eventName: EventName, _, properties: { useraction: string }) => {
telemetryEvent = {
eventName,
properties
};
});
});

teardown(() => {
telemetryEvent = undefined;
sinon.restore();
Telemetry._resetSharedProperties();
});

testData.forEach((t) => {
test(`${t.inExperiment ? 'In' : 'Not in'} experiment and "python.languageServer": "${t.lsType}" should ${
t.shouldShowBanner ? 'show' : 'not show'
Expand Down Expand Up @@ -109,8 +129,15 @@ suite('Propose Pylance Banner', () => {

const testBanner = preparePopup(true, appShell.object, appEnv.object, config.object, true, false);
await testBanner.showBanner();

expect(testBanner.enabled).to.be.equal(false, 'Banner should be permanently disabled when user clicked No');
appShell.verifyAll();

sinon.assert.calledOnce(sendTelemetryStub);
assert.deepEqual(telemetryEvent, {
eventName: EventName.PYTHON_LANGUAGE_SERVER_TRY_PYLANCE,
properties: { useraction: 'no' }
});
});
test('Clicking Later should disable banner in session', async () => {
appShell
Expand All @@ -128,11 +155,20 @@ suite('Propose Pylance Banner', () => {

const testBanner = preparePopup(true, appShell.object, appEnv.object, config.object, true, false);
await testBanner.showBanner();

expect(testBanner.enabled).to.be.equal(
true,
'Banner should not be permanently disabled when user clicked Later'
);
appShell.verifyAll();

sinon.assert.calledOnce(sendTelemetryStub);
assert.deepEqual(telemetryEvent, {
eventName: EventName.PYTHON_LANGUAGE_SERVER_TRY_PYLANCE,
properties: {
useraction: 'later'
}
});
});
test('Clicking Yes opens the extension marketplace entry', async () => {
appShell
Expand All @@ -150,8 +186,17 @@ suite('Propose Pylance Banner', () => {

const testBanner = preparePopup(true, appShell.object, appEnv.object, config.object, true, false);
await testBanner.showBanner();

expect(testBanner.enabled).to.be.equal(false, 'Banner should be permanently disabled after opening store URL');
appShell.verifyAll();

sinon.assert.calledOnce(sendTelemetryStub);
assert.deepEqual(telemetryEvent, {
eventName: EventName.PYTHON_LANGUAGE_SERVER_TRY_PYLANCE,
properties: {
useraction: 'yes'
}
});
});
});

Expand Down