Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(discoveryService: DiscoveryService) {
expect.toExist(discoveryService);
this.discoveryService = discoveryService;
this.discoveryService.onHello((device) => this.onResponse(device));
this.discoveryService.onGoodbye((device) => this.onResponse(device));
// Trigger the initial search
this.discoveryService.search();
// Trigger search every 10 seconds
setInterval(() => this.discoveryService.search(), 10000);
// Trigger check for unresponsive devices every 5 seconds
setInterval(() => this.findAndUpdateUnresponsiveDevices(), 5000);
}
constructor(analytics: Analytics, window: Electron.BrowserWindow) {
expect.toExist(analytics);
expect.toExist(window);
this.updater = this.createUpdater(analytics, window);
// Register for messages sent from the renderer
ipcMain.on(ApplicationUpdatesChannelName.Check, () => this.checkForUpdates());
ipcMain.on(ApplicationUpdatesChannelName.Apply, () => this.applyUpdates());
}
export const addHeartbeat: Mutation = (state: State, mutation: Heartbeat) => {
expect.toExist(state);
expect.toExist(mutation);
let heartbeats = state[mutation.macAddress];
if (!heartbeats) {
heartbeats = [];
Vue.set(state, mutation.macAddress, heartbeats);
}
// Add heartbeat
heartbeats.push(mutation.timestamp);
// Remove heartbeats that are to old
const now = new Date();
while (heartbeats.length > 0 && now.getTime() - heartbeats[0].getTime() > historyDuration) {
heartbeats.splice(0, 1);
}
};
export const addHeartbeat: Mutation = (state: State, mutation: Heartbeat) => {
expect.toExist(state);
expect.toExist(mutation);
let heartbeats = state[mutation.macAddress];
if (!heartbeats) {
heartbeats = [];
Vue.set(state, mutation.macAddress, heartbeats);
}
// Add heartbeat
heartbeats.push(mutation.timestamp);
// Remove heartbeats that are to old
const now = new Date();
while (heartbeats.length > 0 && now.getTime() - heartbeats[0].getTime() > historyDuration) {
heartbeats.splice(0, 1);
}
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);
constructor(analytics: Analytics, webContents: Electron.WebContents) {
expect.toExist(analytics);
expect.toExist(webContents);
this.analytics = analytics;
this.webContents = webContents;
this.state = State.Idle;
}
public reportEventWithValue(category: string, action: string, label: string, value?: number) {
expect.toExist(category);
expect.toExist(action);
expect.toExist(label);
log.info('Analytics', 'reportEventWithValue', category, action, label, value);
if (value) {
this.visitor.event(category, action, label, value, this.errorHandler);
} else {
this.visitor.event(category, action, label, this.errorHandler);
}
}
public reportEvent(category: string, action: string) {
expect.toExist(category);
expect.toExist(action);
log.info('Analytics', 'reportEvent', category, action);
this.visitor.event(category, action, this.errorHandler);
}
export const disconnectDevice: Mutation = (state: State, mutation: Device) => {
expect.toExist(state);
expect.toExist(mutation);
const index = indexOf(mutation, state);
if (index > -1) {
state[index].networkStatus.isResponsive = false;
}
};
constructor(analytics: Analytics, webContents: Electron.WebContents) {
expect.toExist(analytics);
expect.toExist(webContents);
this.analytics = analytics;
this.webContents = webContents;
this.gitHub = new GitHub();
this.state = State.Idle;
}