: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.sdk import (
CanonicalDescriptions,
DataWarehouseSourceCategory,
ExternalDataSourceType,
FieldType,
ReleaseStatus,
ResumableSource,
ResumableSourceManager,
SourceConfig,
SourceFieldInputConfig,
SourceFieldInputConfigType,
SourceInputs,
SourceRegistry,
SourceResponse,
SourceSchema,
detect,
)
from products.warehouse_sources.sources.wrike._config import WrikeSourceConfig
from products.warehouse_sources.sources.wrike.settings import ENDPOINTS
from products.warehouse_sources.sources.wrike.wrike import (
WrikeResumeConfig,
validate_credentials as validate_wrike_credentials,
wrike_source,
)
@SourceRegistry.register
class WrikeSource(ResumableSource[WrikeSourceConfig, WrikeResumeConfig]):
codebase_detection = detect(env=("^WRIKE_",))
supported_versions = ("v4",)
default_version = "v4"
api_docs_url = "https://developers.wrike.com"
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.WRIKE
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.WRIKE,
category=DataWarehouseSourceCategory.PRODUCTIVITY,
label="Wrike",
releaseStatus=ReleaseStatus.GA,
caption="""Enter a Wrike permanent access token to pull your Wrike data into the PostHog Data warehouse.
Create a permanent access token under **Apps & Integrations → API** in Wrike. The token needs read access (the default `Default` scope is sufficient) to the resources you want to sync.
Set **Host** to the domain shown in your browser when you're logged into Wrike (e.g. `www.wrike.com`, `app-us2.wrike.com`, or `app-eu.wrike.com`).""",
iconPath="/static/services/wrike.png",
docsUrl="https://posthog.com/docs/cdp/sources/wrike",
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="access_token",
label="Permanent access token",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="",
secret=True,
),
SourceFieldInputConfig(
name="host",
label="Host",
type=SourceFieldInputConfigType.TEXT,
required=True,
placeholder="www.wrike.com",
secret=False,
),
],
),
)
def get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.sources.wrike.canonical_descriptions import CANONICAL_DESCRIPTIONS
return CANONICAL_DESCRIPTIONS
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {
"401 Client Error": "Invalid or expired Wrike access token. Please generate a new token and reconnect.",
"403 Client Error": "Your Wrike access token does not have the required permissions for this resource.",
}
def get_schemas(
self,
config: WrikeSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
# Wrike's API has no reliably-verifiable server-side timestamp filter, so every endpoint
# ships as full refresh (see settings.py for the rationale).
schemas = [
SourceSchema(
name=endpoint,
supports_incremental=False,
supports_append=False,
incremental_fields=[],
)
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: WrikeSourceConfig, team_id: int, schema_name: Optional[str] = None, api_version: str | None = None
) -> tuple[bool, str | None]:
return validate_wrike_credentials(config.access_token, config.host)
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[WrikeResumeConfig]:
return ResumableSourceManager[WrikeResumeConfig](inputs, WrikeResumeConfig)
def source_for_pipeline(
self,
config: WrikeSourceConfig,
resumable_source_manager: ResumableSourceManager[WrikeResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
return wrike_source(
access_token=config.access_token,
host=config.host,
endpoint=inputs.schema_name,
team_id=inputs.team_id,
job_id=inputs.job_id,
resumable_source_manager=resumable_source_manager,
db_incremental_field_last_value=None, # every Wrike endpoint is full refresh
)