diff --git a/package.nls.json b/package.nls.json index 8a0db0d40533..36a153817396 100644 --- a/package.nls.json +++ b/package.nls.json @@ -417,8 +417,8 @@ "DataScience.findJupyterCommandProgress": "Active interpreter does not support {0}. Searching for the best available interpreter.", "DataScience.findJupyterCommandProgressCheckInterpreter": "Checking {0}.", "DataScience.findJupyterCommandProgressSearchCurrentPath": "Searching current path.", - "DataScience.gatheredScriptDescription": "# This file contains only the code required to produce the results of the gathered cell.\n", - "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)", + "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", + "DataScience.gatheredNotebookDescriptionInMarkdown": "## Gathered Notebook\nGathered from ```{0}```\n\n| | |\n|---|---|\n|   |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)", "DataScience.savePngTitle": "Save Image", "DataScience.jupyterSelectURIQuickPickTitle": "Pick how to connect to Jupyter", "DataScience.jupyterSelectURIQuickPickPlaceholder": "Choose an option", diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index a6c017df4d00..b7e322b0029f 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -722,11 +722,11 @@ export namespace DataScience { ); export const gatheredScriptDescription = localize( 'DataScience.gatheredScriptDescription', - '# This file contains only the code required to produce the results of the gathered cell.\n' + '# 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' ); export const gatheredNotebookDescriptionInMarkdown = localize( '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)' + '# Gathered Notebook\nGathered from ```{0}```\n\n| | |\n|---|---|\n|   |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)' ); export const savePngTitle = localize('DataScience.savePngTitle', 'Save Image'); export const fallbackToUseActiveInterpeterAsKernel = localize( diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index 02cb95a1c6a9..b87e48b63f0b 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -284,6 +284,7 @@ export enum Telemetry { NewFileForInteractiveWindow = 'DS_INTERNAL.NEW_FILE_USED_IN_INTERACTIVE', KernelInvalid = 'DS_INTERNAL.INVALID_KERNEL_USED', GatherCompleted = 'DATASCIENCE.GATHER_COMPLETED', + GatheredNotebookSaved = 'DATASCIENCE.GATHERED_NOTEBOOK_SAVED', ZMQNotSupported = 'DATASCIENCE.ZMQ_NATIVE_BINARIES_NOT_LOADING' } diff --git a/src/client/datascience/gather/gather.ts b/src/client/datascience/gather/gather.ts index 97d74d54a977..27a76e0960fe 100644 --- a/src/client/datascience/gather/gather.ts +++ b/src/client/datascience/gather/gather.ts @@ -7,7 +7,8 @@ import { IConfigurationService, IDisposableRegistry } from '../../common/types'; import * as localize from '../../common/utils/localize'; // tslint:disable-next-line: no-duplicate-imports import { Common } from '../../common/utils/localize'; -import { Identifiers } from '../constants'; +import { sendTelemetryEvent } from '../../telemetry'; +import { Identifiers, Telemetry } from '../constants'; import { CellState, ICell as IVscCell, IGatherProvider } from '../types'; /** @@ -46,7 +47,9 @@ export class GatherProvider implements IGatherProvider { ); } } catch (ex) { - traceInfo('Gathering tools could not be activated. Indicates build of VSIX was not'); + traceInfo( + 'Gathering tools could not be activated. Indicates build of VSIX could not find @msrvida/python-program-analysis' + ); } } } @@ -72,6 +75,7 @@ export class GatherProvider implements IGatherProvider { */ public gatherCode(vscCell: IVscCell): string { if (!this._executionSlicer) { + sendTelemetryEvent(Telemetry.GatherCompleted, undefined, { result: 'unavailable' }); return '# %% [markdown]\n## Gather not available'; } diff --git a/src/client/datascience/gather/gatherListener.ts b/src/client/datascience/gather/gatherListener.ts index 08221ba14207..2824da8e0d59 100644 --- a/src/client/datascience/gather/gatherListener.ts +++ b/src/client/datascience/gather/gatherListener.ts @@ -1,4 +1,5 @@ import { inject, injectable } from 'inversify'; +import { IDisposable } from 'monaco-editor'; import * as uuid from 'uuid/v4'; import { Event, EventEmitter, Position, Uri, ViewColumn } from 'vscode'; import { createMarkdownCell } from '../../../datascience-ui/common/cellFactory'; @@ -173,9 +174,17 @@ export class GatherListener implements IInteractiveWindowListener { const notebook = await this.jupyterExporter.translateToNotebook(cells); if (notebook) { - notebook.metadata.gatheredNotebook = true; const contents = JSON.stringify(notebook); - await this.ipynbProvider.createNew(contents); + const editor = await this.ipynbProvider.createNew(contents); + + let disposable: IDisposable; + const handler = () => { + sendTelemetryEvent(Telemetry.GatheredNotebookSaved); + if (disposable) { + disposable.dispose(); + } + }; + disposable = editor.saved(handler); } } } diff --git a/src/client/telemetry/index.ts b/src/client/telemetry/index.ts index aba19912ec31..3a279a109a79 100644 --- a/src/client/telemetry/index.ts +++ b/src/client/telemetry/index.ts @@ -1894,8 +1894,12 @@ export interface IEventNamePropertyMapping { /** * result indicates whether the gather was completed to a script, notebook or suffered an internal error. */ - result: 'err' | 'script' | 'notebook'; + result: 'err' | 'script' | 'notebook' | 'unavailable'; }; + /** + * Telemetry event sent when a gathered notebook has been saved by the user. + */ + [Telemetry.GatheredNotebookSaved]: undefined | never; /** * Telemetry event sent when the ZMQ native binaries do not work. */