Skip to content

Commit

Permalink
Boost: Add tracks events (#38211)
Browse files Browse the repository at this point in the history
* Add identifiers to upgrade CTA

* Track CTA click on performance history

* changelog
  • Loading branch information
haqadn authored Jul 8, 2024
1 parent d1da4aa commit f392190
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ const PerformanceHistoryBody = () => {
);
}

const handleUpgrade = () => {
recordBoostEvent( 'performance_history_upgrade_cta_click', {} );
navigate( '/upgrade' );
};

return (
<GraphComponent
{ ...( data as PerformanceHistoryData ) }
isFreshStart={ ! freshStartCompleted }
needsUpgrade={ needsUpgrade }
handleUpgrade={ () => navigate( '/upgrade' ) }
handleUpgrade={ handleUpgrade }
handleDismissFreshStart={ dismissFreshStart }
isLoading={ isFetching && ( ! data || data.periods.length === 0 ) }
/>
Expand All @@ -68,7 +73,9 @@ const PerformanceHistory = () => {
title={ __( 'Historical Performance', 'jetpack-boost' ) }
initialOpen={ isPanelOpen }
onToggle={ ( value: boolean ) => {
recordBoostEvent( 'performance_history_panel_toggle', { status: value ? 'open' : 'close' } );
recordBoostEvent( 'performance_history_panel_toggle', {
status: value ? 'open' : 'close',
} );
setPanelOpen( value );
} }
className={ styles[ 'performance-history-body' ] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import { useNavigate } from 'react-router-dom';

type UpgradeCTAProps = {
description: string;
identifier: string;
};

const UpgradeCTA = ( { description }: UpgradeCTAProps ) => {
const UpgradeCTA = ( { description, identifier }: UpgradeCTAProps ) => {
const navigate = useNavigate();

const showBenefits = () => {
recordBoostEvent( 'upsell_cta_from_settings_page_in_plugin', {} );
recordBoostEvent( 'upsell_cta_from_settings_page_in_plugin', { identifier } );
navigate( '/upgrade' );
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const Index = () => {
<CriticalCssMeta />

<UpgradeCTA
identifier="critical-css"
description={ __(
'Save time by upgrading to Automatic Critical CSS generation.',
'jetpack-boost'
Expand Down Expand Up @@ -200,6 +201,7 @@ const Index = () => {
>
{ ! hasPremiumCdnFeatures && (
<UpgradeCTA
identifier="image-cdn"
description={ __(
'Auto-resize lazy images and adjust their quality.',
'jetpack-boost'
Expand All @@ -224,6 +226,7 @@ const Index = () => {
</p>
{ ! isaState?.available && (
<UpgradeCTA
identifier="image-guide"
description={ __(
'Upgrade to scan your site for issues - automatically!',
'jetpack-boost'
Expand Down
5 changes: 5 additions & 0 deletions projects/plugins/boost/changelog/add-tracks-events
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Added some tracks events


0 comments on commit f392190

Please sign in to comment.