@@ -3,8 +3,12 @@ import { defineIntegration } from '@sentry/core';
3
3
import type { CanvasManagerInterface , CanvasManagerOptions } from '@sentry-internal/replay' ;
4
4
import { CanvasManager } from '@sentry-internal/rrweb' ;
5
5
6
+ interface SnapshotOptions {
7
+ skipRequestAnimationFrame ?: boolean ;
8
+ }
9
+
6
10
interface ReplayCanvasIntegration extends Integration {
7
- snapshot : ( canvasElement ?: HTMLCanvasElement ) => Promise < void > ;
11
+ snapshot : ( canvasElement ?: HTMLCanvasElement , options ?: SnapshotOptions ) => Promise < void > ;
8
12
}
9
13
10
14
interface ReplayCanvasOptions {
@@ -106,9 +110,29 @@ export const _replayCanvasIntegration = ((options: Partial<ReplayCanvasOptions>
106
110
...( CANVAS_QUALITY [ quality || 'medium' ] || CANVAS_QUALITY . medium ) ,
107
111
} ;
108
112
} ,
109
- async snapshot ( canvasElement ?: HTMLCanvasElement ) {
113
+ async snapshot ( canvasElement ?: HTMLCanvasElement , options ?: SnapshotOptions ) {
110
114
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
+ // });
112
136
} ,
113
137
} ;
114
138
} ) satisfies IntegrationFn < ReplayCanvasIntegration > ;
0 commit comments