Skip to content

Disable surveys if running in codespaces #14332

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 7 commits into from
Oct 9, 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
2 changes: 2 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@
"DataScience.gatherError": "Gather internal error",
"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/gatherfeedback\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.gatheredScriptDescriptionWithoutSurvey": "# 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",
"DataScience.gatheredNotebookDescriptionInMarkdownWithoutSurvey": "## 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",
"DataScience.savePngTitle": "Save Image",
"DataScience.jupyterSelectURIQuickPickTitle": "Pick how to connect to Jupyter",
"DataScience.jupyterSelectURIQuickPickPlaceholder": "Choose an option",
Expand Down
4 changes: 4 additions & 0 deletions src/client/activation/extensionSurvey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { inject, injectable, optional } from 'inversify';
import * as querystring from 'querystring';
import { env, UIKind } from 'vscode';
import { IApplicationEnvironment, IApplicationShell } from '../common/application/types';
import { ShowExtensionSurveyPrompt } from '../common/experiments/groups';
import '../common/extensions';
Expand Down Expand Up @@ -53,6 +54,9 @@ export class ExtensionSurveyPrompt implements IExtensionSingleActivationService

@traceDecorators.error('Failed to check whether to display prompt for extension survey')
public shouldShowBanner(): boolean {
if (env.uiKind === UIKind?.Web) {
return false;
}
const doNotShowSurveyAgain = this.persistentState.createGlobalPersistentState(
extensionSurveyStateKeys.doNotShowAgain,
false
Expand Down
8 changes: 8 additions & 0 deletions src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,10 +935,18 @@ export namespace DataScience {
'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/gatherfeedback\n\n'
);
export const gatheredScriptDescriptionWithoutSurvey = localize(
'DataScience.gatheredScriptDescriptionWithoutSurvey',
'# 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'
);
export const gatheredNotebookDescriptionInMarkdown = localize(
'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)'
);
export const gatheredNotebookDescriptionInMarkdownWithoutSurvey = localize(
'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'
);
export const savePngTitle = localize('DataScience.savePngTitle', 'Save Image');
export const fallbackToUseActiveInterpreterAsKernel = localize(
'DataScience.fallbackToUseActiveInterpeterAsKernel',
Expand Down
7 changes: 5 additions & 2 deletions src/client/datascience/dataScienceSurveyBanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import { inject, injectable, named } from 'inversify';
import { Event, EventEmitter } from 'vscode';
import { env, Event, EventEmitter, UIKind } from 'vscode';
import { IApplicationShell } from '../common/application/types';
import '../common/extensions';
import {
Expand Down Expand Up @@ -100,7 +100,10 @@ export class DataScienceSurveyBanner implements IPythonExtensionBanner {
this.isInitialized = true;
}
public get enabled(): boolean {
return this.persistentState.createGlobalPersistentState<boolean>(DSSurveyStateKeys.ShowBanner, true).value;
return (
this.persistentState.createGlobalPersistentState<boolean>(DSSurveyStateKeys.ShowBanner, true).value &&
env.uiKind !== UIKind?.Web
);
}

public async showBanner(): Promise<void> {
Expand Down
16 changes: 13 additions & 3 deletions src/client/datascience/gather/gatherListener.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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 { env, Event, EventEmitter, Position, UIKind, Uri, ViewColumn } from 'vscode';
import { createMarkdownCell } from '../../../datascience-ui/common/cellFactory';
import { IApplicationShell, IDocumentManager } from '../../common/application/types';
import { PYTHON_LANGUAGE } from '../../common/constants';
Expand Down Expand Up @@ -224,13 +224,20 @@ export class GatherListener implements IInteractiveWindowListener {
const file =
cell.file === Identifiers.EmptyFileName && this.notebookUri ? this.notebookUri.fsPath : cell.file;

const data =
env.uiKind === UIKind?.Web
? createMarkdownCell(
localize.DataScience.gatheredNotebookDescriptionInMarkdownWithoutSurvey().format(file)
)
: createMarkdownCell(localize.DataScience.gatheredNotebookDescriptionInMarkdown().format(file));

let cells: ICell[] = [
{
id: uuid(),
file: '',
line: 0,
state: 0,
data: createMarkdownCell(localize.DataScience.gatheredNotebookDescriptionInMarkdown().format(file))
data
}
];

Expand Down Expand Up @@ -290,7 +297,10 @@ export class GatherListener implements IInteractiveWindowListener {
slicedProgram = slicedProgram.replace(re, '');
}

const annotatedScript = `${localize.DataScience.gatheredScriptDescription()}${defaultCellMarker}\n${slicedProgram}`;
const annotatedScript =
env?.uiKind === UIKind?.Web
? `${localize.DataScience.gatheredScriptDescriptionWithoutSurvey()}${defaultCellMarker}\n${slicedProgram}`
: `${localize.DataScience.gatheredScriptDescription()}${defaultCellMarker}\n${slicedProgram}`;

// Don't want to open the gathered code on top of the interactive window
let viewColumn: ViewColumn | undefined;
Expand Down
7 changes: 5 additions & 2 deletions src/client/datascience/notebook/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'use strict';

import { inject, injectable } from 'inversify';
import { env, UIKind } from 'vscode';
import { IExtensionSingleActivationService } from '../../activation/types';
import { IApplicationShell, IVSCodeNotebook } from '../../common/application/types';
import { traceError } from '../../common/logger';
Expand All @@ -27,8 +28,10 @@ export type NotebookSurveyUsageData = {
@injectable()
export class NotebookSurveyBanner {
public get enabled(): boolean {
return !this.persistentState.createGlobalPersistentState<NotebookSurveyUsageData>(storageKey, {}).value
.surveyDisabled;
return (
!this.persistentState.createGlobalPersistentState<NotebookSurveyUsageData>(storageKey, {}).value
.surveyDisabled && env.uiKind !== UIKind?.Web
);
}
private disabledInCurrentSession: boolean = false;
constructor(
Expand Down
4 changes: 2 additions & 2 deletions src/client/debugger/extension/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import { inject, injectable } from 'inversify';
import { Disposable } from 'vscode';
import { Disposable, env, UIKind } from 'vscode';
import { IApplicationShell, IDebugService } from '../../common/application/types';
import '../../common/extensions';
import { traceError } from '../../common/logger';
Expand Down Expand Up @@ -63,7 +63,7 @@ export class DebuggerBanner implements IDebuggerBanner {
// showing banner

public async shouldShow(): Promise<boolean> {
if (!this.isEnabled() || this.disabledInCurrentSession) {
if (!this.isEnabled() || this.disabledInCurrentSession || env.uiKind === UIKind?.Web) {
return false;
}
if (!(await this.passedThreshold())) {
Expand Down