added signin button color experiment. closes #1306 (#1320)

This commit is contained in:
Danny Coates 2019-05-03 10:10:56 -07:00 committed by Donovan Preston
parent b82177dc44
commit 23ecb632eb
9 changed files with 157 additions and 82 deletions

View file

@ -3,7 +3,7 @@ import { platform, locale } from './utils';
import { sendMetrics } from './api';
let appState = null;
// let experiment = null;
let experiment = null;
const HOUR = 1000 * 60 * 60;
const events = [];
let session_id = Date.now();
@ -11,11 +11,13 @@ const lang = locale();
export default function initialize(state, emitter) {
appState = state;
if (!appState.user.firstAction) {
appState.user.firstAction = appState.route === '/' ? 'upload' : 'download';
}
emitter.on('DOMContentLoaded', () => {
// experiment = storage.enrolled[0];
experiment = storage.enrolled;
if (!appState.user.firstAction) {
appState.user.firstAction =
appState.route === '/' ? 'upload' : 'download';
}
const query = appState.query;
addEvent('client_visit', {
entrypoint: appState.route === '/' ? 'upload' : 'download',
@ -59,6 +61,11 @@ function submitEvents() {
async function addEvent(event_type, event_properties) {
const user_id = await appState.user.metricId();
const device_id = await appState.user.deviceId();
const ab_id = Object.keys(experiment)[0];
if (ab_id) {
event_properties.experiment = ab_id;
event_properties.variant = experiment[ab_id];
}
events.push({
device_id,
event_properties,