Skip to content

Fix the gather survey #13086

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

Merged
merged 6 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,11 @@
"command": "python.datascience.gatherquality",
"title": "DataScience.gatherQuality",
"category": "Python"
},
{
"command": "python.datascience.latestExtension",
"title": "DataScience.latestExtension",
"category": "Python"
}
],
"menus": {
Expand Down Expand Up @@ -1281,6 +1286,12 @@
"category": "Python",
"when": "false"
},
{
"command": "python.datascience.latestExtension",
"title": "%DataScience.latestExtension%",
"category": "Python",
"when": "false"
},
{
"command": "python.datascience.export",
"title": "%DataScience.notebookExportAs%",
Expand Down
15 changes: 8 additions & 7 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@
"DataScience.findJupyterCommandProgressCheckInterpreter": "Checking {0}.",
"DataScience.findJupyterCommandProgressSearchCurrentPath": "Searching current path.",
"DataScience.gatherError": "Gather internal error",
"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",
"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)",
"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",
"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)",
"DataScience.savePngTitle": "Save Image",
"DataScience.jupyterSelectURIQuickPickTitle": "Pick how to connect to Jupyter",
"DataScience.jupyterSelectURIQuickPickPlaceholder": "Choose an option",
Expand Down Expand Up @@ -514,6 +514,7 @@
"DataScience.jupyterSelectURIQuickPickTitleRemoteOnly": "Pick an already running jupyter server",
"DataScience.jupyterSelectURIRemoteDetail": "Specify the URI of an existing server",
"DataScience.gatherQuality": "Did gather work as desired?",
"DataScience.latestExtension": "Download the latest version of the Python Extension",
"DataScience.loadClassFailedWithNoInternet": "Error loading {0}:{1}. Internet connection required for loading 3rd party widgets.",
"DataScience.useCDNForWidgets": "Widgets require us to download supporting files from a 3rd party website. Click [here](https://aka.ms/PVSCIPyWidgets) for more information.",
"DataScience.loadThirdPartyWidgetScriptsPostEnabled": "Please restart the Kernel when changing the setting 'python.dataScience.widgetScriptSources'.",
Expand Down Expand Up @@ -557,9 +558,9 @@
"DataScienceRendererExtension.downloadCompletedOutputMessage": "Notebook Renderers extension download complete.",
"DataScience.uriProviderDescriptionFormat": "{0} (From {1} extension)",
"DataScience.unknownPackage": "unknown",
"DataScience.interactiveWindowTitleFormat" : "Python Interactive - {0}",
"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).",
"DataScience.interactiveWindowModeBannerSwitchYes" : "Yes",
"DataScience.interactiveWindowModeBannerSwitchAlways" : "Always",
"DataScience.interactiveWindowModeBannerSwitchNo" : "No"
"DataScience.interactiveWindowTitleFormat": "Python Interactive - {0}",
"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).",
"DataScience.interactiveWindowModeBannerSwitchYes": "Yes",
"DataScience.interactiveWindowModeBannerSwitchAlways": "Always",
"DataScience.interactiveWindowModeBannerSwitchNo": "No"
}
1 change: 1 addition & 0 deletions src/client/common/application/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
[DSCommands.SaveAsNotebookNonCustomEditor]: [Uri, Uri];
[DSCommands.OpenNotebookNonCustomEditor]: [Uri];
[DSCommands.GatherQuality]: [string];
[DSCommands.LatestExtension]: [string];
[DSCommands.EnableLoadingWidgetsFrom3rdPartySource]: [undefined | never];
[DSCommands.TrustNotebook]: [undefined | never | Uri];
}
4 changes: 2 additions & 2 deletions src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -886,11 +886,11 @@ export namespace DataScience {
export const gatherError = localize('DataScience.gatherError', 'Gather internal error');
export const gatheredScriptDescription = localize(
'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'
'# 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'
);
export const gatheredNotebookDescriptionInMarkdown = localize(
'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)'
'# 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)'
);
export const savePngTitle = localize('DataScience.savePngTitle', 'Save Image');
export const fallbackToUseActiveInterpeterAsKernel = localize(
Expand Down
9 changes: 7 additions & 2 deletions src/client/datascience/commands/commandRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class CommandRegistry implements IDisposable {
this.registerCommand(Commands.CreateNewNotebook, this.createNewNotebook);
this.registerCommand(Commands.ViewJupyterOutput, this.viewJupyterOutput);
this.registerCommand(Commands.GatherQuality, this.reportGatherQuality);
this.registerCommand(Commands.LatestExtension, this.openPythonExtensionPage);
this.registerCommand(
Commands.EnableLoadingWidgetsFrom3rdPartySource,
this.enableLoadingWidgetScriptsFromThirdParty
Expand Down Expand Up @@ -394,7 +395,11 @@ export class CommandRegistry implements IDisposable {
}

private reportGatherQuality(val: string) {
sendTelemetryEvent(Telemetry.GatherQualityReport, undefined, { result: val === 'no' ? 'no' : 'yes' });
env.openExternal(Uri.parse(`https://aka.ms/gathersurvey?succeed=${val}`));
sendTelemetryEvent(Telemetry.GatherQualityReport, undefined, { result: val[0] === 'no' ? 'no' : 'yes' });
env.openExternal(Uri.parse(`https://aka.ms/gathersurvey?succeed=${val[0]}`));
}

private openPythonExtensionPage() {
env.openExternal(Uri.parse(`https://marketplace.visualstudio.com/items?itemName=ms-python.python`));
}
}
2 changes: 2 additions & 0 deletions src/client/datascience/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export namespace Commands {
export const SaveAsNotebookNonCustomEditor = 'python.datascience.notebookeditor.saveAs';
export const OpenNotebookNonCustomEditor = 'python.datascience.notebookeditor.open';
export const GatherQuality = 'python.datascience.gatherquality';
export const LatestExtension = 'python.datascience.latestExtension';
export const TrustNotebook = 'python.datascience.notebookeditor.trust';
export const EnableLoadingWidgetsFrom3rdPartySource =
'python.datascience.enableLoadingWidgetScriptsFromThirdPartySource';
Expand Down Expand Up @@ -320,6 +321,7 @@ export enum Telemetry {
KernelInvalid = 'DS_INTERNAL.INVALID_KERNEL_USED',
GatherIsInstalled = 'DS_INTERNAL.GATHER_IS_INSTALLED',
GatherCompleted = 'DATASCIENCE.GATHER_COMPLETED',
GatherStats = 'DS_INTERNAL.GATHER_STATS',
GatheredNotebookSaved = 'DATASCIENCE.GATHERED_NOTEBOOK_SAVED',
GatherQualityReport = 'DS_INTERNAL.GATHER_QUALITY_REPORT',
ZMQSupported = 'DS_INTERNAL.ZMQ_NATIVE_BINARIES_LOADING',
Expand Down
17 changes: 17 additions & 0 deletions src/client/datascience/gather/gatherListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export class GatherListener implements IInteractiveWindowListener {
private notebookUri: Uri | undefined;
private gatherProvider: IGatherProvider | undefined;
private gatherTimer: StopWatch | undefined;
private linesSubmitted: number = 0;
private cellsSubmitted: number = 0;

constructor(
@inject(IApplicationShell) private applicationShell: IApplicationShell,
Expand Down Expand Up @@ -78,11 +80,19 @@ export class GatherListener implements IInteractiveWindowListener {
break;

case InteractiveWindowMessages.RestartKernel:
this.linesSubmitted = 0;
this.cellsSubmitted = 0;
if (this.gatherProvider) {
this.gatherProvider.resetLog();
}
break;

case InteractiveWindowMessages.FinishCell:
const lineCount: number = payload.cell.data.source.length as number;
this.linesSubmitted += lineCount;
this.cellsSubmitted += 1;
break;

default:
break;
}
Expand Down Expand Up @@ -155,6 +165,13 @@ export class GatherListener implements IInteractiveWindowListener {
await this.showNotebook(slicedProgram, cell);
sendTelemetryEvent(Telemetry.GatherCompleted, this.gatherTimer?.elapsedTime, { result: 'notebook' });
}

sendTelemetryEvent(Telemetry.GatherStats, undefined, {
linesSubmitted: this.linesSubmitted,
cellsSubmitted: this.cellsSubmitted,
linesGathered: slicedProgram.splitLines().length,
cellsGathered: generateCellsFromString(slicedProgram).length
});
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/client/datascience/interactive-common/linkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const LineQueryRegex = /line=(\d+)/;
// in a markdown cell using the syntax: https://command:[my.vscode.command].
const linkCommandWhitelist = [
'python.datascience.gatherquality',
'python.datascience.latestExtension',
'python.datascience.enableLoadingWidgetScriptsFromThirdPartySource'
];

Expand Down Expand Up @@ -52,8 +53,7 @@ export class LinkProvider implements IInteractiveWindowListener {
this.openFile(href);
} else if (href.startsWith('https://command:')) {
const temp: string = href.split(':')[2];
const params: string[] =
temp.includes('/?') && temp.includes(',') ? temp.split('/?')[1].split(',') : [];
const params: string[] = temp.includes('/?') ? temp.split('/?')[1].split(',') : [];
Copy link

Choose a reason for hiding this comment

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

Does this change break the reason the ',' was looked for before? Did you look to see what originally put this && condition here and make sure that still worked?

Copy link
Author

Choose a reason for hiding this comment

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

I didn't look for the specific case, but I tested having both a single and multiple parameters and that works as expected.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I just checked it, out of the 3 commands that use this, only the gather survey one uses parameters

let command = temp.split('/?')[0];
if (command.endsWith('/')) {
command = command.substring(0, command.length - 1);
Expand Down
6 changes: 6 additions & 0 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,12 @@ export interface IEventNamePropertyMapping {
*/
result: 'err' | 'script' | 'notebook' | 'unavailable';
};
[Telemetry.GatherStats]: {
linesSubmitted: number;
cellsSubmitted: number;
linesGathered: number;
cellsGathered: number;
};
/**
* Telemetry event sent when a gathered notebook has been saved by the user.
*/
Expand Down