File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
18
18
import { PriorityQueue } from '../../lib/priority-queue'
19
19
import { getCDN , setGlobalCDNUrl } from '../../lib/parse-cdn'
20
20
import { clearAjsBrowserStorage } from '../../test-helpers/browser-storage'
21
+ import { ActionDestination } from '@/plugins/remote-loader'
21
22
22
23
// eslint-disable-next-line @typescript-eslint/no-explicit-any
23
24
let fetchCalls : Array < any > [ ] = [ ]
@@ -711,6 +712,35 @@ describe('addDestinationMiddleware', () => {
711
712
hello : 'from the other side' ,
712
713
} )
713
714
} )
715
+
716
+ it ( 'supports registering action destination middlewares' , async ( ) => {
717
+ const testPlugin : Plugin = {
718
+ name : 'test' ,
719
+ type : 'destination' ,
720
+ version : '0.1.0' ,
721
+ load : ( ) => Promise . resolve ( ) ,
722
+ isLoaded : ( ) => true ,
723
+ }
724
+
725
+ const [ analytics ] = await AnalyticsBrowser . load ( {
726
+ writeKey,
727
+ } )
728
+
729
+ const fullstory = new ActionDestination ( 'fullstory' , testPlugin )
730
+
731
+ await analytics . register ( fullstory )
732
+ await fullstory . ready ( )
733
+
734
+ analytics
735
+ . addDestinationMiddleware ( 'fullstory' , ( { next, payload } ) =>
736
+ next ( payload )
737
+ )
738
+ . catch ( ( err ) => {
739
+ throw err
740
+ } )
741
+
742
+ expect ( analytics . queue . plugins ) . toContain ( fullstory )
743
+ } )
714
744
} )
715
745
716
746
describe ( 'use' , ( ) => {
Original file line number Diff line number Diff line change @@ -405,9 +405,7 @@ export class Analytics
405
405
...middlewares : DestinationMiddlewareFunction [ ]
406
406
) : Promise < Analytics > {
407
407
const legacyDestinations = this . queue . plugins . filter (
408
- ( xt ) =>
409
- // xt instanceof LegacyDestination &&
410
- xt . name . toLowerCase ( ) === integrationName . toLowerCase ( )
408
+ ( xt ) => xt . name . toLowerCase ( ) === integrationName . toLowerCase ( )
411
409
) as LegacyDestination [ ]
412
410
413
411
legacyDestinations . forEach ( ( destination ) => {
You can’t perform that action at this time.
0 commit comments