Skip to content

: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.

715 B
Raw Blame
import { seriesFromMetricsResponse } from './metricsResponseSeries'

describe('seriesFromMetricsResponse', () => {
    const series = [{ metricName: 'logs_pii_replacements_total', labels: {}, points: [[1, 2]] }]

    it.each([
        ['a live query response (results)', { results: series }, series],
        ['a cached dashboard insight (result)', { id: 123, short_id: 'abc', result: series }, series],
        ['an insight with a null result', { id: 123, result: null }, []],
        ['no response yet', undefined, []],
        ['a response with neither key', {}, []],
    ])('reads series from %s', (_name, response, expected) => {
        expect(seriesFromMetricsResponse(response)).toEqual(expected)
    })
})