import { Entity } from '@backstage/catalog-model' ; export const DATADOG_ANNOTATION_DASHBOARD_URL = 'datadoghq.com/dashboard-url' ; export const DATADOG_ANNOTATION_GRAPH_TOKEN = 'datadoghq.com/graph-token' ; export const DATADOG_ANNOTATION_GRAPH_SIZE = 'datadoghq.com/graph-size' ; export const DATADOG_ANNOTATION_SITE = 'datadoghq.com/site' ; export type GraphSize = 'small' | 'medium' | 'large' | 'x-large' ; export const useDatadogAppData = ( { entity } ) => { const dashboardUrl = entity ?. metadata . annotations ?. [ DATADOG_ANNOTATION_DASHBOARD_URL ] ?? '' ; const graphToken = entity ?. metadata . annotations ?. [ DATADOG_ANNOTATION_GRAPH_TOKEN ] ?? '' ; const graphSize = ( entity ?. metadata . annotations ?. [ DATADOG_ANNOTATION_GRAPH_SIZE ] as GraphSize ) ?? 'medium' ; const site = ( entity ?. metadata . annotations ?. [ DATADOG_ANNOTATION_SITE ] as String ) ?? 'datadoghq.eu' ; if ( ! dashboardUrl && ! graphToken ) { throw new Error ( "'datadog' annotation is missing" ) ; } return { dashboardUrl , graphToken , graphSize , site } ; } ;