insomnia/app/analytics/index.js
2016-11-17 15:22:23 -08:00

43 lines
752 B
JavaScript

import * as segment from './segment';
import * as google from './google';
let initialized = false;
export async function init (accountId) {
if (initialized) {
return;
}
try {
await segment.init();
await google.init(accountId);
initialized = true;
} catch (e) {
// Just to be extra safe
}
}
export function trackEvent (...args) {
try {
google.sendEvent(...args);
} catch (e) {
// Just to be extra safe
}
}
export function setAccountId (accountId) {
try {
google.setUserId(accountId);
} catch (e) {
// Just to be extra safe
}
}
export function trackLegacyEvent (event, properties) {
try {
segment.trackLegacyEvent(event, properties)
} catch (e) {
// Just to be extra safe
}
}