parent
b82177dc44
commit
23ecb632eb
9 changed files with 157 additions and 82 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue