diff --git a/.changeset/fifty-dogs-collect.md b/.changeset/fifty-dogs-collect.md new file mode 100644 index 0000000000..6e3d971bf5 --- /dev/null +++ b/.changeset/fifty-dogs-collect.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-sentry': patch +--- + +Providing a way for users to determine if sentry is available. diff --git a/plugins/sentry/api-report.md b/plugins/sentry/api-report.md index 5ad2992ee4..043fa7a1fd 100644 --- a/plugins/sentry/api-report.md +++ b/plugins/sentry/api-report.md @@ -31,6 +31,9 @@ export const EntitySentryContent: ({ tableOptions, }: SentryPageProps) => JSX.Element; +// @public +export const isSentryAvailable: (entity: Entity) => boolean; + // Warning: (ae-missing-release-tag) "MockSentryApi" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) diff --git a/plugins/sentry/src/components/index.ts b/plugins/sentry/src/components/index.ts index 210ba8d718..f2dddaff18 100644 --- a/plugins/sentry/src/components/index.ts +++ b/plugins/sentry/src/components/index.ts @@ -15,3 +15,4 @@ */ export * from './SentryIssuesWidget'; +export { isSentryAvailable } from './useProjectSlug'; diff --git a/plugins/sentry/src/components/useProjectSlug.ts b/plugins/sentry/src/components/useProjectSlug.ts index 0796e9e8df..a8f07436b0 100644 --- a/plugins/sentry/src/components/useProjectSlug.ts +++ b/plugins/sentry/src/components/useProjectSlug.ts @@ -18,6 +18,13 @@ import { Entity } from '@backstage/catalog-model'; export const SENTRY_PROJECT_SLUG_ANNOTATION = 'sentry.io/project-slug'; +/** + * @public + * Checks to see if sentry is available + */ +export const isSentryAvailable = (entity: Entity) => + Boolean(entity.metadata.annotations?.[SENTRY_PROJECT_SLUG_ANNOTATION]); + export const useProjectSlug = (entity: Entity) => { return entity?.metadata.annotations?.[SENTRY_PROJECT_SLUG_ANNOTATION] ?? ''; };