: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.coassemble._config import CoassembleSourceConfig
from products.warehouse_sources.sources.coassemble.coassemble import (
CoassembleResumeConfig,
coassemble_source,
validate_credentials,
)
from products.warehouse_sources.sources.coassemble.settings import COASSEMBLE_ENDPOINTS, 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 CoassembleSource(ResumableSource[CoassembleSourceConfig, CoassembleResumeConfig]):
codebase_detection = detect(env=("^COASSEMBLE_",))
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
api_docs_url = "https://developers.coassemble.com"
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.COASSEMBLE
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.COASSEMBLE,
category=DataWarehouseSourceCategory.HR___RECRUITING,
label="Coassemble",
releaseStatus=ReleaseStatus.BETA,
keywords=["lms", "training", "courses"],
caption="""Enter your Coassemble workspace ID and API key to pull your courses, collections, learners, learner progress, and client usage into the PostHog Data warehouse.
You can generate an API key from your workspace API settings in [Coassemble](https://coassemble.com). API access must be enabled on your workspace plan.
""",
iconPath="/static/services/coassemble.png",
docsUrl="https://posthog.com/docs/cdp/sources/coassemble",
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="workspace_id",
label="Workspace ID",
type=SourceFieldInputConfigType.TEXT,
required=True,
placeholder="",
secret=False,
),
SourceFieldInputConfig(
name="api_key",
label="API key",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="",
secret=True,
),
],
),
)
def get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.sources.coassemble.canonical_descriptions import (
CANONICAL_DESCRIPTIONS, # noqa: PLC0415
)
return CANONICAL_DESCRIPTIONS
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {
"401 Client Error: Unauthorized for url: https://api.coassemble.com": "Your Coassemble workspace ID or API key is invalid or has been regenerated. Generate a new key in your workspace API settings, then reconnect.",
"403 Client Error: Forbidden for url: https://api.coassemble.com": "Your Coassemble API key does not have access to this data. Check that API access is enabled on your workspace plan, then reconnect.",
}
def get_schemas(
self,
config: CoassembleSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
# Every endpoint is full refresh only — see the rationale in settings.py.
return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)
def validate_credentials(
self,
config: CoassembleSourceConfig,
team_id: int,
schema_name: Optional[str] = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
# The API key is workspace-wide, so a single probe validates access to every schema.
return validate_credentials(config.workspace_id, config.api_key)
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[CoassembleResumeConfig]:
return ResumableSourceManager[CoassembleResumeConfig](inputs, CoassembleResumeConfig)
def source_for_pipeline(
self,
config: CoassembleSourceConfig,
resumable_source_manager: ResumableSourceManager[CoassembleResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
if inputs.schema_name not in COASSEMBLE_ENDPOINTS:
raise ValueError(f"Unknown Coassemble schema '{inputs.schema_name}'")
return coassemble_source(
workspace_id=config.workspace_id,
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,
)