2016-11-10 01:34:03 +00:00
|
|
|
import * as segment from './segment';
|
|
|
|
import * as google from './google';
|
|
|
|
|
2016-11-10 19:08:45 +00:00
|
|
|
let initialized = false;
|
2016-11-16 17:18:39 +00:00
|
|
|
export function init (accountId) {
|
2016-11-10 19:08:45 +00:00
|
|
|
if (initialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-10 01:34:03 +00:00
|
|
|
segment.init();
|
|
|
|
google.init(accountId);
|
2016-11-10 19:08:45 +00:00
|
|
|
|
|
|
|
initialized = true;
|
2016-11-10 01:34:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function trackEvent (...args) {
|
2016-11-11 23:06:24 +00:00
|
|
|
google.sendEvent(...args);
|
2016-11-10 22:34:55 +00:00
|
|
|
console.log(`[analytics] track ${args.join(', ')}`);
|
2016-11-10 01:34:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function setAccountId (accountId) {
|
2016-11-11 23:06:24 +00:00
|
|
|
google.setUserId(accountId);
|
2016-11-10 22:34:55 +00:00
|
|
|
console.log(`[analytics] account Id ${accountId}`);
|
2016-11-10 01:34:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function trackLegacyEvent (event, properties) {
|
|
|
|
segment.trackLegacyEvent(event, properties)
|
|
|
|
}
|