Skip to content

Commit

Permalink
Stats: add learn more button on StatsUpsell pointing to Jetpack Stats…
Browse files Browse the repository at this point in the history
… Help Center (#96993)
  • Loading branch information
Initsogar authored Dec 3, 2024
1 parent 43e6df7 commit 21d2469
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 13 deletions.
53 changes: 40 additions & 13 deletions client/my-sites/stats/stats-upsell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { isEnabled } from '@automattic/calypso-config';
import { PLAN_PREMIUM } from '@automattic/calypso-products';
import page from '@automattic/calypso-router';
import { Gridicon } from '@automattic/components';
import { Plans } from '@automattic/data-stores';
import { Plans, HelpCenter } from '@automattic/data-stores';
import formatCurrency from '@automattic/format-currency';
import { useLocalizeUrl } from '@automattic/i18n-utils';
import { Button } from '@wordpress/components';
import { useDispatch as useDataStoreDispatch } from '@wordpress/data';
import { useTranslate } from 'i18n-calypso';
import statsFeaturesPNG from 'calypso/assets/images/stats/paid-features.png';
import TrackComponentView from 'calypso/lib/analytics/track-component-view';
Expand All @@ -16,6 +18,8 @@ import { getSelectedSiteId, getSelectedSiteSlug } from 'calypso/state/ui/selecto

import './style.scss';

const HELP_CENTER_STORE = HelpCenter.register();

export default function StatsUpsell( { siteId }: { siteId: number } ) {
const translate = useTranslate();
const selectedSiteId = useSelector( getSelectedSiteId );
Expand All @@ -33,6 +37,8 @@ export default function StatsUpsell( { siteId }: { siteId: number } ) {
const isOdysseyStats = isEnabled( 'is_running_in_jetpack_site' );
const eventPrefix = isOdysseyStats ? 'jetpack_odyssey' : 'calypso';
const statType = useSelector( ( state ) => getUpsellModalStatType( state, siteId ) );
const { setShowHelpCenter, setShowSupportDoc } = useDataStoreDispatch( HELP_CENTER_STORE );
const localizeUrl = useLocalizeUrl();

const onClick = ( event: React.MouseEvent< HTMLButtonElement, MouseEvent > ) => {
event.preventDefault();
Expand All @@ -49,6 +55,18 @@ export default function StatsUpsell( { siteId }: { siteId: number } ) {
}
};

const learnMoreLink = localizeUrl( 'https://wordpress.com/support/stats/' );

const onLearnMoreClick = ( event: React.MouseEvent< HTMLButtonElement, MouseEvent > ) => {
event.preventDefault();
setShowHelpCenter( true );
setShowSupportDoc( learnMoreLink );

recordTracksEvent( `${ eventPrefix }_stats_upsell_learn_more`, {
stat_type: statType,
} );
};

return (
<div className="stats-upsell">
<TrackComponentView
Expand Down Expand Up @@ -118,18 +136,27 @@ export default function StatsUpsell( { siteId }: { siteId: number } ) {
</div>
</div>
</div>
<Button
variant="primary"
className="stats-upsell__button"
onClick={ onClick }
disabled={ isLoading }
>
{ ! plan?.productNameShort
? translate( 'Upgrade plan' )
: translate( 'Upgrade to %(planName)s', {
args: { planName: plan.productNameShort },
} ) }
</Button>
<div className="stats-upsell__buttons">
<Button
variant="primary"
className="stats-upsell__button"
onClick={ onClick }
disabled={ isLoading }
>
{ ! plan?.productNameShort
? translate( 'Upgrade plan' )
: translate( 'Upgrade to %(planName)s', {
args: { planName: plan.productNameShort },
} ) }
</Button>
<Button
variant="secondary"
className="stats-upsell__button"
onClick={ onLearnMoreClick }
>
{ translate( 'Learn more' ) }
</Button>
</div>
</div>
<div className="stats-upsell__right">
<img src={ statsFeaturesPNG } alt={ translate( 'Features' ) } />
Expand Down
5 changes: 5 additions & 0 deletions client/my-sites/stats/stats-upsell/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,9 @@
}
}
}

.stats-upsell__buttons {
display: flex;
gap: 16px;
}
}

0 comments on commit 21d2469

Please sign in to comment.