Skip to content

Firestore (Desktop): send current user agent with every request - #1987

Open
AustinBenoit wants to merge 2 commits into
mainfrom
fix/firestore-desktop-user-agent
Open

AustinBenoit wants to merge 2 commits into
mainfrom
fix/firestore-desktop-user-agent

Conversation

@AustinBenoit

Copy link
Copy Markdown
Contributor

Description

On desktop, FirebaseMetadataProviderCpp previously sent the user agent stored inside today's heartbeat once per day and omitted x-firebase-client on subsequent requests. Because that heartbeat is logged during App::Create() before Firestore registers fire-fst, desktop Firestore usage was largely unattributed.

Match the Android and iOS metadata providers:

  • Send the current App::GetUserAgent() in x-firebase-client on every gRPC request.
  • Attach x-firebase-client-log-type: 2 at most once per day using GetAndResetTodaysStoredHeartbeats().

Testing

  • Compiled firebase_metadata_provider_desktop.cc.o locally on Linux (clang-19).
  • Passed scripts/gha/check_copyright.sh -g and scripts/format_code.py -git_diff -noformat_file.
  • Relying on CI for cross-platform builds and integration tests.

Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

The desktop metadata provider sent the user agent stored with the day's heartbeat, once a day, and nothing on other requests. That heartbeat is logged when the App is created, before Firestore registers fire-fst, so desktop Firestore usage was mostly unattributed.

Match the Android and iOS providers: flag one request per day as the heartbeat, and send the current App::GetUserAgent() on every request.

@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 updates the desktop Firestore metadata provider to always send the current Firebase user agent with each request, aligning its behavior with the Android and iOS SDKs, and updates the release notes. The review feedback correctly identifies a potential null pointer dereference risk if App::GetUserAgent() returns nullptr, recommending a defensive check before adding the user agent to the metadata.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

1 participant