mirror of
https://github.com/frappe/books.git
synced 2025-02-14 01:40:26 +00:00
incr: complete telemetry sending of data
This commit is contained in:
parent
c295ba0416
commit
e348d14849
@ -15,7 +15,7 @@ import { autoUpdater } from 'electron-updater';
|
|||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib';
|
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib';
|
||||||
import { sendError } from './contactMothership';
|
import { getUrlAndTokenString, sendError } from './contactMothership';
|
||||||
import { getLanguageMap } from './getLanguageMap';
|
import { getLanguageMap } from './getLanguageMap';
|
||||||
import { IPC_ACTIONS, IPC_CHANNELS, IPC_MESSAGES } from './messages';
|
import { IPC_ACTIONS, IPC_CHANNELS, IPC_MESSAGES } from './messages';
|
||||||
import saveHtmlAsPdf from './saveHtmlAsPdf';
|
import saveHtmlAsPdf from './saveHtmlAsPdf';
|
||||||
@ -261,6 +261,10 @@ ipcMain.handle(IPC_ACTIONS.GET_FILE, async (event, options) => {
|
|||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle(IPC_ACTIONS.GET_CREDS, async (event) => {
|
||||||
|
return await getUrlAndTokenString();
|
||||||
|
});
|
||||||
|
|
||||||
/* ------------------------------
|
/* ------------------------------
|
||||||
* Register autoUpdater events lis
|
* Register autoUpdater events lis
|
||||||
* ------------------------------*/
|
* ------------------------------*/
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
|
import { ipcRenderer } from 'electron';
|
||||||
import SQLiteDatabase from 'frappe/backends/sqlite';
|
import SQLiteDatabase from 'frappe/backends/sqlite';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import models from '../models';
|
import models from '../models';
|
||||||
import regionalModelUpdates from '../models/regionalModelUpdates';
|
import regionalModelUpdates from '../models/regionalModelUpdates';
|
||||||
import postStart, { setCurrencySymbols } from '../server/postStart';
|
import postStart, { setCurrencySymbols } from '../server/postStart';
|
||||||
import { DB_CONN_FAILURE } from './messages';
|
import { DB_CONN_FAILURE, IPC_ACTIONS } from './messages';
|
||||||
import runMigrate from './migrate';
|
import runMigrate from './migrate';
|
||||||
import { getId } from './telemetry/helpers';
|
import { getId } from './telemetry/helpers';
|
||||||
import telemetry from './telemetry/telemetry';
|
import telemetry from './telemetry/telemetry';
|
||||||
@ -96,9 +97,11 @@ export async function connectToLocalDatabase(filePath) {
|
|||||||
|
|
||||||
// second init with currency, normal usage
|
// second init with currency, normal usage
|
||||||
await callInitializeMoneyMaker();
|
await callInitializeMoneyMaker();
|
||||||
|
const creds = await ipcRenderer.invoke(IPC_ACTIONS.GET_CREDS);
|
||||||
|
telemetry.setCreds(creds?.telemetryUrl ?? '', creds?.tokenString ?? '');
|
||||||
telemetry.start();
|
telemetry.start();
|
||||||
await telemetry.setCount();
|
await telemetry.setCount();
|
||||||
|
|
||||||
return { connectionSuccess: true, reason: '' };
|
return { connectionSuccess: true, reason: '' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ function registerIpcRendererListeners() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const telemetryData = telemetry.stop();
|
const { url, data } = telemetry.stop();
|
||||||
navigator.sendBeacon('http://0.0.0.0:6969', telemetryData);
|
navigator.sendBeacon(url, data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ export const IPC_ACTIONS = {
|
|||||||
GET_LANGUAGE_MAP: 'get-language-map',
|
GET_LANGUAGE_MAP: 'get-language-map',
|
||||||
CHECK_FOR_UPDATES: 'check-for-updates',
|
CHECK_FOR_UPDATES: 'check-for-updates',
|
||||||
GET_FILE: 'get-file',
|
GET_FILE: 'get-file',
|
||||||
|
GET_CREDS: 'get-creds',
|
||||||
};
|
};
|
||||||
|
|
||||||
// ipcMain.send(...)
|
// ipcMain.send(...)
|
||||||
|
@ -5,6 +5,8 @@ import { getCounts, getDeviceId, getInstanceId, getLocale } from './helpers';
|
|||||||
import { Noun, Telemetry, Verb } from './types';
|
import { Noun, Telemetry, Verb } from './types';
|
||||||
|
|
||||||
class TelemetryManager {
|
class TelemetryManager {
|
||||||
|
#url: string = '';
|
||||||
|
#token: string = '';
|
||||||
#started = false;
|
#started = false;
|
||||||
#telemetryObject: Partial<Telemetry> = {};
|
#telemetryObject: Partial<Telemetry> = {};
|
||||||
|
|
||||||
@ -23,6 +25,11 @@ class TelemetryManager {
|
|||||||
return telemetrySetting === TelemetrySetting.allow;
|
return telemetrySetting === TelemetrySetting.allow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setCreds(url: string, token: string) {
|
||||||
|
this.#url ||= url;
|
||||||
|
this.#token ||= token;
|
||||||
|
}
|
||||||
|
|
||||||
log(verb: Verb, noun: Noun, more?: Record<string, unknown>) {
|
log(verb: Verb, noun: Noun, more?: Record<string, unknown>) {
|
||||||
if (!this.#started) {
|
if (!this.#started) {
|
||||||
this.start();
|
this.start();
|
||||||
@ -70,7 +77,12 @@ class TelemetryManager {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON.stringify(telemetryObject);
|
const data = JSON.stringify({
|
||||||
|
token: this.#token,
|
||||||
|
telemetryData: telemetryObject,
|
||||||
|
});
|
||||||
|
|
||||||
|
return { url: this.#url, data };
|
||||||
}
|
}
|
||||||
|
|
||||||
get telemetryObject(): Readonly<Partial<Telemetry>> {
|
get telemetryObject(): Readonly<Partial<Telemetry>> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user