From c55f6cb22d8caf54f6de98186d8f0c752433847d Mon Sep 17 00:00:00 2001 From: Jonathan Sundquist Date: Wed, 18 May 2022 10:53:27 -0500 Subject: [PATCH 1/3] feat(sentry): adding a check if sentry is available Signed-off-by: Jonathan Sundquist Signed-off-by: Jonathan Sundquist --- .changeset/fifty-dogs-collect.md | 5 +++++ plugins/sentry/api-report.md | 3 +++ plugins/sentry/src/components/index.ts | 1 + plugins/sentry/src/components/useProjectSlug.ts | 7 +++++++ 4 files changed, 16 insertions(+) create mode 100644 .changeset/fifty-dogs-collect.md 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] ?? ''; }; From 19283230646a1f98206e65c3c49ffac21325132b Mon Sep 17 00:00:00 2001 From: Jonathan Sundquist Date: Thu, 19 May 2022 07:37:33 -0500 Subject: [PATCH 2/3] docs(changeset): updating with better verbiage Co-authored-by: Johan Haals Signed-off-by: Jonathan Sundquist --- .changeset/fifty-dogs-collect.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/fifty-dogs-collect.md b/.changeset/fifty-dogs-collect.md index 6e3d971bf5..ac04d6b930 100644 --- a/.changeset/fifty-dogs-collect.md +++ b/.changeset/fifty-dogs-collect.md @@ -2,4 +2,4 @@ '@backstage/plugin-sentry': patch --- -Providing a way for users to determine if sentry is available. +Exported `isSentryAvailable` which can be used to determine if sentry is available. From 607a3ed0e2c04af2e86262ffc0ffd1f72e58eaf1 Mon Sep 17 00:00:00 2001 From: Jonathan Sundquist Date: Fri, 20 May 2022 10:01:42 -0500 Subject: [PATCH 3/3] feat(sentry): move isSentryAvailable check to its own file Signed-off-by: Jonathan Sundquist --- plugins/sentry/src/components/index.ts | 2 +- .../src/components/isSentryAvailable.ts | 25 +++++++++++++++++++ .../sentry/src/components/useProjectSlug.ts | 7 ------ 3 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 plugins/sentry/src/components/isSentryAvailable.ts diff --git a/plugins/sentry/src/components/index.ts b/plugins/sentry/src/components/index.ts index f2dddaff18..9af8a05853 100644 --- a/plugins/sentry/src/components/index.ts +++ b/plugins/sentry/src/components/index.ts @@ -15,4 +15,4 @@ */ export * from './SentryIssuesWidget'; -export { isSentryAvailable } from './useProjectSlug'; +export { isSentryAvailable } from './isSentryAvailable'; diff --git a/plugins/sentry/src/components/isSentryAvailable.ts b/plugins/sentry/src/components/isSentryAvailable.ts new file mode 100644 index 0000000000..1a7d26f97c --- /dev/null +++ b/plugins/sentry/src/components/isSentryAvailable.ts @@ -0,0 +1,25 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Entity } from '@backstage/catalog-model'; +import { SENTRY_PROJECT_SLUG_ANNOTATION } from './useProjectSlug'; + +/** + * @public + * Checks to see if sentry is available + */ +export const isSentryAvailable = (entity: Entity) => + Boolean(entity.metadata.annotations?.[SENTRY_PROJECT_SLUG_ANNOTATION]); diff --git a/plugins/sentry/src/components/useProjectSlug.ts b/plugins/sentry/src/components/useProjectSlug.ts index a8f07436b0..0796e9e8df 100644 --- a/plugins/sentry/src/components/useProjectSlug.ts +++ b/plugins/sentry/src/components/useProjectSlug.ts @@ -18,13 +18,6 @@ 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] ?? ''; };