insomnia/app/analytics/index.js
Gregory Schier d58edf1d25 Cleanup before major team features (#72)
* Started on UI makeover for teams

* Some small tweaks and fixes

* Adjusted settings
2016-12-21 15:37:48 -08:00

41 lines
942 B
JavaScript

import * as segment from './segment';
import * as google from './google';
import {ipcRenderer} from 'electron';
import {getAppVersion, getAppPlatform} from '../common/constants';
let initialized = false;
export async function init (accountId) {
if (initialized) {
return;
}
await segment.init();
await google.init(accountId, getAppPlatform(), getAppVersion());
initialized = true;
ipcRenderer.on('analytics-track-event', (_, args) => {
trackEvent(...args);
});
}
export function trackEvent (...args) {
// Do on next tick in case it fails or blocks
process.nextTick(() => {
google.sendEvent(...args);
});
}
export function setAccountId (accountId) {
// Do on next tick in case it fails or blocks
process.nextTick(() => {
google.setUserId(accountId);
});
}
export function trackLegacyEvent (event, properties) {
process.nextTick(() => {
segment.trackLegacyEvent(event, properties)
});
}