Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metrics): Add custom metrics banner #70946

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion static/app/utils/analytics/ddmAnalyticsEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type DDMEventParameters = {
source: 'global' | 'widget';
};
'ddm.open-onboarding': {
source: 'onboarding_panel' | 'header';
source: 'onboarding_panel' | 'header' | 'banner';
};
'ddm.opt_in_modal_closed': {
source: 'im_in' | 'learn_more' | 'close_button';
Expand Down
38 changes: 35 additions & 3 deletions static/app/views/metrics/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {Fragment, memo, useCallback} from 'react';
import {useTheme} from '@emotion/react';
import styled from '@emotion/styled';
import * as Sentry from '@sentry/react';

import emptyStateImg from 'sentry-images/spot/custom-metrics-empty-state.svg';

import FeatureBadge from 'sentry/components/badge/featureBadge';
import Banner from 'sentry/components/banner';
import {Button} from 'sentry/components/button';
import ButtonBar from 'sentry/components/buttonBar';
import FloatingFeedbackWidget from 'sentry/components/feedback/widget/floatingFeedbackWidget';
Expand All @@ -21,8 +23,11 @@ import {space} from 'sentry/styles/space';
import {trackAnalytics} from 'sentry/utils/analytics';
import {METRICS_DOCS_URL} from 'sentry/utils/metrics/constants';
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';
Expand All @@ -42,9 +47,12 @@ 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(
(referrer: 'header' | 'onboarding_panel') => {
(referrer: 'header' | 'onboarding_panel' | 'banner') => {
Sentry.metrics.increment('ddm.add_custom_metric', 1, {
tags: {
referrer,
Expand Down Expand Up @@ -84,14 +92,35 @@ export const MetricsLayout = memo(() => {
</Layout.HeaderContent>
<Layout.HeaderActions>
<PageHeaderActions
showCustomMetricButton={hasCustomMetrics || isEmptyStateDismissed}
showCustomMetricButton={
hasCustomMetrics || (isEmptyStateDismissed && isBannerDismissed)
}
addCustomMetric={() => addCustomMetric('header')}
/>
</Layout.HeaderActions>
</Layout.Header>
<Layout.Body>
<FloatingFeedbackWidget />
<Layout.Main fullWidth>
{isEmptyStateDismissed && !hasCustomMetrics && (
<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>
)}

<FilterContainer>
<PageFilterBar condensed>
<ProjectPageFilter />
Expand Down Expand Up @@ -122,7 +151,10 @@ export const MetricsLayout = memo(() => {
priority="primary"
onClick={() => addCustomMetric('onboarding_panel')}
>
{t('Add Custom Metric')}
{t('Set Up Custom Metric')}
</Button>
<Button href={METRICS_DOCS_URL} external>
{t('Read Docs')}
</Button>
{hasPerformanceMetrics && (
<Button onClick={viewPerformanceMetrics}>
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/metrics/pageHeaderActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export function PageHeaderActions({showCustomMetricButton, addCustomMetric}: Pro
<ButtonBar gap={1}>
{showCustomMetricButton && (
<Button priority="primary" onClick={() => addCustomMetric()} size="sm">
{t('Set Up Custom Metrics')}
{t('Add Custom Metrics')}
</Button>
)}
<Button
Expand Down
Loading