@@ -49,9 +49,17 @@ const EXECUTE_GRAPH_QL_READ_ENDPOINT = 'executeGraphqlRead';
4949const IMPERSONATE_QUERY_ENDPOINT = 'impersonateQuery' ;
5050const IMPERSONATE_MUTATION_ENDPOINT = 'impersonateMutation' ;
5151
52- const DATA_CONNECT_CONFIG_HEADERS = {
53- 'X-Firebase-Client' : `fire-admin-node/${ utils . getSdkVersion ( ) } `
54- } ;
52+
53+ function getHeaders ( isUsingGen : boolean ) : { [ key : string ] : string } {
54+ const headerValue = {
55+ 'X-Firebase-Client' : `fire-admin-node/${ utils . getSdkVersion ( ) } ` ,
56+ 'X-Goog-Api-Client' : utils . getMetricsHeader ( ) ,
57+ } ;
58+ if ( isUsingGen ) {
59+ headerValue [ 'X-Goog-Api-Client' ] += ' admin-js/gen' ;
60+ }
61+ return headerValue ;
62+ }
5563
5664/**
5765 * URL params for requests to an endpoint under services:
@@ -82,6 +90,7 @@ interface ConnectorsUrlParams extends ServicesUrlParams {
8290export class DataConnectApiClient {
8391 private readonly httpClient : HttpClient ;
8492 private projectId ?: string ;
93+ private isUsingGen = false ;
8594
8695 constructor ( private readonly connectorConfig : ConnectorConfig , private readonly app : App ) {
8796 if ( ! validator . isNonNullObject ( app ) || ! ( 'options' in app ) ) {
@@ -91,6 +100,14 @@ export class DataConnectApiClient {
91100 }
92101 this . httpClient = new DataConnectHttpClient ( app as FirebaseApp ) ;
93102 }
103+
104+ /**
105+ * Update whether the SDK is using a generated one or not.
106+ * @param isUsingGen
107+ */
108+ setIsUsingGen ( isUsingGen : boolean ) : void {
109+ this . isUsingGen = isUsingGen ;
110+ }
94111
95112 /**
96113 * Execute arbitrary GraphQL, including both read and write queries
@@ -342,7 +359,7 @@ export class DataConnectApiClient {
342359 const request : HttpRequestConfig = {
343360 method : 'POST' ,
344361 url,
345- headers : DATA_CONNECT_CONFIG_HEADERS ,
362+ headers : getHeaders ( this . isUsingGen ) ,
346363 data,
347364 } ;
348365 const resp = await this . httpClient . send ( request ) ;
0 commit comments