@@ -3,8 +3,12 @@ import { defineIntegration } from '@sentry/core';
33import type { CanvasManagerInterface , CanvasManagerOptions } from '@sentry-internal/replay' ;
44import { CanvasManager } from '@sentry-internal/rrweb' ;
55
6+ interface SnapshotOptions {
7+ skipRequestAnimationFrame ?: boolean ;
8+ }
9+
610interface ReplayCanvasIntegration extends Integration {
7- snapshot : ( canvasElement ?: HTMLCanvasElement ) => Promise < void > ;
11+ snapshot : ( canvasElement ?: HTMLCanvasElement , options ?: SnapshotOptions ) => Promise < void > ;
812}
913
1014interface ReplayCanvasOptions {
@@ -106,9 +110,29 @@ export const _replayCanvasIntegration = ((options: Partial<ReplayCanvasOptions>
106110 ...( CANVAS_QUALITY [ quality || 'medium' ] || CANVAS_QUALITY . medium ) ,
107111 } ;
108112 } ,
109- async snapshot ( canvasElement ?: HTMLCanvasElement ) {
113+ async snapshot ( canvasElement ?: HTMLCanvasElement , options ?: SnapshotOptions ) {
110114 const canvasManager = await _canvasManager ;
111- canvasManager . snapshot ( canvasElement ) ;
115+
116+ canvasManager . snapshot ( canvasElement , options ) ;
117+ // createImageBitmap(canvasElement).then(async imageBitmap => {
118+ // // debug
119+ // const canvas = document.getElementById('test');
120+ // canvas.height = imageBitmap.height;
121+ // canvas.width = imageBitmap.width;
122+ // // temp1.getContext("2d").drawImage(bitmap, 0, 0);
123+ // // const canvas = new OffscreenCanvas(imageBitmap.width, imageBitmap.height);
124+ // const ctx = canvas.getContext('2d');
125+ //
126+ // // Draw the ImageBitmap onto the canvas
127+ // ctx.drawImage(imageBitmap, 0, 0);
128+ //
129+ // // Convert the canvas content to a data URL (Base64 encoded PNG by default)
130+ // const dataURL = await canvas.toDataURL('image/webp'); // Specify format if needed
131+ //
132+ // console.log(dataURL);
133+ // canvasManager.snapshotBitmap(canvasElement, imageBitmap);
134+ // imageBitmap.close();
135+ // });
112136 } ,
113137 } ;
114138} ) satisfies IntegrationFn < ReplayCanvasIntegration > ;
0 commit comments