diff --git a/src/config.ts b/src/config.ts index 17f0321d..847f4405 100644 --- a/src/config.ts +++ b/src/config.ts @@ -10,6 +10,7 @@ export enum ConfigKeys { Language = 'language', DeviceId = 'deviceId', Telemetry = 'telemetry', + OpenCount = 'openCount', } export enum TelemetrySetting { diff --git a/src/main.js b/src/main.js index 447b6b10..65d01eca 100644 --- a/src/main.js +++ b/src/main.js @@ -4,7 +4,7 @@ import { createApp } from 'vue'; import models from '../models'; import App from './App'; import FeatherIcon from './components/FeatherIcon'; -import config from './config'; +import config, { ConfigKeys } from './config'; import { getErrorHandled, handleError } from './errorHandling'; import { IPC_CHANNELS, IPC_MESSAGES } from './messages'; import router from './router'; @@ -17,6 +17,10 @@ import { setLanguageMap, showToast, stringifyCircular } from './utils'; await setLanguageMap(language); } + if (process.env.NODE_ENV === 'development') { + window.config = config; + } + frappe.isServer = true; frappe.isElectron = true; frappe.initializeAndRegister(models, language); @@ -85,9 +89,21 @@ import { setLanguageMap, showToast, stringifyCircular } from './utils'; console.error(err, vm, info); }; + incrementOpenCount(); app.mount('body'); })(); +function incrementOpenCount() { + let openCount = config.get(ConfigKeys.OpenCount); + if (typeof openCount !== 'number') { + openCount = 1; + } else { + openCount += 1; + } + + config.set(ConfigKeys.OpenCount, openCount); +} + function registerIpcRendererListeners() { ipcRenderer.on(IPC_CHANNELS.STORE_ON_WINDOW, (event, message) => { Object.assign(window.frappe.store, message); @@ -143,7 +159,6 @@ function registerIpcRendererListeners() { } const telemetryData = telemetry.stop(); - console.log(telemetryData); - // navigator.sendBeacon('', telemetryData) + navigator.sendBeacon('http://0.0.0.0:6969', telemetryData); }); }