@@ -184,6 +184,7 @@ export class Replayer {
184184 pauseAnimation : true ,
185185 mouseTail : defaultMouseTailConfig ,
186186 useVirtualDom : true , // Virtual-dom optimization is enabled by default.
187+ logger : console ,
187188 } ;
188189 this . config = Object . assign ( { } , defaultConfig , config ) ;
189190
@@ -269,9 +270,7 @@ export class Replayer {
269270 ) ;
270271 value . node = realNode ;
271272 } catch ( error ) {
272- if ( this . config . showWarning ) {
273- console . warn ( error ) ;
274- }
273+ this . warn ( error ) ;
275274 }
276275 }
277276 }
@@ -495,7 +494,7 @@ export class Replayer {
495494 }
496495
497496 public resume ( timeOffset = 0 ) {
498- console . warn (
497+ this . warn (
499498 `The 'resume' was deprecated in 1.0. Please use 'play' method which has the same interface.` ,
500499 ) ;
501500 this . play ( timeOffset ) ;
@@ -753,10 +752,10 @@ export class Replayer {
753752 isSync = false ,
754753 ) {
755754 if ( ! this . iframe . contentDocument ) {
756- return console . warn ( 'Looks like your replayer has been destroyed.' ) ;
755+ return this . warn ( 'Looks like your replayer has been destroyed.' ) ;
757756 }
758757 if ( Object . keys ( this . legacy_missingNodeRetryMap ) . length ) {
759- console . warn (
758+ this . warn (
760759 'Found unresolved missing node map' ,
761760 this . legacy_missingNodeRetryMap ,
762761 ) ;
@@ -1252,12 +1251,10 @@ export class Replayer {
12521251 mediaEl . playbackRate = d . playbackRate ;
12531252 }
12541253 } catch ( error ) {
1255- if ( this . config . showWarning ) {
1256- console . warn (
1257- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions
1258- `Failed to replay media interactions: ${ error . message || error } ` ,
1259- ) ;
1260- }
1254+ this . warn (
1255+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions
1256+ `Failed to replay media interactions: ${ error . message || error } ` ,
1257+ ) ;
12611258 }
12621259 break ;
12631260 }
@@ -1314,9 +1311,7 @@ export class Replayer {
13141311 ) ;
13151312 this . iframe . contentDocument ?. fonts . add ( fontFace ) ;
13161313 } catch ( error ) {
1317- if ( this . config . showWarning ) {
1318- console . warn ( error ) ;
1319- }
1314+ this . warn ( error ) ;
13201315 }
13211316 break ;
13221317 }
@@ -1354,9 +1349,7 @@ export class Replayer {
13541349 ) ;
13551350 if ( virtualNode ) value . node = virtualNode ;
13561351 } catch ( error ) {
1357- if ( this . config . showWarning ) {
1358- console . warn ( error ) ;
1359- }
1352+ this . warn ( error ) ;
13601353 }
13611354 }
13621355 }
@@ -1437,7 +1430,7 @@ export class Replayer {
14371430
14381431 const appendNode = ( mutation : addedNodeMutation ) => {
14391432 if ( ! this . iframe . contentDocument ) {
1440- return console . warn ( 'Looks like your replayer has been destroyed.' ) ;
1433+ return this . warn ( 'Looks like your replayer has been destroyed.' ) ;
14411434 }
14421435 let parent : Node | null | ShadowRoot | RRNode = mirror . getNode (
14431436 mutation . parentId ,
@@ -1718,12 +1711,10 @@ export class Replayer {
17181711 value ,
17191712 ) ;
17201713 } catch ( error ) {
1721- if ( this . config . showWarning ) {
1722- console . warn (
1723- 'An error occurred may due to the checkout feature.' ,
1724- error ,
1725- ) ;
1726- }
1714+ this . warn (
1715+ 'An error occurred may due to the checkout feature.' ,
1716+ error ,
1717+ ) ;
17271718 }
17281719 } else if ( attributeName === 'style' ) {
17291720 const styleValues = value ;
@@ -2136,20 +2127,20 @@ export class Replayer {
21362127 * is microtask, so events fired on a removed DOM may emit
21372128 * snapshots in the reverse order.
21382129 */
2139- this . debug ( REPLAY_CONSOLE_PREFIX , `Node with id '${ id } ' not found. ` , d ) ;
2130+ this . debug ( `Node with id '${ id } ' not found. ` , d ) ;
21402131 }
21412132
21422133 private warn ( ...args : Parameters < typeof console . warn > ) {
21432134 if ( ! this . config . showWarning ) {
21442135 return ;
21452136 }
2146- console . warn ( REPLAY_CONSOLE_PREFIX , ...args ) ;
2137+ this . config . logger . warn ( REPLAY_CONSOLE_PREFIX , ...args ) ;
21472138 }
21482139
21492140 private debug ( ...args : Parameters < typeof console . log > ) {
21502141 if ( ! this . config . showDebug ) {
21512142 return ;
21522143 }
2153- console . log ( REPLAY_CONSOLE_PREFIX , ...args ) ;
2144+ this . config . logger . log ( REPLAY_CONSOLE_PREFIX , ...args ) ;
21542145 }
21552146}
0 commit comments