File tree Expand file tree Collapse file tree 4 files changed +62
-9
lines changed Expand file tree Collapse file tree 4 files changed +62
-9
lines changed Original file line number Diff line number Diff line change @@ -53,3 +53,33 @@ export const MAX_REPLAY_DURATION = 3_600_000; // 60 minutes in ms;
53
53
54
54
/** Default attributes to be ignored when `maskAllText` is enabled */
55
55
export const DEFAULT_IGNORED_ATTRIBUTES = [ 'title' , 'placeholder' ] ;
56
+
57
+ export const CANVAS_QUALITY = {
58
+ low : {
59
+ sampling : {
60
+ canvas : 1 ,
61
+ } ,
62
+ dataURLOptions : {
63
+ type : 'image/webp' ,
64
+ quality : 0.25 ,
65
+ } ,
66
+ } ,
67
+ normal : {
68
+ sampling : {
69
+ canvas : 2 ,
70
+ } ,
71
+ dataURLOptions : {
72
+ type : 'image/webp' ,
73
+ quality : 0.4 ,
74
+ } ,
75
+ } ,
76
+ high : {
77
+ sampling : {
78
+ canvas : 4 ,
79
+ } ,
80
+ dataURLOptions : {
81
+ type : 'image/webp' ,
82
+ quality : 0.5 ,
83
+ } ,
84
+ } ,
85
+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { logger } from '@sentry/utils';
6
6
7
7
import {
8
8
BUFFER_CHECKOUT_TIME ,
9
+ CANVAS_QUALITY ,
9
10
SESSION_IDLE_EXPIRE_DURATION ,
10
11
SESSION_IDLE_PAUSE_DURATION ,
11
12
SLOW_CLICK_SCROLL_TIMEOUT ,
@@ -340,14 +341,10 @@ export class ReplayContainer implements ReplayContainerInterface {
340
341
...( this . recordingMode === 'buffer' && { checkoutEveryNms : BUFFER_CHECKOUT_TIME } ) ,
341
342
emit : getHandleRecordingEmit ( this ) ,
342
343
onMutation : this . _onMutationHandler ,
343
- ...( canvas && {
344
+ ...( canvas && canvas . manager && {
344
345
recordCanvas : true ,
345
- sampling : { canvas : canvas . fps || 4 } ,
346
- dataURLOptions : {
347
- type : canvas . type || 'image/webp' ,
348
- quality : canvas . quality || 0.6 ,
349
- } ,
350
346
getCanvasManager : canvas . manager ,
347
+ ...( CANVAS_QUALITY [ canvas . quality || 'normal' ] || CANVAS_QUALITY . normal )
351
348
} ) ,
352
349
} ) ;
353
350
} catch ( err ) {
Original file line number Diff line number Diff line change @@ -233,9 +233,7 @@ export interface ReplayPluginOptions extends ReplayNetworkOptions {
233
233
captureExceptions : boolean ;
234
234
traceInternals : boolean ;
235
235
canvas : {
236
- fps ?: number ;
237
- quality ?: number ;
238
- type ?: string ;
236
+ quality ?: 'low' | 'normal' | 'high' ;
239
237
manager : ( options : GetCanvasManagerOptions ) => CanvasManagerInterface ;
240
238
} ;
241
239
} > ;
Original file line number Diff line number Diff line change
1
+ import type { CanvasManagerInterface , } from '../../src/types' ;
1
2
import { resetSdkMock } from '../mocks/resetSdkMock' ;
2
3
import { useFakeTimers } from '../utils/use-fake-timers' ;
3
4
@@ -40,4 +41,31 @@ describe('Integration | rrweb', () => {
40
41
}
41
42
` ) ;
42
43
} ) ;
44
+
45
+ it ( 'calls rrweb.record with default canvas options' , async ( ) => {
46
+ const { mockRecord } = await resetSdkMock ( {
47
+ replayOptions : {
48
+ _experiments : {
49
+ canvas : {
50
+ // @ts -expect-error This should return
51
+ // CanvasManagerInterface, but we don't care about it
52
+ // for this test
53
+ manager : ( ) => null ,
54
+ }
55
+ } ,
56
+ }
57
+ } ) ;
58
+
59
+ expect ( mockRecord ) . toHaveBeenLastCalledWith ( expect . objectContaining ( {
60
+ recordCanvas : true ,
61
+ getCanvasManager : expect . any ( Function ) ,
62
+ dataURLOptions : {
63
+ quality : 0.4 ,
64
+ type : 'image/webp' ,
65
+ } ,
66
+ sampling : {
67
+ canvas : 2 ,
68
+ }
69
+ } ) ) ;
70
+ } ) ;
43
71
} ) ;
You can’t perform that action at this time.
0 commit comments