@@ -429,6 +429,73 @@ describe('SessionRecording', () => {
429
429
)
430
430
} )
431
431
432
+ describe ( 'masking config' , ( ) => {
433
+ it . each ( [
434
+ [
435
+ 'enabled when both enabled' ,
436
+ { maskAllInputs : true , maskTextSelector : '*' } ,
437
+ { maskAllInputs : true , maskTextSelector : '*' } ,
438
+ { maskAllInputs : true , maskTextSelector : '*' } ,
439
+ ] ,
440
+ [
441
+ 'disabled when both disabled' ,
442
+ { maskAllInputs : false } ,
443
+ { maskAllInputs : false } ,
444
+ { maskAllInputs : false } ,
445
+ ] ,
446
+ [
447
+ 'is undefined when nothing is set' ,
448
+ undefined ,
449
+ undefined ,
450
+ {
451
+ maskAllInputs : undefined ,
452
+ maskTextSelector : undefined ,
453
+ } ,
454
+ ] ,
455
+ [
456
+ 'uses client config when set if server config is not set' ,
457
+ undefined ,
458
+ { maskAllInputs : true , maskTextSelector : '#client' } ,
459
+ { maskAllInputs : true , maskTextSelector : '#client' } ,
460
+ ] ,
461
+ [
462
+ 'uses server config when set if client config is not set' ,
463
+ { maskAllInputs : false , maskTextSelector : '#server' } ,
464
+ undefined ,
465
+ { maskAllInputs : false , maskTextSelector : '#server' } ,
466
+ ] ,
467
+ [
468
+ 'overrides server config with client config if both are set' ,
469
+ { maskAllInputs : false , maskTextSelector : '#server' } ,
470
+ { maskAllInputs : true , maskTextSelector : '#client' } ,
471
+ { maskAllInputs : true , maskTextSelector : '#client' } ,
472
+ ] ,
473
+ [
474
+ 'partially overrides server config with client config if both are set' ,
475
+ { maskAllInputs : true , maskTextSelector : '*' } ,
476
+ { maskAllInputs : false } ,
477
+ { maskAllInputs : false , maskTextSelector : '*' } ,
478
+ ] ,
479
+ ] ) (
480
+ '%s' ,
481
+ (
482
+ _name : string ,
483
+ serverConfig : { maskAllInputs ?: boolean ; maskTextSelector ?: string } | undefined ,
484
+ clientConfig : { maskAllInputs : boolean ; maskTextSelector ?: string } | undefined ,
485
+ expected : { maskAllInputs : boolean ; maskTextSelector ?: string } | undefined
486
+ ) => {
487
+ posthog . persistence ?. register ( {
488
+ [ SESSION_RECORDING_MASKING ] : serverConfig ,
489
+ } )
490
+
491
+ posthog . config . session_recording . maskAllInputs = clientConfig ?. maskAllInputs
492
+ posthog . config . session_recording . maskTextSelector = clientConfig ?. maskTextSelector
493
+
494
+ expect ( sessionRecording [ 'masking' ] ) . toEqual ( expected )
495
+ }
496
+ )
497
+ } )
498
+
432
499
describe ( 'startIfEnabledOrStop' , ( ) => {
433
500
beforeEach ( ( ) => {
434
501
// need to cast as any to mock private methods
0 commit comments