import { UsageCollectionSetup } from 'src/plugins/usage_collection/server' ; import { CoreSetup , Logger , Plugin , PluginInitializerContext } from 'src/core/server' ; import { CloudConfigType } from './config' ; import { registerCloudUsageCollector } from './collectors' ; import { getIsCloudEnabled } from '../common/is_cloud_enabled' ; import { parseDeploymentIdFromDeploymentUrl } from './utils' ; import { registerFullstoryRoute } from './routes/fullstory' ; interface PluginsSetup { usageCollection ? : UsageCollectionSetup ; } export interface CloudSetup { cloudId ? : string ; deploymentId ? : string ; isCloudEnabled : boolean ; apm : { url ? : string ; secretToken ? : string ; } ; } export class CloudPlugin implements Plugin < CloudSetup > { private readonly logger : Logger ; private readonly config : CloudConfigType ; constructor ( private readonly context ) { this . logger = this . context . logger . get ( ) ; this . config = this . context . config . get < CloudConfigType > ( ) ; } public setup ( core , { usageCollection } ) { this . logger . debug ( 'Setting up Cloud plugin' ) ; const isCloudEnabled = getIsCloudEnabled ( this . config . id ) ; registerCloudUsageCollector ( usageCollection , { isCloudEnabled } ) ; if ( this . config . full_story . enabled ) { registerFullstoryRoute ( { httpResources : core . http . resources , packageInfo : this . context . env . packageInfo , } ) ; } return { cloudId : this . config . id , deploymentId : parseDeploymentIdFromDeploymentUrl ( this . config . deployment_url ) , isCloudEnabled , apm : { url : this . config . apm ?. url , secretToken : this . config . apm ?. secret_token , } , } ; } public start ( ) { } }