Skip to content

Commit

Permalink
Log when opt-in or opt-out of ALL experiments (#15144)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig authored Jan 14, 2021
1 parent d955fda commit e2bf90c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"Pylance.pylanceNotInstalledMessage": "Pylance extension is not installed.",
"Pylance.pylanceInstalledReloadPromptMessage": "Pylance extension is now installed. Reload window to activate?",
"Experiments.inGroup": "User belongs to experiment group '{0}'",
"Experiments.optedOutOf": "User opted out of experiment group '{0}'",
"Interpreters.RefreshingInterpreters": "Refreshing Python Interpreters",
"Interpreters.entireWorkspace": "Entire workspace",
"Interpreters.pythonInterpreterPath": "Python interpreter path: {0}",
Expand Down
41 changes: 39 additions & 2 deletions src/client/common/experiments/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,48 @@ export class ExperimentService implements IExperimentService {
}

private logExperiments() {
if (this._optOutFrom.includes('All')) {
// We prioritize opt out first
this.output.appendLine(Experiments.optedOutOf().format('All'));

// Since we are in the Opt Out all case, this means when checking for experiment we
// short circuit and return. So, printing out additional experiment info might cause
// confusion. So skip printing out any specific experiment details to the log.
return;
} else if (this._optInto.includes('All')) {
// Only if 'All' is not in optOut then check if it is in Opt In.
this.output.appendLine(Experiments.inGroup().format('All'));

// Similar to the opt out case. If user is opting into to all experiments we short
// circuit the experiment checks. So, skip printing any additional details to the logs.
return;
}

const experiments = this.globalState.get<{ features: string[] }>(EXP_MEMENTO_KEY, { features: [] });

// Log experiments that users manually opt out, these are experiments which are added using the exp framework.
this._optOutFrom
.filter((exp) => exp !== 'All' && exp.toLowerCase().startsWith('python'))
.forEach((exp) => {
this.output.appendLine(Experiments.optedOutOf().format(exp));
});

// Log experiments that users manually opt into, these are experiments which are added using the exp framework.
this._optInto
.filter((exp) => exp !== 'All' && exp.toLowerCase().startsWith('python'))
.forEach((exp) => {
this.output.appendLine(Experiments.inGroup().format(exp));
});

// Log experiments that users are added to by the exp framework
experiments.features.forEach((exp) => {
// Filter out experiments groups that are not from the Python extension.
if (exp.toLowerCase().startsWith('python')) {
// Filter out experiment groups that are not from the Python extension.
// Filter out experiment groups that are not already opted out or opted into.
if (
exp.toLowerCase().startsWith('python') &&
!this._optOutFrom.includes(exp) &&
!this._optInto.includes(exp)
) {
this.output.appendLine(Experiments.inGroup().format(exp));
}
});
Expand Down
1 change: 1 addition & 0 deletions src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export namespace Http {
}
export namespace Experiments {
export const inGroup = localize('Experiments.inGroup', "User belongs to experiment group '{0}'");
export const optedOutOf = localize('Experiments.optedOutOf', "User opted out of experiment group '{0}'");
}
export namespace Interpreters {
export const loading = localize('Interpreters.LoadingInterpreters', 'Loading Python Interpreters');
Expand Down

0 comments on commit e2bf90c

Please sign in to comment.