Browse Source

ref(metrics): Add alerts informing users metrics beta will end (#76830)

Priscila Oliveira 6 months ago
parent
commit
d264ca37b9

+ 2 - 0
static/app/components/modals/metricWidgetViewerModal.tsx

@@ -37,6 +37,7 @@ import {
   useGenerateExpressionId,
 } from 'sentry/views/dashboards/metrics/utils';
 import {DisplayType} from 'sentry/views/dashboards/types';
+import {MetricsBetaEndAlert} from 'sentry/views/metrics/metricsBetaEndAlert';
 import {MetricDetails} from 'sentry/views/metrics/widgetDetails';
 import {OrganizationContext} from 'sentry/views/organizationContext';
 
@@ -324,6 +325,7 @@ function MetricWidgetViewerModal({
           <CloseButton onClick={handleClose} />
         </Header>
         <Body>
+          <MetricsBetaEndAlert />
           <Queries
             displayType={displayType}
             metricQueries={metricQueries}

+ 3 - 0
static/app/components/sidebar/index.tsx

@@ -525,6 +525,9 @@ function Sidebar() {
       to={metricsPath}
       search={location?.pathname === normalizeUrl(metricsPath) ? location.search : ''}
       id="metrics"
+      badgeTitle={t(
+        'The Metrics beta will end and we will retire the current solution on October 7th, 2024'
+      )}
       isBeta
     />
   );

+ 9 - 4
static/app/components/sidebar/sidebarItem.tsx

@@ -58,6 +58,10 @@ export type SidebarItemProps = {
    * Additional badge to display after label
    */
   badge?: number;
+  /**
+   * Custom tooltip title for the badge
+   */
+  badgeTitle?: string;
   className?: string;
   /**
    * Is sidebar in a collapsed state
@@ -81,6 +85,7 @@ export type SidebarItemProps = {
    * Additional badge letting users know a tab is in alpha.
    */
   isAlpha?: boolean;
+
   /**
    * Additional badge letting users know a tab is in beta.
    */
@@ -90,7 +95,6 @@ export type SidebarItemProps = {
    * Is main item in a floating accordion
    */
   isMainItem?: boolean;
-
   /**
    * Is this item nested within another item
    */
@@ -145,6 +149,7 @@ function SidebarItem({
   isMainItem,
   isOpenInFloatingSidebar,
   hasNewNav,
+  badgeTitle,
   ...props
 }: SidebarItemProps) {
   const {setExpandedItemId, shouldAccordionFloat} = useContext(ExpandedContext);
@@ -195,9 +200,9 @@ function SidebarItem({
 
   const badges = (
     <Fragment>
-      {showIsNew && <FeatureBadge type="new" variant={variant} />}
-      {isBeta && <FeatureBadge type="beta" variant={variant} />}
-      {isAlpha && <FeatureBadge type="alpha" variant={variant} />}
+      {showIsNew && <FeatureBadge type="new" variant={variant} title={badgeTitle} />}
+      {isBeta && <FeatureBadge type="beta" variant={variant} title={badgeTitle} />}
+      {isAlpha && <FeatureBadge type="alpha" variant={variant} title={badgeTitle} />}
     </Fragment>
   );
 

+ 0 - 1
static/app/views/alerts/rules/issue/index.tsx

@@ -1181,7 +1181,6 @@ class IssueRuleEditor extends DeprecatedAsyncView<Props, State> {
     return (
       <Main fullWidth>
         <PermissionAlert access={['alerts:write']} project={project} />
-
         <StyledForm
           key={isSavedAlertRule(rule) ? rule.id : undefined}
           onCancel={this.handleCancel}

+ 6 - 0
static/app/views/alerts/rules/metric/details/body.tsx

@@ -32,6 +32,7 @@ import {getAlertRuleActionCategory} from 'sentry/views/alerts/rules/utils';
 import type {Incident} from 'sentry/views/alerts/types';
 import {AlertRuleStatus} from 'sentry/views/alerts/types';
 import {alertDetailsLink} from 'sentry/views/alerts/utils';
+import {MetricsBetaEndAlert} from 'sentry/views/metrics/metricsBetaEndAlert';
 
 import {isCrashFreeAlert} from '../utils/isCrashFreeAlert';
 import {isCustomMetricAlert} from '../utils/isCustomMetricAlert';
@@ -166,6 +167,11 @@ export default function MetricDetailsBody({
 
   return (
     <Fragment>
+      <StyledLayoutBody>
+        {isCustomMetricAlert(rule.aggregate) && (
+          <MetricsBetaEndAlert style={{marginBottom: 0}} />
+        )}
+      </StyledLayoutBody>
       {selectedIncident?.alertRule.status === AlertRuleStatus.SNAPSHOT && (
         <StyledLayoutBody>
           <StyledAlert type="warning" showIcon>

+ 3 - 0
static/app/views/alerts/rules/metric/ruleForm.tsx

@@ -56,6 +56,7 @@ import Triggers from 'sentry/views/alerts/rules/metric/triggers';
 import TriggersChart from 'sentry/views/alerts/rules/metric/triggers/chart';
 import {getEventTypeFilter} from 'sentry/views/alerts/rules/metric/utils/getEventTypeFilter';
 import hasThresholdValue from 'sentry/views/alerts/rules/metric/utils/hasThresholdValue';
+import {isCustomMetricAlert} from 'sentry/views/alerts/rules/metric/utils/isCustomMetricAlert';
 import {isOnDemandMetricAlert} from 'sentry/views/alerts/rules/metric/utils/onDemandMetricAlert';
 import {AlertRuleType} from 'sentry/views/alerts/types';
 import {ruleNeedsErrorMigration} from 'sentry/views/alerts/utils/migrationUi';
@@ -65,6 +66,7 @@ import {
   DatasetMEPAlertQueryTypes,
 } from 'sentry/views/alerts/wizard/options';
 import {getAlertTypeFromAggregateDataset} from 'sentry/views/alerts/wizard/utils';
+import {MetricsBetaEndAlert} from 'sentry/views/metrics/metricsBetaEndAlert';
 import PermissionAlert from 'sentry/views/settings/project/permissionAlert';
 
 import {isCrashFreeAlert} from './utils/isCrashFreeAlert';
@@ -1194,6 +1196,7 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
     return (
       <Main fullWidth>
         <PermissionAlert access={['alerts:write']} project={project} />
+        {isCustomMetricAlert(rule.aggregate) && <MetricsBetaEndAlert />}
 
         {eventView && <IncompatibleAlertQuery eventView={eventView} />}
         <Form

+ 8 - 1
static/app/views/dashboards/addWidget.tsx

@@ -160,7 +160,14 @@ export function AddWidgetButton({onAddWidget, ...buttonProps}: Props & ButtonPro
         key: DataSet.METRICS,
         label: t('Metrics'),
         onAction: () => handleAction(DataSet.METRICS),
-        trailingItems: <FeatureBadge type="beta" />,
+        trailingItems: (
+          <FeatureBadge
+            type="beta"
+            title={
+              'The Metrics beta will end and we will retire the current solution on October 7th, 2024'
+            }
+          />
+        ),
       });
     }
 

+ 4 - 9
static/app/views/metrics/layout.spec.tsx

@@ -53,9 +53,8 @@ describe('Metrics Layout', function () {
       await screen.findByRole('button', {name: 'Set Up Custom Metric'})
     ).toBeInTheDocument();
 
-    expect(
-      screen.queryByText(/there are upcoming changes to the Metrics API/i)
-    ).toBeInTheDocument();
+    // Alert: Metrics beta experience ending soon.
+    expect(screen.getByText(/we are ending the beta/i)).toBeInTheDocument();
 
     // Main View: Displays the empty state.
     expect(screen.queryByText(/track and solve what matters/i)).toBeInTheDocument();
@@ -96,12 +95,8 @@ describe('Metrics Layout', function () {
 
     render(<MetricsLayout />, {organization});
 
-    // Alert: Old API metrics ingestion ending soon.
-    expect(
-      await screen.findByText(
-        /There are upcoming changes to the Metrics API that may affect your usage/i
-      )
-    ).toBeInTheDocument();
+    // Alert: Metrics beta experience ending soon.
+    expect(await screen.findByText(/we are ending the beta/i)).toBeInTheDocument();
 
     // Button: Add Custom Metrics
     expect(screen.getByRole('button', {name: 'Add Custom Metrics'})).toBeInTheDocument();

+ 8 - 28
static/app/views/metrics/layout.tsx

@@ -1,5 +1,4 @@
 import {Fragment, memo, useCallback} from 'react';
-import {useTheme} from '@emotion/react';
 import styled from '@emotion/styled';
 import * as Sentry from '@sentry/react';
 
@@ -8,7 +7,6 @@ import emptyStateImg from 'sentry-images/spot/custom-metrics-empty-state.svg';
 import Alert from 'sentry/components/alert';
 import GuideAnchor from 'sentry/components/assistant/guideAnchor';
 import FeatureBadge from 'sentry/components/badge/featureBadge';
-import Banner from 'sentry/components/banner';
 import {Button, LinkButton} from 'sentry/components/button';
 import ButtonBar from 'sentry/components/buttonBar';
 import FloatingFeedbackWidget from 'sentry/components/feedback/widget/floatingFeedbackWidget';
@@ -29,14 +27,12 @@ import {hasCustomMetrics} from 'sentry/utils/metrics/features';
 import {useVirtualMetricsContext} from 'sentry/utils/metrics/virtualMetricsContext';
 import useDismissAlert from 'sentry/utils/useDismissAlert';
 import {useLocalStorageState} from 'sentry/utils/useLocalStorageState';
-import useMedia from 'sentry/utils/useMedia';
 import useOrganization from 'sentry/utils/useOrganization';
 import usePageFilters from 'sentry/utils/usePageFilters';
-import BackgroundSpace from 'sentry/views/discover/backgroundSpace';
 import {useMetricsContext} from 'sentry/views/metrics/context';
 import {useMetricsOnboardingSidebar} from 'sentry/views/metrics/ddmOnboarding/useMetricsOnboardingSidebar';
 import {IntervalSelect} from 'sentry/views/metrics/intervalSelect';
-import {MetricsApiChangeAlert} from 'sentry/views/metrics/metricsApiChangeAlert';
+import {MetricsBetaEndAlert} from 'sentry/views/metrics/metricsBetaEndAlert';
 import {PageHeaderActions} from 'sentry/views/metrics/pageHeaderActions';
 import {Queries} from 'sentry/views/metrics/queries';
 import {MetricScratchpad} from 'sentry/views/metrics/scratchpad';
@@ -73,8 +69,6 @@ export const MetricsLayout = memo(() => {
     useDismissAlert({
       key: `${organization.id}:${selectedProjects}:metrics-empty-state-dismissed`,
     });
-  const theme = useTheme();
-  const isSmallBanner = useMedia(`(max-width: ${theme.breakpoints.medium})`);
   const [isBannerDismissed] = useLocalStorageState('metrics-banner-dismissed', false);
 
   const addCustomMetric = useCallback(
@@ -128,7 +122,12 @@ export const MetricsLayout = memo(() => {
                 'Metrics help you track and visualize the data points you care about, making it easier to monitor your application health and identify issues.'
               )}
             />
-            <FeatureBadge type="beta" />
+            <FeatureBadge
+              type="beta"
+              title={t(
+                'The Metrics beta will end and we will retire the current solution on October 7th, 2024'
+              )}
+            />
           </Layout.Title>
         </Layout.HeaderContent>
         <Layout.HeaderActions>
@@ -145,26 +144,7 @@ export const MetricsLayout = memo(() => {
       <Layout.Body>
         <FloatingFeedbackWidget />
         <Layout.Main fullWidth>
-          {isEmptyStateDismissed && !hasSentCustomMetrics && (
-            <Banner
-              title={t('Custom Metrics')}
-              subtitle={t(
-                "Track your system's behaviour and profit from the same powerful features as you do with errors, like alerting and dashboards."
-              )}
-              backgroundComponent={<BackgroundSpace />}
-              dismissKey="metrics"
-            >
-              <Button
-                size={isSmallBanner ? 'xs' : undefined}
-                translucentBorder
-                onClick={() => addCustomMetric('banner')}
-              >
-                {t('Set Up')}
-              </Button>
-            </Banner>
-          )}
-
-          <MetricsApiChangeAlert />
+          <MetricsBetaEndAlert />
 
           <FilterContainer>
             <PageFilterBar condensed>

+ 0 - 43
static/app/views/metrics/metricsApiChangeAlert.tsx

@@ -1,43 +0,0 @@
-import Alert from 'sentry/components/alert';
-import {Button} from 'sentry/components/button';
-import ExternalLink from 'sentry/components/links/externalLink';
-import {IconClose} from 'sentry/icons/iconClose';
-import {t, tct} from 'sentry/locale';
-import useDismissAlert from 'sentry/utils/useDismissAlert';
-
-const LOCAL_STORAGE_KEY = 'custom-metrics-sdk-api-change-alert-dismissed';
-
-export function MetricsApiChangeAlert() {
-  const {isDismissed, dismiss} = useDismissAlert({
-    key: LOCAL_STORAGE_KEY,
-  });
-
-  if (isDismissed) {
-    return null;
-  }
-
-  return (
-    <Alert
-      type="warning"
-      showIcon
-      trailingItems={
-        <Button
-          aria-label={t('Dismiss banner')}
-          icon={<IconClose />}
-          onClick={dismiss}
-          size="zero"
-          borderless
-        />
-      }
-    >
-      {tct(
-        'There are upcoming changes to the Metrics API that may affect your usage. Read the [link:FAQs] for more details.',
-        {
-          link: (
-            <ExternalLink href="https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics" />
-          ),
-        }
-      )}
-    </Alert>
-  );
-}

Some files were not shown because too many files changed in this diff