@@ -50,9 +50,10 @@ export function patchFirestore(
50
50
unwrap : typeof shimmerUnwrap ,
51
51
config : FirebaseInstrumentationConfig ,
52
52
) : InstrumentationNodeModuleDefinition {
53
- // Setting an empty function as a default
54
53
// eslint-disable-next-line @typescript-eslint/no-empty-function
55
- let firestoreSpanCreationHook : FirestoreSpanCreationHook = ( ) => { } ;
54
+ const defaultFirestoreSpanCreationHook : FirestoreSpanCreationHook = ( ) => { } ;
55
+
56
+ let firestoreSpanCreationHook : FirestoreSpanCreationHook = defaultFirestoreSpanCreationHook ;
56
57
const configFirestoreSpanCreationHook = config . firestoreSpanCreationHook ;
57
58
58
59
if ( typeof configFirestoreSpanCreationHook === 'function' ) {
@@ -63,7 +64,7 @@ export function patchFirestore(
63
64
if ( ! error ) {
64
65
return ;
65
66
}
66
- diag . error ( 'Firebase Firestore span creation hook failed' , error ?. message ) ;
67
+ diag . error ( error ?. message ) ;
67
68
} ,
68
69
true ,
69
70
) ;
@@ -151,14 +152,12 @@ function patchAddDoc<AppModelType, DbModelType extends DocumentData>(
151
152
data : WithFieldValue < AppModelType > ,
152
153
) => Promise < DocumentReference < AppModelType , DbModelType > > {
153
154
return function addDoc ( original : AddDocType < AppModelType , DbModelType > ) {
154
- return function patchAddDoc (
155
+ return function (
155
156
reference : CollectionReference < AppModelType , DbModelType > ,
156
157
data : WithFieldValue < AppModelType > ,
157
158
) : Promise < DocumentReference < AppModelType , DbModelType > > {
158
159
const span = startDBSpan ( tracer , 'addDoc' , reference ) ;
159
-
160
160
firestoreSpanCreationHook ( span ) ;
161
-
162
161
return executeContextWithSpan < Promise < DocumentReference < AppModelType , DbModelType > > > ( span , ( ) => {
163
162
return original ( reference , data ) ;
164
163
} ) ;
@@ -173,7 +172,7 @@ function patchDeleteDoc<AppModelType, DbModelType extends DocumentData>(
173
172
original : DeleteDocType < AppModelType , DbModelType > ,
174
173
) => ( this : FirebaseInstrumentation , reference : DocumentReference < AppModelType , DbModelType > ) => Promise < void > {
175
174
return function deleteDoc ( original : DeleteDocType < AppModelType , DbModelType > ) {
176
- return function patchDeleteDoc ( reference : DocumentReference < AppModelType , DbModelType > ) : Promise < void > {
175
+ return function ( reference : DocumentReference < AppModelType , DbModelType > ) : Promise < void > {
177
176
const span = startDBSpan ( tracer , 'deleteDoc' , reference . parent || reference ) ;
178
177
firestoreSpanCreationHook ( span ) ;
179
178
return executeContextWithSpan < Promise < void > > ( span , ( ) => {
@@ -193,7 +192,7 @@ function patchGetDocs<AppModelType, DbModelType extends DocumentData>(
193
192
reference : CollectionReference < AppModelType , DbModelType > ,
194
193
) => Promise < QuerySnapshot < AppModelType , DbModelType > > {
195
194
return function getDocs ( original : GetDocsType < AppModelType , DbModelType > ) {
196
- return function patchGetDocs (
195
+ return function (
197
196
reference : CollectionReference < AppModelType , DbModelType > ,
198
197
) : Promise < QuerySnapshot < AppModelType , DbModelType > > {
199
198
const span = startDBSpan ( tracer , 'getDocs' , reference ) ;
@@ -217,7 +216,7 @@ function patchSetDoc<AppModelType, DbModelType extends DocumentData>(
217
216
options ?: SetOptions ,
218
217
) => Promise < void > {
219
218
return function setDoc ( original : SetDocType < AppModelType , DbModelType > ) {
220
- return function patchSetDoc (
219
+ return function (
221
220
reference : DocumentReference < AppModelType , DbModelType > ,
222
221
data : WithFieldValue < AppModelType > & PartialWithFieldValue < AppModelType > ,
223
222
options ?: SetOptions ,
0 commit comments