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 {
84
84
}
85
85
return this . _buffer . add (
86
86
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 ) => {
88
107
const statusCode = res . statusCode || 500 ;
89
108
const status = Status . fromHttpCode ( statusCode ) ;
90
109
@@ -118,7 +137,7 @@ export abstract class BaseTransport implements Transport {
118
137
} ) ;
119
138
} ) ;
120
139
req . on ( 'error' , reject ) ;
121
- req . end ( JSON . stringify ( event ) ) ;
140
+ req . end ( payload ) ;
122
141
} ) ,
123
142
) ;
124
143
}
You can’t perform that action at this time.
0 commit comments