Skip to content

Commit 3e117ba

Browse files
David KutugataDavidKutu
authored andcommitted
Fix the gather survey (#13086)
* fix the gather survey added 'gather stats' telemetry mention the gather comments to update the python ext * oops * fix tests and address comments * update gather stats when resetting the kernel * set globalstate vars to 0 when we open vs code * fix gather stats telemetry
1 parent d272d91 commit 3e117ba

File tree

9 files changed

+57
-9
lines changed

9 files changed

+57
-9
lines changed

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,11 @@
765765
"command": "python.datascience.gatherquality",
766766
"title": "DataScience.gatherQuality",
767767
"category": "Python"
768+
},
769+
{
770+
"command": "python.datascience.latestExtension",
771+
"title": "DataScience.latestExtension",
772+
"category": "Python"
768773
}
769774
],
770775
"menus": {
@@ -1276,6 +1281,12 @@
12761281
"category": "Python",
12771282
"when": "false"
12781283
},
1284+
{
1285+
"command": "python.datascience.latestExtension",
1286+
"title": "%DataScience.latestExtension%",
1287+
"category": "Python",
1288+
"when": "false"
1289+
},
12791290
{
12801291
"command": "python.datascience.export",
12811292
"title": "%DataScience.notebookExportAs%",

package.nls.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@
475475
"DataScience.findJupyterCommandProgressCheckInterpreter": "Checking {0}.",
476476
"DataScience.findJupyterCommandProgressSearchCurrentPath": "Searching current path.",
477477
"DataScience.gatherError": "Gather internal error",
478-
"DataScience.gatheredScriptDescription": "# This file was generated by the Gather Extension.\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",
479-
"DataScience.gatheredNotebookDescriptionInMarkdown": "## Gathered Notebook\nGathered from ```{0}```\n\n| | |\n|---|---|\n|  &nbsp|This notebook was generated by the Gather Extension. 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://command:python.datascience.gatherquality?yes) [No](https://command:python.datascience.gatherquality?no)",
478+
"DataScience.gatheredScriptDescription": "# This file was generated by the Gather Extension.\n# It requires version 2020.7.94776 (or newer) of the Python Extension.\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",
479+
"DataScience.gatheredNotebookDescriptionInMarkdown": "## Gathered Notebook\nGathered from ```{0}```\n\n| | |\n|---|---|\n|  &nbsp|This notebook was generated by the Gather Extension. It requires version 2020.7.94776 (or newer) of the Python Extension, please update [here](https://command:python.datascience.latestExtension). 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://command:python.datascience.gatherquality?yes) [No](https://command:python.datascience.gatherquality?no)",
480480
"DataScience.savePngTitle": "Save Image",
481481
"DataScience.jupyterSelectURIQuickPickTitle": "Pick how to connect to Jupyter",
482482
"DataScience.jupyterSelectURIQuickPickPlaceholder": "Choose an option",
@@ -515,6 +515,7 @@
515515
"DataScience.jupyterSelectURIQuickPickTitleRemoteOnly": "Pick an already running jupyter server",
516516
"DataScience.jupyterSelectURIRemoteDetail": "Specify the URI of an existing server",
517517
"DataScience.gatherQuality": "Did gather work as desired?",
518+
"DataScience.latestExtension": "Download the latest version of the Python Extension",
518519
"DataScience.loadClassFailedWithNoInternet": "Error loading {0}:{1}. Internet connection required for loading 3rd party widgets.",
519520
"DataScience.useCDNForWidgets": "Widgets require us to download supporting files from a 3rd party website. Click [here](https://aka.ms/PVSCIPyWidgets) for more information.",
520521
"DataScience.loadThirdPartyWidgetScriptsPostEnabled": "Please restart the Kernel when changing the setting 'python.dataScience.widgetScriptSources'.",
@@ -557,5 +558,10 @@
557558
"DataScienceRendererExtension.downloadingMessage": "Downloading Notebook Renderers Extension...",
558559
"DataScienceRendererExtension.downloadCompletedOutputMessage": "Notebook Renderers extension download complete.",
559560
"DataScience.uriProviderDescriptionFormat": "{0} (From {1} extension)",
560-
"DataScience.unknownPackage": "unknown"
561+
"DataScience.unknownPackage": "unknown",
562+
"DataScience.interactiveWindowTitleFormat": "Python Interactive - {0}",
563+
"DataScience.interactiveWindowModeBannerTitle": "Do you want to open a new Python Interactive window for this file? [More Information](command:workbench.action.openSettings?%5B%22python.dataScience.interactiveWindowMode%22%5D).",
564+
"DataScience.interactiveWindowModeBannerSwitchYes": "Yes",
565+
"DataScience.interactiveWindowModeBannerSwitchAlways": "Always",
566+
"DataScience.interactiveWindowModeBannerSwitchNo": "No"
561567
}

src/client/common/application/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
182182
[DSCommands.SaveAsNotebookNonCustomEditor]: [Uri, Uri];
183183
[DSCommands.OpenNotebookNonCustomEditor]: [Uri];
184184
[DSCommands.GatherQuality]: [string];
185+
[DSCommands.LatestExtension]: [string];
185186
[DSCommands.EnableLoadingWidgetsFrom3rdPartySource]: [undefined | never];
186187
[DSCommands.TrustNotebook]: [undefined | never | Uri];
187188
}

src/client/common/utils/localize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,11 +870,11 @@ export namespace DataScience {
870870
export const gatherError = localize('DataScience.gatherError', 'Gather internal error');
871871
export const gatheredScriptDescription = localize(
872872
'DataScience.gatheredScriptDescription',
873-
'# This file was generated by the Gather Extension.\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'
873+
'# This file was generated by the Gather Extension.\n# It requires version 2020.7.94776 (or newer) of the Python Extension.\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'
874874
);
875875
export const gatheredNotebookDescriptionInMarkdown = localize(
876876
'DataScience.gatheredNotebookDescriptionInMarkdown',
877-
'# Gathered Notebook\nGathered from ```{0}```\n\n| | |\n|---|---|\n|  &nbsp|This notebook was generated by the Gather Extension. 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://command:python.datascience.gatherquality?yes) [No](https://command:python.datascience.gatherquality?no)'
877+
'# Gathered Notebook\nGathered from ```{0}```\n\n| | |\n|---|---|\n|  &nbsp|This notebook was generated by the Gather Extension. It requires version 2020.7.94776 (or newer) of the Python Extension, please update [here](https://command:python.datascience.latestExtension). 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://command:python.datascience.gatherquality?yes) [No](https://command:python.datascience.gatherquality?no)'
878878
);
879879
export const savePngTitle = localize('DataScience.savePngTitle', 'Save Image');
880880
export const fallbackToUseActiveInterpeterAsKernel = localize(

src/client/datascience/commands/commandRegistry.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class CommandRegistry implements IDisposable {
7878
this.registerCommand(Commands.CreateNewNotebook, this.createNewNotebook);
7979
this.registerCommand(Commands.ViewJupyterOutput, this.viewJupyterOutput);
8080
this.registerCommand(Commands.GatherQuality, this.reportGatherQuality);
81+
this.registerCommand(Commands.LatestExtension, this.openPythonExtensionPage);
8182
this.registerCommand(
8283
Commands.EnableLoadingWidgetsFrom3rdPartySource,
8384
this.enableLoadingWidgetScriptsFromThirdParty
@@ -388,7 +389,11 @@ export class CommandRegistry implements IDisposable {
388389
}
389390

390391
private reportGatherQuality(val: string) {
391-
sendTelemetryEvent(Telemetry.GatherQualityReport, undefined, { result: val === 'no' ? 'no' : 'yes' });
392-
env.openExternal(Uri.parse(`https://aka.ms/gathersurvey?succeed=${val}`));
392+
sendTelemetryEvent(Telemetry.GatherQualityReport, undefined, { result: val[0] === 'no' ? 'no' : 'yes' });
393+
env.openExternal(Uri.parse(`https://aka.ms/gathersurvey?succeed=${val[0]}`));
394+
}
395+
396+
private openPythonExtensionPage() {
397+
env.openExternal(Uri.parse(`https://marketplace.visualstudio.com/items?itemName=ms-python.python`));
393398
}
394399
}

src/client/datascience/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export namespace Commands {
9090
export const SaveAsNotebookNonCustomEditor = 'python.datascience.notebookeditor.saveAs';
9191
export const OpenNotebookNonCustomEditor = 'python.datascience.notebookeditor.open';
9292
export const GatherQuality = 'python.datascience.gatherquality';
93+
export const LatestExtension = 'python.datascience.latestExtension';
9394
export const TrustNotebook = 'python.datascience.notebookeditor.trust';
9495
export const EnableLoadingWidgetsFrom3rdPartySource =
9596
'python.datascience.enableLoadingWidgetScriptsFromThirdPartySource';
@@ -320,6 +321,7 @@ export enum Telemetry {
320321
KernelInvalid = 'DS_INTERNAL.INVALID_KERNEL_USED',
321322
GatherIsInstalled = 'DS_INTERNAL.GATHER_IS_INSTALLED',
322323
GatherCompleted = 'DATASCIENCE.GATHER_COMPLETED',
324+
GatherStats = 'DS_INTERNAL.GATHER_STATS',
323325
GatheredNotebookSaved = 'DATASCIENCE.GATHERED_NOTEBOOK_SAVED',
324326
GatherQualityReport = 'DS_INTERNAL.GATHER_QUALITY_REPORT',
325327
ZMQSupported = 'DS_INTERNAL.ZMQ_NATIVE_BINARIES_LOADING',

src/client/datascience/gather/gatherListener.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export class GatherListener implements IInteractiveWindowListener {
4242
private notebookUri: Uri | undefined;
4343
private gatherProvider: IGatherProvider | undefined;
4444
private gatherTimer: StopWatch | undefined;
45+
private linesSubmitted: number = 0;
46+
private cellsSubmitted: number = 0;
4547

4648
constructor(
4749
@inject(IApplicationShell) private applicationShell: IApplicationShell,
@@ -78,11 +80,19 @@ export class GatherListener implements IInteractiveWindowListener {
7880
break;
7981

8082
case InteractiveWindowMessages.RestartKernel:
83+
this.linesSubmitted = 0;
84+
this.cellsSubmitted = 0;
8185
if (this.gatherProvider) {
8286
this.gatherProvider.resetLog();
8387
}
8488
break;
8589

90+
case InteractiveWindowMessages.FinishCell:
91+
const lineCount: number = payload.cell.data.source.length as number;
92+
this.linesSubmitted += lineCount;
93+
this.cellsSubmitted += 1;
94+
break;
95+
8696
default:
8797
break;
8898
}
@@ -155,6 +165,13 @@ export class GatherListener implements IInteractiveWindowListener {
155165
await this.showNotebook(slicedProgram, cell);
156166
sendTelemetryEvent(Telemetry.GatherCompleted, this.gatherTimer?.elapsedTime, { result: 'notebook' });
157167
}
168+
169+
sendTelemetryEvent(Telemetry.GatherStats, undefined, {
170+
linesSubmitted: this.linesSubmitted,
171+
cellsSubmitted: this.cellsSubmitted,
172+
linesGathered: slicedProgram.splitLines().length,
173+
cellsGathered: generateCellsFromString(slicedProgram).length
174+
});
158175
}
159176
};
160177

src/client/datascience/interactive-common/linkProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const LineQueryRegex = /line=(\d+)/;
1919
// in a markdown cell using the syntax: https://command:[my.vscode.command].
2020
const linkCommandWhitelist = [
2121
'python.datascience.gatherquality',
22+
'python.datascience.latestExtension',
2223
'python.datascience.enableLoadingWidgetScriptsFromThirdPartySource'
2324
];
2425

@@ -52,8 +53,7 @@ export class LinkProvider implements IInteractiveWindowListener {
5253
this.openFile(href);
5354
} else if (href.startsWith('https://command:')) {
5455
const temp: string = href.split(':')[2];
55-
const params: string[] =
56-
temp.includes('/?') && temp.includes(',') ? temp.split('/?')[1].split(',') : [];
56+
const params: string[] = temp.includes('/?') ? temp.split('/?')[1].split(',') : [];
5757
let command = temp.split('/?')[0];
5858
if (command.endsWith('/')) {
5959
command = command.substring(0, command.length - 1);

src/client/telemetry/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,12 @@ export interface IEventNamePropertyMapping {
20412041
*/
20422042
result: 'err' | 'script' | 'notebook' | 'unavailable';
20432043
};
2044+
[Telemetry.GatherStats]: {
2045+
linesSubmitted: number;
2046+
cellsSubmitted: number;
2047+
linesGathered: number;
2048+
cellsGathered: number;
2049+
};
20442050
/**
20452051
* Telemetry event sent when a gathered notebook has been saved by the user.
20462052
*/

0 commit comments

Comments
 (0)