File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -415,6 +415,16 @@ export const emptyRuntime = (config: JitsuOptions): RuntimeFacade => ({
415415 } ,
416416} ) ;
417417
418+ function deepCopy ( o ) {
419+ if ( typeof o !== "object" ) {
420+ return o ;
421+ }
422+ if ( ! o ) {
423+ return o ;
424+ }
425+ return JSON . parse ( JSON . stringify ( o ) ) ;
426+ }
427+
418428function deepMerge ( target : any , source : any ) {
419429 if ( typeof source !== "object" || source === null ) {
420430 return source ;
@@ -574,15 +584,17 @@ async function processDestinations(
574584 const promises : Promise < any > [ ] = [ ] ;
575585
576586 for ( const destination of destinations ) {
577- let newEvents = [ originalEvent ] ;
587+ let newEvents : AnalyticsClientEvent [ ] = [ ] ;
578588 if ( destination . newEvents ) {
579589 try {
580590 newEvents = destination . newEvents . map ( e =>
581- e === "same" ? originalEvent : isDiff ( e ) ? diff . patch ( originalEvent , e . __diff ) : e
591+ e === "same" ? deepCopy ( originalEvent ) : isDiff ( e ) ? diff . patch ( deepCopy ( originalEvent ) , e . __diff ) : e
582592 ) ;
583593 } catch ( e ) {
584594 console . error ( `[JITSU] Error applying '${ destination . id } ' changes to event: ${ e ?. message } ` , e ) ;
585595 }
596+ } else {
597+ newEvents = [ deepCopy ( originalEvent ) ] ;
586598 }
587599 const credentials = { ...destination . credentials , ...destination . options } ;
588600
You can’t perform that action at this time.
0 commit comments