Skip to content

fix: Send the Flagsmith-SDK-User-Agent header so Flagsmith can tell which SDK sent each request - #99

Merged
Zaimwa9 merged 1 commit into
mainfrom
fix/sdk-user-agent-header
Nov 10, 2026
Merged

Zaimwa9 merged 1 commit into
mainfrom
fix/sdk-user-agent-header

Conversation

@Zaimwa9

@Zaimwa9 Zaimwa9 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Why

Flagsmith's events ingestion server reads the SDK language and version only from the Flagsmith-SDK-User-Agent header, parsing flagsmith-<lang>-sdk/<version>. It ignores User-Agent. The Kotlin SDK only sends User-Agent, so its events would be stored with sdk_language and sdk_version set to unknown.

What changed

FlagsmithRetrofitService.userAgentInterceptor() now also sets Flagsmith-SDK-User-Agent to the same value as User-Agent (flagsmith-kotlin-android-sdk/<version>). User-Agent is unchanged. The header name is a named constant, like USER_AGENT_HEADER.

The header goes on every request the interceptor handles, not only events:

  • The JS SDK already sends it on all requests, including flags and identities.
  • The Node, Python and Flutter SDKs send it only on event requests and keep User-Agent for the rest.
  • The core API reads Flagsmith-SDK-User-Agent first and falls back to User-Agent when it labels SDK usage. Both headers carry the same value here, so API labelling does not change.

Adding it in the shared interceptor keeps the change to one place and means any client built on that interceptor sends it.

PR #98 adds FlagsmithEventProcessor, whose OkHttp client reuses userAgentInterceptor(). Once #98 is rebased on this, its event requests send the header with no further change.

How it was tested

  • New UserAgentTests.testFlagsmithSdkUserAgentHeaderIsSent makes a real flags request against MockServer and checks the recorded Flagsmith-SDK-User-Agent value. The version line sits inside the release-please markers like the existing test, so release bumps keep it in sync.
  • Without the interceptor change the new test fails. With it, the test passes.
  • ./gradlew check -x koverVerify -P excludeIntegrationTests passes locally.

…hich SDK sent each request

Flagsmith's events ingestion server reads the SDK language and version
only from the Flagsmith-SDK-User-Agent header. Send it from the shared
user agent interceptor, with the same value as User-Agent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Zaimwa9
Zaimwa9 requested a review from a team as a code owner November 10, 2026 14:23
@Zaimwa9
Zaimwa9 requested review from talissoncosta and removed request for a team November 10, 2026 14:23
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The interceptor now sets the SDK version string in both the standard User-Agent header and the Flagsmith-SDK-User-Agent header. A test makes a successful feature-flags request and checks the recorded request's SDK-specific header value.

Estimated code review effort: 2 (Simple) | ~8 minutes

Merge Risk: Minimal · up to af443

The additional header carries the existing SDK value. No merge-blocking issue is identified.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d9a37594-7e22-4bc0-9bcc-a7de8f1da951
Commits

Reviewing files that changed from the base of the PR and between 07f9181 and af44335.

Files selected for processing: 2

  • FlagsmithClient/src/main/java/com/flagsmith/internal/FlagsmithRetrofitService.kt
  • FlagsmithClient/src/test/java/com/flagsmith/UserAgentTests.kt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@Zaimwa9
Zaimwa9 merged commit 0c50799 into main Nov 10, 2026
5 checks passed
Zaimwa9 pushed a commit that referenced this pull request Nov 10, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.10.0](v1.9.0...v1.10.0)
(2026-11-10)


### Features

* Support `getExperimentFlag`, `trackEvent` and `trackExposure` methods
([#98](#98))
([6989568](6989568))


### Bug Fixes

* Send the Flagsmith-SDK-User-Agent header so Flagsmith can tell which
SDK sent each request
([#99](#99))
([0c50799](0c50799))
* Send trait values with their JSON types
([#90](#90))
([644d69f](644d69f))


### CI

* Run the Flagsmith SDK behavioural spec
([#89](#89))
([169807e](169807e))


### Other

* Give Renovate's pull requests Conventional Commit titles
([#94](#94))
([1e5a09e](1e5a09e))
* Let Renovate keep updating spec bumps the webhook handler commits to
([#95](#95))
([07f9181](07f9181))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants