import { useTranslate } from 'i18n-calypso'; import { useEffect } from 'react'; import DocumentHead from 'calypso/components/data/document-head'; import { useLeadMutation } from 'calypso/data/site-profiler/use-lead-query'; import { recordTracksEvent } from 'calypso/lib/analytics/tracks'; import { MessageDisplay, ErrorSecondLine, } from 'calypso/performance-profiler/components/message-display'; import LoaderText from 'calypso/performance-profiler/components/weekly-report/loader-text'; import { WeeklyReportProps } from 'calypso/performance-profiler/types/weekly-report'; export const WeeklyReport = ( props: WeeklyReportProps ) => { const translate = useTranslate(); const { url, hash } = props; const siteUrl = new URL( url ); const { mutate, isPending, isError, isSuccess } = useLeadMutation( url, hash ); useEffect( () => { mutate(); }, [ mutate ] ); useEffect( () => { if ( isSuccess ) { recordTracksEvent( 'calypso_performance_profiler_emails_subscribe', { url, hash, } ); } }, [ isSuccess, url, hash ] ); const secondaryMessage = translate( 'You can stop receiving performance reports at any time by clicking the Unsubscribe link in the email footer.' ); return (