import React from 'react'; import { burst_get_website_url } from '@/utils/lib.js'; import Icon from '@/utils/Icon'; import ButtonInput from '@/components/Inputs/ButtonInput'; import { useABTest } from '@/hooks/useABTest'; import { __, sprintf } from '@wordpress/i18n'; import useLicenseData from '@/hooks/useLicenseData'; interface UpsellCopyProps { className?: string; type: string; compact?: boolean; } interface UpsellConfigsProps { [key: string]: { testID: string; upgradePlan: { header: string; subTitle: string; licenseInsufficient: string; }; variations: { [key: string]: { utm_medium: string; title: string; description: string; bullets: { icon: string; text: string; }[]; }; }; }; } const upsellConfigs: UpsellConfigsProps = { sales: { upgradePlan: { header: __( 'Unlock Sales Performance', 'burst-statistics' ), subTitle: __( 'Gain valuable insights into your store’s revenue, top products, and sales trends.', 'burst-statistics' ), licenseInsufficient: __( 'Your current license does not include the Sales dashboard.', 'burst-statistics' ) }, testID: 'sales-upsell-copy-v1', variations: { B: { utm_medium: 'sales-upsell-variation-b', title: __( 'Are your visitors buying, or just browsing?', 'burst-statistics' ), description: '', bullets: [ { icon: 'goals', text: __( 'Uncover checkout drop‑offs', 'burst-statistics' ) }, { icon: 'goals', text: __( 'Spot and fix cart abandonment issues', 'burst-statistics' ) }, { icon: 'goals', text: __( 'See which products and channels earn revenue', 'burst-statistics' ) } ] } } }, sources: { upgradePlan: { header: __( 'See which sources actually bring visitors', 'burst-statistics' ), subTitle: __( 'Free shows your visitor locations. Pro adds source trends, top referrers, and campaign performance, so you can see where traffic and conversions come from.', 'burst-statistics' ), licenseInsufficient: '' }, // Keeping testID to upsell-copy-v1 for backwards compatibility. testID: 'upsell-copy-v1', variations: { A: { utm_medium: 'upsell-variation-a', title: __( 'Are you just guessing with your marketing?', 'burst-statistics' ), description: __( 'You spend time and money creating campaigns, but can\'t see what\'s actually working. Are your newsletters driving traffic or just getting opened? Is your social media budget paying off? Without clear tracking, you\'re making decisions in the dark, which is inefficient and frustrating.', 'burst-statistics' ), bullets: [ { icon: 'goals', text: __( 'Stop guessing: Track UTM campaigns to see which channels deliver real visitors.', 'burst-statistics' ) }, { icon: 'filter', text: __( 'Optimize with confidence: Refine on-site promotions by analyzing custom URL parameters.', 'burst-statistics' ) }, { icon: 'world', text: __( 'Go beyond numbers: Visualize exactly where your visitors are with an interactive world map.', 'burst-statistics' ) } ] }, B: { utm_medium: 'upsell-variation-b', title: __( 'Turn your traffic into targeted growth.', 'burst-statistics' ), description: __( 'Effective growth comes from understanding your audience on a deeper level. Burst Pro provides the tools to see not just how many people visit, but who they are and what brought them to you, so you can focus your efforts where they matter most.', 'burst-statistics' ), bullets: [ { icon: 'goals', text: __( 'Measure the success of your marketing with automatic UTM campaign tracking.', 'burst-statistics' ) }, { icon: 'filter', text: __( 'Optimize your website by tracking how visitors interact with specific parameters.', 'burst-statistics' ) }, { icon: 'world', text: __( 'Tailor your content by identifying key visitor locations, from country down to the city.', 'burst-statistics' ) } ] } } }, forms: { upgradePlan: { header: __( 'Track form submissions and conversion rates', 'burst-statistics' ), subTitle: __( 'Burst Pro shows which forms are being submitted and how well they convert. Upgrade when you need to measure which forms are working.', 'burst-statistics' ), licenseInsufficient: __( 'Your current license does not include forms tracking.', 'burst-statistics' ) }, testID: 'forms-upsell-copy-v1', variations: { A: { utm_medium: 'forms-upsell-variation-a', title: __( 'Are your forms losing you conversions?', 'burst-statistics' ), description: __( 'Your forms are where visitors become leads and customers. But if people start filling them in and never submit, you’re losing conversions without knowing why. Burst Pro shows you exactly how visitors interact with your forms, so you can fix what’s holding them back.', 'burst-statistics' ), bullets: [ { icon: 'goals', text: __( 'Track submissions: See which forms convert and which get ignored.', 'burst-statistics' ) }, { icon: 'filter', text: __( 'Spot abandonment: Find out where visitors give up before submitting.', 'burst-statistics' ) }, { icon: 'goals', text: __( 'Boost conversions: Optimize your forms based on real interaction data.', 'burst-statistics' ) } ] } } }, external_links: { upgradePlan: { header: __( 'Start tracking outgoing links', 'burst-statistics' ), subTitle: 'Outgoing link tracking is available in Burst Pro - Creator', licenseInsufficient: __( 'Your current license does not include outgoing link tracking.', 'burst-statistics' ) }, testID: 'external-links-upsell-copy-v1', variations: { A: { utm_medium: 'external-links-upsell-variation-a', title: __( 'Where are your visitors going?', 'burst-statistics' ), description: '', bullets: [ { icon: 'world', text: __( 'Track outgoing clicks: Real-time clicks on all external domain links.', 'burst-statistics' ) }, { icon: 'goals', text: __( 'Measure affiliate revenue: Identify which partner links convert best.', 'burst-statistics' ) }, { icon: 'filter', text: __( 'Keep visitors engaged: See which content triggers exit clicks.', 'burst-statistics' ) } ] } } } }; /** * UpsellCopy component that displays different upsell messages based on A/B testing. * Uses campaign parameters to track conversion rates for each variation. * @param root0 * @param root0.className * @param root0.type */ // fallow-ignore-next-line complexity const UpsellCopy: React.FC = ({ className = '', type = 'sources', compact = false }) => { const { licenseActivated, isPro } = useLicenseData(); const upsellConfig = upsellConfigs[type] || upsellConfigs.sources; const testID = upsellConfig.testID; const variations = Object.keys( upsellConfig.variations ); // Use A/B testing to assign variation. const { variation } = useABTest( testID, variations ); // Get the appropriate copy based on variation // Note: Only A and B are used, but keeping C content for potential future use const content = upsellConfig.variations[variation] || upsellConfig.variations.A; // Base campaign parameters for all variations // Don't use `utm_campaign` here as it is filled in by the plugin automatically const baseParams = { utm_source: 'plugin', utm_medium: content.utm_medium }; // Unified compact block layout for both Free and Pro configurations if ( compact ) { return (

{upsellConfig.upgradePlan.header}

{upsellConfig.upgradePlan.subTitle}

{isPro && ! licenseActivated && ( {__( 'Activate License', 'burst-statistics' )} )} { window.open( burst_get_website_url( 'pricing', baseParams ), '_blank' ); }} > {isPro ? __( 'Upgrade Plan', 'burst-statistics' ) : __( 'Upgrade to Pro', 'burst-statistics' )}
); } // if this is premium, but user has not activated the license, or has a not sufficient tier if ( isPro ) { return (

{upsellConfig.upgradePlan.header}

{upsellConfig.upgradePlan.subTitle}

{! licenseActivated && __( 'Already have a license? Activate it to access these features.', 'burst-statistics' )} {licenseActivated && upsellConfig.upgradePlan.licenseInsufficient}

{! licenseActivated && ( {__( 'Activate License', 'burst-statistics' )} )} { window.open( burst_get_website_url( 'pricing', baseParams ), '_blank' ); }} > {__( 'Upgrade Plan', 'burst-statistics' )}
); } // if we're here, this is free. return (

{content.title}

{content.description}

{content.bullets.map( ( bullet, index ) => { const parts = bullet.text.split( ':' ); const hasColon = 1 < parts.length; return (

{hasColon ? ( <> {parts[0]}: {parts.slice( 1 ).join( ':' )} ) : ( {bullet.text} )}

); })}
{__( 'Upgrade to Pro', 'burst-statistics' )}
{__( 'Learn about all features', 'burst-statistics' )}
{'development' === process.env.NODE_ENV && (
{sprintf( __( 'Variation: %s', 'burst-statistics' ), variation )}
)}
); }; export default UpsellCopy;