:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(insights): support quarter and year intervals in the backend (#68291)
Sam Pennington605dde4ab2b6
diff --git a/frontend/src/lib/components/AnnotationsOverlay/AnnotationsOverlay.tsx b/frontend/src/lib/components/AnnotationsOverlay/AnnotationsOverlay.tsxindex 808d5655e5fd..47ba97064dbc 100644--- a/frontend/src/lib/components/AnnotationsOverlay/AnnotationsOverlay.tsx+++ b/frontend/src/lib/components/AnnotationsOverlay/AnnotationsOverlay.tsx@@ -40,6 +40,8 @@ const GROUPING_UNIT_TO_HUMAN_DAYJS_FORMAT: Record<IntervalType, string> = {day: 'MMMM D, YYYY',week: 'MMMM D, YYYY',month: 'MMMM D, YYYY',+ quarter: 'MMMM D, YYYY',+ year: 'MMMM D, YYYY',}interface AnnotationBadgeCluster {diff --git a/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.test.ts b/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.test.tsindex 8489c93e5a1c..330c6518e7b4 100644--- a/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.test.ts+++ b/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.test.ts@@ -396,6 +396,64 @@ describe('annotationsOverlayLogic', () => {})describe('groupedAnnotations', () => {+ // day/week/month/quarter/year intervals all group annotations at day level+ const GROUPINGS_AT_DAY_LEVEL_UTC: Record<string, AnnotationType[]> = {+ '2022-08-10 00:00:00+0000': [+ MOCK_ANNOTATION_ORG_SCOPED,+ MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,+ MOCK_ANNOTATION_PROJECT_SCOPED,+ MOCK_ANNOTATION_INSIGHT_1_SCOPED,+ MOCK_ANNOTATION_DASHBOARD_SCOPED,+ ].map((annotation) => deserializeAnnotation(annotation, 'UTC')),+ '2022-08-11 00:00:00+0000': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>+ deserializeAnnotation(annotation, 'UTC')+ ),+ '2022-08-17 00:00:00+0000': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>+ deserializeAnnotation(annotation, 'UTC')+ ),+ '2022-09-10 00:00:00+0000': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>+ deserializeAnnotation(annotation, 'UTC')+ ),+ }++ const GROUPINGS_AT_DAY_LEVEL_PHOENIX: Record<string, AnnotationType[]> = {+ '2022-08-09 00:00:00-0700': [+ MOCK_ANNOTATION_ORG_SCOPED,+ MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,+ MOCK_ANNOTATION_PROJECT_SCOPED,+ MOCK_ANNOTATION_INSIGHT_1_SCOPED,+ MOCK_ANNOTATION_DASHBOARD_SCOPED,+ ].map((annotation) => deserializeAnnotation(annotation, 'America/Phoenix')),+ '2022-08-10 00:00:00-0700': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>+ deserializeAnnotation(annotation, 'America/Phoenix')+ ),+ '2022-08-16 00:00:00-0700': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>+ deserializeAnnotation(annotation, 'America/Phoenix')+ ),+ '2022-09-09 00:00:00-0700': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>+ deserializeAnnotation(annotation, 'America/Phoenix')+ ),+ }++ const GROUPINGS_AT_DAY_LEVEL_MOSCOW: Record<string, AnnotationType[]> = {+ '2022-08-10 00:00:00+0300': [+ MOCK_ANNOTATION_ORG_SCOPED,+ MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,+ MOCK_ANNOTATION_PROJECT_SCOPED,+ MOCK_ANNOTATION_INSIGHT_1_SCOPED,+ MOCK_ANNOTATION_DASHBOARD_SCOPED,+ ].map((annotation) => deserializeAnnotation(annotation, 'Europe/Moscow')),+ '2022-08-11 00:00:00+0300': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>+ deserializeAnnotation(annotation, 'Europe/Moscow')+ ),+ '2022-08-17 00:00:00+0300': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>+ deserializeAnnotation(annotation, 'Europe/Moscow')+ ),+ '2022-09-10 00:00:00+0300': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>+ deserializeAnnotation(annotation, 'Europe/Moscow')+ ),+ }+const EXPECTED_GROUPINGS_BY_INTERVAL_AND_TIMEZONE: Record<string,Record<IntervalType, Record<string, AnnotationType[]>> // All IntervalType variants should be covered@@ -466,62 +524,13 @@ describe('annotationsOverlayLogic', () => {deserializeAnnotation(annotation, 'UTC')),},- day: {- '2022-08-10 00:00:00+0000': [- MOCK_ANNOTATION_ORG_SCOPED,- MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,- MOCK_ANNOTATION_PROJECT_SCOPED,- MOCK_ANNOTATION_INSIGHT_1_SCOPED,- MOCK_ANNOTATION_DASHBOARD_SCOPED,- ].map((annotation) => deserializeAnnotation(annotation, 'UTC')),- '2022-08-11 00:00:00+0000': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'UTC')- ),- '2022-08-17 00:00:00+0000': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'UTC')- ),- '2022-09-10 00:00:00+0000': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>- deserializeAnnotation(annotation, 'UTC')- ),- },+ day: GROUPINGS_AT_DAY_LEVEL_UTC,// week and month charts bucket annotations per day — not per week/month — so that// e.g. an annotation on Dec 1 and an annotation on Dec 15 don't collapse into one badge.- week: {- '2022-08-10 00:00:00+0000': [- MOCK_ANNOTATION_ORG_SCOPED,- MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,- MOCK_ANNOTATION_PROJECT_SCOPED,- MOCK_ANNOTATION_INSIGHT_1_SCOPED,- MOCK_ANNOTATION_DASHBOARD_SCOPED,- ].map((annotation) => deserializeAnnotation(annotation, 'UTC')),- '2022-08-11 00:00:00+0000': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'UTC')- ),- '2022-08-17 00:00:00+0000': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'UTC')- ),- '2022-09-10 00:00:00+0000': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>- deserializeAnnotation(annotation, 'UTC')- ),- },- month: {- '2022-08-10 00:00:00+0000': [- MOCK_ANNOTATION_ORG_SCOPED,- MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,- MOCK_ANNOTATION_PROJECT_SCOPED,- MOCK_ANNOTATION_INSIGHT_1_SCOPED,- MOCK_ANNOTATION_DASHBOARD_SCOPED,- ].map((annotation) => deserializeAnnotation(annotation, 'UTC')),- '2022-08-11 00:00:00+0000': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'UTC')- ),- '2022-08-17 00:00:00+0000': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'UTC')- ),- '2022-09-10 00:00:00+0000': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>- deserializeAnnotation(annotation, 'UTC')- ),- },+ week: GROUPINGS_AT_DAY_LEVEL_UTC,+ month: GROUPINGS_AT_DAY_LEVEL_UTC,+ quarter: GROUPINGS_AT_DAY_LEVEL_UTC,+ year: GROUPINGS_AT_DAY_LEVEL_UTC,},'America/Phoenix': {// Purposefully using Phoenix for test determinism - Arizona does NOT observe DST@@ -590,61 +599,12 @@ describe('annotationsOverlayLogic', () => {deserializeAnnotation(annotation, 'America/Phoenix')),},- day: {- '2022-08-09 00:00:00-0700': [- MOCK_ANNOTATION_ORG_SCOPED,- MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,- MOCK_ANNOTATION_PROJECT_SCOPED,- MOCK_ANNOTATION_INSIGHT_1_SCOPED,- MOCK_ANNOTATION_DASHBOARD_SCOPED,- ].map((annotation) => deserializeAnnotation(annotation, 'America/Phoenix')),- '2022-08-10 00:00:00-0700': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'America/Phoenix')- ),- '2022-08-16 00:00:00-0700': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'America/Phoenix')- ),- '2022-09-09 00:00:00-0700': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>- deserializeAnnotation(annotation, 'America/Phoenix')- ),- },+ day: GROUPINGS_AT_DAY_LEVEL_PHOENIX,// week and month charts bucket per day — see UTC block above.- week: {- '2022-08-09 00:00:00-0700': [- MOCK_ANNOTATION_ORG_SCOPED,- MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,- MOCK_ANNOTATION_PROJECT_SCOPED,- MOCK_ANNOTATION_INSIGHT_1_SCOPED,- MOCK_ANNOTATION_DASHBOARD_SCOPED,- ].map((annotation) => deserializeAnnotation(annotation, 'America/Phoenix')),- '2022-08-10 00:00:00-0700': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'America/Phoenix')- ),- '2022-08-16 00:00:00-0700': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'America/Phoenix')- ),- '2022-09-09 00:00:00-0700': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>- deserializeAnnotation(annotation, 'America/Phoenix')- ),- },- month: {- '2022-08-09 00:00:00-0700': [- MOCK_ANNOTATION_ORG_SCOPED,- MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,- MOCK_ANNOTATION_PROJECT_SCOPED,- MOCK_ANNOTATION_INSIGHT_1_SCOPED,- MOCK_ANNOTATION_DASHBOARD_SCOPED,- ].map((annotation) => deserializeAnnotation(annotation, 'America/Phoenix')),- '2022-08-10 00:00:00-0700': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'America/Phoenix')- ),- '2022-08-16 00:00:00-0700': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'America/Phoenix')- ),- '2022-09-09 00:00:00-0700': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>- deserializeAnnotation(annotation, 'America/Phoenix')- ),- },+ week: GROUPINGS_AT_DAY_LEVEL_PHOENIX,+ month: GROUPINGS_AT_DAY_LEVEL_PHOENIX,+ quarter: GROUPINGS_AT_DAY_LEVEL_PHOENIX,+ year: GROUPINGS_AT_DAY_LEVEL_PHOENIX,},'Europe/Moscow': {// Purposefully using Moscow for test determinism - Russia does NOT observe DST@@ -713,61 +673,12 @@ describe('annotationsOverlayLogic', () => {deserializeAnnotation(annotation, 'Europe/Moscow')),},- day: {- '2022-08-10 00:00:00+0300': [- MOCK_ANNOTATION_ORG_SCOPED,- MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,- MOCK_ANNOTATION_PROJECT_SCOPED,- MOCK_ANNOTATION_INSIGHT_1_SCOPED,- MOCK_ANNOTATION_DASHBOARD_SCOPED,- ].map((annotation) => deserializeAnnotation(annotation, 'Europe/Moscow')),- '2022-08-11 00:00:00+0300': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'Europe/Moscow')- ),- '2022-08-17 00:00:00+0300': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'Europe/Moscow')- ),- '2022-09-10 00:00:00+0300': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>- deserializeAnnotation(annotation, 'Europe/Moscow')- ),- },+ day: GROUPINGS_AT_DAY_LEVEL_MOSCOW,// week and month charts bucket per day — see UTC block above.- week: {- '2022-08-10 00:00:00+0300': [- MOCK_ANNOTATION_ORG_SCOPED,- MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,- MOCK_ANNOTATION_PROJECT_SCOPED,- MOCK_ANNOTATION_INSIGHT_1_SCOPED,- MOCK_ANNOTATION_DASHBOARD_SCOPED,- ].map((annotation) => deserializeAnnotation(annotation, 'Europe/Moscow')),- '2022-08-11 00:00:00+0300': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'Europe/Moscow')- ),- '2022-08-17 00:00:00+0300': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'Europe/Moscow')- ),- '2022-09-10 00:00:00+0300': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>- deserializeAnnotation(annotation, 'Europe/Moscow')- ),- },- month: {- '2022-08-10 00:00:00+0300': [- MOCK_ANNOTATION_ORG_SCOPED,- MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_3,- MOCK_ANNOTATION_PROJECT_SCOPED,- MOCK_ANNOTATION_INSIGHT_1_SCOPED,- MOCK_ANNOTATION_DASHBOARD_SCOPED,- ].map((annotation) => deserializeAnnotation(annotation, 'Europe/Moscow')),- '2022-08-11 00:00:00+0300': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'Europe/Moscow')- ),- '2022-08-17 00:00:00+0300': [MOCK_ANNOTATION_ORG_SCOPED_FROM_INSIGHT_1].map((annotation) =>- deserializeAnnotation(annotation, 'Europe/Moscow')- ),- '2022-09-10 00:00:00+0300': [MOCK_ANNOTATION_PROJECT_SCOPED_FROM_INSIGHT_3].map((annotation) =>- deserializeAnnotation(annotation, 'Europe/Moscow')- ),- },+ week: GROUPINGS_AT_DAY_LEVEL_MOSCOW,+ month: GROUPINGS_AT_DAY_LEVEL_MOSCOW,+ quarter: GROUPINGS_AT_DAY_LEVEL_MOSCOW,+ year: GROUPINGS_AT_DAY_LEVEL_MOSCOW,},}diff --git a/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts b/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.tsindex 6719e988bb6c..d4082ec4adc5 100644--- a/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts+++ b/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts@@ -40,7 +40,7 @@ export interface AnnotationsOverlayLogicProps extends Omit<InsightLogicProps, 'd/** Week/month charts bucket annotations by day so distinct dates don't collapse into one badge. */export function getGroupingUnit(intervalUnit: IntervalType): IntervalType {- return intervalUnit === 'week' || intervalUnit === 'month' ? 'day' : intervalUnit+ return ['week', 'month', 'quarter', 'year'].includes(intervalUnit) ? 'day' : intervalUnit}export function determineAnnotationsDateGroup(date: Dayjs, intervalUnit: IntervalType): string {diff --git a/frontend/src/lib/components/DateDisplay/index.tsx b/frontend/src/lib/components/DateDisplay/index.tsxindex 2bfe45352ac1..bbec89688373 100644--- a/frontend/src/lib/components/DateDisplay/index.tsx+++ b/frontend/src/lib/components/DateDisplay/index.tsx@@ -23,6 +23,8 @@ const DISPLAY_DATE_FORMAT: Record<IntervalType, string> = {day: 'D MMM',week: 'D MMM',month: 'MMM',+ quarter: '[Q]Q',+ year: 'YYYY',}const dateHighlight = (parsedDate: dayjs.Dayjs, interval: IntervalType): string => {@@ -39,6 +41,10 @@ const dateHighlight = (parsedDate: dayjs.Dayjs, interval: IntervalType): stringreturn parsedDate.format('dd')case 'month':return parsedDate.format('YYYY')+ case 'quarter':+ return parsedDate.format('YYYY')+ case 'year':+ return ''default:return parsedDate.format('dd')}diff --git a/frontend/src/lib/components/IntervalFilter/intervals.ts b/frontend/src/lib/components/IntervalFilter/intervals.tsindex 26d65675b2fc..422239fa4279 100644--- a/frontend/src/lib/components/IntervalFilter/intervals.ts+++ b/frontend/src/lib/components/IntervalFilter/intervals.ts@@ -34,4 +34,14 @@ export const intervals: Intervals = {label: 'month',newDateFrom: '-90d',},+ quarter: {+ label: 'quarter',+ newDateFrom: '-3y',+ hidden: true,+ },+ year: {+ label: 'year',+ newDateFrom: '-5y',+ hidden: true,+ },}diff --git a/frontend/src/lib/components/SmoothingFilter/smoothings.ts b/frontend/src/lib/components/SmoothingFilter/smoothings.tsindex 810630ee2773..155b4d92ff0c 100644--- a/frontend/src/lib/components/SmoothingFilter/smoothings.ts+++ b/frontend/src/lib/components/SmoothingFilter/smoothings.ts@@ -50,6 +50,8 @@ export const smoothingOptions: Record<IntervalType, { label: string; value: Smoo],week: [],month: [],+ quarter: [],+ year: [],}export type SmoothingKeyType = keyof typeof smoothingOptionsdiff --git a/frontend/src/lib/dayjs.ts b/frontend/src/lib/dayjs.tsindex 0a1d8376447f..a3733c2b86ae 100644--- a/frontend/src/lib/dayjs.ts+++ b/frontend/src/lib/dayjs.ts@@ -1,5 +1,11 @@// oxlint-disable-next-line no-restricted-imports-import dayjs, { Dayjs as DayjsOriginal, isDayjs } from 'dayjs'+import dayjs, {+ Dayjs as DayjsOriginal,+ isDayjs,+ type ManipulateType as DayjsManipulateType,+ type QUnitType as DayjsQUnitType,+} from 'dayjs'+import advancedFormat from 'dayjs/plugin/advancedFormat'import customParseFormat from 'dayjs/plugin/customParseFormat'import duration from 'dayjs/plugin/duration'import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'@@ -12,6 +18,7 @@ import updateLocale from 'dayjs/plugin/updateLocale'import utc from 'dayjs/plugin/utc'import weekOfYear from 'dayjs/plugin/weekOfYear'+dayjs.extend(advancedFormat)// necessary for parsing custom date formats like 'YYYYMMDD_HHmmss'dayjs.extend(customParseFormat)// necessary for any localized date formatting to work@@ -26,6 +33,19 @@ dayjs.extend(quarterOfYear)dayjs.extend(weekOfYear)dayjs.extend(updateLocale)+// The base add/subtract accept ManipulateType (has week, no quarter) and the quarterOfYear plugin+// adds a QUnitType overload (has quarter, no week). Neither alone accepts a union spanning both+// (e.g. IntervalType), so merge one overload that takes both. Casting to a single side instead+// would be unsound: `x as QUnitType` lies when x is 'week'. The aliased Dayjs* imports are+// required: this file's own ManipulateType/QUnitType (declared below) shadow dayjs's inside the+// augmentation and are file-private there, which fails declaration emit with TS4075.+declare module 'dayjs' {+ interface Dayjs {+ add(value: number, unit?: DayjsManipulateType | DayjsQUnitType): DayjsOriginal+ subtract(value: number, unit?: DayjsManipulateType | DayjsQUnitType): DayjsOriginal+ }+}+const now = (): Dayjs => dayjs()export { dayjs, isDayjs, now }diff --git a/frontend/src/lib/utils/dateFilters.ts b/frontend/src/lib/utils/dateFilters.tsindex 1b6aa4e637dd..74b5e7a5260a 100644--- a/frontend/src/lib/utils/dateFilters.ts+++ b/frontend/src/lib/utils/dateFilters.ts@@ -408,7 +408,11 @@ export const areDatesValidForInterval = (const parsedOldDateTo = dateStringToDayJs(oldDateTo) || dayjs()if (oldDateFrom === 'all' || !parsedOldDateFrom) {- return interval === 'month'+ return interval === 'month' || interval === 'quarter' || interval === 'year'+ } else if (interval === 'year') {+ return parsedOldDateTo.diff(parsedOldDateFrom, 'year') >= 2+ } else if (interval === 'quarter') {+ return parsedOldDateTo.diff(parsedOldDateFrom, 'quarter') >= 2} else if (interval === 'month') {return parsedOldDateTo.diff(parsedOldDateFrom, 'month') >= 2} else if (interval === 'week') {@@ -435,13 +439,15 @@ export const areDatesValidForInterval = (throw new UnexpectedNeverError(interval)}-const defaultDatesForInterval = {+const defaultDatesForInterval: Record<IntervalType, { dateFrom: string; dateTo: null }> = {second: { dateFrom: '-1M', dateTo: null },minute: { dateFrom: '-1h', dateTo: null },hour: { dateFrom: '-24h', dateTo: null },day: { dateFrom: '-7d', dateTo: null },week: { dateFrom: '-28d', dateTo: null },month: { dateFrom: '-6m', dateTo: null },+ quarter: { dateFrom: '-3y', dateTo: null },+ year: { dateFrom: '-5y', dateTo: null },}export const updateDatesWithInterval = (diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex d5da32ed6a2b..9c59b1de80aa 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -25790,7 +25790,7 @@"type": "string"},"IntervalType": {- "enum": ["second", "minute", "hour", "day", "week", "month"],+ "enum": ["second", "minute", "hour", "day", "week", "month", "quarter", "year"],"type": "string"},"IsolationForestDetectorConfig": {diff --git a/frontend/src/scenes/insights/InsightTooltip/insightTooltipUtils.tsx b/frontend/src/scenes/insights/InsightTooltip/insightTooltipUtils.tsxindex 2936bc1e262b..563356f9a975 100644--- a/frontend/src/scenes/insights/InsightTooltip/insightTooltipUtils.tsx+++ b/frontend/src/scenes/insights/InsightTooltip/insightTooltipUtils.tsx@@ -113,6 +113,8 @@ export const INTERVAL_UNIT_TO_DAYJS_FORMAT: Record<IntervalType, string> = {day: 'D MMM YYYY',week: 'D MMM YYYY',month: 'MMMM YYYY',+ quarter: '[Q]Q YYYY',+ year: 'YYYY',}const INTERVAL_UNIT_TO_DAYJS_FORMAT_SHORT: Record<IntervalType, string> = {@@ -122,6 +124,8 @@ const INTERVAL_UNIT_TO_DAYJS_FORMAT_SHORT: Record<IntervalType, string> = {day: 'D MMM',week: 'D MMM',month: 'MMM',+ quarter: '[Q]Q',+ year: 'YYYY',}/**diff --git a/frontend/src/scenes/insights/insightVizDataLogic.test.ts b/frontend/src/scenes/insights/insightVizDataLogic.test.tsindex 1c979968f39e..3b2e9a480891 100644--- a/frontend/src/scenes/insights/insightVizDataLogic.test.ts+++ b/frontend/src/scenes/insights/insightVizDataLogic.test.ts@@ -584,6 +584,8 @@ describe('insightVizDataLogic', () => {hour: { label: 'hour', newDateFrom: 'dStart' },month: { label: 'month', newDateFrom: '-90d' },week: { label: 'week', newDateFrom: '-30d' },+ quarter: { label: 'quarter', newDateFrom: '-3y', hidden: true },+ year: { label: 'year', newDateFrom: '-5y', hidden: true },},})})@@ -620,6 +622,8 @@ describe('insightVizDataLogic', () => {'Grouping by month is not supported on insights with weekly active users series.',},week: { label: 'week', newDateFrom: '-30d' },+ quarter: { label: 'quarter', newDateFrom: '-3y', hidden: true },+ year: { label: 'year', newDateFrom: '-5y', hidden: true },},})})diff --git a/frontend/src/scenes/retention/constants.ts b/frontend/src/scenes/retention/constants.tsindex d91e63f8b26d..cdf997436c72 100644--- a/frontend/src/scenes/retention/constants.ts+++ b/frontend/src/scenes/retention/constants.ts@@ -3,7 +3,7 @@ import {RETENTION_FIRST_OCCURRENCE_MATCHING_FILTERS,RETENTION_RECURRING,} from 'lib/constants'-import { OpUnitType } from 'lib/dayjs'+import { ManipulateType } from 'lib/dayjs'import { LemonSelectOptions } from 'lib/lemon-ui/LemonSelect'import { RetentionFilter } from '~/queries/schema/schema-general'@@ -12,7 +12,7 @@ import { RetentionPeriod } from '~/types'export const dateOptions: RetentionPeriod[] = [RetentionPeriod.Day, RetentionPeriod.Week, RetentionPeriod.Month]// https://day.js.org/docs/en/durations/creating#list-of-all-available-units-export const dateOptionToTimeIntervalMap: Record<RetentionPeriod, OpUnitType> = {+export const dateOptionToTimeIntervalMap: Record<RetentionPeriod, ManipulateType> = {Hour: 'h',Day: 'd',Week: 'w',diff --git a/frontend/src/scenes/retention/retentionGraphLogic.ts b/frontend/src/scenes/retention/retentionGraphLogic.tsindex 7a5fa5e6631d..4629f500c624 100644--- a/frontend/src/scenes/retention/retentionGraphLogic.ts+++ b/frontend/src/scenes/retention/retentionGraphLogic.ts@@ -1,6 +1,6 @@import { connect, kea, key, path, props, selectors } from 'kea'-import { QUnitType, dayjs } from 'lib/dayjs'+import { dayjs } from 'lib/dayjs'import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils'import { dateOptionPlurals } from 'scenes/retention/constants'@@ -178,7 +178,7 @@ export const retentionGraphLogic = kea<retentionGraphLogicType>([(_, i) =>dayjs(date_to).tz(timezone)- .add(i - numUnits, interval as QUnitType) >= startDate+ .add(i - numUnits, interval) >= startDate)if (startIndex !== undefined && startIndex !== -1) {diff --git a/frontend/src/scenes/trends/trendsDataLogic.ts b/frontend/src/scenes/trends/trendsDataLogic.tsindex 2bf3f6b45d2b..421e50941594 100644--- a/frontend/src/scenes/trends/trendsDataLogic.ts+++ b/frontend/src/scenes/trends/trendsDataLogic.ts@@ -63,6 +63,8 @@ export const INTERVAL_TO_DEFAULT_MOVING_AVERAGE_PERIOD: Record<IntervalType, numday: 7,week: 4,month: 3,+ quarter: 4,+ year: 3,}const DEFAULT_CONFIDENCE_LEVEL = 95diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 3303ed69e746..b5211a466571 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -2959,7 +2959,7 @@ export type BreakdownType =| 'data_warehouse'| 'data_warehouse_person_property'| 'revenue_analytics'-export type IntervalType = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month'+export type IntervalType = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'export type SimpleIntervalType = 'day' | 'month'export type SmoothingType = numberexport type InsightSceneSource = 'web-analytics' | 'llm-analytics' | 'endpoints'diff --git a/packages/quill/packages/charts/src/utils/dates.ts b/packages/quill/packages/charts/src/utils/dates.tsindex 57fd1e51e129..fba97de22bab 100644--- a/packages/quill/packages/charts/src/utils/dates.ts+++ b/packages/quill/packages/charts/src/utils/dates.ts@@ -2,7 +2,7 @@ import { type Dayjs, parseDateInTimezone } from './dayjs'/** Bucket size for a date-based X axis. Mirrors `IntervalType` from product code without* coupling hog-charts to it. */-export type TimeInterval = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month'+export type TimeInterval = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'interface CreateXAxisTickCallbackArgs {interval?: TimeInterval@@ -90,7 +90,7 @@ function pickMode(interval: TimeInterval, parsedDates: Dayjs[], first: Dayjs, laconst spanMonths = (last.year() - first.year()) * 12 + last.month() - first.month()const spanDays = last.diff(first, 'day')- if (interval === 'month') {+ if (interval === 'month' || interval === 'quarter' || interval === 'year') {return { type: 'month' }}if ((interval === 'day' || interval === 'week') && spanMonths >= 3) {diff --git a/posthog/hogql_queries/endpoints/endpoints_usage_trends.py b/posthog/hogql_queries/endpoints/endpoints_usage_trends.pyindex 895af0f7e9d4..b622cffbcb8c 100644--- a/posthog/hogql_queries/endpoints/endpoints_usage_trends.py+++ b/posthog/hogql_queries/endpoints/endpoints_usage_trends.py@@ -97,6 +97,16 @@ class EndpointsUsageTrendsQueryRunner(EndpointsUsageQueryRunner[EndpointsUsageTrname="toStartOfMonth",args=[ast.Field(chain=["event_date"])],)+ elif interval == IntervalType.QUARTER:+ return ast.Call(+ name="toStartOfQuarter",+ args=[ast.Field(chain=["event_date"])],+ )+ elif interval == IntervalType.YEAR:+ return ast.Call(+ name="toStartOfYear",+ args=[ast.Field(chain=["event_date"])],+ )else:# Default to dayreturn ast.Field(chain=["event_date"])diff --git a/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py b/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.pyindex 71db6a7b6209..76cf301bb056 100644--- a/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py+++ b/posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py@@ -481,6 +481,51 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):self.assertEqual([1, 0, 1, 3, 1, 0, 2, 0, 1, 0, 1], response.results[0]["data"])+ @parameterized.expand(+ [+ (+ "quarter",+ IntervalType.QUARTER,+ "2021-03-31",+ ["2020-01-01", "2020-04-01", "2020-07-01", "2020-10-01", "2021-01-01"],+ [1, 2, 1, 0, 1],+ ),+ (+ "year",+ IntervalType.YEAR,+ "2021-12-31",+ ["2020-01-01", "2021-01-01"],+ [4, 1],+ ),+ ]+ )+ def test_trends_quarter_and_year_intervals(self, _name, interval, date_to, expected_days, expected_data):+ self._create_events(+ [+ SeriesTestData(+ distinct_id="p1",+ events=[+ Series(+ event="$pageview",+ timestamps=[+ "2020-01-15T12:00:00Z",+ "2020-04-10T12:00:00Z",+ "2020-05-10T12:00:00Z",+ "2020-09-01T12:00:00Z",+ "2021-02-01T12:00:00Z",+ ],+ )+ ],+ properties={},+ )+ ]+ )++ response = self._run_trends_query("2020-01-01", date_to, interval, None, None, None)++ self.assertEqual(expected_days, response.results[0]["days"])+ self.assertEqual(expected_data, response.results[0]["data"])+def test_trends_days(self):self._create_test_events()diff --git a/posthog/hogql_queries/insights/trends/trends_query_runner.py b/posthog/hogql_queries/insights/trends/trends_query_runner.pyindex 225b1788543a..db344fadd895 100644--- a/posthog/hogql_queries/insights/trends/trends_query_runner.py+++ b/posthog/hogql_queries/insights/trends/trends_query_runner.py@@ -535,12 +535,12 @@ class TrendsQueryRunner(AnalyticsQueryRunner[TrendsQueryResponse]):# Hiding weekends is purely a display concern: we keep weekend events in the aggregation# (so windowed math like WAU/MAU, cumulative, and smoothing stay correct) and only drop the# weekend date buckets from the response so the chart x-axis shows weekdays.- # For week/month intervals we keep all buckets since they span multiple days.+ # For week and longer intervals we keep all buckets since they span multiple days.# For hour/minute intervals we skip bucket removal to avoid discarding all data on weekends.if (self.query.trendsFilterand self.query.trendsFilter.hideWeekends- and self.query_date_range.interval_name not in ("hour", "minute", "week", "month")+ and self.query_date_range.interval_name not in ("hour", "minute", "week", "month", "quarter", "year")):final_result = self._filter_weekend_buckets(final_result)diff --git a/posthog/hogql_queries/utils/query_date_range.py b/posthog/hogql_queries/utils/query_date_range.pyindex eeb0a2937f1c..8c0f74b946d5 100644--- a/posthog/hogql_queries/utils/query_date_range.py+++ b/posthog/hogql_queries/utils/query_date_range.py@@ -200,7 +200,7 @@ class QueryDateRange:def interval_relativedelta(self) -> relativedelta:spec = interval_spec(self.interval_name)- return relativedelta(**{spec.relativedelta_kwarg: self.interval_count}) # type: ignore[arg-type]+ return relativedelta(**{spec.relativedelta_kwarg: self.interval_count * spec.relativedelta_multiplier}) # type: ignore[arg-type]def all_values(self, *, interval_name: Optional[IntervalLiteral] = None) -> list[datetime]:start = self.align_with_interval(self.date_from(), interval_name=interval_name)diff --git a/posthog/hogql_queries/utils/test/test_query_date_range.py b/posthog/hogql_queries/utils/test/test_query_date_range.pyindex 29906ba91d2a..ce75b4a9f809 100644--- a/posthog/hogql_queries/utils/test/test_query_date_range.py+++ b/posthog/hogql_queries/utils/test/test_query_date_range.py@@ -99,6 +99,21 @@ class TestQueryDateRange(APIBaseTest):],)+ @parameterized.expand(+ [+ ("quarter", IntervalType.QUARTER, "-7m", ["2021-01-01", "2021-04-01", "2021-07-01"]),+ ("year", IntervalType.YEAR, "-2y", ["2019-01-01", "2020-01-01", "2021-01-01"]),+ ]+ )+ def test_all_values_quarter_year(self, _name, interval, date_from, expected_starts):+ now = parser.isoparse("2021-08-25T00:00:00.000Z")+ self.assertEqual(+ QueryDateRange(+ team=self.team, date_range=DateRange(date_from=date_from), interval=interval, now=now+ ).all_values(),+ [parser.isoparse(f"{start}T00:00:00Z") for start in expected_starts],+ )+def test_date_to_explicit(self):now = parser.isoparse("2021-08-25T00:00:00.000Z")date_range = DateRange(diff --git a/posthog/interval_specs.py b/posthog/interval_specs.pyindex 6f6a11984dab..57fd8c87443c 100644--- a/posthog/interval_specs.py+++ b/posthog/interval_specs.py@@ -7,7 +7,7 @@ from dateutil.relativedelta import relativedeltafrom posthog.schema_enums import IntervalType-IntervalLiteral = Literal["second", "minute", "hour", "day", "week", "month"]+IntervalLiteral = Literal["second", "minute", "hour", "day", "week", "month", "quarter", "year"]class UnsupportedIntervalError(ValueError):@@ -43,6 +43,15 @@ def _align_month(date: datetime, week_start_day: Optional[int]) -> datetime:return date.replace(day=1, hour=0, minute=0, second=0, microsecond=0)+def _align_quarter(date: datetime, week_start_day: Optional[int]) -> datetime:+ quarter_start_month = ((date.month - 1) // 3) * 3 + 1+ return date.replace(month=quarter_start_month, day=1, hour=0, minute=0, second=0, microsecond=0)+++def _align_year(date: datetime, week_start_day: Optional[int]) -> datetime:+ return date.replace(month=1, day=1, hour=0, minute=0, second=0, microsecond=0)++@dataclass(frozen=True)class IntervalSpec:"""Everything the query layer knows about one interval size — adding an interval means adding one entry to INTERVAL_SPECS."""@@ -56,6 +65,8 @@ class IntervalSpec:align: Callable[[datetime, Optional[int]], datetime]staleness_default: Optional[timedelta]staleness_lazy: Optional[timedelta]+ # For intervals relativedelta has no kwarg for (a quarter is months=3)+ relativedelta_multiplier: int = 1# Ordered smallest to largest — ORDERED_INTERVALS derives interval comparison from this order@@ -120,6 +131,27 @@ INTERVAL_SPECS: dict[IntervalLiteral, IntervalSpec] = {staleness_default=timedelta(days=1),staleness_lazy=timedelta(days=1),),+ "quarter": IntervalSpec(+ interval_type=IntervalType.QUARTER,+ trunc_func="toStartOfQuarter",+ interval_func="toIntervalQuarter",+ relativedelta_kwarg="months",+ relativedelta_multiplier=3,+ period=relativedelta(months=3),+ align=_align_quarter,+ staleness_default=timedelta(days=1),+ staleness_lazy=timedelta(days=1),+ ),+ "year": IntervalSpec(+ interval_type=IntervalType.YEAR,+ trunc_func="toStartOfYear",+ interval_func="toIntervalYear",+ relativedelta_kwarg="years",+ period=relativedelta(years=1),+ align=_align_year,+ staleness_default=timedelta(days=1),+ staleness_lazy=timedelta(days=1),+ ),}ORDERED_INTERVALS: list[IntervalType] = [spec.interval_type for spec in INTERVAL_SPECS.values()]diff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex 9c5c7528acbd..d8976d1433b4 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -2231,6 +2231,8 @@ class IntervalType(StrEnum):DAY = "day"WEEK = "week"MONTH = "month"+ QUARTER = "quarter"+ YEAR = "year"class Method(StrEnum):diff --git a/posthog/tasks/alerts/detector.py b/posthog/tasks/alerts/detector.pyindex 6692fa289121..8c8b8d3899f1 100644--- a/posthog/tasks/alerts/detector.py+++ b/posthog/tasks/alerts/detector.py@@ -121,6 +121,10 @@ def _date_range_override_for_detector(query: TrendsQuery, min_samples: int) -> ddate_from = f"-{min_samples}w"case IntervalType.MONTH:date_from = f"-{min_samples}m"+ case IntervalType.QUARTER:+ date_from = f"-{min_samples}q"+ case IntervalType.YEAR:+ date_from = f"-{min_samples}y"case _:date_from = f"-{min_samples}h"diff --git a/posthog/tasks/alerts/trends.py b/posthog/tasks/alerts/trends.pyindex d63d1032d2b5..8622dba62107 100644--- a/posthog/tasks/alerts/trends.py+++ b/posthog/tasks/alerts/trends.py@@ -67,6 +67,10 @@ def _date_range_override_for_intervals(query: TrendsQuery, last_x_intervals: intdate_from = f"-{last_x_intervals}w"case IntervalType.MONTH:date_from = f"-{last_x_intervals}m"+ case IntervalType.QUARTER:+ date_from = f"-{last_x_intervals}q"+ case IntervalType.YEAR:+ date_from = f"-{last_x_intervals}y"case _:date_from = f"-{last_x_intervals}h"diff --git a/products/alerts/backend/evaluation/funnels.py b/products/alerts/backend/evaluation/funnels.pyindex 0d3ff23aef2c..bcf3cfc65e3b 100644--- a/products/alerts/backend/evaluation/funnels.py+++ b/products/alerts/backend/evaluation/funnels.py@@ -23,6 +23,10 @@ def _trailing_date_range_override(interval: IntervalType | None, periods: int) -unit = "w"case IntervalType.MONTH:unit = "m"+ case IntervalType.QUARTER:+ unit = "q"+ case IntervalType.YEAR:+ unit = "y"case _:unit = "h"return {"date_from": f"-{periods}{unit}"}diff --git a/products/alerts/backend/evaluation/test/test_date_range_overrides.py b/products/alerts/backend/evaluation/test/test_date_range_overrides.pynew file mode 100644index 000000000000..9c446f31d64d--- /dev/null+++ b/products/alerts/backend/evaluation/test/test_date_range_overrides.py@@ -0,0 +1,31 @@+from unittest import TestCase++from parameterized import parameterized++from posthog.schema import IntervalType, TrendsQuery++from posthog.tasks.alerts.detector import _date_range_override_for_detector+from posthog.tasks.alerts.trends import _date_range_override_for_intervals++from products.alerts.backend.evaluation.funnels import _trailing_date_range_override+++class TestDateRangeOverrides(TestCase):+ @parameterized.expand(+ [+ (IntervalType.DAY, "-2d"),+ (IntervalType.WEEK, "-2w"),+ (IntervalType.MONTH, "-2m"),+ (IntervalType.QUARTER, "-2q"),+ (IntervalType.YEAR, "-2y"),+ (IntervalType.HOUR, "-2h"),+ ]+ )+ def test_interval_maps_to_matching_date_from_unit(self, interval, expected_date_from):+ query = TrendsQuery(series=[], interval=interval)++ self.assertEqual(+ _date_range_override_for_intervals(query, last_x_intervals=2), {"date_from": expected_date_from}+ )+ self.assertEqual(_date_range_override_for_detector(query, min_samples=2), {"date_from": expected_date_from})+ self.assertEqual(_trailing_date_range_override(interval, periods=2), {"date_from": expected_date_from})diff --git a/products/alerts/backend/evaluation/validation.py b/products/alerts/backend/evaluation/validation.pyindex dbba238733e3..109eafb5ee3a 100644--- a/products/alerts/backend/evaluation/validation.py+++ b/products/alerts/backend/evaluation/validation.py@@ -196,6 +196,8 @@ _INTERVAL_DURATION_MINUTES: dict[IntervalType, float] = {IntervalType.DAY: 60 * 24,IntervalType.WEEK: 60 * 24 * 7,IntervalType.MONTH: 60 * 24 * 30,+ IntervalType.QUARTER: 60 * 24 * 30 * 3,+ IntervalType.YEAR: 60 * 24 * 365,}diff --git a/products/alerts/frontend/logic/alertIntervalHelpers.ts b/products/alerts/frontend/logic/alertIntervalHelpers.tsindex 52515ea89779..8334aa850bf8 100644--- a/products/alerts/frontend/logic/alertIntervalHelpers.ts+++ b/products/alerts/frontend/logic/alertIntervalHelpers.ts@@ -66,6 +66,8 @@ const INSIGHT_INTERVAL_DURATION_MINUTES: Record<IntervalType, number> = {day: 60 * 24,week: 60 * 24 * 7,month: 60 * 24 * 30,+ quarter: 60 * 24 * 30 * 3,+ year: 60 * 24 * 365,}/** An alert re-checks the insight's last completed bucket, whose size is the insight's groupingdiff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 081173065c0c..f1926cb3b4a4 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -990,6 +990,8 @@ export const IntervalTypeApi = {Day: 'day',Week: 'week',Month: 'month',+ Quarter: 'quarter',+ Year: 'year',} as constexport type BounceRatePageViewModeApi = (typeof BounceRatePageViewModeApi)[keyof typeof BounceRatePageViewModeApi]diff --git a/products/endpoints/frontend/generated/api.schemas.ts b/products/endpoints/frontend/generated/api.schemas.tsindex c115434b7e49..e516b3ff757b 100644--- a/products/endpoints/frontend/generated/api.schemas.ts+++ b/products/endpoints/frontend/generated/api.schemas.ts@@ -584,6 +584,8 @@ export const IntervalTypeApi = {Day: 'day',Week: 'week',Month: 'month',+ Quarter: 'quarter',+ Year: 'year',} as constexport type PropertyOperatorApi = (typeof PropertyOperatorApi)[keyof typeof PropertyOperatorApi]diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 7f8167379e8c..56e728495f96 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -305,6 +305,8 @@ export const IntervalTypeApi = {Day: 'day',Week: 'week',Month: 'month',+ Quarter: 'quarter',+ Year: 'year',} as constexport type BounceRatePageViewModeApi = (typeof BounceRatePageViewModeApi)[keyof typeof BounceRatePageViewModeApi]diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 02e35b872e4b..f8b75885a35e 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -2261,6 +2261,8 @@ export namespace Schemas {Day: 'day',Week: 'week',Month: 'month',+ Quarter: 'quarter',+ Year: 'year',} as const;export interface PropertyGroupFilter {diff --git a/services/mcp/src/generated/endpoints/api.ts b/services/mcp/src/generated/endpoints/api.tsindex 3ed25681cd41..8e572e54847c 100644--- a/services/mcp/src/generated/endpoints/api.ts+++ b/services/mcp/src/generated/endpoints/api.ts@@ -415,7 +415,10 @@ export const EndpointsRunCreateBody = /* @__PURE__ */ zod.object({'Tri-state test-account override. Null/absent = inherit; true = force on; false = force off.'),interval: zod- .union([zod.enum(['second', 'minute', 'hour', 'day', 'week', 'month']), zod.null()])+ .union([+ zod.enum(['second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year']),+ zod.null(),+ ]).optional().describe('Time granularity forced onto every insight that supports one. Absent/null = inherit.'),properties: zoddiff --git a/services/mcp/src/tools/generated/query-wrappers.ts b/services/mcp/src/tools/generated/query-wrappers.tsindex 14f71b2e46db..800070efaf88 100644--- a/services/mcp/src/tools/generated/query-wrappers.ts+++ b/services/mcp/src/tools/generated/query-wrappers.ts@@ -79,7 +79,7 @@ const AssistantDurationRange = z.object({const AssistantDateRangeFilter = z.union([AssistantDateRange, AssistantDurationRange])-const IntervalType = z.enum(['second', 'minute', 'hour', 'day', 'week', 'month'])+const IntervalType = z.enum(['second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'])const AssistantStringOrBooleanValuePropertyFilterOperator = z.enum(['exact',diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel-actors.jsonindex c1633e4444b6..e8d472bf0aea 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel-actors.json@@ -231,7 +231,7 @@},"interval": {"description": "Granularity of the response. Can be one of `hour`, `day`, `week` or `month`",- "enum": ["second", "minute", "hour", "day", "week", "month"],+ "enum": ["second", "minute", "hour", "day", "week", "month", "quarter", "year"],"type": "string"},"kind": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel.jsonindex 83bbf51262a2..a98b29e24853 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-funnel.json@@ -191,7 +191,7 @@},"interval": {"description": "Granularity of the response. Can be one of `hour`, `day`, `week` or `month`",- "enum": ["second", "minute", "hour", "day", "week", "month"],+ "enum": ["second", "minute", "hour", "day", "week", "month", "quarter", "year"],"type": "string"},"kind": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle-actors.jsonindex 82ab0e71bc58..34fdd385bfaa 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle-actors.json@@ -76,7 +76,7 @@"interval": {"default": "day","description": "Granularity of the response. Can be one of `hour`, `day`, `week` or `month`",- "enum": ["second", "minute", "hour", "day", "week", "month"],+ "enum": ["second", "minute", "hour", "day", "week", "month", "quarter", "year"],"type": "string"},"kind": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle.jsonindex 50169c8210fc..2405216b84b1 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-lifecycle.json@@ -58,7 +58,7 @@"interval": {"default": "day","description": "Granularity of the response. Can be one of `hour`, `day`, `week` or `month`",- "enum": ["second", "minute", "hour", "day", "week", "month"],+ "enum": ["second", "minute", "hour", "day", "week", "month", "quarter", "year"],"type": "string"},"kind": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.jsonindex 6337462d5ae6..37b531b64c27 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness-actors.json@@ -104,7 +104,7 @@"interval": {"default": "day","description": "Granularity of the response. Can be one of `hour`, `day`, `week` or `month`. This determines what counts as one \"interval\" for stickiness measurement. For example, with `day` interval over a 30-day range, the X-axis shows 1 through 30 days, and each bar/point shows how many users performed the event on exactly that many days.",- "enum": ["second", "minute", "hour", "day", "week", "month"],+ "enum": ["second", "minute", "hour", "day", "week", "month", "quarter", "year"],"type": "string"},"intervalCount": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness.jsonindex 36f1b6700cf4..6738f5ec9b30 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-stickiness.json@@ -73,7 +73,7 @@"interval": {"default": "day","description": "Granularity of the response. Can be one of `hour`, `day`, `week` or `month`. This determines what counts as one \"interval\" for stickiness measurement. For example, with `day` interval over a 30-day range, the X-axis shows 1 through 30 days, and each bar/point shows how many users performed the event on exactly that many days.",- "enum": ["second", "minute", "hour", "day", "week", "month"],+ "enum": ["second", "minute", "hour", "day", "week", "month", "quarter", "year"],"type": "string"},"intervalCount": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.jsonindex 950b15bba4c3..a79edcaddcde 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json@@ -193,7 +193,7 @@"interval": {"default": "day","description": "Granularity of the response. Can be one of `hour`, `day`, `week` or `month`",- "enum": ["second", "minute", "hour", "day", "week", "month"],+ "enum": ["second", "minute", "hour", "day", "week", "month", "quarter", "year"],"type": "string"},"kind": {diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.jsonindex 6d7945975f9f..a5f31e1ae4c0 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json@@ -152,7 +152,7 @@"interval": {"default": "day","description": "Granularity of the response. Can be one of `hour`, `day`, `week` or `month`",- "enum": ["second", "minute", "hour", "day", "week", "month"],+ "enum": ["second", "minute", "hour", "day", "week", "month", "quarter", "year"],"type": "string"},"kind": {