File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ export class Client {
2626 const uploader = new NodeUploader ( ) ;
2727 const downloader = new NodeDownloader ( ) ;
2828
29+ const nodeVersion =
30+ typeof process !== 'undefined' ? process . version : 'unknown' ;
31+
2932 this . apiClient = new ApiClient ( {
3033 auth,
3134 uploader,
@@ -35,7 +38,8 @@ export class Client {
3538 vertexai : true ,
3639 httpOptions : options . apiEndpoint ? { baseUrl : options . apiEndpoint } :
3740 undefined ,
38- userAgentExtra : `vertex-genai-modules/${ SDK_VERSION } ` ,
41+ userAgentExtra :
42+ `vertex-genai-modules/${ SDK_VERSION } gl-node/${ nodeVersion } ` ,
3943 } ) ;
4044
4145 this . _agentEnginesInternal = new AgentEngines ( this . apiClient ) ;
Original file line number Diff line number Diff line change @@ -86,6 +86,18 @@ export class ReplayClient extends Client {
8686 }
8787
8888 const [ url , init ] = actualArgs ;
89+
90+
91+ const actualHeaders = new Headers ( init ?. headers || { } ) ;
92+ const xGoogApiClient = actualHeaders . get ( 'x-goog-api-client' ) || '' ;
93+ const userAgent = actualHeaders . get ( 'user-agent' ) || '' ;
94+
95+ // Validate that user-agent is set correctly.
96+ expect ( xGoogApiClient ) . toContain ( 'vertex-genai-modules/' ) ;
97+ expect ( xGoogApiClient ) . toContain ( 'gl-node/' ) ;
98+ expect ( userAgent ) . toContain ( 'vertex-genai-modules/' ) ;
99+ expect ( userAgent ) . toContain ( 'gl-node/' ) ;
100+
89101 const normalizedActual = normalizeRequest ( init || { } , url . toString ( ) ) ;
90102 assertMessagesEqual ( normalizedActual , expectedRequestCamel ) ;
91103 }
You can’t perform that action at this time.
0 commit comments