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.

4.4 KB
Raw Blame
import { combineUrl } from 'kea-router'

import { urls } from 'scenes/urls'

import { FileSystemIconType, ProductItemCategory, ProductKey } from '~/queries/schema/schema-general'

import { ActivityScope, FileSystemIconColor, ProductManifest } from '../../frontend/src/types'

export const manifest: ProductManifest = {
    name: 'Endpoints',
    activityDescribers: {
        [ActivityScope.ENDPOINT]: () =>
            import('./frontend/activityDescriber').then((module) => module.endpointActivityDescriber),
        [ActivityScope.ENDPOINT_VERSION]: () =>
            import('./frontend/activityDescriber').then((module) => module.endpointActivityDescriber),
    },
    scenes: {
        EndpointsScene: {
            import: () => import('./frontend/EndpointsScene'),
            projectBased: true,
            name: 'Endpoints',
            activityScope: 'Endpoints',
            layout: 'app-container',
            iconType: 'endpoints',
            description: 'Define queries your application will use via the API and monitor their cost and usage.',
            docsHref: 'https://posthog.com/docs/endpoints',
        },
        EndpointScene: {
            import: () => import('./frontend/EndpointScene'),
            projectBased: true,
            name: 'Endpoint',
            activityScope: 'Endpoint',
        },
    },
    routes: {
        '/endpoints': ['EndpointsScene', 'endpoints'],
        '/endpoints/:name': ['EndpointScene', 'endpoint'],
    },
    urls: {
        endpoints: (): string => '/endpoints',
        endpoint: (name: string, version?: number): string => {
            const searchParams: Record<string, string> = {}
            if (version) {
                searchParams.version = String(version)
            }
            return combineUrl(`/endpoints/${name}`, searchParams).url
        },
        endpointsUsage: (params?: {
            endpointFilter?: string[]
            dateFrom?: string
            dateTo?: string
            materializationType?: 'materialized' | 'inline'
            interval?: string
            breakdownBy?: string
        }): string => {
            if (!params) {
                return '/endpoints?tab=usage'
            }
            const searchParams: Record<string, string> = {}
            if (params.endpointFilter?.length) {
                searchParams.endpointFilter = params.endpointFilter.join(',')
            }
            if (params.dateFrom) {
                searchParams.dateFrom = params.dateFrom
            }
            if (params.dateTo) {
                searchParams.dateTo = params.dateTo
            }
            if (params.materializationType) {
                searchParams.materializationType = params.materializationType
            }
            if (params.interval) {
                searchParams.interval = params.interval
            }
            if (params.breakdownBy) {
                searchParams.breakdownBy = params.breakdownBy
            }
            return combineUrl('/endpoints', { tab: 'usage', ...searchParams }).url
        },
    },
    fileSystemTypes: {
        endpoints: {
            name: 'Endpoints',
            iconType: 'endpoints',
            href: () => urls.endpoints(),
            iconColor: ['var(--color-product-endpoints-light)', 'var(--color-product-endpoints-dark)'],
            filterKey: 'endpoints',
        },
    },
    treeItemsProducts: [
        {
            path: 'Endpoints',
            intents: [ProductKey.ENDPOINTS],
            category: ProductItemCategory.DATA,
            href: urls.endpoints(),
            searchKeywords: ['rest api', 'query api'],
            searchTabs: [{ name: 'Usage', href: urls.endpointsUsage() }],
            type: 'endpoints',
            iconType: 'endpoints',
            iconColor: [
                'var(--color-product-endpoints-light)',
                'var(--color-product-endpoints-dark)',
            ] as FileSystemIconColor,
            sceneKey: 'EndpointsScene',
        },
    ],
    treeItemsMetadata: [
        {
            path: 'Endpoints',
            category: 'Data',
            iconType: 'endpoints' as FileSystemIconType,
            iconColor: [
                'var(--color-product-endpoints-light)',
                'var(--color-product-endpoints-dark)',
            ] as FileSystemIconColor,
            href: urls.endpoints(),
            sceneKey: 'EndpointsScene',
            sceneKeys: ['EndpointsScene', 'EndpointScene'],
        },
    ],
}