diff --git a/frontend/src/components/print/metricConstants.js b/frontend/src/components/print/metricConstants.js new file mode 100644 index 0000000000..17281bedf7 --- /dev/null +++ b/frontend/src/components/print/metricConstants.js @@ -0,0 +1 @@ +export const NUM_PRINT_CONFIG_ITEMS_USED = 'numPrintConfigItems' diff --git a/frontend/src/components/print/print-client/generatePdfMixin.js b/frontend/src/components/print/print-client/generatePdfMixin.js index a47185bc43..4dcd80b7ac 100644 --- a/frontend/src/components/print/print-client/generatePdfMixin.js +++ b/frontend/src/components/print/print-client/generatePdfMixin.js @@ -2,6 +2,7 @@ import { saveAs } from 'file-saver' import slugify from 'slugify' import * as Sentry from '@sentry/browser' import { generatePdf } from './generatePdf.js' +import { NUM_PRINT_CONFIG_ITEMS_USED } from '@/components/print/metricConstants.js' const RENDER_IN_WORKER = true @@ -23,10 +24,21 @@ export const generatePdfMixin = { return } + const config = this.config + Sentry.startSpan( + { + attributes: { + 'print.clientPrintUsed': '1', + [`print.${NUM_PRINT_CONFIG_ITEMS_USED}`]: config?.contents?.length, + }, + }, + () => {} + ) + this.loading = true const { blob, error } = await generatePdf({ - config: { ...this.config, apiGet: this.api.get.bind(this) }, + config: { ...config, apiGet: this.api.get.bind(this) }, storeData: this.$store.state, translationData: this.$i18n.messages, renderInWorker: RENDER_IN_WORKER, @@ -41,7 +53,7 @@ export const generatePdfMixin = { saveAs( blob, - slugify(this.config.documentName, { + slugify(config.documentName, { locale: this.$store.state.lang.language.substring(0, 2), }) + '.pdf' ) diff --git a/frontend/src/components/print/print-nuxt/generatePdfMixin.js b/frontend/src/components/print/print-nuxt/generatePdfMixin.js index ec71ae205f..143cb19bff 100644 --- a/frontend/src/components/print/print-nuxt/generatePdfMixin.js +++ b/frontend/src/components/print/print-nuxt/generatePdfMixin.js @@ -4,6 +4,7 @@ import { cloneDeep } from 'lodash-es' import axios from 'axios' import { getEnv } from '@/environment.js' import * as Sentry from '@sentry/browser' +import { NUM_PRINT_CONFIG_ITEMS_USED } from '@/components/print/metricConstants.js' const PRINT_URL = getEnv().PRINT_URL @@ -26,6 +27,16 @@ export const generatePdfMixin = { } const config = cloneDeep(this.config) + Sentry.startSpan( + { + attributes: { + 'print.nuxtPrintUsed': 1, + [`print.${NUM_PRINT_CONFIG_ITEMS_USED}`]: config?.contents?.length, + }, + }, + () => {} + ) + config.documentName = slugify(config.documentName, { locale: this.$store.state.lang.language.substring(0, 2), })