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/organization';
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.'
)}