Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed AB test variants attached to keen analytics #79

Open
wants to merge 1 commit into
base: minicore
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/clientapi/analytics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import pixel from 'facebook-pixel';

import { merge, logger } from 'base';

const BATCH_UPDATE_INTERVAL = 5000;

/**
* Ployfill for toISOString from:
Expand Down Expand Up @@ -46,6 +47,7 @@ class Analytics {
this.eventQueue = [];
this.sessionData = {};
this._amplitudeClient = null;
this._abTestVariants = null;
this.pixelEnabled = false;
}

Expand Down Expand Up @@ -115,9 +117,7 @@ class Analytics {
output: 'parsed_user_agent'
}, {
name: 'keen:date_time_parser',
input: {
date_time: 'timestamp',
},
input: { date_time: 'timestamp' },
output: 'timestamp_info'
}]
};
Expand All @@ -139,7 +139,7 @@ class Analytics {

this.processEventQueue();

window.setInterval(() => this.processEventQueue(), 5000);
window.setInterval(() => this.processEventQueue(), BATCH_UPDATE_INTERVAL);
}

/**
Expand Down Expand Up @@ -237,6 +237,10 @@ class Analytics {
data.keen = this.keenAddons;
data.userProperties = merge({}, this.userProperties);

if (this._abTestVariants) {
data.abTestVariants = this._abTestVariants;
}

// special nested ab tests for Keen
if (GC.app && GC.app.abTests) {
GC.app.abTests.applyKeenData(data);
Expand All @@ -258,11 +262,10 @@ class Analytics {
}

/**
* Keen.io API for tracking AB Tests
* API for tracking AB Tests
*/

setABTestVariants (data) {
keen.setABTestVariants(data);
this._abTestVariants = this._abTestVariants ? merge(data, this._abTestVariants) : merge({}, data);
}

/**
Expand Down