mirror of
https://github.com/frappe/books.git
synced 2025-01-25 16:18:33 +00:00
feat: count errors
This commit is contained in:
parent
7696435504
commit
9bad5e69d8
@ -3,8 +3,8 @@ const Observable = require('frappe/utils/observable');
|
|||||||
const naming = require('./naming');
|
const naming = require('./naming');
|
||||||
const { isPesa } = require('../utils/index');
|
const { isPesa } = require('../utils/index');
|
||||||
const { DEFAULT_INTERNAL_PRECISION } = require('../utils/consts');
|
const { DEFAULT_INTERNAL_PRECISION } = require('../utils/consts');
|
||||||
const telemetry = require('@/telemetry/telemetry');
|
|
||||||
const { Verb } = require('@/telemetry/types');
|
const { Verb } = require('@/telemetry/types');
|
||||||
|
const { default: telemetry } = require('@/telemetry/telemetry');
|
||||||
|
|
||||||
module.exports = class BaseDocument extends Observable {
|
module.exports = class BaseDocument extends Observable {
|
||||||
constructor(data) {
|
constructor(data) {
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
} from 'frappe/common/errors';
|
} from 'frappe/common/errors';
|
||||||
import BaseDocument from 'frappe/model/document';
|
import BaseDocument from 'frappe/model/document';
|
||||||
import { IPC_ACTIONS, IPC_MESSAGES } from './messages';
|
import { IPC_ACTIONS, IPC_MESSAGES } from './messages';
|
||||||
|
import telemetry from './telemetry/telemetry';
|
||||||
import { showMessageDialog, showToast } from './utils';
|
import { showMessageDialog, showToast } from './utils';
|
||||||
|
|
||||||
interface ErrorLog {
|
interface ErrorLog {
|
||||||
@ -74,6 +75,7 @@ export function handleError(
|
|||||||
more: object = {},
|
more: object = {},
|
||||||
cb?: Function
|
cb?: Function
|
||||||
) {
|
) {
|
||||||
|
telemetry.error(error.name);
|
||||||
if (shouldLog) {
|
if (shouldLog) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
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';
|
||||||
import { Noun, Telemetry, Verb } from './types';
|
import { Noun, Telemetry, Verb } from './types';
|
||||||
@ -12,6 +13,7 @@ class TelemetryManager {
|
|||||||
this.#telemetryObject.instanceId ||= getInstanceId();
|
this.#telemetryObject.instanceId ||= getInstanceId();
|
||||||
this.#telemetryObject.openTime ||= new Date().valueOf();
|
this.#telemetryObject.openTime ||= new Date().valueOf();
|
||||||
this.#telemetryObject.timeline ??= [];
|
this.#telemetryObject.timeline ??= [];
|
||||||
|
this.#telemetryObject.errors ??= {};
|
||||||
this.#started = true;
|
this.#started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,10 +30,21 @@ class TelemetryManager {
|
|||||||
this.#telemetryObject.timeline.push({ time, verb, noun, more });
|
this.#telemetryObject.timeline.push({ time, verb, noun, more });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error(name: string) {
|
||||||
|
if (this.#telemetryObject.errors === undefined) {
|
||||||
|
this.#telemetryObject.errors = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#telemetryObject.errors[name] ??= 0;
|
||||||
|
this.#telemetryObject.errors[name] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
async stop() {
|
async stop() {
|
||||||
// Will set ids if not set.
|
// Will set ids if not set.
|
||||||
this.start();
|
this.start();
|
||||||
|
|
||||||
|
//@ts-ignore
|
||||||
|
this.#telemetryObject.version = frappe.store.appVersion ?? '';
|
||||||
this.#telemetryObject.counts = await getCounts();
|
this.#telemetryObject.counts = await getCounts();
|
||||||
this.#telemetryObject.closeTime = new Date().valueOf();
|
this.#telemetryObject.closeTime = new Date().valueOf();
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ export interface Telemetry {
|
|||||||
closeTime: Timestamp;
|
closeTime: Timestamp;
|
||||||
timeline?: InteractionEvent[];
|
timeline?: InteractionEvent[];
|
||||||
counts?: Count;
|
counts?: Count;
|
||||||
|
errors: Record<string, number>;
|
||||||
locale: Locale;
|
locale: Locale;
|
||||||
version: AppVersion;
|
version: AppVersion;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user