mirror of
https://github.com/frappe/books.git
synced 2025-04-02 08:11:52 +00:00
fix: log level checks
This commit is contained in:
parent
2e67dddc09
commit
132edff44b
@ -12,10 +12,16 @@ export enum ConfigKeys {
|
|||||||
Telemetry = 'telemetry',
|
Telemetry = 'telemetry',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum TelemetrySetting {
|
||||||
|
allow = 'allow',
|
||||||
|
dontLogUsage = 'dontLogUsage',
|
||||||
|
dontLogAnything = 'dontLogAnything',
|
||||||
|
}
|
||||||
|
|
||||||
export const telemetryOptions = {
|
export const telemetryOptions = {
|
||||||
allow: frappe.t`Allow Telemetry`,
|
[TelemetrySetting.allow]: frappe.t`Allow Telemetry`,
|
||||||
dontLogUsage: frappe.t`Don't Log Usage`,
|
[TelemetrySetting.dontLogUsage]: frappe.t`Don't Log Usage`,
|
||||||
dontLogAnything: frappe.t`Don't Log Anything`,
|
[TelemetrySetting.dontLogAnything]: frappe.t`Don't Log Anything`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface ConfigFile {
|
export interface ConfigFile {
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
ValidationError,
|
ValidationError,
|
||||||
} from 'frappe/common/errors';
|
} from 'frappe/common/errors';
|
||||||
import BaseDocument from 'frappe/model/document';
|
import BaseDocument from 'frappe/model/document';
|
||||||
import config, { ConfigKeys, telemetryOptions } from './config';
|
import config, { ConfigKeys, TelemetrySetting } from './config';
|
||||||
import { IPC_ACTIONS, IPC_MESSAGES } from './messages';
|
import { IPC_ACTIONS, IPC_MESSAGES } from './messages';
|
||||||
import telemetry from './telemetry/telemetry';
|
import telemetry from './telemetry/telemetry';
|
||||||
import { showMessageDialog, showToast } from './utils';
|
import { showMessageDialog, showToast } from './utils';
|
||||||
@ -21,7 +21,7 @@ interface ErrorLog {
|
|||||||
|
|
||||||
function getCanLog(): boolean {
|
function getCanLog(): boolean {
|
||||||
const telemetrySetting = config.get(ConfigKeys.Telemetry);
|
const telemetrySetting = config.get(ConfigKeys.Telemetry);
|
||||||
return telemetrySetting !== telemetryOptions.dontLogAnything;
|
return telemetrySetting !== TelemetrySetting.dontLogAnything;
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldNotStore(error: Error) {
|
function shouldNotStore(error: Error) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import config, { ConfigKeys, telemetryOptions } from '@/config';
|
import config, { ConfigKeys, TelemetrySetting } from '@/config';
|
||||||
import frappe from 'frappe';
|
import frappe from 'frappe';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
import { getCounts, getDeviceId, getInstanceId, getLocale } from './helpers';
|
import { getCounts, getDeviceId, getInstanceId, getLocale } from './helpers';
|
||||||
@ -20,7 +20,7 @@ class TelemetryManager {
|
|||||||
|
|
||||||
getCanLog(): boolean {
|
getCanLog(): boolean {
|
||||||
const telemetrySetting = config.get(ConfigKeys.Telemetry) as string;
|
const telemetrySetting = config.get(ConfigKeys.Telemetry) as string;
|
||||||
return telemetrySetting === telemetryOptions.allow;
|
return telemetrySetting === TelemetrySetting.allow;
|
||||||
}
|
}
|
||||||
|
|
||||||
log(verb: Verb, noun: Noun, more?: Record<string, unknown>) {
|
log(verb: Verb, noun: Noun, more?: Record<string, unknown>) {
|
||||||
@ -58,7 +58,7 @@ class TelemetryManager {
|
|||||||
this.#telemetryObject.counts = this.getCanLog() ? await getCounts() : {};
|
this.#telemetryObject.counts = this.getCanLog() ? await getCounts() : {};
|
||||||
this.#telemetryObject.closeTime = new Date().valueOf();
|
this.#telemetryObject.closeTime = new Date().valueOf();
|
||||||
|
|
||||||
if (config.get(ConfigKeys.Telemetry) === telemetryOptions.dontLogAnything) {
|
if (config.get(ConfigKeys.Telemetry) === TelemetrySetting.dontLogAnything) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user