: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.render._config import RenderSourceConfig
from products.warehouse_sources.sources.render.render import (
KEY_FORBIDDEN_MESSAGE,
KEY_REJECTED_MESSAGE,
RenderResumeConfig,
render_source,
validate_credentials as validate_render_credentials,
)
from products.warehouse_sources.sources.render.settings import ENDPOINTS, INCREMENTAL_FIELDS, RENDER_ENDPOINTS
from products.warehouse_sources.sources.sdk import (
CanonicalDescriptions,
DataWarehouseSourceCategory,
ExternalDataSourceType,
FieldType,
ReleaseStatus,
ResumableSource,
ResumableSourceManager,
SourceConfig,
SourceFieldInputConfig,
SourceFieldInputConfigType,
SourceInputs,
SourceRegistry,
SourceResponse,
SourceSchema,
detect,
)
@SourceRegistry.register
class RenderSource(ResumableSource[RenderSourceConfig, RenderResumeConfig]):
# RENDER_ is a generic word in front-end code - exact key only.
codebase_detection = detect(env=("^RENDER_API_KEY$",))
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
supported_versions = ("v1",)
default_version = "v1"
api_docs_url = "https://api-docs.render.com/reference/introduction"
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.RENDER
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.RENDER,
category=DataWarehouseSourceCategory.ENGINEERING___MONITORING,
label="Render",
releaseStatus=ReleaseStatus.GA,
caption="""Enter your Render API key to pull your services, deploys, jobs, and databases into the PostHog Data warehouse.
You can create an API key in your [Render account settings](https://dashboard.render.com/settings#api-keys).
An API key grants access to every workspace your user belongs to. To sync a single workspace, set the optional workspace ID (found in your workspace settings, or via the `owners` table).
""",
iconPath="/static/services/render.svg",
docsUrl="https://posthog.com/docs/cdp/sources/render",
keywords=["cloud", "hosting", "deploys", "infrastructure"],
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="api_key",
label="API key",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="rnd_...",
secret=True,
),
SourceFieldInputConfig(
name="owner_id",
label="Workspace ID (optional)",
type=SourceFieldInputConfigType.TEXT,
required=False,
placeholder="tea-...",
secret=False,
),
],
),
)
def get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.sources.render.canonical_descriptions import CANONICAL_DESCRIPTIONS
return CANONICAL_DESCRIPTIONS
def get_non_retryable_errors(self) -> dict[str, str | None]:
# An invalid or revoked Render API key surfaces as a requests HTTPError when
# `_fetch_page` calls `raise_for_status()`. Retrying can never satisfy a credential
# problem, so stop the sync. Match the stable status text and base host, not the
# per-request path/query.
return {
"401 Client Error: Unauthorized for url: https://api.render.com": KEY_REJECTED_MESSAGE,
"403 Client Error: Forbidden for url: https://api.render.com": KEY_FORBIDDEN_MESSAGE,
}
def get_schemas(
self,
config: RenderSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
def _build_schema(endpoint: str) -> SourceSchema:
endpoint_config = RENDER_ENDPOINTS[endpoint]
has_incremental = bool(endpoint_config.incremental_fields)
return SourceSchema(
name=endpoint,
# Events are immutable, so append-only is the only incremental-style sync mode;
# every other resource mutates and needs merge semantics.
supports_incremental=has_incremental and not endpoint_config.append_only,
supports_append=has_incremental and endpoint_config.append_only,
incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),
should_sync_default=endpoint_config.should_sync_default,
)
schemas = [_build_schema(endpoint) for endpoint in ENDPOINTS]
if names is not None:
names_set = set(names)
schemas = [s for s in schemas if s.name in names_set]
return schemas
def validate_credentials(
self,
config: RenderSourceConfig,
team_id: int,
schema_name: Optional[str] = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
return validate_render_credentials(config.api_key)
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[RenderResumeConfig]:
return ResumableSourceManager[RenderResumeConfig](inputs, RenderResumeConfig)
def source_for_pipeline(
self,
config: RenderSourceConfig,
resumable_source_manager: ResumableSourceManager[RenderResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
return render_source(
api_key=config.api_key,
endpoint=inputs.schema_name,
logger=inputs.logger,
resumable_source_manager=resumable_source_manager,
owner_id=config.owner_id,
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,
incremental_field=inputs.incremental_field,
)