From b6968714c3d881c718daa1f1c062064241608357 Mon Sep 17 00:00:00 2001 From: Bryan Elliott Date: Fri, 20 Dec 2024 02:10:17 -0500 Subject: [PATCH] Adjust wording & add link in the "Threats" tooltip. --- .../protect-card/use-protect-tooltip-copy.ts | 82 ++++++++++++++----- 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/projects/packages/my-jetpack/_inc/components/product-cards-section/protect-card/use-protect-tooltip-copy.ts b/projects/packages/my-jetpack/_inc/components/product-cards-section/protect-card/use-protect-tooltip-copy.ts index 4561bf81eacf7..6d67a4b839ea8 100644 --- a/projects/packages/my-jetpack/_inc/components/product-cards-section/protect-card/use-protect-tooltip-copy.ts +++ b/projects/packages/my-jetpack/_inc/components/product-cards-section/protect-card/use-protect-tooltip-copy.ts @@ -27,13 +27,17 @@ export type TooltipContent = { export function useProtectTooltipCopy(): TooltipContent { const slug = PRODUCT_SLUGS.PROTECT; const { detail } = useProduct( slug ); - const { isPluginActive: isProtectPluginActive, hasPaidPlanForProduct: hasProtectPaidPlan } = - detail || {}; + const { + isPluginActive: isProtectPluginActive, + hasPaidPlanForProduct: hasProtectPaidPlan, + manageUrl: protectPluginDashboardUrl, + } = detail || {}; const { recordEvent } = useAnalytics(); const { plugins, themes, protect: { scanData, wafConfig: wafData }, + siteSuffix, } = getMyJetpackWindowInitialState(); const { plugins: fromScanPlugins, @@ -63,6 +67,13 @@ export function useProtectTooltipCopy(): TooltipContent { return isJetpackPluginActive() ? 'admin.php?page=jetpack#/settings' : null; }, [ isProtectPluginActive ] ); + const protectDashboardUrl = useMemo( () => { + if ( isProtectPluginActive ) { + return protectPluginDashboardUrl; + } + return `https://cloud.jetpack.com/scan/${ siteSuffix }`; + }, [ isProtectPluginActive, protectPluginDashboardUrl, siteSuffix ] ); + const trackFirewallSettingsLinkClick = useCallback( () => { recordEvent( 'jetpack_protect_card_tooltip_content_link_click', { page: 'my-jetpack', @@ -72,6 +83,15 @@ export function useProtectTooltipCopy(): TooltipContent { } ); }, [ recordEvent, settingsLink ] ); + const trackProtectDashboardLinkClick = useCallback( () => { + recordEvent( 'jetpack_protect_card_tooltip_content_link_click', { + page: 'my-jetpack', + feature: 'jetpack-protect', + location: 'scan-threats-tooltip', + path: protectDashboardUrl, + } ); + }, [ recordEvent, protectDashboardUrl ] ); + const isBruteForcePluginsActive = isProtectPluginActive || isJetpackPluginActive(); const blockedLoginsTooltip = useMemo( () => { @@ -181,30 +201,48 @@ export function useProtectTooltipCopy(): TooltipContent { ? { title: __( 'Auto-fix threats', 'jetpack-my-jetpack' ), text: criticalThreatCount - ? sprintf( - /* translators: %1$s is the number of threats and %2$s is the numner of critical threats on the site. */ - __( - 'The last scan identified %1$s (%2$d\u00A0critical). But don’t worry, use the “Auto-fix” button in the product to automatically fix most threats.', - 'jetpack-my-jetpack' - ), + ? createInterpolateElement( sprintf( - /* translators: %d is the number of detected scan threats on the site. */ - _n( '%d threat', '%d threats', numThreats, 'jetpack-my-jetpack' ), - numThreats + /* translators: %1$s is the number of threats and %2$s is the numner of critical threats on the site. */ + __( + 'The last scan identified %1$s (%2$d\u00A0critical). But don’t worry, Protect is usually able to “Auto-fix” threats, in most cases. Visit the %3$s dashboard to view more details.', + 'jetpack-my-jetpack' + ), + sprintf( + /* translators: %d is the number of detected scan threats on the site. */ + _n( '%d threat', '%d threats', numThreats, 'jetpack-my-jetpack' ), + numThreats + ), + criticalThreatCount, + isProtectPluginActive ? 'Protect' : 'Scan' ), - criticalThreatCount + { + a: createElement( 'a', { + href: protectDashboardUrl, + onClick: trackProtectDashboardLinkClick, + } ), + } ) - : sprintf( - /* translators: %s is the singular or plural of number of detected critical threats on the site. */ - __( - 'The last scan identified %s. But don’t worry, use the “Auto-fix” button in the product to automatically fix most threats.', - 'jetpack-my-jetpack' - ), + : createInterpolateElement( sprintf( - /* translators: %d is the number of detected scan threats on the site. */ - _n( '%d threat', '%d threats', numThreats, 'jetpack-my-jetpack' ), - numThreats - ) + /* translators: %s is the singular or plural of number of detected threats on the site. */ + __( + 'The last scan identified %1$s. But don’t worry, Protect is usually able to “Auto-fix” threats, in most cases. Visit the %2$s dashboard to view more details.', + 'jetpack-my-jetpack' + ), + sprintf( + /* translators: %d is the number of detected scan threats on the site. */ + _n( '%d threat', '%d threats', numThreats, 'jetpack-my-jetpack' ), + numThreats + ), + isProtectPluginActive ? 'Protect' : 'Scan' + ), + { + a: createElement( 'a', { + href: protectDashboardUrl, + onClick: trackProtectDashboardLinkClick, + } ), + } ), } : {