: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.confluence._config import ConfluenceSourceConfig
from products.warehouse_sources.sources.confluence.confluence import (
ConfluenceResumeConfig,
confluence_source,
validate_credentials as validate_confluence_credentials,
)
from products.warehouse_sources.sources.confluence.settings import ENDPOINTS, INCREMENTAL_FIELDS, SHOULD_SYNC_DEFAULT
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 ConfluenceSource(ResumableSource[ConfluenceSourceConfig, ConfluenceResumeConfig]):
codebase_detection = detect(env=("^CONFLUENCE_",), npm=("confluence.js",))
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
supported_versions = ("v2",)
default_version = "v2"
api_docs_url = "https://developer.atlassian.com/cloud/confluence/rest/v2/"
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.CONFLUENCE
@property
def connection_host_fields(self) -> list[str]:
# The API token is sent to <subdomain>.atlassian.net, so retargeting the
# subdomain must force re-entry of the token.
return ["subdomain"]
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.CONFLUENCE,
category=DataWarehouseSourceCategory.PRODUCTIVITY,
label="Confluence",
releaseStatus=ReleaseStatus.GA,
caption="""Enter your Atlassian Confluence Cloud credentials to pull your Confluence content into the PostHog Data warehouse.
Create an API token from your [Atlassian account settings](https://id.atlassian.com/manage-profile/security/api-tokens), then connect using the email address tied to that account.
Only Confluence Cloud sites (`your-domain.atlassian.net`) are supported.""",
iconPath="/static/services/confluence.png",
docsUrl="https://posthog.com/docs/cdp/sources/confluence",
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="subdomain",
label="Subdomain",
type=SourceFieldInputConfigType.TEXT,
required=True,
placeholder="your-domain",
secret=False,
),
SourceFieldInputConfig(
name="email",
label="Email",
type=SourceFieldInputConfigType.EMAIL,
required=True,
placeholder="[email protected]",
secret=False,
),
SourceFieldInputConfig(
name="api_token",
label="API token",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="",
secret=True,
),
],
),
)
def get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.sources.confluence.canonical_descriptions import CANONICAL_DESCRIPTIONS
return CANONICAL_DESCRIPTIONS
def get_schemas(
self,
config: ConfluenceSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
# v2 list endpoints have no server-side timestamp filter, so every endpoint is
# full refresh only (no incremental fields -> supports_incremental/append False).
return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names, should_sync_default=SHOULD_SYNC_DEFAULT)
def validate_credentials(
self,
config: ConfluenceSourceConfig,
team_id: int,
schema_name: Optional[str] = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
return validate_confluence_credentials(
subdomain=config.subdomain,
email=config.email,
api_token=config.api_token,
schema_name=schema_name,
)
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {
"401 Client Error: Unauthorized": "Your Confluence credentials are invalid or expired. Check your email and API token and reconnect.",
"403 Client Error: Forbidden": "Your Confluence account does not have permission to access this resource.",
}
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[ConfluenceResumeConfig]:
return ResumableSourceManager[ConfluenceResumeConfig](inputs, ConfluenceResumeConfig)
def source_for_pipeline(
self,
config: ConfluenceSourceConfig,
resumable_source_manager: ResumableSourceManager[ConfluenceResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
return confluence_source(
subdomain=config.subdomain,
email=config.email,
api_token=config.api_token,
endpoint=inputs.schema_name,
team_id=inputs.team_id,
job_id=inputs.job_id,
resumable_source_manager=resumable_source_manager,
)