-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry pick several things for 0.8.2 release (#1367)
* Update package * Cherry pick clearer error message for duplicate registry * Cherry pick improved Dockerfile pattern matches, save event telemetry * Cherry pick only refresh if VSCode is in focus * Cherry pick add a command to create the simplest network * Cherry pick ask some active users to take NPS survey
- Loading branch information
1 parent
9125a19
commit f3a3e9f
Showing
11 changed files
with
204 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { window } from 'vscode'; | ||
import { IActionContext } from 'vscode-azureextensionui'; | ||
import { ext } from '../../extensionVariables'; | ||
|
||
export async function createNetwork(_context: IActionContext): Promise<void> { | ||
|
||
const name = await ext.ui.showInputBox({ | ||
value: '', | ||
prompt: 'Name of the network' | ||
}); | ||
|
||
const driverSelection = await ext.ui.showQuickPick( | ||
[ | ||
{ label: 'bridge' }, | ||
{ label: 'host' }, | ||
{ label: 'overlay' }, | ||
{ label: 'macvlan' } | ||
], | ||
{ | ||
canPickMany: false, | ||
placeHolder: 'Select the network driver to use (default is "bridge").' | ||
} | ||
); | ||
|
||
const result = <{ id: string }>await ext.dockerode.createNetwork({ Name: name, Driver: driverSelection.label }); | ||
|
||
window.showInformationMessage(`Network Created with ID ${result.id.substr(0, 12)}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE.md in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { ExtensionContext, TextDocument, workspace } from 'vscode'; | ||
import { ext } from './extensionVariables'; | ||
|
||
let lastUploadTime: number = 0; | ||
const hourInMilliseconds = 1000 * 60 * 60; | ||
|
||
export function registerListeners(ctx: ExtensionContext): void { | ||
ctx.subscriptions.push(workspace.onDidSaveTextDocument(onDidSaveTextDocument)); | ||
} | ||
|
||
function onDidSaveTextDocument(doc: TextDocument): void { | ||
// If it's not a Dockerfile, or last upload time is within an hour, skip | ||
if (doc.languageId !== 'dockerfile' || lastUploadTime + hourInMilliseconds > Date.now()) { | ||
return; | ||
} | ||
|
||
lastUploadTime = Date.now(); | ||
ext.reporter.sendTelemetryEvent('dockerfilesave', { "lineCount": doc.lineCount.toString() }, {}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.md in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
// Loosely adapted from https://github.com/microsoft/vscode-azure-account/blob/2f497562cab5f3db09f983ab5101040f27dceb70/src/nps.ts | ||
|
||
import { env, Memento, Uri, window } from "vscode"; | ||
import { ext } from "vscode-azureappservice/out/src/extensionVariables"; | ||
|
||
const PROBABILITY = 0.15; | ||
const MIN_SESSION_COUNT = 10; | ||
|
||
const SURVEY_NAME = 'nps1'; | ||
const SURVEY_URL = 'https://aka.ms/vscodedockernpsinproduct'; | ||
|
||
const SESSION_COUNT_KEY = `${SURVEY_NAME}/sessioncount`; | ||
const LAST_SESSION_DATE_KEY = `${SURVEY_NAME}/lastsessiondate`; | ||
const IS_CANDIDATE_KEY = `${SURVEY_NAME}/iscandidate`; | ||
|
||
export async function nps(globalState: Memento): Promise<void> { | ||
try { | ||
// If not English-language, don't ask | ||
if (env.language !== 'en' && !env.language.startsWith('en-')) { | ||
return; | ||
} | ||
|
||
let isCandidate: boolean | undefined = globalState.get(IS_CANDIDATE_KEY); | ||
|
||
// If not a candidate, don't ask | ||
if (isCandidate === false) { | ||
return; | ||
} | ||
|
||
const date = new Date().toDateString(); | ||
const lastSessionDate = globalState.get(LAST_SESSION_DATE_KEY, new Date(0).toDateString()); | ||
|
||
// If this session is on same date as last session, don't count it | ||
if (date === lastSessionDate) { | ||
return; | ||
} | ||
|
||
// Count this session | ||
const sessionCount = globalState.get(SESSION_COUNT_KEY, 0) + 1; | ||
await globalState.update(LAST_SESSION_DATE_KEY, date); | ||
await globalState.update(SESSION_COUNT_KEY, sessionCount); | ||
|
||
// If under the MIN_SESSION_COUNT, don't ask | ||
if (sessionCount < MIN_SESSION_COUNT) { | ||
return; | ||
} | ||
|
||
// Decide if they are a candidate (if we previously decided they are and they did Remind Me Later, we will not do probability again) | ||
// i.e. Probability only comes into play if isCandidate is undefined | ||
// tslint:disable-next-line: insecure-random | ||
isCandidate = isCandidate || Math.random() < PROBABILITY; | ||
await globalState.update(IS_CANDIDATE_KEY, isCandidate); | ||
|
||
// If not a candidate, don't ask | ||
if (!isCandidate) { | ||
return; | ||
} | ||
|
||
const take = { title: 'Take Survey', telName: 'take' }; | ||
const remind = { title: 'Remind Me Later', telName: 'remind' }; | ||
const never = { title: 'Don\'t Show Again', telName: 'never' }; | ||
|
||
// Prompt, treating hitting X as Remind Me Later | ||
const result = (await window.showInformationMessage('Do you mind taking a quick feedback survey about the Docker Extension for VS Code?', take, remind, never)) || remind; | ||
|
||
ext.reporter.sendTelemetryEvent('nps', { survey: SURVEY_NAME, response: result.telName }); | ||
|
||
if (result === take) { | ||
// If they hit Take, don't ask again (for this survey name), and open the survey | ||
await globalState.update(IS_CANDIDATE_KEY, false); | ||
await env.openExternal(Uri.parse(`${SURVEY_URL}?o=${encodeURIComponent(process.platform)}&m=${encodeURIComponent(env.machineId)}`)); | ||
} else if (result === remind) { | ||
// If they hit the X or Remind Me Later, ask again in 3 sessions | ||
await globalState.update(SESSION_COUNT_KEY, MIN_SESSION_COUNT - 3); | ||
} else if (result === never) { | ||
// If they hit Never, don't ask again (for this survey name) | ||
await globalState.update(IS_CANDIDATE_KEY, false); | ||
} | ||
} catch { } // Best effort | ||
} |