mirror of
https://github.com/frappe/books.git
synced 2024-11-08 14:50:56 +00:00
fix: minor fixes to telemetry
This commit is contained in:
parent
2c596b11c8
commit
2392dbe2fd
@ -25,11 +25,17 @@ export function getDeviceId(fyo: Fyo): UniqueId {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
export function getInstanceId(fyo: Fyo): UniqueId {
|
||||
const files = (fyo.config.get(ConfigKeys.Files) ?? []) as ConfigFile[];
|
||||
const instanceId = fyo.singles.SystemSettings!.instanceId as string;
|
||||
export async function getInstanceId(fyo: Fyo): Promise<UniqueId> {
|
||||
const instanceId = (await fyo.getValue(
|
||||
ModelNameEnum.SystemSettings,
|
||||
'instanceId'
|
||||
)) as string;
|
||||
const companyName = (await fyo.getValue(
|
||||
ModelNameEnum.AccountingSettings,
|
||||
'companyName'
|
||||
)) as string;
|
||||
const dbPath = fyo.db.dbPath!;
|
||||
const companyName = fyo.singles.AccountingSettings!.companyName as string;
|
||||
const files = (fyo.config.get(ConfigKeys.Files) ?? []) as ConfigFile[];
|
||||
|
||||
let file = files.find((f) => f.id === instanceId);
|
||||
|
||||
|
@ -65,8 +65,8 @@ export class TelemetryManager {
|
||||
async start(openCount?: number) {
|
||||
this.#telemetryObject.country ||= getCountry(this.fyo);
|
||||
this.#telemetryObject.language ??= getLanguage(this.fyo);
|
||||
this.#telemetryObject.device ||= getDeviceId(this.fyo);
|
||||
this.#telemetryObject.instance ||= getInstanceId(this.fyo);
|
||||
this.#telemetryObject.deviceId ||= getDeviceId(this.fyo);
|
||||
this.#telemetryObject.instanceId ||= await getInstanceId(this.fyo);
|
||||
this.#telemetryObject.version ||= await getVersion(this.fyo);
|
||||
|
||||
this.#started = true;
|
||||
@ -91,7 +91,7 @@ export class TelemetryManager {
|
||||
}
|
||||
|
||||
log(verb: Verb, noun: Noun, more?: Record<string, unknown>) {
|
||||
if (!this.#started) {
|
||||
if (!this.#started && this.fyo.db.isConnected) {
|
||||
this.start().then(() => this.#sendBeacon(verb, noun, more));
|
||||
return;
|
||||
}
|
||||
@ -131,8 +131,8 @@ export class TelemetryManager {
|
||||
return {
|
||||
country: this.#telemetryObject.country!,
|
||||
language: this.#telemetryObject.language!,
|
||||
device: this.#telemetryObject.device!,
|
||||
instance: this.#telemetryObject.instance!,
|
||||
deviceId: this.#telemetryObject.deviceId!,
|
||||
instanceId: this.#telemetryObject.instanceId!,
|
||||
version: this.#telemetryObject.version!,
|
||||
openCount: this.#telemetryObject.openCount!,
|
||||
timestamp: DateTime.now().toMillis().toString(),
|
||||
@ -145,8 +145,8 @@ export class TelemetryManager {
|
||||
#clear() {
|
||||
delete this.#telemetryObject.country;
|
||||
delete this.#telemetryObject.language;
|
||||
delete this.#telemetryObject.device;
|
||||
delete this.#telemetryObject.instance;
|
||||
delete this.#telemetryObject.deviceId;
|
||||
delete this.#telemetryObject.instanceId;
|
||||
delete this.#telemetryObject.version;
|
||||
delete this.#telemetryObject.openCount;
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ export enum Verb {
|
||||
export type Noun = string;
|
||||
|
||||
export interface Telemetry {
|
||||
device: UniqueId;
|
||||
instance: UniqueId;
|
||||
deviceId: UniqueId;
|
||||
instanceId: UniqueId;
|
||||
platform?: Platform;
|
||||
country: string;
|
||||
language: string;
|
||||
|
Loading…
Reference in New Issue
Block a user