Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make COUNT queries available to the Firestore Console #6643

Merged
merged 6 commits into from
Oct 7, 2022

Conversation

dconeybe
Copy link
Contributor

@dconeybe dconeybe commented Sep 30, 2022

There are two notable changes in this PR:

  1. Add a call to XhrIo.setWithCredentials(true) when invoking the RunAggregationQuery RPC.
  2. Add a hook in firestore-compat to call getCountFromServer() in the INTERNAL object.

The XhrIo.setWithCredentials(true) change is required so that the Firestore Console's authentication cookie will be included in the HTTP request headers. Without it, the requests fail with HTTP 401 errors. This problem is unique to the Firestore Console because they use 1st-party authentication. This change should have no effect on any other users. Moreover, the "Listen" and "Write" streams have been invoking XhrIo.setWithCredentials(true) indirectly since the dawn of time by specifying supportsCrossDomainXhr: true in the WebChannelOptions:

which trickles down to call XhrIo.setWithCredentials(true) here: https://github.com/google/closure-library/blob/e439bfd5ff09e0efd85693fc5adf23462d5a39d4/closure/goog/labs/net/webchannel/webchannelbase.js#L2601

The change to the firestore-compat library is done because the Firestore Console is stuck using the compat SDK for now, and we don't want to add a new public API surface to the firestore-compat library.

Googlers see b/250662155 for more info.

@changeset-bot
Copy link

changeset-bot bot commented Sep 30, 2022

🦋 Changeset detected

Latest commit: 58a29f7

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

This PR includes changesets to release 4 packages
Name Type
@firebase/firestore Minor
@firebase/firestore-compat Minor
@firebase/webchannel-wrapper Minor
firebase Minor

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 30, 2022

Size Report 1

Affected Products

  • @firebase/firestore

    TypeBase (34ad43c)Merge (5214684)Diff
    browser265 kB265 kB+25 B (+0.0%)
    esm5330 kB330 kB+25 B (+0.0%)
    module265 kB265 kB+25 B (+0.0%)
    react-native266 kB266 kB+25 B (+0.0%)
  • @firebase/webchannel-wrapper

    TypeBase (34ad43c)Merge (5214684)Diff
    esm544.6 kB44.7 kB+75 B (+0.2%)
    main54.6 kB54.6 kB+75 B (+0.1%)
    module42.3 kB42.4 kB+75 B (+0.2%)
  • bundle

    TypeBase (34ad43c)Merge (5214684)Diff
    firestore (Persistence)276 kB276 kB+103 B (+0.0%)
    firestore (Query Cursors)213 kB213 kB+103 B (+0.0%)
    firestore (Query)214 kB214 kB+103 B (+0.0%)
    firestore (Read data once)202 kB202 kB+103 B (+0.1%)
    firestore (Realtime updates)204 kB204 kB+103 B (+0.1%)
    firestore (Transaction)186 kB186 kB+103 B (+0.1%)
    firestore (Write data)186 kB186 kB+103 B (+0.1%)
  • firebase

    TypeBase (34ad43c)Merge (5214684)Diff
    firebase-compat.js739 kB739 kB+103 B (+0.0%)
    firebase-firestore-compat.js313 kB313 kB+102 B (+0.0%)
    firebase-firestore.js314 kB314 kB+102 B (+0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/2WfKkygVu9.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Sep 30, 2022

Size Analysis Report 1

Affected Products

  • @firebase/firestore

    • AbstractUserDataWriter

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps82.9 kB82.9 kB+78 B (+0.1%)
    • AggregateField

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.2 kB+78 B (+0.1%)
    • AggregateQuerySnapshot

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.2 kB75.3 kB+78 B (+0.1%)
    • Bytes

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps76.4 kB76.4 kB+78 B (+0.1%)
    • CACHE_SIZE_UNLIMITED

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.2 kB+78 B (+0.1%)
    • CollectionReference

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps78.7 kB78.8 kB+78 B (+0.1%)
    • DocumentReference

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps78.7 kB78.8 kB+78 B (+0.1%)
    • DocumentSnapshot

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps82.2 kB82.3 kB+78 B (+0.1%)
    • FieldPath

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps77.8 kB77.9 kB+78 B (+0.1%)
    • FieldValue

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.2 kB+78 B (+0.1%)
    • Firestore

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.1 kB+78 B (+0.1%)
    • FirestoreError

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.1 kB+78 B (+0.1%)
    • GeoPoint

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.6 kB75.7 kB+78 B (+0.1%)
    • LoadBundleTask

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.9 kB76.0 kB+78 B (+0.1%)
    • Query

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.2 kB75.3 kB+78 B (+0.1%)
    • QueryConstraint

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.2 kB+78 B (+0.1%)
    • QueryDocumentSnapshot

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps82.2 kB82.3 kB+78 B (+0.1%)
    • QuerySnapshot

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps84.1 kB84.2 kB+78 B (+0.1%)
    • SnapshotMetadata

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.2 kB75.3 kB+78 B (+0.1%)
    • Timestamp

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps76.3 kB76.3 kB+78 B (+0.1%)
    • Transaction

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps109 kB109 kB+78 B (+0.1%)
    • WriteBatch

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps105 kB105 kB+78 B (+0.1%)
    • _DatabaseId

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.1 kB+78 B (+0.1%)
    • _DocumentKey

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps84.4 kB84.5 kB+78 B (+0.1%)
    • _EmptyAppCheckTokenProvider

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.2 kB75.3 kB+78 B (+0.1%)
    • _EmptyAuthCredentialsProvider

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.2 kB+78 B (+0.1%)
    • _FieldPath

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps77.5 kB77.6 kB+78 B (+0.1%)
    • _cast

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.8 kB75.9 kB+78 B (+0.1%)
    • _debugAssert

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.2 kB+78 B (+0.1%)
    • _isBase64Available

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.2 kB+78 B (+0.1%)
    • _logWarn

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.2 kB75.2 kB+78 B (+0.1%)
    • _validateIsNotUsedTogether

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.2 kB+78 B (+0.1%)
    • addDoc

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size116 kB116 kB+25 B (+0.0%)
      size-with-ext-deps176 kB176 kB+103 B (+0.1%)
    • aggregateQuerySnapshotEqual

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps85.3 kB85.4 kB+78 B (+0.1%)
    • arrayRemove

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps87.6 kB87.6 kB+78 B (+0.1%)
    • arrayUnion

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps87.6 kB87.6 kB+78 B (+0.1%)
    • clearIndexedDbPersistence

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps84.0 kB84.1 kB+78 B (+0.1%)
    • collection

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps79.5 kB79.5 kB+78 B (+0.1%)
    • collectionGroup

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps78.4 kB78.5 kB+78 B (+0.1%)
    • connectFirestoreEmulator

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps77.5 kB77.5 kB+78 B (+0.1%)
    • deleteDoc

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size107 kB107 kB+25 B (+0.0%)
      size-with-ext-deps167 kB167 kB+103 B (+0.1%)
    • deleteField

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.5 kB75.5 kB+78 B (+0.1%)
    • disableNetwork

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size95.7 kB95.7 kB+25 B (+0.0%)
      size-with-ext-deps155 kB155 kB+103 B (+0.1%)
    • doc

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps79.5 kB79.6 kB+78 B (+0.1%)
    • documentId

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps77.8 kB77.9 kB+78 B (+0.1%)
    • enableIndexedDbPersistence

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size174 kB174 kB+25 B (+0.0%)
      size-with-ext-deps234 kB234 kB+103 B (+0.0%)
    • enableMultiTabIndexedDbPersistence

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size206 kB207 kB+25 B (+0.0%)
      size-with-ext-deps266 kB267 kB+103 B (+0.0%)
    • enableNetwork

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size95.6 kB95.7 kB+25 B (+0.0%)
      size-with-ext-deps155 kB155 kB+103 B (+0.1%)
    • endAt

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps93.5 kB93.6 kB+78 B (+0.1%)
    • endBefore

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps93.5 kB93.6 kB+78 B (+0.1%)
    • ensureFirestoreConfigured

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.2 kB75.3 kB+78 B (+0.1%)
    • executeWrite

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size106 kB106 kB+25 B (+0.0%)
      size-with-ext-deps166 kB166 kB+103 B (+0.1%)
    • getCountFromServer

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size102 kB102 kB+25 B (+0.0%)
      size-with-ext-deps162 kB162 kB+103 B (+0.1%)
    • getDoc

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size132 kB132 kB+25 B (+0.0%)
      size-with-ext-deps192 kB192 kB+103 B (+0.1%)
    • getDocFromCache

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps148 kB148 kB+78 B (+0.1%)
    • getDocFromServer

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size132 kB132 kB+25 B (+0.0%)
      size-with-ext-deps192 kB192 kB+103 B (+0.1%)
    • getDocs

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size134 kB134 kB+25 B (+0.0%)
      size-with-ext-deps193 kB194 kB+103 B (+0.1%)
    • getDocsFromCache

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps155 kB155 kB+78 B (+0.1%)
    • getDocsFromServer

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size134 kB134 kB+25 B (+0.0%)
      size-with-ext-deps193 kB193 kB+103 B (+0.1%)
    • getFirestore

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps85.3 kB85.4 kB+78 B (+0.1%)
    • increment

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.9 kB76.0 kB+78 B (+0.1%)
    • initializeFirestore

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps76.2 kB76.3 kB+78 B (+0.1%)
    • limit

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.9 kB76.0 kB+78 B (+0.1%)
    • limitToLast

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps76.0 kB76.0 kB+78 B (+0.1%)
    • loadBundle

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size105 kB105 kB+25 B (+0.0%)
      size-with-ext-deps164 kB164 kB+103 B (+0.1%)
    • namedQuery

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps141 kB141 kB+78 B (+0.1%)
    • onSnapshot

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size135 kB135 kB+25 B (+0.0%)
      size-with-ext-deps194 kB194 kB+103 B (+0.1%)
    • onSnapshotsInSync

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size124 kB124 kB+25 B (+0.0%)
      size-with-ext-deps184 kB184 kB+103 B (+0.1%)
    • orderBy

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps80.3 kB80.4 kB+78 B (+0.1%)
    • query

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.2 kB+78 B (+0.1%)
    • queryEqual

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps84.9 kB85.0 kB+78 B (+0.1%)
    • refEqual

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps78.9 kB79.0 kB+78 B (+0.1%)
    • runTransaction

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size116 kB116 kB+25 B (+0.0%)
      size-with-ext-deps176 kB176 kB+103 B (+0.1%)
    • serverTimestamp

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.4 kB75.5 kB+78 B (+0.1%)
    • setDoc

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size115 kB115 kB+25 B (+0.0%)
      size-with-ext-deps175 kB175 kB+103 B (+0.1%)
    • setIndexConfiguration

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps144 kB144 kB+78 B (+0.1%)
    • setLogLevel

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.1 kB75.2 kB+78 B (+0.1%)
    • snapshotEqual

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps91.7 kB91.8 kB+78 B (+0.1%)
    • startAfter

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps93.5 kB93.6 kB+78 B (+0.1%)
    • startAt

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps93.5 kB93.6 kB+78 B (+0.1%)
    • terminate

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps75.4 kB75.4 kB+78 B (+0.1%)
    • updateDoc

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size116 kB116 kB+25 B (+0.0%)
      size-with-ext-deps175 kB175 kB+103 B (+0.1%)
    • waitForPendingWrites

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size96.1 kB96.1 kB+25 B (+0.0%)
      size-with-ext-deps155 kB156 kB+103 B (+0.1%)
    • where

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size-with-ext-deps100 kB100 kB+78 B (+0.1%)
    • writeBatch

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size118 kB118 kB+25 B (+0.0%)
      size-with-ext-deps177 kB177 kB+103 B (+0.1%)
  • @firebase/webchannel-wrapper

    • ErrorCode

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size41.5 kB41.6 kB+77 B (+0.2%)
      size-with-ext-deps41.5 kB41.6 kB+77 B (+0.2%)
    • Event

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size41.5 kB41.6 kB+77 B (+0.2%)
      size-with-ext-deps41.5 kB41.6 kB+77 B (+0.2%)
    • EventType

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size41.5 kB41.6 kB+77 B (+0.2%)
      size-with-ext-deps41.5 kB41.6 kB+77 B (+0.2%)
    • FetchXmlHttpFactory

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size41.5 kB41.6 kB+77 B (+0.2%)
      size-with-ext-deps41.5 kB41.6 kB+77 B (+0.2%)
    • Stat

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size41.6 kB41.7 kB+77 B (+0.2%)
      size-with-ext-deps41.6 kB41.7 kB+77 B (+0.2%)
    • WebChannel

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size41.5 kB41.6 kB+77 B (+0.2%)
      size-with-ext-deps41.5 kB41.6 kB+77 B (+0.2%)
    • XhrIo

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size41.5 kB41.6 kB+77 B (+0.2%)
      size-with-ext-deps41.5 kB41.6 kB+77 B (+0.2%)
    • createWebChannelTransport

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size41.8 kB41.9 kB+77 B (+0.2%)
      size-with-ext-deps41.8 kB41.9 kB+77 B (+0.2%)
    • default

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size42.1 kB42.2 kB+77 B (+0.2%)
      size-with-ext-deps42.1 kB42.2 kB+77 B (+0.2%)
    • getStatEventTarget

      Size

      TypeBase (34ad43c)Merge (5214684)Diff
      size41.5 kB41.6 kB+77 B (+0.2%)
      size-with-ext-deps41.5 kB41.6 kB+77 B (+0.2%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/NMj0FWNSLb.html

@dconeybe dconeybe changed the title Call setWithCredentials(true) on XhrIo Make COUNT queries available to the Firestore Console Oct 6, 2022
@dconeybe dconeybe marked this pull request as ready for review October 6, 2022 19:27
@dconeybe dconeybe requested a review from milaGGL October 6, 2022 20:28
@dconeybe
Copy link
Contributor Author

dconeybe commented Oct 6, 2022

@egilmorez PTAL as a required reviewer. Thanks!

Copy link
Contributor

@egilmorez egilmorez left a comment

Choose a reason for hiding this comment

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

Wondering why TW review is required when there are no public doc changes, but here you go :)

Copy link
Contributor

@milaGGL milaGGL left a comment

Choose a reason for hiding this comment

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

LGMT

@dconeybe dconeybe merged commit 397317b into master Oct 7, 2022
@dconeybe dconeybe deleted the dconeybe/WithCredentialsTrial branch October 7, 2022 00:06
@Thaina
Copy link

Thaina commented Oct 7, 2022

Pardon me but what is this function? It seem like it is a very significant feature yet I have not seen any documents about it

@dconeybe
Copy link
Contributor Author

dconeybe commented Oct 7, 2022

We will be talking about this feature more in the coming weeks. Stay tuned!

@google-oss-bot google-oss-bot mentioned this pull request Oct 10, 2022
@dconeybe
Copy link
Contributor Author

@Thaina Please see https://cloud.google.com/blog/products/databases/aggregating-data-with-firestore for full details about this new feature :)

@Thaina
Copy link

Thaina commented Oct 20, 2022

Thank you very much

It’s accessible via all our server, client SDKs

Sadly still not available in unity sdk

@firebase firebase locked and limited conversation to collaborators Nov 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants