mixpanel / mixpanel-android

Official Android Tracking Library for Mixpanel Analytics
http://mixpanel.com/
Apache License 2.0
1.02k stars 366 forks source link

feat: add headers support for mixpanel proxy api calls #833

Closed abhilashdas-cred closed 5 months ago

abhilashdas-cred commented 5 months ago

Introducing Header Support for Mixpanel Proxy Servers

This pull request introduces a feature enabling proxy servers to request custom headers from the application.

Problem:

Currently, when the proxy server URL is set, it makes API calls in a standard manner. However, if the application wishes to include certain headers, such as authentication tokens or device IDs, this isn't possible.

Solution:

This pull request implements a callback mechanism. Before making an API call, the system requests headers and returns the API endpoint and status code. This information can be utilized by the application for tracking or other purposes.

Implementation:

This implementation introduces a new property in the config class called "MixpanelServerCallback". It contains a method named "getHeaders()" which requests any headers to be passed just before the proxy server API call. Once the API call is complete, it returns the API endpoint and status code via "onResponse()".

Benefits:

Enhanced Proxy API Control: This solution grants the proxy API full control during Mixpanel proxy API calls.