Skip to content

Support custom request headers #365

@ghost

Description

Summary

Can amplitude SDK support custom request headers? Like

amplitude.getInstance().init(APIKEY, null, {
  headers: {     // <- new attribute in option
     'x-session-id': appToken
  }
});

// or

 amplitude.getInstance().init(APIKEY, null, {
  headers: function() {     // <- new attribute in option
    return {
       'x-session-id': appToken
    };
  }
});

Motivations

Our frontend events require to flow into our backend and then to amplitude (frontend -> backend -> amplitude). We are doing so because we want to massage (by adding user information based on the x-session-id) the frontend events a little and then use a centralized forwarder to send events to amplitude.

We still want to keep using the amplitude frontend SDK to collect the metadata information (like device ID) and queue feature. But need a way to pass our backend the auth token.

Is this possible or is there any workaround? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions