fix: suppress OkHttp default User-Agent header on outbound requests#29
fix: suppress OkHttp default User-Agent header on outbound requests#29chrismParticle wants to merge 1 commit into
Conversation
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>
PR SummaryMedium Risk Overview Adds Reviewed by Cursor Bugbot for commit 8a35aa4. Bugbot is set up for automated code reviews on this repo. Configure here. |
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