A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/app/scripts/controllers/ab-test.js

57 lines
1.7 KiB

import ObservableStore from 'obs-store'
import { getRandomArrayItem } from '../lib/util'
/**
* a/b test descriptions:
* - `fullScreenVsPopup`:
* - description: tests whether showing tx confirmations in full screen in the browser will increase rates of successful
* confirmations
* - groups:
* - popup: this is the control group, which follows the current UX of showing tx confirmations in the notification
* window
* - fullScreen: this is the only test group, which will cause users to be shown tx confirmations in a full screen
* browser tab
*/
class ABTestController {
/**
* @constructor
* @param opts
*/
constructor (opts = {}) {
const { initState } = opts
this.store = new ObservableStore(Object.assign({
abTests: {
fullScreenVsPopup: this._getRandomizedTestGroupName('fullScreenVsPopup'),
},
}, initState))
}
/**
* Returns the name of the test group to which the current user has been assigned
* @param {string} abTestKey - the key of the a/b test
* @returns {string} - the name of the assigned test group
*/
getAssignedABTestGroupName (abTestKey) {
return this.store.getState().abTests[abTestKey]
}
/**
* Returns a randomly chosen name of a test group from a given a/b test
* @param {string} abTestKey - the key of the a/b test
* @returns {string} - the name of the randomly selected test group
* @private
*/
_getRandomizedTestGroupName (abTestKey) {
const nameArray = ABTestController.abTestGroupNames[abTestKey]
return getRandomArrayItem(nameArray)
}
}
ABTestController.abTestGroupNames = {
fullScreenVsPopup: ['control', 'fullScreen'],
}
export default ABTestController