@@ -122,6 +122,17 @@ function record<T = eventWithTime>(
122122
123123 let lastFullSnapshotEvent : eventWithTime ;
124124 let incrementalSnapshotCount = 0 ;
125+ const eventProcessor = ( e : eventWithTime ) : T => {
126+ for ( const plugin of plugins || [ ] ) {
127+ if ( plugin . eventProcessor ) {
128+ e = plugin . eventProcessor ( e ) ;
129+ }
130+ }
131+ if ( packFn ) {
132+ e = ( packFn ( e ) as unknown ) as eventWithTime ;
133+ }
134+ return ( e as unknown ) as T ;
135+ } ;
125136 wrappedEmit = ( e : eventWithTime , isCheckout ?: boolean ) => {
126137 if (
127138 mutationBuffers [ 0 ] ?. isFrozen ( ) &&
@@ -136,7 +147,7 @@ function record<T = eventWithTime>(
136147 mutationBuffers . forEach ( ( buf ) => buf . unfreeze ( ) ) ;
137148 }
138149
139- emit ( ( ( packFn ? packFn ( e ) : e ) as unknown ) as T , isCheckout ) ;
150+ emit ( eventProcessor ( e ) , isCheckout ) ;
140151 if ( e . type === EventType . FullSnapshot ) {
141152 lastFullSnapshotEvent = e ;
142153 incrementalSnapshotCount = 0 ;
@@ -417,20 +428,22 @@ function record<T = eventWithTime>(
417428 shadowDomManager,
418429 canvasManager,
419430 plugins :
420- plugins ?. map ( ( p ) => ( {
421- observer : p . observer ,
422- options : p . options ,
423- callback : ( payload : object ) =>
424- wrappedEmit (
425- wrapEvent ( {
426- type : EventType . Plugin ,
427- data : {
428- plugin : p . name ,
429- payload,
430- } ,
431- } ) ,
432- ) ,
433- } ) ) || [ ] ,
431+ plugins
432+ ?. filter ( ( p ) => p . observer )
433+ ?. map ( ( p ) => ( {
434+ observer : p . observer ! ,
435+ options : p . options ,
436+ callback : ( payload : object ) =>
437+ wrappedEmit (
438+ wrapEvent ( {
439+ type : EventType . Plugin ,
440+ data : {
441+ plugin : p . name ,
442+ payload,
443+ } ,
444+ } ) ,
445+ ) ,
446+ } ) ) || [ ] ,
434447 enableStrictPrivacy,
435448 } ,
436449 hooks ,
0 commit comments