Skip to content

Commit 7f24ef7

Browse files
authored
Telemetry updates (microsoft#10631)
Additional telemetry for noting when gathered notebook is saved.
1 parent af074d9 commit 7f24ef7

6 files changed

Lines changed: 27 additions & 9 deletions

File tree

package.nls.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@
417417
"DataScience.findJupyterCommandProgress": "Active interpreter does not support {0}. Searching for the best available interpreter.",
418418
"DataScience.findJupyterCommandProgressCheckInterpreter": "Checking {0}.",
419419
"DataScience.findJupyterCommandProgressSearchCurrentPath": "Searching current path.",
420-
"DataScience.gatheredScriptDescription": "# This file contains only the code required to produce the results of the gathered cell.\n",
421-
"DataScience.gatheredNotebookDescriptionInMarkdown": "## Gathered Notebook\nGenerated from ```{0}```\n\nThis notebook contains only the code and cells required to produce the same results as the gathered cell.\n\nPlease note that the python analysis is quite conservative, so if it is unsure whether a line of code is necessary for execution, it will err on the side of including it.\n\nAs this is an experimental feature, please let us know how well Gather works for you at [https://aka.ms/gathersurvey](https://aka.ms/gathersurvey)",
420+
"DataScience.gatheredScriptDescription":"# This file was generated by an experimental feature called 'Gather'.\n#\n# The intent is that it contains only the code required to produce\n# the same results as the cell originally selected for gathering.\n# Please note that the Python analysis is quite conservative, so if\n# it is unsure whether a line of code is necessary for execution, it\n# will err on the side of including it.\n#\n# Please let us know if you are satisfied with what was gathered here:\n# https://aka.ms/gathersurvey\n\n",
421+
"DataScience.gatheredNotebookDescriptionInMarkdown": "## Gathered Notebook\nGathered from ```{0}```\n\n| | |\n|---|---|\n|  &nbsp|This notebook was generated by an experimental feature called \"Gather\". The intent is that it contains only the code and cells required to produce the same results as the cell originally selected for gathering. Please note that the Python analysis is quite conservative, so if it is unsure whether a line of code is necessary for execution, it will err on the side of including it.|\n\n**Are you satisfied with the code that was gathered?**\n\n[Yes](https://aka.ms/gathersurvey?succeed_value=1) [No](https://aka.ms/gathersurvey?succeed_value=0)",
422422
"DataScience.savePngTitle": "Save Image",
423423
"DataScience.jupyterSelectURIQuickPickTitle": "Pick how to connect to Jupyter",
424424
"DataScience.jupyterSelectURIQuickPickPlaceholder": "Choose an option",

src/client/common/utils/localize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,11 @@ export namespace DataScience {
722722
);
723723
export const gatheredScriptDescription = localize(
724724
'DataScience.gatheredScriptDescription',
725-
'# This file contains only the code required to produce the results of the gathered cell.\n'
725+
'# This file was generated by an experimental feature called "Gather".\n#\n# The intent is that it contains only the code required to produce\n# the same results as the cell originally selected for gathering.\n# Please note that the Python analysis is quite conservative, so if\n# it is unsure whether a line of code is necessary for execution, it\n# will err on the side of including it.\n#\n# Please let us know if you are satisfied with what was gathered here:\n# https://aka.ms/gathersurvey\n\n'
726726
);
727727
export const gatheredNotebookDescriptionInMarkdown = localize(
728728
'DataScience.gatheredNotebookDescriptionInMarkdown',
729-
'## Gathered Notebook\nGenerated from ```{0}```\n\nThis notebook contains only the code and cells required to produce the same results as the gathered cell.\n\nPlease note that the python analysis is quite conservative, so if it is unsure whether a line of code is necessary for execution, it will err on the side of including it.\n\nAs this is an experimental feature, please let us know how well Gather works for you at [https://aka.ms/gathersurvey](https://aka.ms/gathersurvey)'
729+
'# Gathered Notebook\nGathered from ```{0}```\n\n| | |\n|---|---|\n|  &nbsp|This notebook was generated by an experimental feature called "Gather". The intent is that it contains only the code and cells required to produce the same results as the cell originally selected for gathering. Please note that the Python analysis is quite conservative, so if it is unsure whether a line of code is necessary for execution, it will err on the side of including it.|\n\n**Are you satisfied with the code that was gathered?**\n\n[Yes](https://aka.ms/gathersurvey?succeed_value=1) [No](https://aka.ms/gathersurvey?succeed_value=0)'
730730
);
731731
export const savePngTitle = localize('DataScience.savePngTitle', 'Save Image');
732732
export const fallbackToUseActiveInterpeterAsKernel = localize(

src/client/datascience/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ export enum Telemetry {
284284
NewFileForInteractiveWindow = 'DS_INTERNAL.NEW_FILE_USED_IN_INTERACTIVE',
285285
KernelInvalid = 'DS_INTERNAL.INVALID_KERNEL_USED',
286286
GatherCompleted = 'DATASCIENCE.GATHER_COMPLETED',
287+
GatheredNotebookSaved = 'DATASCIENCE.GATHERED_NOTEBOOK_SAVED',
287288
ZMQNotSupported = 'DATASCIENCE.ZMQ_NATIVE_BINARIES_NOT_LOADING'
288289
}
289290

src/client/datascience/gather/gather.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { IConfigurationService, IDisposableRegistry } from '../../common/types';
77
import * as localize from '../../common/utils/localize';
88
// tslint:disable-next-line: no-duplicate-imports
99
import { Common } from '../../common/utils/localize';
10-
import { Identifiers } from '../constants';
10+
import { sendTelemetryEvent } from '../../telemetry';
11+
import { Identifiers, Telemetry } from '../constants';
1112
import { CellState, ICell as IVscCell, IGatherProvider } from '../types';
1213

1314
/**
@@ -46,7 +47,9 @@ export class GatherProvider implements IGatherProvider {
4647
);
4748
}
4849
} catch (ex) {
49-
traceInfo('Gathering tools could not be activated. Indicates build of VSIX was not');
50+
traceInfo(
51+
'Gathering tools could not be activated. Indicates build of VSIX could not find @msrvida/python-program-analysis'
52+
);
5053
}
5154
}
5255
}
@@ -72,6 +75,7 @@ export class GatherProvider implements IGatherProvider {
7275
*/
7376
public gatherCode(vscCell: IVscCell): string {
7477
if (!this._executionSlicer) {
78+
sendTelemetryEvent(Telemetry.GatherCompleted, undefined, { result: 'unavailable' });
7579
return '# %% [markdown]\n## Gather not available';
7680
}
7781

src/client/datascience/gather/gatherListener.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { inject, injectable } from 'inversify';
2+
import { IDisposable } from 'monaco-editor';
23
import * as uuid from 'uuid/v4';
34
import { Event, EventEmitter, Position, Uri, ViewColumn } from 'vscode';
45
import { createMarkdownCell } from '../../../datascience-ui/common/cellFactory';
@@ -173,9 +174,17 @@ export class GatherListener implements IInteractiveWindowListener {
173174

174175
const notebook = await this.jupyterExporter.translateToNotebook(cells);
175176
if (notebook) {
176-
notebook.metadata.gatheredNotebook = true;
177177
const contents = JSON.stringify(notebook);
178-
await this.ipynbProvider.createNew(contents);
178+
const editor = await this.ipynbProvider.createNew(contents);
179+
180+
let disposable: IDisposable;
181+
const handler = () => {
182+
sendTelemetryEvent(Telemetry.GatheredNotebookSaved);
183+
if (disposable) {
184+
disposable.dispose();
185+
}
186+
};
187+
disposable = editor.saved(handler);
179188
}
180189
}
181190
}

src/client/telemetry/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1894,8 +1894,12 @@ export interface IEventNamePropertyMapping {
18941894
/**
18951895
* result indicates whether the gather was completed to a script, notebook or suffered an internal error.
18961896
*/
1897-
result: 'err' | 'script' | 'notebook';
1897+
result: 'err' | 'script' | 'notebook' | 'unavailable';
18981898
};
1899+
/**
1900+
* Telemetry event sent when a gathered notebook has been saved by the user.
1901+
*/
1902+
[Telemetry.GatheredNotebookSaved]: undefined | never;
18991903
/**
19001904
* Telemetry event sent when the ZMQ native binaries do not work.
19011905
*/

0 commit comments

Comments
 (0)