: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.eventbrite._config import EventbriteSourceConfig
from products.warehouse_sources.sources.eventbrite.eventbrite import (
EventbriteResumeConfig,
eventbrite_source,
validate_credentials as validate_eventbrite_credentials,
)
from products.warehouse_sources.sources.eventbrite.settings import ENDPOINTS, INCREMENTAL_ENDPOINTS, INCREMENTAL_FIELDS
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 EventbriteSource(ResumableSource[EventbriteSourceConfig, EventbriteResumeConfig]):
codebase_detection = detect(
env=("^EVENTBRITE_",),
script_hosts=("www.eventbrite.com",),
npm=("eventbrite",),
pypi=("eventbrite",),
rubygems=("eventbrite_sdk",),
)
supported_versions = ("v3",)
default_version = "v3"
api_docs_url = "https://www.eventbrite.com/platform/api"
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.EVENTBRITE
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.EVENTBRITE,
category=DataWarehouseSourceCategory.PRODUCTIVITY,
label="Eventbrite",
releaseStatus=ReleaseStatus.GA,
caption="""Enter your Eventbrite private token to automatically pull your Eventbrite data into the PostHog Data warehouse.
You can create a private token under your [Eventbrite account settings](https://www.eventbrite.com/account-settings/apps) on the **API Keys** page (the **Private token** field of your API key).
The token needs read access to your organizations, events, orders, and attendees.
""",
iconPath="/static/services/eventbrite.png",
docsUrl="https://posthog.com/docs/cdp/sources/eventbrite",
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="api_token",
label="Private token",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="Your Eventbrite private token",
secret=True,
),
],
),
)
def get_schemas(
self,
config: EventbriteSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
schemas = [
SourceSchema(
name=endpoint,
supports_incremental=endpoint in INCREMENTAL_ENDPOINTS,
supports_append=endpoint in INCREMENTAL_ENDPOINTS,
incremental_fields=INCREMENTAL_FIELDS.get(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 get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.sources.eventbrite.canonical_descriptions import CANONICAL_DESCRIPTIONS
return CANONICAL_DESCRIPTIONS
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {
"401 Client Error: Unauthorized for url: https://www.eventbriteapi.com": "Your Eventbrite private token is invalid or has been revoked. Please generate a new token and reconnect.",
"403 Client Error: Forbidden for url: https://www.eventbriteapi.com": "Your Eventbrite private token does not have permission to access this resource. Please check the token's permissions and try again.",
}
def validate_credentials(
self,
config: EventbriteSourceConfig,
team_id: int,
schema_name: Optional[str] = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
if validate_eventbrite_credentials(config.api_token):
return True, None
return False, "Invalid Eventbrite private token"
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[EventbriteResumeConfig]:
return ResumableSourceManager[EventbriteResumeConfig](inputs, EventbriteResumeConfig)
def source_for_pipeline(
self,
config: EventbriteSourceConfig,
resumable_source_manager: ResumableSourceManager[EventbriteResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
return eventbrite_source(
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,
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,
)