Skip to content

Commit

Permalink
Add slush time for survey activation (#2266)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwateratmsft authored Sep 8, 2020
1 parent 6e3a4a0 commit 148edbe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/telemetry/surveys/SurveyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
);
}
}
Expand Down

0 comments on commit 148edbe

Please sign in to comment.