Skip to content
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

Add telemetry #6

Merged
merged 88 commits into from
Nov 3, 2017
Merged

Add telemetry #6

merged 88 commits into from
Nov 3, 2017

Conversation

DonJayamanne
Copy link

No description provided.

@DonJayamanne
Copy link
Author

@brettcannon I can't see the telemetry on app insights, there could be a delay in the data coming through. Will keep monitoring.

Copy link
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's like one design question about an idea that may (or may not) make things easier to maintain, a spelling mistake in an attribute, and a change to the copyright headers.

@@ -0,0 +1,30 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

Less visibly jarring by dropping the --- lines, plus it doesn't mention the license file name since it's actually LICENSE in our case, but if we changed it I don't think we would want to update every single comment. 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied this from VS Code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can go back and fix it, better now

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just fix the mentioning of the license file, easier than removing the lines

// tslint:disable-next-line:prefer-type-cast
(result as Promise<void>)
.then(data => {
sendTelemetryEvent(eventName, stopWatch.elpsedTime);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elapsedTime

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duh


export function sendTelemetryEvent(eventName: string, durationMs?: number, properties?: TelemetryProperties) {
const reporter = getTelemetryReporter();
const measures = typeof durationMs === 'number' ? { duration: durationMs } : undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason we need to worry about the unit of measure changing? E.g. should as label the data as duration-ms?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we'll every want another unit (we can always do the math at the moment of reporting)

}

// tslint:disable-next-line:no-any function-name
export function captureTelemetry(eventName: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss context managers from Python.

// tslint:disable-next-line:no-invalid-this no-use-before-declare no-unsafe-any
const result = originalMethod.apply(this, args);

// If method being wrapped returns a promise then wait for it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth having two separate functions, e.g. captureAsyncTelemetry() and captureTelemetry() to simplify this logic at all?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, this is a decorator function (a decorator that can be applied to any method (sync or async).

e.g.

class Somethind {
    @captureTelemetry()
    public doSomethingSynchronously(){ }

    @captureTelemetry()
    public async doSomethingAsynchronously(){ }
}

@@ -1,36 +1,30 @@
declare module "vscode-extension-telemetry" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there really no .d.ts file on npm for the package? If so, has that fact been reported upstream?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, everyone seems to be creating their own dts for this damn thing... can't understand why. plan was to create a dts a create PR (separate piece of work)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing to do here.

@@ -1,3 +1,7 @@
/*---------------------------------------------------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be added to new files, not pre-existing ones where external contributors may have made changes.

if (stdout && stdout.length > 0) {
// Take the second part, see below example.
// pip 9.0.1 from /Users/donjayamanne/anaconda3/lib/python3.6/site-packages (python 3.6).
const parts = stdout.split(' ');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth using a regex to avoid potential format changes that could break this and lead to accidentally capturing PII?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do,
@brettcannon what's PII?

@@ -203,6 +210,7 @@ function execSelectionInDjangoShell() {
terminal.sendText(unix_code);
}
terminal.show();
sendTelemetryEvent(EXECUTION_DJANGO, undefined, { scope: 'selection' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it there's no way to execute Django as a file since that option isn't listed here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

const pyVersion = await interpreterVersion.getVersion('INVALID_INTERPRETER', 'DEFAULT_TEST_VALUE');
assert.equal(pyVersion, 'DEFAULT_TEST_VALUE', 'Incorrect version');
});
test('Must return the Pip Version', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You definitely do not need to change this, but as an FYI, the official capitalization is "pip" (all lower-case).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, i will deifinitely change this, as i'm making other chages.

Copy link
Member

@brettcannon brettcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I went through and removed the copyright header from all preexisting files. And since I was already doing that I just went ahead and tweaked the formatting for the new files.

@DonJayamanne DonJayamanne merged commit 45530ab into master Nov 3, 2017
@DonJayamanne DonJayamanne deleted the Telemetry branch November 6, 2017 23:28
pypros referenced this pull request in pypros/vscode-python Feb 20, 2019
karrtikr pushed a commit that referenced this pull request Mar 5, 2019
* more corrections

* Merge conflicts

* corrections

* Delete jupyterServerManager.unit.test.ts

* corrections

* CI
@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants