Added experiment for firefox download promo
This commit is contained in:
parent
d0d41b743a
commit
e7fdf76120
20 changed files with 222 additions and 106 deletions
|
@ -1,6 +1,28 @@
|
|||
import hash from 'string-hash';
|
||||
|
||||
const experiments = {};
|
||||
const experiments = {
|
||||
'SyI-hI7gT9agiH-f3f0BYg': {
|
||||
id: 'SyI-hI7gT9agiH-f3f0BYg',
|
||||
run: function(variant, state, emitter) {
|
||||
state.promo = variant === 1 ? 'body' : 'header';
|
||||
emitter.emit('render');
|
||||
},
|
||||
eligible: function() {
|
||||
return (
|
||||
!/firefox/i.test(navigator.userAgent) &&
|
||||
document.querySelector('html').lang === 'en-US'
|
||||
);
|
||||
},
|
||||
variant: function(state) {
|
||||
return this.luckyNumber(state) > 0.5 ? 1 : 0;
|
||||
},
|
||||
luckyNumber: function(state) {
|
||||
return luckyNumber(
|
||||
`${this.id}:${state.storage.get('testpilot_ga__cid')}`
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Returns a number between 0 and 1
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
@ -32,12 +54,12 @@ export default function initialize(state, emitter) {
|
|||
checkExperiments(state, emitter);
|
||||
});
|
||||
} else {
|
||||
const enrolled = state.storage.enrolled;
|
||||
enrolled.forEach(([id, variant]) => {
|
||||
const enrolled = state.storage.enrolled.filter(([id, variant]) => {
|
||||
const xp = experiments[id];
|
||||
if (xp) {
|
||||
xp.run(variant, state, emitter);
|
||||
}
|
||||
return !!xp;
|
||||
});
|
||||
// single experiment per session for now
|
||||
if (enrolled.length === 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue