diff --git a/plugins/newrelic-dashboard/src/Router.tsx b/plugins/newrelic-dashboard/src/Router.tsx index 67fe12f146..64d185defc 100644 --- a/plugins/newrelic-dashboard/src/Router.tsx +++ b/plugins/newrelic-dashboard/src/Router.tsx @@ -22,7 +22,7 @@ import { useEntity } from '@backstage/plugin-catalog-react'; import { NEWRELIC_GUID } from './constants'; export const isNewRelicDashboardAvailable = (entity: Entity) => - Boolean(entity.metadata.annotations?.[NEWRELIC_GUID]); + Boolean(entity?.metadata?.annotations?.[NEWRELIC_GUID]); type Props = { /** @deprecated The entity is now grabbed from context instead */ diff --git a/plugins/newrelic-dashboard/src/hooks/index.ts b/plugins/newrelic-dashboard/src/hooks/index.ts index 3739607b82..517f3b54b6 100644 --- a/plugins/newrelic-dashboard/src/hooks/index.ts +++ b/plugins/newrelic-dashboard/src/hooks/index.ts @@ -20,8 +20,8 @@ import { NEWRELIC_GUID } from '../constants'; export function useNewRelicDashboardEntity() { const { entity } = useEntity(); const integrationKey: string | undefined = - entity.metadata.annotations?.[NEWRELIC_GUID]; - const name: string | undefined = entity.metadata.name; + entity?.metadata?.annotations?.[NEWRELIC_GUID]; + const name: string | undefined = entity?.metadata?.name; return { integrationKey, name }; }