mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
45 lines
865 B
JavaScript
45 lines
865 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);
|
|
console.log(`[analytics] track ${args.join(', ')}`);
|
|
} catch (e) {
|
|
// Just to be extra safe
|
|
}
|
|
}
|
|
|
|
export function setAccountId (accountId) {
|
|
try {
|
|
google.setUserId(accountId);
|
|
console.log(`[analytics] account Id ${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
|
|
}
|
|
}
|