Skip to content

Commit

Permalink
Refactor default date control gates for shortcuts (#97287)
Browse files Browse the repository at this point in the history
  • Loading branch information
dognose24 authored Dec 10, 2024
1 parent 4643cd9 commit 6ab5bdc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions client/my-sites/stats/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const STATS_TYPE_DEVICE_STATS = 'stats_devices_module';

// stats feature are for more granular control, string value is based on component name
export const STATS_FEATURE_DATE_CONTROL = 'StatsDateControl';
export const STATS_FEATURE_DATE_CONTROL_TODAY = 'StatsDateControl/today';
export const STATS_FEATURE_DATE_CONTROL_YESTERDAY = 'StatsDateControl/yesterday';
export const STATS_FEATURE_DATE_CONTROL_LAST_7_DAYS = 'StatsDateControl/last_7_days';
export const STATS_FEATURE_DATE_CONTROL_LAST_30_DAYS = 'StatsDateControl/last_30_days';
export const STATS_FEATURE_DATE_CONTROL_LAST_90_DAYS = 'StatsDateControl/last_3_months';
Expand Down
29 changes: 15 additions & 14 deletions client/my-sites/stats/hooks/use-should-gate-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
STATS_TYPE_DEVICE_STATS,
STATS_FEATURE_UTM_STATS,
STATS_FEATURE_DATE_CONTROL,
STATS_FEATURE_DATE_CONTROL_TODAY,
STATS_FEATURE_DATE_CONTROL_YESTERDAY,
STATS_FEATURE_DATE_CONTROL_LAST_30_DAYS,
STATS_FEATURE_DATE_CONTROL_LAST_90_DAYS,
STATS_FEATURE_DATE_CONTROL_CUSTOM_DATE_RANGE,
Expand All @@ -49,6 +51,16 @@ import {
shouldShowPaywallAfterGracePeriod,
} from './use-stats-purchases';

const defaultDateControlGates = [
STATS_FEATURE_DATE_CONTROL,
STATS_FEATURE_DATE_CONTROL_TODAY,
STATS_FEATURE_DATE_CONTROL_YESTERDAY,
STATS_FEATURE_DATE_CONTROL_LAST_30_DAYS,
STATS_FEATURE_DATE_CONTROL_LAST_90_DAYS,
STATS_FEATURE_DATE_CONTROL_LAST_YEAR,
STATS_FEATURE_DATE_CONTROL_CUSTOM_DATE_RANGE,
];

// If Jetpack sites don't have any purchase that supports commercial use, gate advanced modules accordingly.
const jetpackStatsAdvancedPaywall = [ STATS_TYPE_DEVICE_STATS, STATS_FEATURE_UTM_STATS ];

Expand All @@ -75,10 +87,7 @@ const jetpackStatsCommercialPaywall = [
// If Jetpack commerical sites don't have any purchase that supports commercial use,
// gate controls accordingly.
const granularControlForJetpackStatsCommercialPaywall = [
STATS_FEATURE_DATE_CONTROL,
STATS_FEATURE_DATE_CONTROL_LAST_30_DAYS,
STATS_FEATURE_DATE_CONTROL_LAST_90_DAYS,
STATS_FEATURE_DATE_CONTROL_LAST_YEAR,
...defaultDateControlGates,
STATS_FEATURE_INTERVAL_DROPDOWN_WEEK,
STATS_FEATURE_INTERVAL_DROPDOWN_MONTH,
STATS_FEATURE_INTERVAL_DROPDOWN_YEAR,
Expand All @@ -97,11 +106,7 @@ const gatedStats = [
// Paid Stats
STAT_TYPE_REFERRERS,
STAT_TYPE_CLICKS,
STATS_FEATURE_DATE_CONTROL,
STATS_FEATURE_DATE_CONTROL_LAST_30_DAYS,
STATS_FEATURE_DATE_CONTROL_LAST_90_DAYS,
STATS_FEATURE_DATE_CONTROL_LAST_YEAR,
STATS_FEATURE_DATE_CONTROL_CUSTOM_DATE_RANGE,
...defaultDateControlGates,
STATS_FEATURE_DOWNLOAD_CSV,
STATS_FEATURE_INTERVAL_DROPDOWN_WEEK,
STATS_FEATURE_INTERVAL_DROPDOWN_MONTH,
Expand Down Expand Up @@ -134,11 +139,7 @@ const basicStats = [
// Paid stats
STAT_TYPE_REFERRERS,
STAT_TYPE_CLICKS,
STATS_FEATURE_DATE_CONTROL,
STATS_FEATURE_DATE_CONTROL_LAST_30_DAYS,
STATS_FEATURE_DATE_CONTROL_LAST_90_DAYS,
STATS_FEATURE_DATE_CONTROL_LAST_YEAR,
STATS_FEATURE_DATE_CONTROL_CUSTOM_DATE_RANGE,
...defaultDateControlGates,
STATS_FEATURE_DOWNLOAD_CSV,
STATS_FEATURE_INTERVAL_DROPDOWN_WEEK,
STATS_FEATURE_INTERVAL_DROPDOWN_MONTH,
Expand Down

0 comments on commit 6ab5bdc

Please sign in to comment.