@@ -21,11 +21,12 @@ import { ApiSettings } from '../types/internal';
2121import {
2222 DEFAULT_DOMAIN ,
2323 DEFAULT_FETCH_TIMEOUT_MS ,
24+ HYBRID_TAG ,
2425 LANGUAGE_TAG ,
2526 PACKAGE_VERSION
2627} from '../constants' ;
2728import { logger } from '../logger' ;
28- import { BackendType } from '../public-types' ;
29+ import { BackendType , InferenceMode } from '../public-types' ;
2930
3031export const TIMEOUT_EXPIRED_MESSAGE = 'Timeout has expired.' ;
3132export const ABORT_ERROR_NAME = 'AbortError' ;
@@ -137,17 +138,28 @@ export class WebSocketUrl {
137138/**
138139 * Log language and "fire/version" to x-goog-api-client
139140 */
140- function getClientHeaders ( ) : string {
141+ function getClientHeaders ( url : RequestURL ) : string {
141142 const loggingTags = [ ] ;
142143 loggingTags . push ( `${ LANGUAGE_TAG } /${ PACKAGE_VERSION } ` ) ;
143144 loggingTags . push ( `fire/${ PACKAGE_VERSION } ` ) ;
145+ /**
146+ * No call would be made if ONLY_ON_DEVICE.
147+ * ONLY_IN_CLOUD does not indicate an intention to use hybrid.
148+ */
149+ if (
150+ url . params . apiSettings . inferenceMode === InferenceMode . PREFER_ON_DEVICE ||
151+ url . params . apiSettings . inferenceMode === InferenceMode . PREFER_IN_CLOUD
152+ ) {
153+ // No version
154+ loggingTags . push ( HYBRID_TAG ) ;
155+ }
144156 return loggingTags . join ( ' ' ) ;
145157}
146158
147159export async function getHeaders ( url : RequestURL ) : Promise < Headers > {
148160 const headers = new Headers ( ) ;
149161 headers . append ( 'Content-Type' , 'application/json' ) ;
150- headers . append ( 'x-goog-api-client' , getClientHeaders ( ) ) ;
162+ headers . append ( 'x-goog-api-client' , getClientHeaders ( url ) ) ;
151163 headers . append ( 'x-goog-api-key' , url . params . apiSettings . apiKey ) ;
152164 if ( url . params . apiSettings . automaticDataCollectionEnabled ) {
153165 headers . append ( 'X-Firebase-Appid' , url . params . apiSettings . appId ) ;
0 commit comments