Skip to content

Commit bdc8131

Browse files
joyceerhlluabud
authored andcommitted
Disable surveys if running in codespaces (microsoft#14332)
* Disable surveys if running in codespaces * Also disable debugger survey * Disable gather survey in codespaces too * For gather, show a description without the survey * Fixes for IW tests where UIKind is not defined * Fix all the tests where UIKind is not defined * Appease hygiene
1 parent dd192f2 commit bdc8131

File tree

7 files changed

+39
-9
lines changed

7 files changed

+39
-9
lines changed

package.nls.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@
510510
"DataScience.gatherError": "Gather internal error",
511511
"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",
512512
"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)",
513+
"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",
514+
"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",
513515
"DataScience.savePngTitle": "Save Image",
514516
"DataScience.jupyterSelectURIQuickPickTitle": "Pick how to connect to Jupyter",
515517
"DataScience.jupyterSelectURIQuickPickPlaceholder": "Choose an option",

src/client/activation/extensionSurvey.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

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

5455
@traceDecorators.error('Failed to check whether to display prompt for extension survey')
5556
public shouldShowBanner(): boolean {
57+
if (env.uiKind === UIKind?.Web) {
58+
return false;
59+
}
5660
const doNotShowSurveyAgain = this.persistentState.createGlobalPersistentState(
5761
extensionSurveyStateKeys.doNotShowAgain,
5862
false

src/client/common/utils/localize.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,10 +935,18 @@ export namespace DataScience {
935935
'DataScience.gatheredScriptDescription',
936936
'# 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'
937937
);
938+
export const gatheredScriptDescriptionWithoutSurvey = localize(
939+
'DataScience.gatheredScriptDescriptionWithoutSurvey',
940+
'# 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'
941+
);
938942
export const gatheredNotebookDescriptionInMarkdown = localize(
939943
'DataScience.gatheredNotebookDescriptionInMarkdown',
940944
'# 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)'
941945
);
946+
export const gatheredNotebookDescriptionInMarkdownWithoutSurvey = localize(
947+
'DataScience.gatheredNotebookDescriptionInMarkdown',
948+
'# 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'
949+
);
942950
export const savePngTitle = localize('DataScience.savePngTitle', 'Save Image');
943951
export const fallbackToUseActiveInterpreterAsKernel = localize(
944952
'DataScience.fallbackToUseActiveInterpeterAsKernel',

src/client/datascience/dataScienceSurveyBanner.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'use strict';
55

66
import { inject, injectable, named } from 'inversify';
7-
import { Event, EventEmitter } from 'vscode';
7+
import { env, Event, EventEmitter, UIKind } from 'vscode';
88
import { IApplicationShell } from '../common/application/types';
99
import '../common/extensions';
1010
import {
@@ -100,7 +100,10 @@ export class DataScienceSurveyBanner implements IPythonExtensionBanner {
100100
this.isInitialized = true;
101101
}
102102
public get enabled(): boolean {
103-
return this.persistentState.createGlobalPersistentState<boolean>(DSSurveyStateKeys.ShowBanner, true).value;
103+
return (
104+
this.persistentState.createGlobalPersistentState<boolean>(DSSurveyStateKeys.ShowBanner, true).value &&
105+
env.uiKind !== UIKind?.Web
106+
);
104107
}
105108

106109
public async showBanner(): Promise<void> {

src/client/datascience/gather/gatherListener.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { inject, injectable } from 'inversify';
22
import { IDisposable } from 'monaco-editor';
33
import * as uuid from 'uuid/v4';
4-
import { Event, EventEmitter, Position, Uri, ViewColumn } from 'vscode';
4+
import { env, Event, EventEmitter, Position, UIKind, Uri, ViewColumn } from 'vscode';
55
import { createMarkdownCell } from '../../../datascience-ui/common/cellFactory';
66
import { IApplicationShell, IDocumentManager } from '../../common/application/types';
77
import { PYTHON_LANGUAGE } from '../../common/constants';
@@ -224,13 +224,20 @@ export class GatherListener implements IInteractiveWindowListener {
224224
const file =
225225
cell.file === Identifiers.EmptyFileName && this.notebookUri ? this.notebookUri.fsPath : cell.file;
226226

227+
const data =
228+
env.uiKind === UIKind?.Web
229+
? createMarkdownCell(
230+
localize.DataScience.gatheredNotebookDescriptionInMarkdownWithoutSurvey().format(file)
231+
)
232+
: createMarkdownCell(localize.DataScience.gatheredNotebookDescriptionInMarkdown().format(file));
233+
227234
let cells: ICell[] = [
228235
{
229236
id: uuid(),
230237
file: '',
231238
line: 0,
232239
state: 0,
233-
data: createMarkdownCell(localize.DataScience.gatheredNotebookDescriptionInMarkdown().format(file))
240+
data
234241
}
235242
];
236243

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

293-
const annotatedScript = `${localize.DataScience.gatheredScriptDescription()}${defaultCellMarker}\n${slicedProgram}`;
300+
const annotatedScript =
301+
env?.uiKind === UIKind?.Web
302+
? `${localize.DataScience.gatheredScriptDescriptionWithoutSurvey()}${defaultCellMarker}\n${slicedProgram}`
303+
: `${localize.DataScience.gatheredScriptDescription()}${defaultCellMarker}\n${slicedProgram}`;
294304

295305
// Don't want to open the gathered code on top of the interactive window
296306
let viewColumn: ViewColumn | undefined;

src/client/datascience/notebook/survey.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
'use strict';
55

66
import { inject, injectable } from 'inversify';
7+
import { env, UIKind } from 'vscode';
78
import { IExtensionSingleActivationService } from '../../activation/types';
89
import { IApplicationShell, IVSCodeNotebook } from '../../common/application/types';
910
import { traceError } from '../../common/logger';
@@ -27,8 +28,10 @@ export type NotebookSurveyUsageData = {
2728
@injectable()
2829
export class NotebookSurveyBanner {
2930
public get enabled(): boolean {
30-
return !this.persistentState.createGlobalPersistentState<NotebookSurveyUsageData>(storageKey, {}).value
31-
.surveyDisabled;
31+
return (
32+
!this.persistentState.createGlobalPersistentState<NotebookSurveyUsageData>(storageKey, {}).value
33+
.surveyDisabled && env.uiKind !== UIKind?.Web
34+
);
3235
}
3336
private disabledInCurrentSession: boolean = false;
3437
constructor(

src/client/debugger/extension/banner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'use strict';
55

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

6565
public async shouldShow(): Promise<boolean> {
66-
if (!this.isEnabled() || this.disabledInCurrentSession) {
66+
if (!this.isEnabled() || this.disabledInCurrentSession || env.uiKind === UIKind?.Web) {
6767
return false;
6868
}
6969
if (!(await this.passedThreshold())) {

0 commit comments

Comments
 (0)