Skip to content

Commit

Permalink
Add click_upgrade event
Browse files Browse the repository at this point in the history
  • Loading branch information
okmttdhr committed Dec 21, 2023
1 parent c362ca6 commit 9d2fe14
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { getCalypsoUrl } from '@automattic/calypso-url';
import { useEffect, useState, useCallback } from 'react';
import wpcom from 'calypso/lib/wp';
import tracksRecordEvent from '../../tracking/track-record-event';
import { PREMIUM_THEME, WOOCOMMERCE_THEME } from '../utils';
import { usePreviewingTheme } from './use-previewing-theme';
import type { SiteDetails } from '@automattic/data-stores';
Expand Down Expand Up @@ -92,6 +93,11 @@ export const useCanPreviewButNeedUpgrade = ( {
}, [ previewingTheme.type, setCanPreviewButNeedUpgrade, setSiteSlug ] );

const upgradePlan = useCallback( () => {
tracksRecordEvent( 'calypso_block_theme_live_preview_click_upgrade', {
theme: previewingTheme.id,
theme_type: previewingTheme.type,
} );

const generateCheckoutUrl = ( plan: string ) => {
const locationHref = window.location.href;
let url = locationHref;
Expand Down Expand Up @@ -125,9 +131,7 @@ export const useCanPreviewButNeedUpgrade = ( {
: // For a Premium theme, the users should have the Premium plan or higher.
generateCheckoutUrl( PLAN_PREMIUM );
window.location.href = link;

// TODO: Add the track event.
}, [ previewingTheme.type, siteSlug ] );
}, [ previewingTheme.id, previewingTheme.type, siteSlug ] );

return {
canPreviewButNeedUpgrade,
Expand Down

0 comments on commit 9d2fe14

Please sign in to comment.