1- import { getCanvasManager } from '@sentry-internal/rrweb' ;
1+ import { createCanvasManager } from '@sentry-internal/rrweb' ;
22import type { Integration } from '@sentry/types' ;
33import type { CanvasManagerInterface , GetCanvasManagerOptions , ReplayConfiguration } from './types' ;
44
@@ -19,13 +19,16 @@ export class ReplayCanvas implements Integration {
1919 */
2020 public name : string ;
2121
22+ public canvasManager : ( options : GetCanvasManagerOptions ) => CanvasManagerInterface ;
23+
2224 private _canvasOptions : ReplayCanvasOptions ;
2325
2426 public constructor ( options ?: Partial < ReplayCanvasOptions > ) {
2527 this . name = ReplayCanvas . id ;
2628 // TODO FN: Allow to configure this
2729 // But since we haven't finalized how to configure this, this is predefined for now
2830 // to avoid breaking changes
31+ this . canvasManager = createCanvasManager ;
2932 this . _canvasOptions = {
3033 quality : ( options && options . quality ) || 'medium' ,
3134 manualSnapshot : true ,
@@ -46,14 +49,25 @@ export class ReplayCanvas implements Integration {
4649 _experiments : {
4750 canvas : {
4851 ...this . _canvasOptions ,
49- manager : opts =>
50- this . canvasManager ( {
51- ...opts ,
52- manualSnapshot : this . _canvasOptions . manualSnapshot ,
53- } ) ,
52+ manager : createCanvasManager ,
5453 quality : this . _canvasOptions . quality ,
5554 } ,
5655 } ,
5756 } ;
5857 }
58+
59+ /**
60+ * Take manual snapshot of canvas
61+ */
62+ public snapshotCanvas ( canvasElement ?: HTMLCanvasElement ) : void {
63+ const canvasManager : CanvasManagerInterface = createCanvasManager ( this . canvasManager , {
64+ recordCanvas : true ,
65+ blockClass : '' ,
66+ blockSelector : null ,
67+ unblockSelector : null ,
68+ dataURLOptions : this . _canvasOptions . quality ,
69+ } ) ;
70+
71+ return canvasManager . snapshot ( this . _canvasOptions , canvasElement ) ;
72+ }
5973}
0 commit comments