From 0d9a93efcdd9359b1c641289fa80c364d827a53c Mon Sep 17 00:00:00 2001 From: Jonas Date: Thu, 27 Feb 2025 10:03:02 -0500 Subject: [PATCH] featurebadge: remove expires and internal type (#85977) Dead code. Expiry functionality could be a separate component and internal badge is unused --- .../core/badge/featureBadge.spec.tsx | 42 ------------------- .../components/core/badge/featureBadge.tsx | 39 +---------------- .../screens/views/screenDetailsPage.tsx | 4 +- 3 files changed, 2 insertions(+), 83 deletions(-) delete mode 100644 static/app/components/core/badge/featureBadge.spec.tsx diff --git a/static/app/components/core/badge/featureBadge.spec.tsx b/static/app/components/core/badge/featureBadge.spec.tsx deleted file mode 100644 index 20e3bf4bed52bd..00000000000000 --- a/static/app/components/core/badge/featureBadge.spec.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import {render, screen} from 'sentry-test/reactTestingLibrary'; - -import {FeatureBadge} from 'sentry/components/core/badge/featureBadge'; - -describe('FeatureBadge', function () { - it('auto-hides when expired', function () { - const {rerender} = render( - - ); - expect(screen.getByText('new')).toBeInTheDocument(); - rerender( - - ); - expect(screen.queryByText('new')).not.toBeInTheDocument(); - }); - it('shows before expiry date', function () { - // One hour from 'now'. - const expires = new Date(Date.now() + 1000 * 60 * 60); - render( - - ); - expect(screen.getByText('new')).toBeInTheDocument(); - }); -}); diff --git a/static/app/components/core/badge/featureBadge.tsx b/static/app/components/core/badge/featureBadge.tsx index b6a5baf88f94aa..ae262d9f8cca42 100644 --- a/static/app/components/core/badge/featureBadge.tsx +++ b/static/app/components/core/badge/featureBadge.tsx @@ -1,7 +1,5 @@ import {useTheme} from '@emotion/react'; import styled from '@emotion/styled'; -import type {SeverityLevel} from '@sentry/core'; -import {captureException, withScope} from '@sentry/react'; import CircleIndicator from 'sentry/components/circleIndicator'; import {Badge} from 'sentry/components/core/badge'; @@ -17,7 +15,6 @@ const defaultTitles: Record = { experimental: t( 'This feature is experimental! Try it out and let us know what you think. No promises!' ), - internal: t('This feature is for internal use only'), }; const labels: Record = { @@ -25,7 +22,6 @@ const labels: Record = { beta: t('beta'), new: t('new'), experimental: t('experimental'), - internal: t('internal'), }; const shortLabels: Record = { @@ -33,7 +29,6 @@ const shortLabels: Record = { beta: 'B', new: 'N', experimental: 'E', - internal: 'I', }; const useFeatureBadgeIndicatorColor = () => { @@ -44,14 +39,12 @@ const useFeatureBadgeIndicatorColor = () => { beta: theme.purple300, new: theme.green300, experimental: theme.gray100, - internal: theme.gray100, } satisfies Record; }; export interface FeatureBadgeProps extends Omit, 'title'> { - type: 'alpha' | 'beta' | 'new' | 'experimental' | 'internal'; - expiresAt?: Date; + type: 'alpha' | 'beta' | 'new' | 'experimental'; tooltipProps?: Partial; variant?: 'badge' | 'indicator' | 'short'; } @@ -60,16 +53,11 @@ function InnerFeatureBadge({ type, variant = 'badge', tooltipProps, - expiresAt, ...props }: FeatureBadgeProps) { const indicatorColors = useFeatureBadgeIndicatorColor(); const title = tooltipProps?.title?.toString() ?? defaultTitles[type] ?? ''; - if (hasFeatureBadgeExpired(expiresAt, title, type)) { - return null; - } - return (
@@ -85,31 +73,6 @@ function InnerFeatureBadge({ ); } -/** - * Checks if a feature badge has expired - if it has, reports the result to Sentry - * @param expiresAt The date the feature badge expires. - * @returns True if the feature badge has expired, false otherwise. - */ -function hasFeatureBadgeExpired( - expiresAt: Date | undefined, - title: string, - type: FeatureBadgeProps['type'] -) { - if (expiresAt && expiresAt.valueOf() < Date.now()) { - // Only get 1% of events as we don't need many to know that a badge needs to be cleaned up. - if (Math.random() < 0.01) { - withScope(scope => { - scope.setTag('title', title); - scope.setTag('type', type); - scope.setLevel('warning' as SeverityLevel); - captureException(new Error('Expired Feature Badge')); - }); - } - return true; - } - return false; -} - const StyledBadge = styled(Badge)` margin: 0; padding: 0 ${space(0.75)}; diff --git a/static/app/views/insights/mobile/screens/views/screenDetailsPage.tsx b/static/app/views/insights/mobile/screens/views/screenDetailsPage.tsx index 339e1597300194..1f6c04a1e3297c 100644 --- a/static/app/views/insights/mobile/screens/views/screenDetailsPage.tsx +++ b/static/app/views/insights/mobile/screens/views/screenDetailsPage.tsx @@ -100,9 +100,7 @@ export function ScreenDetailsPage() { return ( ); })}