2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 14:50:56 +00:00

fix: telemetry log when printing

This commit is contained in:
18alantom 2023-06-28 11:16:51 +05:30
parent 18fc0e1a5d
commit 00ce281afc
4 changed files with 18 additions and 9 deletions

View File

@ -34,6 +34,7 @@
<PrintContainer
v-if="printProps"
ref="printContainer"
:print-schema-name="schemaName"
:template="printProps.template"
:values="printProps.values"
:scale="scale"
@ -55,11 +56,11 @@ import PageHeader from 'src/components/PageHeader.vue';
import { handleErrorWithDialog } from 'src/errorHandling';
import { fyo } from 'src/initFyo';
import { getPrintTemplatePropValues } from 'src/utils/printTemplates';
import { showSidebar } from 'src/utils/refs';
import { PrintValues } from 'src/utils/types';
import { getFormRoute, openSettings, routeTo } from 'src/utils/ui';
import { defineComponent } from 'vue';
import PrintContainer from '../TemplateBuilder/PrintContainer.vue';
import { showSidebar } from 'src/utils/refs';
export default defineComponent({
name: 'PrintView',
@ -244,16 +245,16 @@ export default defineComponent({
this.templateList = list.map(({ name }) => name);
},
savePDF() {
async savePDF() {
const printContainer = this.$refs.printContainer as {
savePDF: (name?: string) => void;
savePDF: (name?: string) => Promise<void>;
};
if (!printContainer?.savePDF) {
return;
}
printContainer.savePDF(this.doc?.name);
await printContainer.savePDF(this.doc?.name);
},
async setTemplateFromDefault() {
const defaultName =

View File

@ -145,20 +145,21 @@
</div>
</template>
<script lang="ts">
import { Verb } from 'fyo/telemetry/types';
import { Report } from 'reports/Report';
import { reports } from 'reports/index';
import { OptionField } from 'schemas/types';
import Button from 'src/components/Button.vue';
import Check from 'src/components/Controls/Check.vue';
import Int from 'src/components/Controls/Int.vue';
import Select from 'src/components/Controls/Select.vue';
import PageHeader from 'src/components/PageHeader.vue';
import { getReport } from 'src/utils/misc';
import { getPathAndMakePDF } from 'src/utils/printTemplates';
import { showSidebar } from 'src/utils/refs';
import { paperSizeMap, printSizes } from 'src/utils/ui';
import { PropType, defineComponent } from 'vue';
import ScaledContainer from '../TemplateBuilder/ScaledContainer.vue';
import { getPathAndMakePDF } from 'src/utils/printTemplates';
import { OptionField } from 'schemas/types';
import { paperSizeMap, printSizes } from 'src/utils/ui';
import Select from 'src/components/Controls/Select.vue';
import { showSidebar } from 'src/utils/refs';
export default defineComponent({
components: { PageHeader, Button, Check, Int, ScaledContainer, Select },
@ -276,6 +277,8 @@ export default defineComponent({
this.size.width,
this.size.height
);
this.fyo.telemetry.log(Verb.Printed, this.report!.reportName);
},
cellClasses(cIdx: number, rIdx: number): string[] {
const classes: string[] = [];

View File

@ -49,6 +49,7 @@ import {
generateCodeFrame,
SourceLocation,
} from '@vue/compiler-dom';
import { Verb } from 'fyo/telemetry/types';
import ErrorBoundary from 'src/components/ErrorBoundary.vue';
import { getPathAndMakePDF } from 'src/utils/printTemplates';
import { PrintValues } from 'src/utils/types';
@ -66,6 +67,7 @@ export default defineComponent({
components: { ScaledContainer, ErrorBoundary },
props: {
template: { type: String, required: true },
printSchemaName: { type: String, required: true },
scale: { type: Number, default: 0.65 },
width: { type: Number, default: 21 },
height: { type: Number, default: 29.7 },
@ -179,6 +181,8 @@ export default defineComponent({
this.width,
this.height
);
this.fyo.telemetry.log(Verb.Printed, this.printSchemaName);
},
},
});

View File

@ -46,6 +46,7 @@
<div v-if="canDisplayPreview" class="p-4 overflow-auto custom-scroll">
<PrintContainer
ref="printContainer"
:print-schema-name="displayDoc!.schemaName"
:template="doc.template!"
:values="values!"
:scale="scale"