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

Logged-in Performance Profiler: Show jetpack boost upsell in recommendations #94691

Merged
merged 1 commit into from
Sep 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const CoreWebVitalsDetailsV2: React.FC< CoreWebVitalsDetailsProps > = ( {
style={ {
flexDirection: 'column',
borderRadius: '6px',
flex: 1,
} }
>
<div className="core-web-vitals-display__description">
Expand Down
14 changes: 10 additions & 4 deletions client/performance-profiler/components/metrics-insight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { FoldableCard } from '@automattic/components';
import styled from '@emotion/styled';
import { useTranslate } from 'i18n-calypso';
import { useState } from 'react';
import { useSelector } from 'react-redux';
import {
FullPageScreenshot,
PerformanceMetricsItemQueryResponse,
} from 'calypso/data/site-profiler/types';
import { Tip } from 'calypso/performance-profiler/components/tip';
import { useSupportChatLLMQuery } from 'calypso/performance-profiler/hooks/use-support-chat-llm-query';
import { tips } from 'calypso/performance-profiler/utils/tips';
import { loggedInTips, tips } from 'calypso/performance-profiler/utils/tips';
import { isUserLoggedIn } from 'calypso/state/current-user/selectors';
import { getSelectedSite } from 'calypso/state/ui/selectors';
import { InsightContent } from './insight-content';
import { InsightHeader } from './insight-header';

Expand Down Expand Up @@ -105,13 +108,16 @@ export const MetricsInsight: React.FC< MetricsInsightProps > = ( props ) => {
isWpcom,
isEnabled( 'performance-profiler/llm' ) && retrieveInsight
);
const tip = tips[ insight.id ];
const isLoggedIn = useSelector( isUserLoggedIn );
const site = useSelector( getSelectedSite );

if ( props.url && tip ) {
const tip = isLoggedIn && isWpcom ? loggedInTips[ insight.id ] : tips[ insight.id ];

if ( props.url && tip && ! isWpcom ) {
tip.link = `https://wordpress.com/setup/hosted-site-migration?from=${ props.url }&ref=performance-profiler-dashboard`;
}

if ( tip && isWpcom ) {
if ( tip && isWpcom && ! site?.is_wpcom_atomic ) {
tip.link = '';
}

Expand Down
17 changes: 17 additions & 0 deletions client/performance-profiler/utils/tips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,20 @@ export const tips: Record< string, TipProps > = {
link: 'https://wordpress.com/setup/hosted-site-migration?ref=performance-profiler-dashboard',
},
};

const createLoggedInTip = (): TipProps => ( {
title: translate( 'Did you know?' ),
content: translate(
'Jetpack Boost automatically optimizes images and delivers them using a Global CDN to ensure they load lightning fast.'
),
linkText: translate( 'Get Jetpack Boost' ),
link: 'https://wordpress.com/plugins/jetpack-boost',
} );

export const loggedInTips: Record< string, TipProps > = {
'uses-responsive-images': createLoggedInTip(),
'uses-long-cache-ttl': createLoggedInTip(),
'server-response-time': createLoggedInTip(),
'render-blocking-resources': createLoggedInTip(),
'unminified-css': createLoggedInTip(),
};
Loading