Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats: add learn more button on StatsUpsell pointing to Jetpack Stats Help Center #96993

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading