2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

fix: skip telemetry log for auto entries

This commit is contained in:
18alantom 2023-06-28 10:25:39 +05:30
parent d5fc729d27
commit eeb2eab3e5
3 changed files with 15 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import { Fyo } from 'fyo';
import { Noun, Telemetry, Verb } from './types';
import { ModelNameEnum } from 'models/types';
/**
* # Telemetry
@ -26,6 +27,11 @@ import { Noun, Telemetry, Verb } from './types';
* the app is hidden.
*/
const ignoreList: string[] = [
ModelNameEnum.AccountingLedgerEntry,
ModelNameEnum.StockLedgerEntry,
];
export class TelemetryManager {
#url = '';
#token = '';
@ -80,7 +86,11 @@ export class TelemetryManager {
}
#sendBeacon(verb: Verb, noun: Noun, more?: Record<string, unknown>) {
if (!this.hasCreds || this.fyo.store.skipTelemetryLogging) {
if (
!this.hasCreds ||
this.fyo.store.skipTelemetryLogging ||
ignoreList.includes(noun)
) {
return;
}

View File

@ -9,6 +9,7 @@ export enum Verb {
Cancelled = 'cancelled',
Imported = 'imported',
Exported = 'exported',
Printed = 'printed',
Closed = 'closed',
Opened = 'opened',
Resumed = 'resumed',

View File

@ -290,6 +290,8 @@ export async function updatePrintTemplates(fyo: Fyo) {
updateList.push(...updates);
}
const isLogging = fyo.store.skipTelemetryLogging;
fyo.store.skipTelemetryLogging = true;
for (const { name, type, template } of updateList) {
const doc = await getDocFromNameIfExistsElseNew(
ModelNameEnum.PrintTemplate,
@ -299,6 +301,7 @@ export async function updatePrintTemplates(fyo: Fyo) {
await doc.set({ name, type, template, isCustom: false });
await doc.sync();
}
fyo.store.skipTelemetryLogging = isLogging;
}
function getPrintTemplateUpdateList(