@@ -38,7 +38,11 @@ import { Deferred } from '../../util/promise';
38
38
const LOG_TAG = 'Connection' ;
39
39
const X_GOOG_API_CLIENT_VALUE = `gl-node/${ process . versions . node } fire/${ SDK_VERSION } grpc/${ grpcVersion } ` ;
40
40
41
- function createMetadata ( databasePath : string , token : Token | null ) : Metadata {
41
+ function createMetadata (
42
+ databasePath : string ,
43
+ token : Token | null ,
44
+ appId : string
45
+ ) : Metadata {
42
46
hardAssert (
43
47
token === null || token . type === 'OAuth' ,
44
48
'If provided, token must be OAuth'
@@ -52,10 +56,11 @@ function createMetadata(databasePath: string, token: Token | null): Metadata {
52
56
}
53
57
}
54
58
}
55
- metadata . set ( 'x-goog-api-client' , X_GOOG_API_CLIENT_VALUE ) ;
59
+ metadata . set ( 'X-Firebase-GMPID' , appId ) ;
60
+ metadata . set ( 'X-Goog-Api-Client' , X_GOOG_API_CLIENT_VALUE ) ;
56
61
// This header is used to improve routing and project isolation by the
57
62
// backend.
58
- metadata . set ( 'google-cloud-resource-prefix ' , databasePath ) ;
63
+ metadata . set ( 'Google-Cloud-Resource-Prefix ' , databasePath ) ;
59
64
return metadata ;
60
65
}
61
66
@@ -102,7 +107,11 @@ export class GrpcConnection implements Connection {
102
107
token : Token | null
103
108
) : Promise < Resp > {
104
109
const stub = this . ensureActiveStub ( ) ;
105
- const metadata = createMetadata ( this . databasePath , token ) ;
110
+ const metadata = createMetadata (
111
+ this . databasePath ,
112
+ token ,
113
+ this . databaseInfo . appId
114
+ ) ;
106
115
const jsonRequest = { database : this . databasePath , ...request } ;
107
116
108
117
return nodePromise ( ( callback : NodeCallback < Resp > ) => {
@@ -147,7 +156,11 @@ export class GrpcConnection implements Connection {
147
156
request
148
157
) ;
149
158
const stub = this . ensureActiveStub ( ) ;
150
- const metadata = createMetadata ( this . databasePath , token ) ;
159
+ const metadata = createMetadata (
160
+ this . databasePath ,
161
+ token ,
162
+ this . databaseInfo . appId
163
+ ) ;
151
164
const jsonRequest = { ...request , database : this . databasePath } ;
152
165
const stream = stub [ rpcName ] ( jsonRequest , metadata ) ;
153
166
stream . on ( 'data' , ( response : Resp ) => {
@@ -173,7 +186,11 @@ export class GrpcConnection implements Connection {
173
186
token : Token | null
174
187
) : Stream < Req , Resp > {
175
188
const stub = this . ensureActiveStub ( ) ;
176
- const metadata = createMetadata ( this . databasePath , token ) ;
189
+ const metadata = createMetadata (
190
+ this . databasePath ,
191
+ token ,
192
+ this . databaseInfo . appId
193
+ ) ;
177
194
const grpcStream = stub [ rpcName ] ( metadata ) ;
178
195
179
196
let closed = false ;
0 commit comments