import { schema } from '@kbn/config-schema' ; import { IRouter , StartServicesAccessor } from 'src/core/server' ; import { FeatureUsageTestStartDependencies , FeatureUsageTestPluginStart } from '../plugin' ; export function registerFeatureHitRoute ( router , getStartServices ) { router . get ( { path : '/api/feature_usage_test/hit' , validate : { query : schema . object ( { featureName : schema . string ( ) , usedAt : schema . maybe ( schema . number ( ) ) , } ) , } , } , async ( context , request , response ) => { const [ , { licensing } ] = await getStartServices ( ) ; try { const { featureName , usedAt } = request . query ; licensing . featureUsage . notifyUsage ( featureName , usedAt ) ; return response . ok ( ) ; } catch ( e ) { return response . badRequest ( ) ; } } ) ; }