File size: 1,171 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import { Button } from '@wordpress/components';
import { useAnalytics } from '../../app/analytics';
import ComponentViewTracker from '../component-view-tracker';
import { upsell } from '../icons';
import type { ComponentProps } from 'react';
import './style.scss';
type UpsellCTAButtonProps = ComponentProps< typeof Button > & {
tracksId: string;
onClick?: ( event: React.MouseEvent< HTMLButtonElement | HTMLAnchorElement > ) => void;
};
export default function UpsellCTAButton( props: UpsellCTAButtonProps ) {
const { tracksId, onClick, ...buttonProps } = props;
const { recordTracksEvent } = useAnalytics();
const handleClick = ( event: React.MouseEvent< HTMLButtonElement | HTMLAnchorElement > ) => {
recordTracksEvent( 'calypso_dashboard_upsell_click', {
feature: tracksId,
type: 'cta-button',
} );
onClick?.( event );
};
return (
<>
<ComponentViewTracker
eventName="calypso_dashboard_upsell_impression"
properties={ { feature: tracksId, type: 'cta-button' } }
/>
<Button
className="dashboard-upsell-cta-button"
icon={ upsell }
onClick={ handleClick }
size="compact"
{ ...buttonProps }
/>
</>
);
}
|