From e7f11aaa0d491b13c442043891335269462df948 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Mon, 31 Aug 2020 11:55:27 -0400 Subject: [PATCH 1/2] Add slush time for survey activation --- src/telemetry/surveys/SurveyManager.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/telemetry/surveys/SurveyManager.ts b/src/telemetry/surveys/SurveyManager.ts index e9927e9614..a5547336ef 100644 --- a/src/telemetry/surveys/SurveyManager.ts +++ b/src/telemetry/surveys/SurveyManager.ts @@ -32,12 +32,16 @@ export class SurveyManager { } for (const survey of currentSurveys) { + // Generate a slush of +/- 3 seconds + // eslint-disable-next-line @typescript-eslint/tslint/config + const slush = Math.round(Math.random() * 6000) - 3000; + const timer = setTimeout( async () => { clearTimeout(timer); await this.executeSurvey(survey); }, - survey.activationDelayMs + survey.activationDelayMs + slush ); } } From b1fa0e42527cca08b823bb77cfd05a9b09801512 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Mon, 31 Aug 2020 11:56:32 -0400 Subject: [PATCH 2/2] Make it a const --- src/telemetry/surveys/SurveyManager.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/telemetry/surveys/SurveyManager.ts b/src/telemetry/surveys/SurveyManager.ts index a5547336ef..ad5e8dcbf7 100644 --- a/src/telemetry/surveys/SurveyManager.ts +++ b/src/telemetry/surveys/SurveyManager.ts @@ -16,6 +16,9 @@ const surveyRespondedKeyPrefix = 'vscode-docker.surveys.response'; const surveyFlightPrefix = 'vscode-docker.surveys'; const lastToastedSessionKey = 'vscode-docker.surveys.lastSession'; +// A random value between 0 and slushTime will be added to / subtracted from the activation delay +const slushTime = 3000; + export interface Survey { id: string; url: string; @@ -34,7 +37,7 @@ export class SurveyManager { for (const survey of currentSurveys) { // Generate a slush of +/- 3 seconds // eslint-disable-next-line @typescript-eslint/tslint/config - const slush = Math.round(Math.random() * 6000) - 3000; + const slush = Math.round(Math.random() * slushTime * 2) - slushTime; const timer = setTimeout( async () => {