import {useCallback} from 'react'; import {css} from '@emotion/react'; import styled from '@emotion/styled'; import HeroImg from 'sentry-images/spot/custom-metrics-opt-in-modal-hero.png'; import {type ModalRenderProps, openModal} from 'sentry/actionCreators/modal'; import {Button, type ButtonProps, LinkButton} from 'sentry/components/button'; import {IconClose} from 'sentry/icons/iconClose'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Organization} from 'sentry/types'; import {trackAnalytics} from 'sentry/utils/analytics'; import {useLocalStorageState} from 'sentry/utils/useLocalStorageState'; import useOrganization from 'sentry/utils/useOrganization'; import {OrganizationContext} from 'sentry/views/organizationContext'; export function useOptInModal() { const organization = useOrganization(); const [dismissedModal, setDismissedModal] = useLocalStorageState( 'sentry:metrics-opt-in-modal-dismissed', false ); if (!dismissedModal) { openMetricsOptInModal(organization, setDismissedModal); } } function openMetricsOptInModal( organization: Organization, setDismissedModal: (value: boolean) => void ) { return openModal( deps => ( { setDismissedModal(true); deps.closeModal(); }} /> ), {modalCss, closeEvents: 'none'} ); } function OptInModal({closeModal}: ModalRenderProps) { const organization = useOrganization(); const handleCloseModal = useCallback( source => { trackAnalytics('ddm.opt_in_modal_closed', {organization, source}); closeModal(); }, [organization, closeModal] ); return ( {t('Sentry Metrics: Now in Beta')}
{t('Track and solve what matters')}
handleCloseModal('close_button')} />

{t( 'Create custom metrics to track and visualize the data points you care about over time, like processing time, checkout conversion rate, or user signups, and pinpoint and solve issues faster by using correlated traces.' )}

{t('A few notes:')}
  • {t('This is a beta, so it may be buggy - we recognise the irony.')}
  • {t('If we hit any scaling issues, we may need to turn off metrics ingestion.')}
  • {t( 'We plan to charge for it in the future once it becomes generally available, but it is completely free to use during the beta.' )}
  • { trackAnalytics('ddm.opt_in_modal_closed', { organization, source: 'learn_more', }); }} > {t('Learn more')} {t( 'Metrics is currently supported in the following SDKs, with more coming soon: JavaScript, Node.js, Python, PHP, Laravel, Symfony, Ruby, Rust, Java, React Native, Unity & .NET.' )}
    ); } const Content = styled('div')` background: top no-repeat url('${HeroImg}'); background-size: contain; margin-inline: -46px; padding: 170px 46px 32px 46px; font-size: ${p => p.theme.fontSizeMedium}; border-radius: ${p => p.theme.borderRadius}; p, ul { line-height: 1.6rem; } `; const Subheader = styled('h2')` color: ${p => p.theme.purple300}; font-size: ${p => p.theme.fontSizeSmall}; font-weight: bold; margin-bottom: ${space(3)}; text-transform: uppercase; `; const Header = styled('h1')` font-size: ${p => p.theme.headerFontSize}; font-weight: bold; margin: ${space(1.5)} 0; `; const ListHeader = styled('div')` margin: ${space(1)}; `; const List = styled('ul')` margin: ${space(1)}; `; const ButtonGroup = styled('div')` display: flex; justify-content: flex-end; gap: ${space(1)}; `; const Note = styled('div')` color: ${p => p.theme.gray300}; font-size: ${p => p.theme.fontSizeExtraSmall}; margin-top: ${space(2)}; line-height: 1rem; `; const CloseButton = styled((p: Omit) => (