: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
chore(metrics): add the date range and query shape to metrics query completed (#122337)
Frank Hamand63e15ca8f858
diff --git a/products/metrics/frontend/components/metricsUsageTrackingLogic.test.ts b/products/metrics/frontend/components/metricsUsageTrackingLogic.test.tsindex 7d74787f5c89..5a851c6079ec 100644--- a/products/metrics/frontend/components/metricsUsageTrackingLogic.test.ts+++ b/products/metrics/frontend/components/metricsUsageTrackingLogic.test.ts@@ -230,6 +230,8 @@ describe('metricsUsageTrackingLogic', () => {],} as any)metricsViewerLogic.actions.setMetricName(SECRET_METRIC)+ // A series row with no metric is not part of the request.+ metricsViewerLogic.actions.addClause()metricsViewerLogic.actions.fetchQueryResults({})await expectLogic(metricsViewerLogic).toDispatchActions(['fetchQueryResultsSuccess'])@@ -244,6 +246,9 @@ describe('metricsUsageTrackingLogic', () => {range_function: null,has_group_by: false,has_filters: false,+ date_from: '-1h',+ clause_count: 1,+ has_formula: false,},],])diff --git a/products/metrics/frontend/components/metricsUsageTrackingLogic.ts b/products/metrics/frontend/components/metricsUsageTrackingLogic.tsindex 60c13a9f52a1..81a2d5a5f5a5 100644--- a/products/metrics/frontend/components/metricsUsageTrackingLogic.ts+++ b/products/metrics/frontend/components/metricsUsageTrackingLogic.ts@@ -26,7 +26,12 @@ import { metricsSamplesLogic } from './metricsSamplesLogic'import type { MetricsPanelTab } from './metricsSamplesLogic'import { metricsStarterDashboardLogic } from './metricsStarterDashboardLogic'import { metricsViewerLogic, viewerAggregationFromNode } from './metricsViewerLogic'-import type { MetricAggregation, MetricRangeFunction, MetricsViewerClause } from './metricsViewerLogic'+import type {+ MetricAggregation,+ MetricRangeFunction,+ MetricsQueryRequestBody,+ MetricsViewerClause,+} from './metricsViewerLogic'// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface metricsUsageTrackingLogicValues {@@ -34,11 +39,13 @@ export interface metricsUsageTrackingLogicValues {dashboardImportStep: DashboardImportStep // metricsDashboardImportLogicisRestoringFromUrl: boolean // metricsSceneLogicaggregation: MetricAggregation | null // metricsViewerLogic+ dateFrom: string | null // metricsViewerLogicdisplayType: MetricsDisplayType // metricsViewerLogicformula: string // metricsViewerLogicgroupByKeys: string[] // metricsViewerLogichasMetricName: boolean // metricsViewerLogicqueryFilters: _MetricFilterApi[] // metricsViewerLogic+ queryPayload: MetricsQueryRequestBody | null // metricsViewerLogicrangeFunction: MetricRangeFunction | null // metricsViewerLogicviewerClauses: MetricsViewerClause[] // metricsViewerLogic}@@ -216,11 +223,13 @@ export const metricsUsageTrackingLogic = kea<metricsUsageTrackingLogicType>([['hasMetricName','aggregation',+ 'dateFrom','rangeFunction','groupByKeys','queryFilters','viewerClauses','formula',+ 'queryPayload','displayType',],metricsSceneLogic,@@ -346,6 +355,11 @@ export const metricsUsageTrackingLogic = kea<metricsUsageTrackingLogicType>([range_function: values.rangeFunction,has_group_by: values.groupByKeys.length > 0,has_filters: values.queryFilters.length > 0,+ // The range and the clause shape let this event compare with `query completed` for MetricsQuery.+ date_from: values.dateFrom,+ // From the request body, which leaves out a series row with no metric.+ clause_count: values.queryPayload?.clauses?.length ?? 0,+ has_formula: !!values.queryPayload?.formula,})// Once per mount, not per query — live refresh re-runs the query every 15s,// and each intent call is an API request (the backend counts repeats itself).