2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30:56 +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 { Fyo } from 'fyo';
import { Noun, Telemetry, Verb } from './types'; import { Noun, Telemetry, Verb } from './types';
import { ModelNameEnum } from 'models/types';
/** /**
* # Telemetry * # Telemetry
@ -26,6 +27,11 @@ import { Noun, Telemetry, Verb } from './types';
* the app is hidden. * the app is hidden.
*/ */
const ignoreList: string[] = [
ModelNameEnum.AccountingLedgerEntry,
ModelNameEnum.StockLedgerEntry,
];
export class TelemetryManager { export class TelemetryManager {
#url = ''; #url = '';
#token = ''; #token = '';
@ -80,7 +86,11 @@ export class TelemetryManager {
} }
#sendBeacon(verb: Verb, noun: Noun, more?: Record<string, unknown>) { #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; return;
} }

View File

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

View File

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