From 9da09aa66128a2119bc1bc7102f36077d93bca6b Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Thu, 29 Aug 2024 02:21:13 -0300 Subject: [PATCH 1/2] fix condition for determining if user is on unlimited plan. Add notice for unlimited user going over fair usage. Add usage counter for unlimited plans for current period --- .../jetpack-ai/product-page.jsx | 49 ++++++++++++------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx b/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx index 5a8981407e29e..677e77b3f6d67 100644 --- a/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx +++ b/projects/packages/my-jetpack/_inc/components/product-interstitial/jetpack-ai/product-page.jsx @@ -68,8 +68,8 @@ export default function () { } = aiAssistantFeature || {}; const isFree = currentTier?.value === 0; - const hasUnlimited = currentTier?.value === 1 || ( ! tierPlansEnabled && ! isFree ); - const hasPaidTier = ! isFree && ! hasUnlimited; + const hasUnlimited = currentTier?.value === 1; + const hasPaidTier = ( ! isFree && ! hasUnlimited ) || ( hasUnlimited && ! tierPlansEnabled ); const shouldContactUs = ! hasUnlimited && hasPaidTier && ! nextTier && currentTier; const freeRequestsLeft = isFree && 20 - allTimeRequests >= 0 ? 20 - allTimeRequests : 0; const showCurrentUsage = hasPaidTier && ! isFree && usage; @@ -100,10 +100,15 @@ export default function () { const showRenewalNotice = isOverLimit && hasPaidTier; const showUpgradeNotice = isOverLimit && isFree; - const currentTierValue = currentTier?.value || 0; - const currentUsage = usage?.[ 'requests-count' ] || 0; + const currentTierLimit = currentTier?.limit || 0; + const currentUsage = usage?.requestsCount || 0; + const tierRequestsLeft = - currentTierValue - currentUsage >= 0 ? currentTierValue - currentUsage : 0; + currentTierLimit - currentUsage >= 0 ? currentTierLimit - currentUsage : 0; + const requestCardNumber = tierPlansEnabled ? tierRequestsLeft : currentUsage; + + const currentUsageLabel = __( 'Requests this month', 'jetpack-my-jetpack' ); + const currentRemainingLabel = __( 'Requests for this month', 'jetpack-my-jetpack' ); const renewalNoticeTitle = __( "You've reached your request limit for this month", @@ -111,15 +116,21 @@ export default function () { ); const upgradeNoticeTitle = __( "You've used all your free requests", 'jetpack-my-jetpack' ); - const renewalNoticeBody = sprintf( + const renewalNoticeBodyInfo = sprintf( // translators: %d is the number of days left in the month. - __( - 'Wait for %d days to reset your limit, or upgrade now to a higher tier for additional requests and keep your work moving forward.', - 'jetpack-my-jetpack' - ), + __( 'Wait for %d days to reset your limit', 'jetpack-my-jetpack' ), Math.floor( ( new Date( usage?.nextStart || null ) - new Date() ) / ( 1000 * 60 * 60 * 24 ) ) ); + const renewalNoticeBodyTeaser = __( + ', or upgrade now to a higher tier for additional requests and keep your work moving forward.', + 'jetpack-my-jetpack' + ); + + const renewalNoticeBody = ! tierPlansEnabled + ? renewalNoticeBodyInfo + '.' + : renewalNoticeBodyInfo + renewalNoticeBodyTeaser; + const upgradeNoticeBody = __( 'Reach for More with Jetpack AI! Upgrade now for additional requests and keep your momentum going.', 'jetpack-my-jetpack' @@ -222,10 +233,10 @@ export default function () {
- { __( 'Requests for this month', 'jetpack-my-jetpack' ) } + { tierPlansEnabled ? currentRemainingLabel : currentUsageLabel }
- { tierRequestsLeft } + { requestCardNumber }
@@ -264,11 +275,15 @@ export default function () { { showNotice && (
- { showRenewalNotice ? renewalNoticeCta : upgradeNoticeCta } - , - ] } + actions={ + tierPlansEnabled + ? [ + , + ] + : {} + } onClose={ onNoticeClose } level={ showRenewalNotice ? 'warning' : 'error' } title={ showRenewalNotice ? renewalNoticeTitle : upgradeNoticeTitle } From 395990d9454b14f19cffa1ad37e82bbb2c05fc86 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Thu, 29 Aug 2024 02:22:44 -0300 Subject: [PATCH 2/2] add changelog --- .../changelog/change-jetpack-ai-product-page-limit-handling | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/packages/my-jetpack/changelog/change-jetpack-ai-product-page-limit-handling diff --git a/projects/packages/my-jetpack/changelog/change-jetpack-ai-product-page-limit-handling b/projects/packages/my-jetpack/changelog/change-jetpack-ai-product-page-limit-handling new file mode 100644 index 0000000000000..dee27e808c62e --- /dev/null +++ b/projects/packages/my-jetpack/changelog/change-jetpack-ai-product-page-limit-handling @@ -0,0 +1,4 @@ +Significance: minor +Type: changed + +My Jetpack: show over quota notice and period usage counter for unlimited plans