mirror of
https://github.com/frappe/books.git
synced 2024-12-23 11:29:03 +00:00
fix: log level checks
This commit is contained in:
parent
2e67dddc09
commit
132edff44b
@ -12,10 +12,16 @@ export enum ConfigKeys {
|
||||
Telemetry = 'telemetry',
|
||||
}
|
||||
|
||||
export enum TelemetrySetting {
|
||||
allow = 'allow',
|
||||
dontLogUsage = 'dontLogUsage',
|
||||
dontLogAnything = 'dontLogAnything',
|
||||
}
|
||||
|
||||
export const telemetryOptions = {
|
||||
allow: frappe.t`Allow Telemetry`,
|
||||
dontLogUsage: frappe.t`Don't Log Usage`,
|
||||
dontLogAnything: frappe.t`Don't Log Anything`,
|
||||
[TelemetrySetting.allow]: frappe.t`Allow Telemetry`,
|
||||
[TelemetrySetting.dontLogUsage]: frappe.t`Don't Log Usage`,
|
||||
[TelemetrySetting.dontLogAnything]: frappe.t`Don't Log Anything`,
|
||||
};
|
||||
|
||||
export interface ConfigFile {
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
ValidationError,
|
||||
} from 'frappe/common/errors';
|
||||
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 telemetry from './telemetry/telemetry';
|
||||
import { showMessageDialog, showToast } from './utils';
|
||||
@ -21,7 +21,7 @@ interface ErrorLog {
|
||||
|
||||
function getCanLog(): boolean {
|
||||
const telemetrySetting = config.get(ConfigKeys.Telemetry);
|
||||
return telemetrySetting !== telemetryOptions.dontLogAnything;
|
||||
return telemetrySetting !== TelemetrySetting.dontLogAnything;
|
||||
}
|
||||
|
||||
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 { cloneDeep } from 'lodash';
|
||||
import { getCounts, getDeviceId, getInstanceId, getLocale } from './helpers';
|
||||
@ -20,7 +20,7 @@ class TelemetryManager {
|
||||
|
||||
getCanLog(): boolean {
|
||||
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>) {
|
||||
@ -58,7 +58,7 @@ class TelemetryManager {
|
||||
this.#telemetryObject.counts = this.getCanLog() ? await getCounts() : {};
|
||||
this.#telemetryObject.closeTime = new Date().valueOf();
|
||||
|
||||
if (config.get(ConfigKeys.Telemetry) === telemetryOptions.dontLogAnything) {
|
||||
if (config.get(ConfigKeys.Telemetry) === TelemetrySetting.dontLogAnything) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user