-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Labels
questionFurther information is requestedFurther information is requested
Description
Summary
Hello, like in #267 we would like to add a custom header for authentication with our proxy server. As suggested in that issue I don't think it's possible to replace the transport provider in order to provide a new transport any more. We could use the api_key field but we also need to update that when the token is refreshed so that's no ideal.
In an perfect world we would just extend/swap the fetch transport and add our header there but my attempts failed. Maybe there is an easy way that I am missing :)
I tried like this:
import * as amplitude from '@amplitude/analytics-browser';
amplitude.init('placeholder-apikey', undefined, {
autocapture: false,
serverZone: 'EU',
appVersion: '',
trackingOptions: {
ipAddress: false,
language: false,
platform: false,
},
fetchRemoteConfig: false,
serverUrl: 'http://proxy-url',
transportProvider: (transport?: TransportType): Transport => {
if (transport === 'beacon') {
return new SendBeaconTransport();
}
return new class extends BaseTransport implements Transport {
async send(serverUrl: string, payload: Payload): Promise<Response | null> {
//...
}
}
},
});
SebastianFranze
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested