diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsx index b7ca139fa3056a..0574cab87f7ab2 100644 --- a/frontend/src/scenes/settings/SettingsMap.tsx +++ b/frontend/src/scenes/settings/SettingsMap.tsx @@ -18,6 +18,7 @@ import { CorrelationConfig } from './environment/CorrelationConfig' import { DataAttributes } from './environment/DataAttributes' import { GroupAnalyticsConfig } from './environment/GroupAnalyticsConfig' import { HeatmapsSettings } from './environment/HeatmapsSettings' +import { HumanFriendlyComparisonPeriodsSetting } from './environment/HumanFriendlyComparisonPeriodsSetting' import { IPAllowListInfo } from './environment/IPAllowListInfo' import { IPCapture } from './environment/IPCapture' import { ManagedReverseProxy } from './environment/ManagedReverseProxy' @@ -183,6 +184,11 @@ export const SETTINGS_MAP: SettingSection[] = [ title: 'IP data capture configuration', component: , }, + { + id: 'human-friendly-comparison-periods', + title: 'Human friendly comparison periods', + component: , + }, { id: 'group-analytics', title: 'Group analytics', diff --git a/frontend/src/scenes/settings/environment/HumanFriendlyComparisonPeriodsSetting.tsx b/frontend/src/scenes/settings/environment/HumanFriendlyComparisonPeriodsSetting.tsx new file mode 100644 index 00000000000000..8aad3ddb90d98c --- /dev/null +++ b/frontend/src/scenes/settings/environment/HumanFriendlyComparisonPeriodsSetting.tsx @@ -0,0 +1,32 @@ +import { LemonSwitch } from '@posthog/lemon-ui' +import { useActions, useValues } from 'kea' +import { teamLogic } from 'scenes/teamLogic' + +export function HumanFriendlyComparisonPeriodsSetting(): JSX.Element { + const { updateCurrentTeam } = useActions(teamLogic) + const { currentTeam, currentTeamLoading } = useValues(teamLogic) + + return ( + <> +

+ When comparing against a previous month or year, PostHog will use the same start and end dates as the + current period by default. It might be desirable, however, to compare against the same day of the week + instead of the same day to account for weekend seasonality. If that's the case for your analysis, you + can enable this setting. +

+

+ In practice, this means that an year comparison becomes a 52 week comparison, and a month comparison + becomes a 4 week comparison. +

+ { + updateCurrentTeam({ human_friendly_comparison_periods: checked }) + }} + checked={!!currentTeam?.human_friendly_comparison_periods} + disabled={currentTeamLoading} + label="Use human friendly comparison periods" + bordered + /> + + ) +} diff --git a/frontend/src/scenes/settings/types.ts b/frontend/src/scenes/settings/types.ts index 4281935f541903..3da67415aedde7 100644 --- a/frontend/src/scenes/settings/types.ts +++ b/frontend/src/scenes/settings/types.ts @@ -62,6 +62,7 @@ export type SettingId = | 'person-display-name' | 'path-cleaning' | 'datacapture' + | 'human-friendly-comparison-periods' | 'group-analytics' | 'persons-on-events' | 'replay' diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 4b218bd90f0f97..cf30a5d41b9290 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -544,6 +544,7 @@ export interface TeamType extends TeamBasicType { live_events_columns: string[] | null // Custom columns shown on the Live Events page live_events_token: string cookieless_server_hash_mode?: CookielessServerHashMode + human_friendly_comparison_periods: boolean /** Effective access level of the user in this specific team. Null if user has no access. */ effective_membership_level: OrganizationMembershipLevel | null diff --git a/posthog/api/team.py b/posthog/api/team.py index 4a9e956faf084c..f4c092847c6a1a 100644 --- a/posthog/api/team.py +++ b/posthog/api/team.py @@ -202,6 +202,7 @@ class Meta: "live_events_columns", "recording_domains", "cookieless_server_hash_mode", + "human_friendly_comparison_periods", "person_on_events_querying_enabled", "inject_web_apps", "extra_settings",