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.

959 B
Raw Blame
import { ExternalDataSource } from '~/types'

import { SourceConfigResponseApi } from 'products/warehouse_sources/frontend/generated/api.schemas'

export const FILE_UPLOAD_SOURCE_LABEL = 'File upload'

/**
 * A file upload source imports one file a user uploaded. It has no schedule and no incremental
 * sync: PostHog starts each import itself, and the user refreshes the data by replacing the file.
 */
export function isFileUploadSource(source: Pick<ExternalDataSource, 'source_type'> | null | undefined): boolean {
    return source?.source_type === 'FileUpload'
}

// The source catalog leaves out file upload sources, so their label can't come from it.
export function sourceTypeLabel(
    sourceType: string,
    availableSources: Record<string, SourceConfigResponseApi> | null | undefined
): string {
    if (sourceType === 'FileUpload') {
        return FILE_UPLOAD_SOURCE_LABEL
    }
    return availableSources?.[sourceType]?.label ?? sourceType
}