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.

1011 B
Raw Blame
import type { SeriesNode } from 'scenes/insights/filters/ActionFilter/seriesNode'

import { isEventsNode } from '~/queries/schema/node-guards'
import { InsightLogicProps } from '~/types'

export const CUSTOMER_ANALYTICS_LOGIC_KEY = 'customerAnalytics'

export const buildDashboardItemId = (uniqueKey: string): InsightLogicProps['dashboardItemId'] => {
    return `new-AdHoc.customer-analytics.${uniqueKey}`
}

export function isPageviewWithoutFilters(event: SeriesNode): boolean {
    return isEventsNode(event) && event.event === '$pageview' && (!event.properties || event.properties.length === 0)
}

interface PaginatedPage<T> {
    results: T[]
    next?: string | null
}

export async function loadAllPages<T>(loadPage: (offset: number) => Promise<PaginatedPage<T>>): Promise<T[]> {
    const results: T[] = []
    let page: PaginatedPage<T>
    do {
        page = await loadPage(results.length)
        results.push(...page.results)
    } while (page.next && page.results.length > 0)
    return results
}