: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
import { MetricsQuerySeries } from '~/queries/schema/schema-general'
/**
* Dashboard tiles hand dataNodeLogic the cached insight object, whose data sits
* under `result` (singular); live query responses carry `results`. Accept both
* so a metrics tile renders from cache instead of blank.
*/
export function seriesFromMetricsResponse(response: unknown): MetricsQuerySeries[] {
if (!response || typeof response !== 'object') {
return []
}
const { results, result } = response as { results?: unknown; result?: unknown }
if (Array.isArray(results)) {
return results as MetricsQuerySeries[]
}
if (Array.isArray(result)) {
return result as MetricsQuerySeries[]
}
return []
}