2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

incr: add open count and set config on win if dev

This commit is contained in:
18alantom 2022-03-11 15:15:25 +05:30
parent 67cb1620b2
commit bada1f3969
2 changed files with 19 additions and 3 deletions

View File

@ -10,6 +10,7 @@ export enum ConfigKeys {
Language = 'language',
DeviceId = 'deviceId',
Telemetry = 'telemetry',
OpenCount = 'openCount',
}
export enum TelemetrySetting {

View File

@ -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);
});
}