Skip to content

feat(data-connect): add "X-Client-Platform" and "X-Client-Version" headers - #10217

Open
dconeybe wants to merge 17 commits into
mainfrom
dconeybe/dataconnect/CloudMonitoringHeaders
Open

feat(data-connect): add "X-Client-Platform" and "X-Client-Version" headers#10217
dconeybe wants to merge 17 commits into
mainfrom
dconeybe/dataconnect/CloudMonitoringHeaders

Conversation

@dconeybe

@dconeybe dconeybe commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This PR adds x-client-platform and x-client-version request headers to the @firebase/data-connect SDK. These headers send the client platform (web) and SDK version to enable metrics collection in Cloud Monitoring.

Highlights

  • New Metadata Headers: Added x-client-platform (set to "web") and x-client-version (set to SDK_VERSION) request headers across REST (fetch.ts) and streaming (streamTransport.ts) transports.
  • First Stream Message Scoping: Configured streaming requests to send x-client-platform and x-client-version exclusively on the initial stream message.
  • Expanded Test Coverage: Added unit tests in userAgent.test.ts and streamTransport.test.ts verifying header inclusion on REST calls and initial streaming messages, as well as omission on subsequent streaming messages.
  • Changeset Added: Included a changeset entry for @firebase/data-connect.
Changelog
  • old-roses-juggle.md
    • Added changeset entry documenting platform and version headers for Cloud Monitoring metrics collection.
  • fetch.ts
    • Added x-client-platform and x-client-version headers to dcFetch.
  • streamTransport.ts
    • Added x-client-platform and x-client-version headers inside prepareMessage for the initial stream message.
  • wire.ts
    • Added optional x-client-platform and x-client-version fields to StreamRequestHeaders.
  • streamTransport.test.ts
    • Added unit tests asserting x-client-platform and x-client-version are present on the first stream message only.
  • userAgent.test.ts
    • Updated REST header test expectations to check x-client-platform and x-client-version.

…aders

Googlers see go/dataconnect:sdk:headers for details
@dconeybe dconeybe self-assigned this Jul 28, 2026
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 720b031

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@firebase/data-connect Patch
firebase Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds 'x-client-platform' and 'x-client-version' headers to both REST and stream transport requests in the @firebase/data-connect package to enable metrics collection. These headers are included in the initial stream message and standard fetch requests, and corresponding unit tests have been added to verify this behavior. There are no review comments, and I have no additional feedback to provide.

@dconeybe dconeybe changed the title feat(data-connect): Add "X-Client-Platform" and "X-Client-Version" headers feat(data-connect): Add grpc request headers for platform name and sdk version Jul 28, 2026
@dconeybe dconeybe changed the title feat(data-connect): Add grpc request headers for platform name and sdk version feat(data-connect): add "X-Client-Platform" and "X-Client-Version" headers Jul 28, 2026
@dconeybe
dconeybe marked this pull request as ready for review July 28, 2026 14:36
@dconeybe
dconeybe requested review from a team and stephenarosaj as code owners July 28, 2026 14:36
dconeybe added 16 commits July 28, 2026 17:19
…ersion" headers to see if the github actions still fail.
…Client-Version" headers to see if the github actions still fail."

This reverts commit 37e8a4e.
…-Client-Version" headers to see if the github actions still fail."

This reverts commit aac56b0.
@dconeybe

Copy link
Copy Markdown
Contributor Author

Turns out that the tests were failing because the dataconnect backend servers reject the X-Client-Platform, and return a 403 for the OPTIONS preflight request. However, the X-Client-Version header is whitelisted and results in a 200 for the OPTIONS preflight request.

Therefore, CORS preflight requests that contain both X-Client-Platform and X-Client-Version headers result in the failed preflight on account of the former header, which is not whitelisted.

Googlers can see go/api-cors for where the whitelist is maintained

@dconeybe

Copy link
Copy Markdown
Contributor Author

After discussion, the decision was made to mash X-Client-Platform and X-Client-Version into X-Client-Version. The value of the header will take a form similar to a "user agent" string.

Here are some example values:

  • web/0.7.1
  • android/17.3.2
  • ios/11.12.5
  • flutter/0.3.0+6
  • node/14.2.0

I will update this PR accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant