File tree 3 files changed +30
-0
lines changed
3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ export class FetchTransport extends BaseTransport {
35
35
referrerPolicy : ( supportsReferrerPolicy ( ) ? 'origin' : '' ) as ReferrerPolicy ,
36
36
} ;
37
37
38
+ if ( this . options . fetchParameters !== undefined ) {
39
+ Object . assign ( options , this . options . fetchParameters ) ;
40
+ }
41
+
38
42
if ( this . options . headers !== undefined ) {
39
43
options . headers = this . options . headers ;
40
44
}
Original file line number Diff line number Diff line change @@ -156,5 +156,29 @@ describe('FetchTransport', () => {
156
156
} ) ,
157
157
) . equal ( true ) ;
158
158
} ) ;
159
+
160
+ it ( 'passes in fetch parameters' , async ( ) => {
161
+ transport = new Transports . FetchTransport ( {
162
+ dsn : testDsn ,
163
+ fetchParameters : {
164
+ credentials : 'include' ,
165
+ } ,
166
+ } ) ;
167
+ const response = { status : 200 } ;
168
+
169
+ fetch . returns ( Promise . resolve ( response ) ) ;
170
+
171
+ const res = await transport . sendEvent ( payload ) ;
172
+
173
+ expect ( res . status ) . equal ( Status . Success ) ;
174
+ expect (
175
+ fetch . calledWith ( transportUrl , {
176
+ body : JSON . stringify ( payload ) ,
177
+ credentials : 'include' ,
178
+ method : 'POST' ,
179
+ referrerPolicy : 'origin' ,
180
+ } ) ,
181
+ ) . equal ( true ) ;
182
+ } ) ;
159
183
} ) ;
160
184
} ) ;
Original file line number Diff line number Diff line change @@ -34,4 +34,6 @@ export interface TransportOptions {
34
34
httpsProxy ?: string ;
35
35
/** HTTPS proxy certificates path */
36
36
caCerts ?: string ;
37
+ /** Fetch API init parameters */
38
+ fetchParameters ?: { [ key : string ] : string } ;
37
39
}
You can’t perform that action at this time.
0 commit comments