File tree Expand file tree Collapse file tree 4 files changed +47
-3
lines changed
node/src/plugins/segmentio Expand file tree Collapse file tree 4 files changed +47
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @segment/analytics-next ' : minor
3+ ' @segment/analytics-node ' : minor
4+ ---
5+
6+ Change segmentio to destination type
Original file line number Diff line number Diff line change @@ -75,6 +75,16 @@ const googleAnalytics: Plugin = {
7575 type : 'destination' ,
7676}
7777
78+ const slowPlugin : Plugin = {
79+ ...xt ,
80+ name : 'Slow Plugin' ,
81+ type : 'destination' ,
82+ track : async ( ctx ) => {
83+ await sleep ( 3000 )
84+ return ctx
85+ } ,
86+ }
87+
7888const enrichBilling : Plugin = {
7989 ...xt ,
8090 name : 'Billing Enrichment' ,
@@ -574,6 +584,34 @@ describe('Dispatch', () => {
574584 expect ( segmentSpy ) . toHaveBeenCalledWith ( boo )
575585 } )
576586
587+ it ( 'dispatching to Segmentio not blocked by other destinations' , async ( ) => {
588+ const [ ajs ] = await AnalyticsBrowser . load ( {
589+ writeKey,
590+ plugins : [ slowPlugin ] ,
591+ } )
592+
593+ const segmentio = ajs . queue . plugins . find ( ( p ) => p . name === 'Segment.io' )
594+ const segmentSpy = jest . spyOn ( segmentio ! , 'track' )
595+
596+ await Promise . race ( [
597+ ajs . track (
598+ 'Boo!' ,
599+ {
600+ total : 25 ,
601+ userId : '👻' ,
602+ } ,
603+ {
604+ integrations : {
605+ All : true ,
606+ } ,
607+ }
608+ ) ,
609+ sleep ( 100 ) ,
610+ ] )
611+
612+ expect ( segmentSpy ) . toHaveBeenCalled ( )
613+ } )
614+
577615 it ( 'enriches events before dispatching' , async ( ) => {
578616 const [ ajs ] = await AnalyticsBrowser . load ( {
579617 writeKey,
@@ -611,8 +649,8 @@ describe('Dispatch', () => {
611649 "plugin_time",
612650 "plugin_time",
613651 "plugin_time",
614- "message_delivered",
615652 "plugin_time",
653+ "message_delivered",
616654 "delivered",
617655 ]
618656 ` )
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ export function segmentio(
125125
126126 const segmentio : Plugin = {
127127 name : 'Segment.io' ,
128- type : 'after ' ,
128+ type : 'destination ' ,
129129 version : '0.1.0' ,
130130 isLoaded : ( ) : boolean => true ,
131131 load : ( ) : Promise < void > => Promise . resolve ( ) ,
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export function createNodePlugin(publisher: Publisher): SegmentNodePlugin {
4141
4242 return {
4343 name : 'Segment.io' ,
44- type : 'after ' ,
44+ type : 'destination ' ,
4545 version : '1.0.0' ,
4646 isLoaded : ( ) => true ,
4747 load : ( ) => Promise . resolve ( ) ,
You can’t perform that action at this time.
0 commit comments