{{ message }}
fix: suppress OkHttp default User-Agent header on outbound requests#30
Open
chrismParticle wants to merge 1 commit into
Open
fix: suppress OkHttp default User-Agent header on outbound requests#30chrismParticle wants to merge 1 commit into
chrismParticle wants to merge 1 commit into
Conversation
e9b7eab to
0e389b2
Compare
Adds a UserAgentInterceptor (network interceptor) to ApiClient that removes the okhttp/<version> User-Agent header injected by OkHttp's BridgeInterceptor. This prevents mParticle from enriching device_info.http_header_user_agent with a meaningless SDK string. Caller-supplied User-Agent values are preserved. Wired in both createDefaultAdapter() and configureFromOkclient(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0e389b2 to
29503b1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
UserAgentInterceptor(network interceptor) toApiClientthat strips OkHttp's defaultUser-Agentheader (okhttp/<version>) afterBridgeInterceptorinjects itcreateDefaultAdapter()andconfigureFromOkclient()so all construction paths are coveredUser-Agentvalues (set via a custom OkHttp interceptor) are detected and passed through unchangeddevice_info.http_header_user_agentwith a meaningless library-identifier stringVersion
Changelog entry added for
2.8.0.Test plan
ApiClientUserAgentTestcovers three cases usingMockWebServer: default path (no UA), caller override preserved, andconfigureFromOkclientpath./gradlew test— 9 tests, all passingdevice_info.http_header_user_agent; batch withUser-Agent: my_appshowsmy_appcorrectlyNotes
addNetworkInterceptor(notaddInterceptor) — required because OkHttp'sBridgeInterceptorruns between application and network interceptors and re-injects the default UA if the header is absent at the application layerRateLimitInterceptoris unchanged🤖 Generated with Claude Code