Skip to content

Commit 5d21a13

Browse files
author
David Kutugata
authored
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 18c9f81 commit 5d21a13

File tree

9 files changed

+56
-13
lines changed

9 files changed

+56
-13
lines changed

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,11 @@
770770
"command": "python.datascience.gatherquality",
771771
"title": "DataScience.gatherQuality",
772772
"category": "Python"
773+
},
774+
{
775+
"command": "python.datascience.latestExtension",
776+
"title": "DataScience.latestExtension",
777+
"category": "Python"
773778
}
774779
],
775780
"menus": {
@@ -1281,6 +1286,12 @@
12811286
"category": "Python",
12821287
"when": "false"
12831288
},
1289+
{
1290+
"command": "python.datascience.latestExtension",
1291+
"title": "%DataScience.latestExtension%",
1292+
"category": "Python",
1293+
"when": "false"
1294+
},
12841295
{
12851296
"command": "python.datascience.export",
12861297
"title": "%DataScience.notebookExportAs%",

package.nls.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,8 @@
477477
"DataScience.findJupyterCommandProgressCheckInterpreter": "Checking {0}.",
478478
"DataScience.findJupyterCommandProgressSearchCurrentPath": "Searching current path.",
479479
"DataScience.gatherError": "Gather internal error",
480-
"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",
481-
"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)",
480+
"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",
481+
"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)",
482482
"DataScience.savePngTitle": "Save Image",
483483
"DataScience.jupyterSelectURIQuickPickTitle": "Pick how to connect to Jupyter",
484484
"DataScience.jupyterSelectURIQuickPickPlaceholder": "Choose an option",
@@ -517,6 +517,7 @@
517517
"DataScience.jupyterSelectURIQuickPickTitleRemoteOnly": "Pick an already running jupyter server",
518518
"DataScience.jupyterSelectURIRemoteDetail": "Specify the URI of an existing server",
519519
"DataScience.gatherQuality": "Did gather work as desired?",
520+
"DataScience.latestExtension": "Download the latest version of the Python Extension",
520521
"DataScience.loadClassFailedWithNoInternet": "Error loading {0}:{1}. Internet connection required for loading 3rd party widgets.",
521522
"DataScience.useCDNForWidgets": "Widgets require us to download supporting files from a 3rd party website. Click [here](https://aka.ms/PVSCIPyWidgets) for more information.",
522523
"DataScience.loadThirdPartyWidgetScriptsPostEnabled": "Please restart the Kernel when changing the setting 'python.dataScience.widgetScriptSources'.",
@@ -560,9 +561,9 @@
560561
"DataScienceRendererExtension.downloadCompletedOutputMessage": "Notebook Renderers extension download complete.",
561562
"DataScience.uriProviderDescriptionFormat": "{0} (From {1} extension)",
562563
"DataScience.unknownPackage": "unknown",
563-
"DataScience.interactiveWindowTitleFormat" : "Python Interactive - {0}",
564-
"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).",
565-
"DataScience.interactiveWindowModeBannerSwitchYes" : "Yes",
566-
"DataScience.interactiveWindowModeBannerSwitchAlways" : "Always",
567-
"DataScience.interactiveWindowModeBannerSwitchNo" : "No"
564+
"DataScience.interactiveWindowTitleFormat": "Python Interactive - {0}",
565+
"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).",
566+
"DataScience.interactiveWindowModeBannerSwitchYes": "Yes",
567+
"DataScience.interactiveWindowModeBannerSwitchAlways": "Always",
568+
"DataScience.interactiveWindowModeBannerSwitchNo": "No"
568569
}

src/client/common/application/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
184184
[DSCommands.SaveAsNotebookNonCustomEditor]: [Uri, Uri];
185185
[DSCommands.OpenNotebookNonCustomEditor]: [Uri];
186186
[DSCommands.GatherQuality]: [string];
187+
[DSCommands.LatestExtension]: [string];
187188
[DSCommands.EnableLoadingWidgetsFrom3rdPartySource]: [undefined | never];
188189
[DSCommands.TrustNotebook]: [undefined | never | Uri];
189190
}

src/client/common/utils/localize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,11 +893,11 @@ export namespace DataScience {
893893
export const gatherError = localize('DataScience.gatherError', 'Gather internal error');
894894
export const gatheredScriptDescription = localize(
895895
'DataScience.gatheredScriptDescription',
896-
'# 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'
896+
'# 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'
897897
);
898898
export const gatheredNotebookDescriptionInMarkdown = localize(
899899
'DataScience.gatheredNotebookDescriptionInMarkdown',
900-
'# 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)'
900+
'# 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)'
901901
);
902902
export const savePngTitle = localize('DataScience.savePngTitle', 'Save Image');
903903
export const fallbackToUseActiveInterpeterAsKernel = localize(

src/client/datascience/commands/commandRegistry.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export class CommandRegistry implements IDisposable {
8080
this.registerCommand(Commands.CreateNewNotebook, this.createNewNotebook);
8181
this.registerCommand(Commands.ViewJupyterOutput, this.viewJupyterOutput);
8282
this.registerCommand(Commands.GatherQuality, this.reportGatherQuality);
83+
this.registerCommand(Commands.LatestExtension, this.openPythonExtensionPage);
8384
this.registerCommand(
8485
Commands.EnableLoadingWidgetsFrom3rdPartySource,
8586
this.enableLoadingWidgetScriptsFromThirdParty
@@ -394,7 +395,11 @@ export class CommandRegistry implements IDisposable {
394395
}
395396

396397
private reportGatherQuality(val: string) {
397-
sendTelemetryEvent(Telemetry.GatherQualityReport, undefined, { result: val === 'no' ? 'no' : 'yes' });
398-
env.openExternal(Uri.parse(`https://aka.ms/gathersurvey?succeed=${val}`));
398+
sendTelemetryEvent(Telemetry.GatherQualityReport, undefined, { result: val[0] === 'no' ? 'no' : 'yes' });
399+
env.openExternal(Uri.parse(`https://aka.ms/gathersurvey?succeed=${val[0]}`));
400+
}
401+
402+
private openPythonExtensionPage() {
403+
env.openExternal(Uri.parse(`https://marketplace.visualstudio.com/items?itemName=ms-python.python`));
399404
}
400405
}

src/client/datascience/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export namespace Commands {
9191
export const SaveAsNotebookNonCustomEditor = 'python.datascience.notebookeditor.saveAs';
9292
export const OpenNotebookNonCustomEditor = 'python.datascience.notebookeditor.open';
9393
export const GatherQuality = 'python.datascience.gatherquality';
94+
export const LatestExtension = 'python.datascience.latestExtension';
9495
export const TrustNotebook = 'python.datascience.notebookeditor.trust';
9596
export const EnableLoadingWidgetsFrom3rdPartySource =
9697
'python.datascience.enableLoadingWidgetScriptsFromThirdPartySource';
@@ -321,6 +322,7 @@ export enum Telemetry {
321322
KernelInvalid = 'DS_INTERNAL.INVALID_KERNEL_USED',
322323
GatherIsInstalled = 'DS_INTERNAL.GATHER_IS_INSTALLED',
323324
GatherCompleted = 'DATASCIENCE.GATHER_COMPLETED',
325+
GatherStats = 'DS_INTERNAL.GATHER_STATS',
324326
GatheredNotebookSaved = 'DATASCIENCE.GATHERED_NOTEBOOK_SAVED',
325327
GatherQualityReport = 'DS_INTERNAL.GATHER_QUALITY_REPORT',
326328
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)