diff --git a/packages/kbn-reporting/export_types/pdf/generate_pdf_v2.ts b/packages/kbn-reporting/export_types/pdf/generate_pdf_v2.ts index e569a998ebdf5..54489c6258bd8 100644 --- a/packages/kbn-reporting/export_types/pdf/generate_pdf_v2.ts +++ b/packages/kbn-reporting/export_types/pdf/generate_pdf_v2.ts @@ -43,6 +43,7 @@ export function generatePdfObservableV2( getFullRedirectAppUrl(config, serverInfo, job.spaceId, job.forceNow), locator, ]) as unknown as UrlOrUrlWithContext[]; + const screenshots$ = getScreenshots({ ...options, urls }).pipe( tap(({ metrics }) => { if (metrics.cpu) { diff --git a/packages/kbn-reporting/export_types/pdf/index.ts b/packages/kbn-reporting/export_types/pdf/index.ts index efc80348480b6..e4ce328f9026e 100644 --- a/packages/kbn-reporting/export_types/pdf/index.ts +++ b/packages/kbn-reporting/export_types/pdf/index.ts @@ -7,4 +7,4 @@ */ export { PdfExportType } from './printable_pdf_v2'; -export { PdfV1ExportType } from './deprecated'; +export { PdfV1ExportType } from './printable_pdf'; diff --git a/packages/kbn-reporting/export_types/pdf/deprecated.ts b/packages/kbn-reporting/export_types/pdf/printable_pdf.ts similarity index 98% rename from packages/kbn-reporting/export_types/pdf/deprecated.ts rename to packages/kbn-reporting/export_types/pdf/printable_pdf.ts index f173baa927c07..59868962c0606 100644 --- a/packages/kbn-reporting/export_types/pdf/deprecated.ts +++ b/packages/kbn-reporting/export_types/pdf/printable_pdf.ts @@ -98,7 +98,7 @@ export class PdfV1ExportType extends ExportType this.startDeps.screenshotting!.getScreenshots({ format: 'pdf', @@ -109,6 +109,7 @@ export class PdfV1ExportType extends ExportType apmGetAssets?.end(); apmGeneratePdf = apmTrans.startSpan('generate-pdf-pipeline', 'execute'); + + const snapshotFn = () => + this.startDeps.screenshotting!.getScreenshots({ + format: 'pdf', + title, + logo, + browserTimezone, + headers, + layout, + urls: urls.map((url) => + typeof url === 'string' + ? url + : [url[0], { [REPORTING_REDIRECT_LOCATOR_STORE_KEY]: url[1] }] + ), + }); return generatePdfObservableV2( this.config, this.getServerInfo(), - () => - this.startDeps.screenshotting!.getScreenshots({ - format: 'pdf', - title, - logo, - browserTimezone, - headers, - layout, - urls, - }), + snapshotFn, payload, locatorParams, { diff --git a/packages/kbn-reporting/export_types/png/png_v2.ts b/packages/kbn-reporting/export_types/png/png_v2.ts index cff0fcf23afca..13f26be0ea243 100644 --- a/packages/kbn-reporting/export_types/png/png_v2.ts +++ b/packages/kbn-reporting/export_types/png/png_v2.ts @@ -28,6 +28,7 @@ import { LICENSE_TYPE_GOLD, LICENSE_TYPE_PLATINUM, LICENSE_TYPE_TRIAL, + REPORTING_REDIRECT_LOCATOR_STORE_KEY, REPORTING_TRANSACTION_TYPE, } from '@kbn/reporting-common'; import type { LocatorParams, TaskRunResult } from '@kbn/reporting-common/types'; @@ -38,7 +39,6 @@ import { TaskPayloadPNGV2, } from '@kbn/reporting-export-types-png-common'; import { decryptJobHeaders, getFullRedirectAppUrl, ExportType } from '@kbn/reporting-server'; -import type { Context } from '@kbn/screenshotting-plugin/server/browsers'; import { SerializableRecord } from '@kbn/utility-types'; import { generatePngObservable } from './generate_png'; @@ -105,27 +105,24 @@ export class PngExportType extends ExportType payload.forceNow ); - const [locatorParams] = payload.locatorParams as unknown as Context[]; + const [locatorParams] = payload.locatorParams; apmGetAssets?.end(); apmGeneratePng = apmTrans.startSpan('generate-png-pipeline', 'execute'); - return generatePngObservable( - () => - this.startDeps.screenshotting!.getScreenshots({ - format: 'png', - headers, - layout: { ...payload.layout, id: 'preserve_layout' }, - urls: [[url, locatorParams]], - }), - jobLogger, - { + const snapshotFn = () => + this.startDeps.screenshotting!.getScreenshots({ + format: 'png', headers, - browserTimezone: payload.browserTimezone, layout: { ...payload.layout, id: 'preserve_layout' }, - urls: [[url, locatorParams]], - } - ); + urls: [[url, { [REPORTING_REDIRECT_LOCATOR_STORE_KEY]: locatorParams }]], + }); + + return generatePngObservable(snapshotFn, jobLogger, { + headers, + browserTimezone: payload.browserTimezone, + layout: { ...payload.layout, id: 'preserve_layout' }, + }); }), tap(({ buffer }) => stream.write(buffer)), map(({ metrics, warnings }) => ({ diff --git a/x-pack/plugins/screenshotting/server/screenshots/screenshots.ts b/x-pack/plugins/screenshotting/server/screenshots/screenshots.ts index 5ee41f9fa77fe..64f6ecdb5264a 100644 --- a/x-pack/plugins/screenshotting/server/screenshots/screenshots.ts +++ b/x-pack/plugins/screenshotting/server/screenshots/screenshots.ts @@ -174,8 +174,6 @@ export class Screenshots { getScreenshots(options: PdfScreenshotOptions): Observable; getScreenshots(options: ScreenshotOptions): Observable; getScreenshots(options: ScreenshotOptions): Observable { - console.log('urls', JSON.stringify({ urls: options.urls})); - if (this.systemHasInsufficientMemory()) { return throwError(() => new errors.InsufficientMemoryAvailableOnCloudError()); }