Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(clientId: string, userId: string) {
expect.toBeTrue(Analytics.IdFormat.test(clientId));
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);
public applyUpdates() {
expect.toBeTrue(this.state === State.DownloadedUpdates, 'Cannot restart until updates are downloaded');
log.info('DefaultUpdater', 'restart and apply updates');
try {
autoUpdater.quitAndInstall();
} catch (error) {
this.onError(error);
}
}
constructor(public readonly path: string) {
expect.toExist(path);
expect.toBeTrue(path.startsWith('/'));
}
}
public reportPageView(path: string) {
expect.toExist(path);
expect.toBeTrue(path.startsWith('/'));
log.info('Analytics', 'reportPageView', path);
this.visitor.pageview(path, this.errorHandler);
}
public applyUpdates() {
expect.toBeTrue(this.state === State.UpdatesAvailable, 'Cannot download and restart until updates available');
log.info('MacOSUpdater', 'download');
try {
shell.openExternal(this.downloadUrl);
} catch (error) {
this.onError(error);
}
}
public reportDuration(category: string, variable: string, time: number) {
expect.toExist(category);
expect.toExist(variable);
expect.toBeTrue(time >= 0);
log.info('Analytics', 'reportDuration', category, variable, time);
this.visitor.timing(category, variable, time, this.errorHandler);
}
public start() {
expect.toBeTrue(this.state === State.Idle, 'Cannot start unless state is Idle');
log.info('DefaultUpdater', 'start');
autoUpdater.autoDownload = true;
autoUpdater.logger = null;
autoUpdater.on('checking-for-update', () => this.onCheckingForUpdates());
autoUpdater.on('update-available', (version: UpdateInfo) => this.onUpdateAvailable(version));
autoUpdater.on('update-not-available', (version: UpdateInfo) => this.onUpdateNotAvailable(version));
autoUpdater.on('download-progress', (progress: ProgressInfo) => this.onDownloadProgress(progress));
autoUpdater.on('update-downloaded', (version: UpdateInfo) => this.onUpdateDownloaded(version));
autoUpdater.on('error', (error: Error) => this.onError(error));
}
public start() {
expect.toBeTrue(this.state === State.Idle, 'Cannot start unless state is Idle');
log.info('MacOSUpdater', 'start');
autoUpdater.autoDownload = false;
autoUpdater.logger = null;
autoUpdater.on('checking-for-update', () => this.onCheckingForUpdates());
autoUpdater.on('update-available', async (version: UpdateInfo) => await this.onUpdateAvailable(version));
autoUpdater.on('update-not-available', (version: UpdateInfo) => this.onUpdateNotAvailable(version));
autoUpdater.on('error', (error: Error) => this.onError(error));
}