Skip to content

Commit

Permalink
stats feature check (Automattic#81053)
Browse files Browse the repository at this point in the history
Co-authored-by: Dognose <dognose24@gmail.com>
  • Loading branch information
kangzj and dognose24 authored Aug 28, 2023
1 parent 77bb870 commit 2cec316
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
13 changes: 6 additions & 7 deletions client/blocks/jetpack-benefits/feature-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
FEATURE_CLOUD_CRITICAL_CSS,
isJetpackStatsSlug,
isJetpackStatsPaidProductSlug,
FEATURE_STATS_PAID,
FEATURE_STATS_FREE,
} from '@automattic/calypso-products';

export const productHasBackups = ( productSlug: string ): boolean => {
Expand Down Expand Up @@ -84,16 +86,13 @@ export const productHasStats = ( productSlug: string, onlyPaid = false ): boolea
if ( isJetpackStatsSlug( productSlug ) ) {
return ! onlyPaid || isJetpackStatsPaidProductSlug( productSlug );
}
// Check for stats features in plans
// Check for paid stats features in plans
if ( isJetpackPlanSlug( productSlug ) && onlyPaid ) {
return planHasAtLeastOneFeature( productSlug, [
/** TODO: STATS PAID FEATURE NAME */
] );
return planHasAtLeastOneFeature( productSlug, [ FEATURE_STATS_PAID ] );
}
// Check for all stats features in plans
if ( isJetpackPlanSlug( productSlug ) && ! onlyPaid ) {
return planHasAtLeastOneFeature( productSlug, [
/** TODO: STATS FEATURE NAME */
] );
return planHasAtLeastOneFeature( productSlug, [ FEATURE_STATS_PAID, FEATURE_STATS_FREE ] );
}
return false;
};
Expand Down
1 change: 1 addition & 0 deletions packages/calypso-products/src/constants/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const FEATURE_SECURITY_SETTINGS = 'security-settings';
export const FEATURE_WOOP = 'woop';
export const FEATURE_PREMIUM_THEMES = 'unlimited-premium-themes';
export const FEATURE_STATS_PAID = 'stats-paid';
export const FEATURE_STATS_FREE = 'stats-free';

// Jetpack features constants
export const FEATURE_BLANK = 'blank-feature';
Expand Down
2 changes: 2 additions & 0 deletions packages/calypso-products/src/plans-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ import {
PRODUCT_JETPACK_STATS_MONTHLY,
PRODUCT_JETPACK_STATS_YEARLY,
TERM_CENTENNIALLY,
FEATURE_STATS_PAID,
} from './constants';
import type {
BillingTerm,
Expand Down Expand Up @@ -2322,6 +2323,7 @@ const getPlanJetpackCompleteDetails = (): IncompleteJetpackPlan => ( {
WPCOM_FEATURES_SCAN,
WPCOM_FEATURES_ANTISPAM,
WPCOM_FEATURES_BACKUPS,
FEATURE_STATS_PAID,
] ),
getInferiorFeatures: () => [
FEATURE_JETPACK_BACKUP_DAILY,
Expand Down

0 comments on commit 2cec316

Please sign in to comment.