11import { Fragment , memo , useCallback } from 'react' ;
2+ import { useTheme } from '@emotion/react' ;
23import styled from '@emotion/styled' ;
34import * as Sentry from '@sentry/react' ;
45
56import emptyStateImg from 'sentry-images/spot/custom-metrics-empty-state.svg' ;
67
78import FeatureBadge from 'sentry/components/badge/featureBadge' ;
9+ import Banner from 'sentry/components/banner' ;
810import { Button } from 'sentry/components/button' ;
911import ButtonBar from 'sentry/components/buttonBar' ;
1012import FloatingFeedbackWidget from 'sentry/components/feedback/widget/floatingFeedbackWidget' ;
@@ -21,8 +23,11 @@ import {space} from 'sentry/styles/space';
2123import { trackAnalytics } from 'sentry/utils/analytics' ;
2224import { METRICS_DOCS_URL } from 'sentry/utils/metrics/constants' ;
2325import useDismissAlert from 'sentry/utils/useDismissAlert' ;
26+ import { useLocalStorageState } from 'sentry/utils/useLocalStorageState' ;
27+ import useMedia from 'sentry/utils/useMedia' ;
2428import useOrganization from 'sentry/utils/useOrganization' ;
2529import usePageFilters from 'sentry/utils/usePageFilters' ;
30+ import BackgroundSpace from 'sentry/views/discover/backgroundSpace' ;
2631import { useMetricsContext } from 'sentry/views/metrics/context' ;
2732import { useMetricsOnboardingSidebar } from 'sentry/views/metrics/ddmOnboarding/useMetricsOnboardingSidebar' ;
2833import { IntervalSelect } from 'sentry/views/metrics/intervalSelect' ;
@@ -42,9 +47,12 @@ export const MetricsLayout = memo(() => {
4247 useDismissAlert ( {
4348 key : `${ organization . id } :${ selectedProjects } :metrics-empty-state-dismissed` ,
4449 } ) ;
50+ const theme = useTheme ( ) ;
51+ const isSmallBanner = useMedia ( `(max-width: ${ theme . breakpoints . medium } )` ) ;
52+ const [ isBannerDismissed ] = useLocalStorageState ( 'metrics-banner-dismissed' , false ) ;
4553
4654 const addCustomMetric = useCallback (
47- ( referrer : 'header' | 'onboarding_panel' ) => {
55+ ( referrer : 'header' | 'onboarding_panel' | 'banner' ) => {
4856 Sentry . metrics . increment ( 'ddm.add_custom_metric' , 1 , {
4957 tags : {
5058 referrer,
@@ -84,14 +92,35 @@ export const MetricsLayout = memo(() => {
8492 </ Layout . HeaderContent >
8593 < Layout . HeaderActions >
8694 < PageHeaderActions
87- showCustomMetricButton = { hasCustomMetrics || isEmptyStateDismissed }
95+ showCustomMetricButton = {
96+ hasCustomMetrics || ( isEmptyStateDismissed && isBannerDismissed )
97+ }
8898 addCustomMetric = { ( ) => addCustomMetric ( 'header' ) }
8999 />
90100 </ Layout . HeaderActions >
91101 </ Layout . Header >
92102 < Layout . Body >
93103 < FloatingFeedbackWidget />
94104 < Layout . Main fullWidth >
105+ { isEmptyStateDismissed && ! hasCustomMetrics && (
106+ < Banner
107+ title = { t ( 'Custom Metrics' ) }
108+ subtitle = { t (
109+ "Track your system's behaviour and profit from the same powerful features as you do with errors, like alerting and dashboards."
110+ ) }
111+ backgroundComponent = { < BackgroundSpace /> }
112+ dismissKey = "metrics"
113+ >
114+ < Button
115+ size = { isSmallBanner ? 'xs' : undefined }
116+ translucentBorder
117+ onClick = { ( ) => addCustomMetric ( 'banner' ) }
118+ >
119+ { t ( 'Set Up' ) }
120+ </ Button >
121+ </ Banner >
122+ ) }
123+
95124 < FilterContainer >
96125 < PageFilterBar condensed >
97126 < ProjectPageFilter />
@@ -122,7 +151,10 @@ export const MetricsLayout = memo(() => {
122151 priority = "primary"
123152 onClick = { ( ) => addCustomMetric ( 'onboarding_panel' ) }
124153 >
125- { t ( 'Add Custom Metric' ) }
154+ { t ( 'Set Up Custom Metric' ) }
155+ </ Button >
156+ < Button href = { METRICS_DOCS_URL } external >
157+ { t ( 'Read Docs' ) }
126158 </ Button >
127159 { hasPerformanceMetrics && (
128160 < Button onClick = { viewPerformanceMetrics } >
0 commit comments