import { ISavedObjectsRepository , SavedObjectsServiceStart , SavedObjectAttributes , Logger , } from 'src/core/server' ; import { SavedObjectsErrorHelpers } from '../../../../../../src/core/server' ; /**
 * Fetches saved objects attributes - used by collectors
 */ export const getSavedObjectAttributesFromRepo = async ( id , savedObjectsRepository , log ) : Promise < SavedObjectAttributes | null > => { try { return ( await savedObjectsRepository . get ( id , id ) ) . attributes as SavedObjectAttributes ; } catch ( e ) { if ( ! SavedObjectsErrorHelpers . isNotFoundError ( e ) ) { log . warn ( `Failed to retrieve ${ id } telemetry data: ${ e }` ) ; } return null ; } } ; /**
 * Set saved objection attributes - used by telemetry route
 */ interface IncrementUICounter { id : string ; savedObjects : SavedObjectsServiceStart ; uiAction : string ; metric : string ; } export async function incrementUICounter ( { id , savedObjects , uiAction , metric , } ) { const internalRepository = savedObjects . createInternalRepository ( ) ; await internalRepository . incrementCounter ( id , id , [ `${ uiAction }.${ metric }` ] ) ; return { success : true } ; }