44 gatewayTargetPrimitive ,
55 policyEnginePrimitive ,
66} from '../../primitives/registry' ;
7+ import { withAddTelemetry } from '../../telemetry/cli-command-run.js' ;
8+ import { AuthorizerType , PolicyEngineMode , standardize } from '../../telemetry/schemas/common-shapes.js' ;
79import type { AddGatewayConfig } from '../screens/mcp/types' ;
810import { useCallback , useEffect , useState } from 'react' ;
911
@@ -23,22 +25,33 @@ export function useCreateGateway() {
2325 const createGateway = useCallback ( async ( config : AddGatewayConfig ) => {
2426 setStatus ( { state : 'loading' } ) ;
2527 try {
26- const addResult = await gatewayPrimitive . add ( {
27- name : config . name ,
28- description : config . description ,
29- authorizerType : config . authorizerType ,
30- discoveryUrl : config . jwtConfig ?. discoveryUrl ,
31- allowedAudience : config . jwtConfig ?. allowedAudience ?. join ( ',' ) ,
32- allowedClients : config . jwtConfig ?. allowedClients ?. join ( ',' ) ,
33- allowedScopes : config . jwtConfig ?. allowedScopes ?. join ( ',' ) ,
34- customClaims : config . jwtConfig ?. customClaims ,
35- clientId : config . jwtConfig ?. clientId ,
36- clientSecret : config . jwtConfig ?. clientSecret ,
37- enableSemanticSearch : config . enableSemanticSearch ,
38- exceptionLevel : config . exceptionLevel ,
39- policyEngine : config . policyEngineConfiguration ?. policyEngineName ,
40- policyEngineMode : config . policyEngineConfiguration ?. mode ,
41- } ) ;
28+ const addResult = await withAddTelemetry (
29+ 'add.gateway' ,
30+ {
31+ authorizer_type : standardize ( AuthorizerType , config . authorizerType ?? 'NONE' ) ,
32+ has_policy_engine : ! ! config . policyEngineConfiguration ?. policyEngineName ,
33+ policy_engine_mode : standardize ( PolicyEngineMode , config . policyEngineConfiguration ?. mode ?? 'log_only' ) ,
34+ semantic_search : config . enableSemanticSearch !== false ,
35+ runtime_count : 0 ,
36+ } ,
37+ ( ) =>
38+ gatewayPrimitive . add ( {
39+ name : config . name ,
40+ description : config . description ,
41+ authorizerType : config . authorizerType ,
42+ discoveryUrl : config . jwtConfig ?. discoveryUrl ,
43+ allowedAudience : config . jwtConfig ?. allowedAudience ?. join ( ',' ) ,
44+ allowedClients : config . jwtConfig ?. allowedClients ?. join ( ',' ) ,
45+ allowedScopes : config . jwtConfig ?. allowedScopes ?. join ( ',' ) ,
46+ customClaims : config . jwtConfig ?. customClaims ,
47+ clientId : config . jwtConfig ?. clientId ,
48+ clientSecret : config . jwtConfig ?. clientSecret ,
49+ enableSemanticSearch : config . enableSemanticSearch ,
50+ exceptionLevel : config . exceptionLevel ,
51+ policyEngine : config . policyEngineConfiguration ?. policyEngineName ,
52+ policyEngineMode : config . policyEngineConfiguration ?. mode ,
53+ } )
54+ ) ;
4255 if ( ! addResult . success ) {
4356 throw new Error ( addResult . error ?? 'Failed to create gateway' ) ;
4457 }
0 commit comments