-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(settings): Rollout new account recovery flow at 15%
Because: * We want to rollout the new account recovery key creation flow to 15% of users before rolling out to 100% on prod. This commit: * Add NewRecoveryKeyUI experiment with 15% rollout * Passes experiment group to Settings App, allows forceExperiment * Conditionally render new UI if user is in treatment group AND feature flag is turned on * Update related tests Closes #FXA-8030 Co-authored-by: Lauren Zugai <lauren@zugai.com>
- Loading branch information
Showing
20 changed files
with
170 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...ages/fxa-content-server/app/scripts/lib/experiments/grouping-rules/new-recovery-key-UI.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
/** | ||
* Feature flag for new account recovery key UI. | ||
* | ||
*/ | ||
'use strict'; | ||
|
||
const BaseGroupingRule = require('./base'); | ||
|
||
const GROUPS = [ | ||
'control', | ||
// Treatment branch is the new account recovery key creation flow | ||
'treatment', | ||
]; | ||
|
||
// This experiment is disabled by default. If you would like to go through | ||
// the flow, load email-first screen and append query params | ||
// `?forceExperiment=newRecoveryKeyUI&forceExperimentGroup=treatment` | ||
const ROLLOUT_RATE = 0.15; | ||
|
||
module.exports = class NewRecoveryKeyUI extends BaseGroupingRule { | ||
constructor() { | ||
super(); | ||
this.name = 'newRecoveryKeyUI'; | ||
this.groups = GROUPS; | ||
this.rolloutRate = ROLLOUT_RATE; | ||
} | ||
|
||
/** | ||
* Enable new recovery key creation flow if user is in the treatment group. | ||
* | ||
* @param {Object} subject data used to decide | ||
* @returns {Any} | ||
*/ | ||
choose(subject = {}) { | ||
let choice = false; | ||
|
||
if (this.bernoulliTrial(this.rolloutRate, subject.uniqueUserId)) { | ||
choice = this.uniformChoice(GROUPS, subject.uniqueUserId); | ||
} | ||
|
||
return choice; | ||
} | ||
}; |
15 changes: 15 additions & 0 deletions
15
packages/fxa-content-server/app/scripts/lib/new-recovery-key-UI-experiment-mixin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import ExperimentMixin from '../views/mixins/experiment-mixin'; | ||
|
||
export default { | ||
dependsOn: [ExperimentMixin], | ||
|
||
isInNewRecoveryKeyUIExperiment() { | ||
const experimentGroup = | ||
this.getAndReportExperimentGroup('newRecoveryKeyUI'); | ||
return experimentGroup === 'treatment'; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...s/fxa-content-server/app/tests/spec/lib/experiments/grouping-rules/new-recovery-key-UI.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import { assert } from 'chai'; | ||
import Experiment from 'lib/experiments/grouping-rules/new-recovery-key-UI'; | ||
|
||
describe('lib/experiments/grouping-rules/new-recovery-key-UI', () => { | ||
let experiment; | ||
|
||
beforeEach(() => { | ||
experiment = new Experiment(); | ||
}); | ||
|
||
describe('choose', () => { | ||
it('returns treatment if valid clientId', () => { | ||
const rules = experiment.groups; | ||
assert.isTrue( | ||
rules.include( | ||
experiment.choose({ | ||
experimentGroupingRules: { choose: () => experiment.name }, | ||
uniqueUserId: 'user-id', | ||
}) | ||
) | ||
); | ||
}); | ||
|
||
it('returns false if rollout 0%', () => { | ||
experiment.rolloutRate = 0; | ||
assert.isFalse( | ||
experiment.choose({ | ||
experimentGroupingRules: { choose: () => experiment.name }, | ||
uniqueUserId: 'user-id', | ||
}) | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.