@@ -14,8 +14,6 @@ var Identify = require('segmentio-facade').Identify;
14
14
var SourceMiddlewareChain = require ( './middleware' ) . SourceMiddlewareChain ;
15
15
var IntegrationMiddlewareChain = require ( './middleware' )
16
16
. IntegrationMiddlewareChain ;
17
- var DestinationMiddlewareChain = require ( './middleware' )
18
- . DestinationMiddlewareChain ;
19
17
var Page = require ( 'segmentio-facade' ) . Page ;
20
18
var Track = require ( 'segmentio-facade' ) . Track ;
21
19
var bindAll = require ( 'bind-all' ) ;
@@ -52,7 +50,6 @@ function Analytics() {
52
50
this . Integrations = { } ;
53
51
this . _sourceMiddlewares = new SourceMiddlewareChain ( ) ;
54
52
this . _integrationMiddlewares = new IntegrationMiddlewareChain ( ) ;
55
- this . _destinationMiddlewares = { } ;
56
53
this . _integrations = { } ;
57
54
this . _readied = false ;
58
55
this . _timeout = 300 ;
@@ -114,7 +111,6 @@ Analytics.prototype.addSourceMiddleware = function(middleware) {
114
111
115
112
/**
116
113
* Define a new `IntegrationMiddleware`
117
- * DEPRECATED
118
114
*
119
115
* @param {Function } Middleware
120
116
* @return {Analytics }
@@ -125,32 +121,6 @@ Analytics.prototype.addIntegrationMiddleware = function(middleware) {
125
121
return this ;
126
122
} ;
127
123
128
- /**
129
- * Define a new `DestinationMiddleware`
130
- * Destination Middleware is chained after integration middleware
131
- *
132
- * @param {String } integrationName
133
- * @param {Array } Middlewares
134
- * @return {Analytics }
135
- */
136
-
137
- Analytics . prototype . addDestinationMiddleware = function (
138
- integrationName ,
139
- middlewares
140
- ) {
141
- var self = this ;
142
- middlewares . forEach ( function ( middleware ) {
143
- if ( ! self . _destinationMiddlewares [ integrationName ] ) {
144
- self . _destinationMiddlewares [
145
- integrationName
146
- ] = new DestinationMiddlewareChain ( ) ;
147
- }
148
-
149
- self . _destinationMiddlewares [ integrationName ] . add ( middleware ) ;
150
- } ) ;
151
- return self ;
152
- } ;
153
-
154
124
/**
155
125
* Initialize with the given integration `settings` and `options`.
156
126
*
@@ -764,6 +734,11 @@ Analytics.prototype._invoke = function(method, facade) {
764
734
result = new Facade ( result ) ;
765
735
}
766
736
737
+ self . emit ( 'invoke' , result ) ;
738
+ metrics . increment ( 'analytics_js.invoke' , {
739
+ method : method
740
+ } ) ;
741
+
767
742
applyIntegrationMiddlewares ( result ) ;
768
743
}
769
744
) ;
@@ -816,53 +791,12 @@ Analytics.prototype._invoke = function(method, facade) {
816
791
result = new Facade ( result ) ;
817
792
}
818
793
819
- // apply destination middlewares
820
- // Apply any integration middlewares that exist, then invoke the integration with the result.
821
- if ( self . _destinationMiddlewares [ integration . name ] ) {
822
- self . _destinationMiddlewares [ integration . name ] . applyMiddlewares (
823
- facadeCopy ,
824
- integration . name ,
825
- function ( result ) {
826
- // A nullified payload should not be sent to an integration.
827
- if ( result === null ) {
828
- self . log (
829
- 'Payload to destination "%s" was null and dropped by a middleware.' ,
830
- name
831
- ) ;
832
- return ;
833
- }
834
-
835
- // Check if the payload is still a Facade. If not, convert it to one.
836
- if ( ! ( result instanceof Facade ) ) {
837
- result = new Facade ( result ) ;
838
- }
839
-
840
- self . emit ( 'invoke' , result ) ;
841
- metrics . increment ( 'analytics_js.invoke' , {
842
- method : method
843
- } ) ;
844
-
845
- metrics . increment ( 'analytics_js.integration.invoke' , {
846
- method : method ,
847
- integration_name : integration . name
848
- } ) ;
849
-
850
- integration . invoke . call ( integration , method , result ) ;
851
- }
852
- ) ;
853
- } else {
854
- self . emit ( 'invoke' , result ) ;
855
- metrics . increment ( 'analytics_js.invoke' , {
856
- method : method
857
- } ) ;
858
-
859
- metrics . increment ( 'analytics_js.integration.invoke' , {
860
- method : method ,
861
- integration_name : integration . name
862
- } ) ;
863
-
864
- integration . invoke . call ( integration , method , result ) ;
865
- }
794
+ metrics . increment ( 'analytics_js.integration.invoke' , {
795
+ method : method ,
796
+ integration_name : integration . name
797
+ } ) ;
798
+
799
+ integration . invoke . call ( integration , method , result ) ;
866
800
}
867
801
) ;
868
802
} catch ( e ) {
0 commit comments