@@ -113,7 +113,7 @@ export function getFirestoreOptions(app: App, firestoreSettings?: FirestoreSetti
113113 const projectId : string | null = utils . getExplicitProjectId ( app ) ;
114114 const credential = app . options . credential ;
115115 // eslint-disable-next-line @typescript-eslint/no-var-requires
116- const { version : firebaseVersion } = require ( '../../package.json' ) ;
116+ const sdkVersion = utils . getSdkVersion ( ) ;
117117 const preferRest = firestoreSettings ?. preferRest ;
118118 if ( credential instanceof ServiceAccountCredential ) {
119119 return {
@@ -124,16 +124,26 @@ export function getFirestoreOptions(app: App, firestoreSettings?: FirestoreSetti
124124 // When the SDK is initialized with ServiceAccountCredentials an explicit projectId is
125125 // guaranteed to be available.
126126 projectId : projectId ! ,
127- firebaseVersion,
127+ firebaseVersion : sdkVersion ,
128+ firebaseAdminVersion : sdkVersion ,
128129 preferRest,
129130 } ;
130131 } else if ( isApplicationDefault ( app . options . credential ) ) {
131132 // Try to use the Google application default credentials.
132133 // If an explicit project ID is not available, let Firestore client discover one from the
133134 // environment. This prevents the users from having to set GOOGLE_CLOUD_PROJECT in GCP runtimes.
134135 return validator . isNonEmptyString ( projectId )
135- ? { projectId, firebaseVersion, preferRest }
136- : { firebaseVersion, preferRest } ;
136+ ? {
137+ projectId,
138+ firebaseVersion : sdkVersion ,
139+ firebaseAdminVersion : sdkVersion ,
140+ preferRest
141+ }
142+ : {
143+ firebaseVersion : sdkVersion ,
144+ firebaseAdminVersion : sdkVersion ,
145+ preferRest
146+ } ;
137147 }
138148
139149 throw new FirebaseFirestoreError ( {
@@ -155,8 +165,8 @@ function initFirestore(app: App, databaseId: string, firestoreSettings?: Firesto
155165 throw new FirebaseFirestoreError ( {
156166 code : 'missing-dependencies' ,
157167 message : 'Failed to import the Cloud Firestore client library for Node.js. '
158- + 'Make sure to install the "@google-cloud/firestore" npm package. '
159- + `Original error: ${ err } ` ,
168+ + 'Make sure to install the "@google-cloud/firestore" npm package. '
169+ + `Original error: ${ err } ` ,
160170 } ) ;
161171 }
162172
0 commit comments