Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add slush time for survey activation #2266

Merged
merged 2 commits into from
Sep 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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