@@ -39,6 +39,7 @@ import { ConflictException } from './common/exceptions/conflict.exception';
3939import { CryptoProvider } from './common/crypto/crypto-provider' ;
4040import { ParseError } from './common/exceptions/parse-error' ;
4141import { getEnv } from './common/utils/env' ;
42+ import { getRuntimeInfo } from './common/utils/runtime-info' ;
4243
4344const VERSION = '8.0.0-beta.3' ;
4445
@@ -99,21 +100,33 @@ export class WorkOS {
99100 this . baseURL = this . baseURL + `:${ port } ` ;
100101 }
101102
103+ this . webhooks = this . createWebhookClient ( ) ;
104+ this . actions = this . createActionsClient ( ) ;
105+
106+ // Must initialize UserManagement after baseURL is configured
107+ this . userManagement = new UserManagement ( this ) ;
108+
109+ const userAgent = this . createUserAgent ( options ) ;
110+
111+ this . client = this . createHttpClient ( options , userAgent ) ;
112+ }
113+
114+ private createUserAgent ( options : WorkOSOptions ) : string {
102115 let userAgent : string = `workos-node/${ VERSION } ` ;
103116
104117 if ( options . appInfo ) {
105- const { name, version } : { name : string ; version : string } =
106- options . appInfo ;
118+ const { name, version } = options . appInfo ;
107119 userAgent += ` ${ name } : ${ version } ` ;
108120 }
109121
110- this . webhooks = this . createWebhookClient ( ) ;
111- this . actions = this . createActionsClient ( ) ;
122+ const { name : runtimeName , version : runtimeVersion } = getRuntimeInfo ( ) ;
123+ userAgent += ` ${ runtimeName } ` ;
112124
113- // Must initialize UserManagement after baseURL is configured
114- this . userManagement = new UserManagement ( this ) ;
125+ if ( runtimeVersion ) {
126+ userAgent += `/${ runtimeVersion } ` ;
127+ }
115128
116- this . client = this . createHttpClient ( options , userAgent ) ;
129+ return userAgent ;
117130 }
118131
119132 createWebhookClient ( ) {
0 commit comments