Skip to content

fix(admin): attach usage-tracking headers to Firestore requests#308

Open
demolaf wants to merge 7 commits into
firestore/settings-headersfrom
firestore/admin-usage-headers
Open

fix(admin): attach usage-tracking headers to Firestore requests#308
demolaf wants to merge 7 commits into
firestore/settings-headersfrom
firestore/admin-usage-headers

Conversation

@demolaf

@demolaf demolaf commented Jul 23, 2026

Copy link
Copy Markdown
Member

Firestore requests never carried the SDK's usage-tracking headers (X-Firebase-Client, X-Goog-Api-Client) — FirestoreHttpClient builds its own HTTP client independently of FirebaseApp.client/FirebaseUserAgentClient, so it was never wrapped.

Uses the new Settings.headers from #307 to attach the same headers, and extracts a shared firebaseUserAgentHeaders helper so the values aren't duplicated between FirebaseUserAgentClient and Firestore. Depends on #307 merging first.

@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 ensures that Firestore requests carry the SDK's usage-tracking headers (X-Firebase-Client and X-Goog-Api-Client) by extracting them into a shared utility and applying them to both FirebaseUserAgentClient and Firestore settings. The review feedback highlights two important improvements: first, instead of only applying tracking headers when no custom headers exist, they should be merged with any user-provided headers to prevent them from being completely omitted; second, the shared headers should be defined as a final variable rather than a getter to avoid redundant map allocations and regex evaluations on every HTTP request.

Comment thread packages/firebase_admin_sdk/lib/src/firestore/firestore.dart Outdated
Comment thread packages/firebase_admin_sdk/lib/src/utils/utils.dart Outdated
@github-actions

Copy link
Copy Markdown

Coverage Report

✅ Coverage 75.53% meets 40% threshold

Total Coverage: 75.53%
Lines Covered: 5228/6922

Package Breakdown

Package Coverage
firebase_admin_sdk 72.72%
google_cloud_firestore 78.69%

Minimum threshold: 40%

@demolaf
demolaf marked this pull request as ready for review July 24, 2026 12:04
@demolaf
demolaf requested a review from brianquinlan July 24, 2026 12:07
request.headers['X-Firebase-Client'] = 'fire-admin-dart/$packageVersion';
request.headers['X-Goog-Api-Client'] =
'gl-dart/$dartVersion fire-admin/$packageVersion';
request.headers.addAll(firebaseUserAgentHeaders);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this semantically different than what was there before?

@@ -1,5 +1,6 @@
## 0.5.4-wip

- Fixed `Firestore` requests not carrying the SDK's usage-tracking headers (`X-Firebase-Client`, `X-Goog-Api-Client`).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this meant to be wrapped at 80 columns.

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