Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose API to set custom headers to /events and /builds requests #1731

Open
abhaysood opened this issue Jan 15, 2025 · 0 comments
Open

Expose API to set custom headers to /events and /builds requests #1731

abhaysood opened this issue Jan 15, 2025 · 0 comments
Labels
android android related feature new features

Comments

@abhaysood
Copy link
Contributor

abhaysood commented Jan 15, 2025

Description

Measure Gradle Plugin

  • In MeasurePluginExtension expose a new httpHeaders: Map<String, String> field which allows adding custom headers at build time.
measure {
  httpHeaders = mapOf(
    "key" to "value"
  )
}

Also ensure that these headers can be overriden by a variant filter config:

 variantFilter {
        httpHeaders = when {
            name.contains("debug") -> mapOf("key" to "debug-value")
            name.contains("alpha") -> mapOf("key" to "alpha-value")
            else -> mapOf("key" to "prod-value")
        }
    }
  • Modify the BuildUploadTask to accept the headers as a input
  • Modify the request to add the headers received.
  • Update BuildUploadTaskTest.
  • Update public facing documentation @abhaysood.

Measure SDK

  • Add a new MeasureConfig called requestHeadersProvider: MsrRequestHeadersProvider, with a default implementation which returns an empty map.
interface MsrRequestHeadersProvider {
    fun getRequestHeaders(): Map<String, String>
}
  • Modify NetworkClientImpl to add the headers from the config.
  • Update public facing documentation @abhaysood
  • Update NetworkClientTest as necessary.
  • Update EventsTest instrumentation test to verify headers are set correctly.

Disallowed Headers

Any new header can be added except the ones specified below. Both the gradle plugin and SDK implementations must ignore if any of the following headers have been provided. The comparison must be case insensitive.

  • Content-Type
  • msr-req-id
  • Authorization
  • Content-Length

For the SDK, these disallowed headers must be added to a new InternalConfig called disallowedCustomHeaders: List<String>.

Related issue

Feature request: #1689

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android android related feature new features
Projects
Status: Todo
Development

No branches or pull requests

1 participant