: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
from typing import Optional, cast
from products.warehouse_sources.sources.omni._config import OmniSourceConfig
from products.warehouse_sources.sources.omni.omni import (
OmniResumeConfig,
get_endpoint_permissions as get_omni_endpoint_permissions,
omni_source,
validate_credentials as validate_omni_credentials,
)
from products.warehouse_sources.sources.omni.settings import ENDPOINTS, INCREMENTAL_FIELDS
from products.warehouse_sources.sources.sdk import (
CanonicalDescriptions,
DataWarehouseSourceCategory,
ExternalDataSourceType,
FieldType,
ReleaseStatus,
ResumableSource,
ResumableSourceManager,
SourceConfig,
SourceFieldInputConfig,
SourceFieldInputConfigType,
SourceInputs,
SourceRegistry,
SourceResponse,
SourceSchema,
build_endpoint_schemas,
detect,
)
@SourceRegistry.register
class OmniSource(ResumableSource[OmniSourceConfig, OmniResumeConfig]):
codebase_detection = detect(
env=("^OMNI_API_TOKEN$", "^OMNI_API_KEY$", "^OMNI_BASE_URL$", "^OMNI_URL$"),
npm=("@omni-co/embed", "@omni-co/mcp"),
pypi=("omni-python-sdk",),
)
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
api_docs_url = "https://docs.omni.co/api"
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.OMNI
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {
"401 Client Error": "Your Omni API key is invalid or expired. Please generate a new key and reconnect.",
"403 Client Error": "Your Omni API key does not have the required permissions. Please check the key's access and try again.",
}
def get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.sources.omni.canonical_descriptions import CANONICAL_DESCRIPTIONS
return CANONICAL_DESCRIPTIONS
def get_schemas(
self,
config: OmniSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)
def validate_credentials(
self,
config: OmniSourceConfig,
team_id: int,
schema_name: Optional[str] = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
return validate_omni_credentials(config.host, config.api_key, team_id, schema_name)
def get_endpoint_permissions(
self, config: OmniSourceConfig, team_id: int, endpoints: list[str], api_version: str | None = None
) -> dict[str, str | None]:
return get_omni_endpoint_permissions(config.host, config.api_key, endpoints)
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[OmniResumeConfig]:
return ResumableSourceManager[OmniResumeConfig](inputs, OmniResumeConfig)
def source_for_pipeline(
self,
config: OmniSourceConfig,
resumable_source_manager: ResumableSourceManager[OmniResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
return omni_source(
host=config.host,
api_key=config.api_key,
endpoint=inputs.schema_name,
team_id=inputs.team_id,
job_id=inputs.job_id,
resumable_source_manager=resumable_source_manager,
should_use_incremental_field=inputs.should_use_incremental_field,
db_incremental_field_last_value=inputs.db_incremental_field_last_value
if inputs.should_use_incremental_field
else None,
)
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.OMNI,
category=DataWarehouseSourceCategory.ANALYTICS,
label="Omni Analytics",
releaseStatus=ReleaseStatus.BETA,
caption="Sync documents, folders, connections, schedules, models, users, user groups, and access settings from your Omni instance.\n\nUse an **Organization API key** for full coverage (**Settings > API access**) — Personal Access Tokens only see content the token owner can access, and can't read the Users or User groups tables at all.",
docsUrl="https://posthog.com/docs/cdp/sources/omni",
iconPath="/static/services/omni.png",
keywords=["bi", "business intelligence"],
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="host",
label="Instance URL",
type=SourceFieldInputConfigType.TEXT,
required=True,
placeholder="https://your-company.omniapp.co",
secret=False,
),
SourceFieldInputConfig(
name="api_key",
label="API key",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="",
secret=True,
),
],
),
)