Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
expect.toBeTrue(Analytics.IdFormat.test(userId));
const trackingId: string = (config as any).analytics.trackingId;
log.info('Analytics', 'tracking id', trackingId.slice(0, 7) + '*******');
log.info('Analytics', 'client id', clientId);
log.info('Analytics', 'user id', userId);
const options: ua.VisitorOptions = {
tid: trackingId,
cid: clientId,
uid: userId,
https: true,
};
this.visitor = new ua.Visitor(options);
// Register for messages sent from the renderer
ipcMain.on(
AnalyticsChannelName.ReportEventWithValue,
(event: any, arg: ValueEvent) => this.reportEventWithValue(arg.category, arg.action, arg.label, arg.value));
ipcMain.on(
AnalyticsChannelName.ReportPageView,
(event: any, arg: PageViewEvent) => this.reportPageView(arg.path));
ipcMain.on(
AnalyticsChannelName.ReportException,
(event: any, arg: ExceptionEvent) => this.reportException(arg.description));
}
return new Promise(resolve => {
// check if the user has opted in to tracking
if (optIn()) {
const params = {
ec: fcVersion + ' - ' + category,
ea: getOS(),
el: message,
};
const analytics: Visitor = new Visitor(GA_TRACKING_ID, vscode.window.forceCode.uuid);
analytics
.event(params, response => {
if (!response) {
// according to universal-analytics, no response from the callback is a success
resolve(true);
}
resolve(false);
})
.send();
} else {
resolve(false);
}
});
}