File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
packages/node/src/transports Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,26 @@ export abstract class BaseTransport implements Transport {
8484 }
8585 return this . _buffer . add (
8686 new Promise < Response > ( ( resolve , reject ) => {
87- const req = httpModule . request ( this . _getRequestOptions ( ) , ( res : http . IncomingMessage ) => {
87+ const options = this . _getRequestOptions ( ) ;
88+ let payload = JSON . stringify ( event ) ;
89+
90+ if ( event . type === 'transaction' ) {
91+ options . path = ( options . path || '' ) . replace ( '/store' , '/envelope' ) ;
92+ ( options . headers || { } ) [ 'content-type' ] = 'application/x-sentry-envelope' ;
93+
94+ const enveloperHeaders = JSON . stringify ( {
95+ event_id : event . event_id ,
96+ sent_at : null ,
97+ } ) ;
98+ const itemHeaders = JSON . stringify ( {
99+ content_type : 'application/json' ,
100+ type : event . type ,
101+ } ) ;
102+ const envelope = `${ enveloperHeaders } \n${ itemHeaders } \n${ payload } \n` ;
103+ payload = envelope ;
104+ }
105+
106+ const req = httpModule . request ( options , ( res : http . IncomingMessage ) => {
88107 const statusCode = res . statusCode || 500 ;
89108 const status = Status . fromHttpCode ( statusCode ) ;
90109
@@ -118,7 +137,7 @@ export abstract class BaseTransport implements Transport {
118137 } ) ;
119138 } ) ;
120139 req . on ( 'error' , reject ) ;
121- req . end ( JSON . stringify ( event ) ) ;
140+ req . end ( payload ) ;
122141 } ) ,
123142 ) ;
124143 }
You can’t perform that action at this time.
0 commit comments