From 148edbe73c970e0efd9f2cc3868104d8e6ee1a6f Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Tue, 8 Sep 2020 12:44:44 -0400 Subject: [PATCH] Add slush time for survey activation (#2266) --- src/telemetry/surveys/SurveyManager.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/telemetry/surveys/SurveyManager.ts b/src/telemetry/surveys/SurveyManager.ts index e9927e9614..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; @@ -32,12 +35,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() * slushTime * 2) - slushTime; + const timer = setTimeout( async () => { clearTimeout(timer); await this.executeSurvey(survey); }, - survey.activationDelayMs + survey.activationDelayMs + slush ); } }