File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
Expand file tree Collapse file tree 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 {
3535 referrerPolicy : ( supportsReferrerPolicy ( ) ? 'origin' : '' ) as ReferrerPolicy ,
3636 } ;
3737
38+ if ( this . options . fetchParameters !== undefined ) {
39+ Object . assign ( options , this . options . fetchParameters ) ;
40+ }
41+
3842 if ( this . options . headers !== undefined ) {
3943 options . headers = this . options . headers ;
4044 }
Original file line number Diff line number Diff line change @@ -156,5 +156,29 @@ describe('FetchTransport', () => {
156156 } ) ,
157157 ) . equal ( true ) ;
158158 } ) ;
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+ } ) ;
159183 } ) ;
160184} ) ;
Original file line number Diff line number Diff line change @@ -34,4 +34,6 @@ export interface TransportOptions {
3434 httpsProxy ?: string ;
3535 /** HTTPS proxy certificates path */
3636 caCerts ?: string ;
37+ /** Fetch API init parameters */
38+ fetchParameters ?: { [ key : string ] : string } ;
3739}
You can’t perform that action at this time.
0 commit comments