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 18:16:55 +00:00
|
|
|
export async function init (accountId) {
|
2016-11-10 19:08:45 +00:00
|
|
|
if (initialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-17 21:22:19 +00:00
|
|
|
try {
|
|
|
|
await segment.init();
|
|
|
|
await google.init(accountId);
|
2016-11-10 19:08:45 +00:00
|
|
|
|
2016-11-17 21:22:19 +00:00
|
|
|
initialized = true;
|
|
|
|
} catch (e) {
|
|
|
|
// Just to be extra safe
|
|
|
|
}
|
2016-11-10 01:34:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function trackEvent (...args) {
|
2016-11-17 21:22:19 +00:00
|
|
|
try {
|
|
|
|
google.sendEvent(...args);
|
|
|
|
} catch (e) {
|
|
|
|
// Just to be extra safe
|
|
|
|
}
|
2016-11-10 01:34:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function setAccountId (accountId) {
|
2016-11-17 21:22:19 +00:00
|
|
|
try {
|
|
|
|
google.setUserId(accountId);
|
|
|
|
} catch (e) {
|
|
|
|
// Just to be extra safe
|
|
|
|
}
|
2016-11-10 01:34:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function trackLegacyEvent (event, properties) {
|
2016-11-17 21:22:19 +00:00
|
|
|
try {
|
|
|
|
segment.trackLegacyEvent(event, properties)
|
|
|
|
} catch (e) {
|
|
|
|
// Just to be extra safe
|
|
|
|
}
|
2016-11-10 01:34:03 +00:00
|
|
|
}
|