: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
feat(data-warehouse): implement attentive import source (#62998)
Tom Owers2c53e4e0cb7e
diff --git a/posthog/temporal/data_imports/sources/SOURCES.md b/posthog/temporal/data_imports/sources/SOURCES.mdindex 3b5cba5c79ca..72d332cbff5f 100644--- a/posthog/temporal/data_imports/sources/SOURCES.md+++ b/posthog/temporal/data_imports/sources/SOURCES.md@@ -53,6 +53,7 @@ the row lists both.| appsflyer | HTTP (CSV reports) | requests | ✅ || asana | HTTP | requests | ✅ || ashby | HTTP | requests | ✅ |+| attentive | HTTP (webhook-first) | requests (webhook management) | ✅ || attio | HTTP | requests + `rest_source.RESTClient` | ✅ || azure_devops | HTTP | requests | ✅ || bamboohr | HTTP | requests | ✅ |@@ -229,7 +230,6 @@ doesn't conflict with concurrent PRs.- amazon_sns- amazon_sqs- apple_search_ads-- attentive- auth0- azure_blob- bigcommercediff --git a/posthog/temporal/data_imports/sources/attentive/api_client.py b/posthog/temporal/data_imports/sources/attentive/api_client.pynew file mode 100644index 000000000000..ec49b384c86b--- /dev/null+++ b/posthog/temporal/data_imports/sources/attentive/api_client.py@@ -0,0 +1,263 @@+"""Thin client for the Attentive REST API endpoints used by the data warehouse source.++Spec: https://docs.attentive.com/openapi/reference/+Attentive's public API is write-oriented; the only endpoints this source needs+are webhook management (`/v1/webhooks`) and the token probe (`/v2/me`).+"""++from typing import Any++import requests+import structlog++from posthog.temporal.data_imports.sources.attentive.constants import (+ ATTENTIVE_API_ORIGIN,+ ATTENTIVE_V1_BASE_URL,+ RESOURCE_TO_ATTENTIVE_EVENT_TYPE,+)+from posthog.temporal.data_imports.sources.common.base import (+ ExternalWebhookInfo,+ WebhookCreationResult,+ WebhookDeletionResult,+ WebhookSyncResult,+)+from posthog.temporal.data_imports.sources.common.http import make_tracked_session++LOGGER = structlog.get_logger(__name__)++WEBHOOKS_URL = f"{ATTENTIVE_V1_BASE_URL}/webhooks"+REQUEST_TIMEOUT_SECONDS = 30+++def _session(api_key: str) -> requests.Session:+ return make_tracked_session(+ headers={+ "Authorization": f"Bearer {api_key}",+ "Accept": "application/json",+ "Content-Type": "application/json",+ },+ redact_values=(api_key,),+ )+++def _events_for_resources(resource_names: list[str]) -> list[str]:+ events: list[str] = []+ for resource in resource_names:+ event = RESOURCE_TO_ATTENTIVE_EVENT_TYPE.get(resource)+ if event is not None and event not in events:+ events.append(event)+ return events+++def _format_http_error(error: requests.HTTPError) -> str:+ status_code = error.response.status_code+ if status_code == 401:+ return (+ "Attentive rejected the API key (401). Create a private app under Marketplace > "+ "Create app in Attentive and use its API key."+ )+ if status_code == 403:+ return "Attentive denied the request (403). Make sure the private app has the Webhooks permission."+ if status_code == 429:+ return "Attentive rate-limited the request (429). Try again in a few seconds."+ return f"Attentive API error ({status_code})."+++def validate_credentials(api_key: str) -> tuple[bool, str | None]:+ """Validate the API key against Attentive's token-probe endpoint."""+ try:+ response = _session(api_key).get(f"{ATTENTIVE_API_ORIGIN}/v2/me", timeout=REQUEST_TIMEOUT_SECONDS)+ if response.status_code == 404:+ response = _session(api_key).get(f"{ATTENTIVE_V1_BASE_URL}/me", timeout=REQUEST_TIMEOUT_SECONDS)+ response.raise_for_status()+ except requests.HTTPError as e:+ return False, _format_http_error(e)+ except requests.RequestException as e:+ return False, f"Could not reach Attentive: {e}"+ return True, None+++def _list_webhooks(api_key: str) -> list[dict[str, Any]]:+ response = _session(api_key).get(WEBHOOKS_URL, timeout=REQUEST_TIMEOUT_SECONDS)+ response.raise_for_status()+ payload = response.json() or {}+ raw = payload.get("webhooks") or []+ return [hook for hook in raw if isinstance(hook, dict)]+++def _find_webhook_by_url(webhooks: list[dict[str, Any]], webhook_url: str) -> dict[str, Any] | None:+ for hook in webhooks:+ if hook.get("url") == webhook_url:+ return hook+ return None+++def create_webhook(api_key: str, webhook_url: str, resource_names: list[str]) -> WebhookCreationResult:+ events = _events_for_resources(resource_names)+ if not events:+ supported = ", ".join(RESOURCE_TO_ATTENTIVE_EVENT_TYPE.keys())+ return WebhookCreationResult(+ success=False,+ error=f"None of the selected tables map to Attentive webhook events. Choose at least one of: {supported}.",+ )++ try:+ existing = _find_webhook_by_url(_list_webhooks(api_key), webhook_url)+ if existing is not None:+ # Webhook already exists for this URL — treat as success so the user+ # can finish setup by entering the signing key.+ return WebhookCreationResult(success=True, pending_inputs=["signing_secret"])++ session = _session(api_key)+ response = session.post(+ WEBHOOKS_URL,+ json={"url": webhook_url, "events": events},+ timeout=REQUEST_TIMEOUT_SECONDS,+ )+ response.raise_for_status()++ # Attentive has no create-disabled option, so immediately disable the+ # webhook until the user provides the signing key — otherwise events+ # would fire at PostHog before deliveries can be verified.+ webhook_id = (response.json() or {}).get("id")+ if not webhook_id:+ # The create response occasionally omits the id; look it up by URL so+ # we can still disable it rather than leaving an active webhook behind.+ created = _find_webhook_by_url(_list_webhooks(api_key), webhook_url)+ webhook_id = created.get("id") if created else None+ if not webhook_id:+ LOGGER.warning("Attentive webhook created but no id was returned; cannot disable it")+ return WebhookCreationResult(+ success=False,+ error=(+ "Attentive created the webhook but did not return its id, so it could not be disabled "+ "for signing-key setup. Please disable or delete the webhook in Attentive and try again."+ ),+ )+ session.put(+ f"{WEBHOOKS_URL}/{webhook_id}",+ json={"url": webhook_url, "events": events, "disabled": True},+ timeout=REQUEST_TIMEOUT_SECONDS,+ ).raise_for_status()+ except requests.HTTPError as e:+ LOGGER.warning("Failed to create Attentive webhook", error=str(e))+ return WebhookCreationResult(success=False, error=_format_http_error(e))+ except requests.RequestException as e:+ LOGGER.warning("Could not reach Attentive to create webhook", error=str(e))+ return WebhookCreationResult(success=False, error=f"Could not reach Attentive: {e}")++ # Attentive does NOT return the signing key in the create response — the+ # user has to copy it from the webhook's settings in the Attentive UI.+ return WebhookCreationResult(success=True, pending_inputs=["signing_secret"])+++def enable_webhook(api_key: str, webhook_url: str) -> tuple[bool, str | None]:+ """Re-enable the webhook once the user has provided the signing key."""+ try:+ existing = _find_webhook_by_url(_list_webhooks(api_key), webhook_url)+ if existing is None:+ return False, "No webhook found for this URL in Attentive."++ webhook_id = existing.get("id")+ if webhook_id is None:+ return False, "Attentive returned a webhook without an id; please enable it manually."++ _session(api_key).put(+ f"{WEBHOOKS_URL}/{webhook_id}",+ json={"url": webhook_url, "events": existing.get("events") or [], "disabled": False},+ timeout=REQUEST_TIMEOUT_SECONDS,+ ).raise_for_status()+ except requests.HTTPError as e:+ LOGGER.warning("Failed to enable Attentive webhook", error=str(e))+ return False, _format_http_error(e)+ except requests.RequestException as e:+ LOGGER.warning("Could not reach Attentive to enable webhook", error=str(e))+ return False, f"Could not reach Attentive: {e}"++ return True, None+++def sync_webhook_events(api_key: str, webhook_url: str, resource_names: list[str]) -> WebhookSyncResult:+ """Reconcile the webhook's subscribed events with the selected schemas."""+ desired = _events_for_resources(resource_names)+ if not desired:+ return WebhookSyncResult(success=False, error="No selected tables map to Attentive webhook events.")++ try:+ existing = _find_webhook_by_url(_list_webhooks(api_key), webhook_url)+ if existing is None:+ return WebhookSyncResult(success=False, error="No webhook found for this URL in Attentive.")++ current = existing.get("events") or []+ if set(current) == set(desired):+ return WebhookSyncResult(success=True)++ webhook_id = existing.get("id")+ if webhook_id is None:+ return WebhookSyncResult(success=False, error="Attentive returned a webhook without an id.")++ # Preserve the webhook's current disabled state — an events-only sync+ # must not silently re-enable a webhook that is still awaiting its signing key.+ _session(api_key).put(+ f"{WEBHOOKS_URL}/{webhook_id}",+ json={"url": webhook_url, "events": desired, "disabled": existing.get("disabledAt") is not None},+ timeout=REQUEST_TIMEOUT_SECONDS,+ ).raise_for_status()+ except requests.HTTPError as e:+ LOGGER.warning("Failed to sync Attentive webhook events", error=str(e))+ return WebhookSyncResult(success=False, error=_format_http_error(e))+ except requests.RequestException as e:+ LOGGER.warning("Could not reach Attentive to sync webhook events", error=str(e))+ return WebhookSyncResult(success=False, error=f"Could not reach Attentive: {e}")++ return WebhookSyncResult(success=True)+++def delete_webhook(api_key: str, webhook_url: str) -> WebhookDeletionResult:+ try:+ existing = _find_webhook_by_url(_list_webhooks(api_key), webhook_url)+ if existing is None:+ return WebhookDeletionResult(success=True)++ webhook_id = existing.get("id")+ if webhook_id is None:+ return WebhookDeletionResult(+ success=False, error="Attentive returned a webhook without an id; please delete it manually."+ )++ response = _session(api_key).delete(f"{WEBHOOKS_URL}/{webhook_id}", timeout=REQUEST_TIMEOUT_SECONDS)+ if response.status_code == 404:+ return WebhookDeletionResult(success=True)+ response.raise_for_status()+ except requests.HTTPError as e:+ LOGGER.warning("Failed to delete Attentive webhook", error=str(e))+ return WebhookDeletionResult(success=False, error=_format_http_error(e))+ except requests.RequestException as e:+ LOGGER.warning("Could not reach Attentive to delete webhook", error=str(e))+ return WebhookDeletionResult(success=False, error=f"Could not reach Attentive: {e}")++ return WebhookDeletionResult(success=True)+++def get_external_webhook_info(api_key: str, webhook_url: str) -> ExternalWebhookInfo:+ try:+ webhooks = _list_webhooks(api_key)+ except requests.HTTPError as e:+ return ExternalWebhookInfo(exists=False, error=_format_http_error(e))+ except requests.RequestException as e:+ return ExternalWebhookInfo(exists=False, error=f"Could not reach Attentive: {e}")++ existing = _find_webhook_by_url(webhooks, webhook_url)+ if existing is None:+ return ExternalWebhookInfo(exists=False)++ enabled_events = existing.get("events")+ if not isinstance(enabled_events, list):+ enabled_events = None++ return ExternalWebhookInfo(+ exists=True,+ url=existing.get("url"),+ enabled_events=enabled_events,+ status="disabled" if existing.get("disabledAt") else "enabled",+ )diff --git a/posthog/temporal/data_imports/sources/attentive/constants.py b/posthog/temporal/data_imports/sources/attentive/constants.pynew file mode 100644index 000000000000..c3ff27c0b549--- /dev/null+++ b/posthog/temporal/data_imports/sources/attentive/constants.py@@ -0,0 +1,21 @@+ATTENTIVE_API_ORIGIN = "https://api.attentivemobile.com"+ATTENTIVE_V1_BASE_URL = f"{ATTENTIVE_API_ORIGIN}/v1"++# Maps PostHog webhook-backed schema name -> Attentive webhook event `type`+# value. The webhook payload's top-level `type` field is matched against this+# map's values (via `webhook_resource_map` on the source) to route incoming+# events into the right warehouse table. Attentive's public REST API is+# write-oriented (no list-subscribers/messages/campaigns endpoints), so+# webhooks are the only extraction surface — there is no backfill path.+RESOURCE_TO_ATTENTIVE_EVENT_TYPE: dict[str, str] = {+ "sms_subscribed": "sms.subscribed",+ "sms_sent": "sms.sent",+ "sms_message_link_click": "sms.message_link_click",+ "email_subscribed": "email.subscribed",+ "email_unsubscribed": "email.unsubscribed",+ "email_opened": "email.opened",+ "email_message_link_click": "email.message_link_click",+ "custom_attribute_set": "custom_attribute.set",+}++ATTENTIVE_WEBHOOK_SCHEMA_NAMES: tuple[str, ...] = tuple(RESOURCE_TO_ATTENTIVE_EVENT_TYPE.keys())diff --git a/posthog/temporal/data_imports/sources/attentive/source.py b/posthog/temporal/data_imports/sources/attentive/source.pyindex 91818b64a3d3..b1d078bb5064 100644--- a/posthog/temporal/data_imports/sources/attentive/source.py+++ b/posthog/temporal/data_imports/sources/attentive/source.py@@ -1,29 +1,244 @@-from typing import cast+import hashlib+from collections.abc import AsyncIterable, Iterable+from typing import TYPE_CHECKING, Any, Optional, cast++import orjson+import pyarrow as pa+from asgiref.sync import async_to_syncfrom posthog.schema import (ExternalDataSourceType as SchemaExternalDataSourceType,+ ReleaseStatus,SourceConfig,+ SourceFieldInputConfig,+ SourceFieldInputConfigType,)-from posthog.temporal.data_imports.sources.common.base import FieldType, SimpleSource+from posthog.temporal.data_imports.pipelines.pipeline.typings import SourceInputs, SourceResponse+from posthog.temporal.data_imports.pipelines.pipeline.utils import table_from_py_list+from posthog.temporal.data_imports.sources.attentive import api_client+from posthog.temporal.data_imports.sources.attentive.constants import (+ ATTENTIVE_WEBHOOK_SCHEMA_NAMES,+ RESOURCE_TO_ATTENTIVE_EVENT_TYPE,+)+from posthog.temporal.data_imports.sources.common.base import (+ ExternalWebhookInfo,+ FieldType,+ SimpleSource,+ WebhookCreationResult,+ WebhookDeletionResult,+ WebhookSource,+ WebhookSyncResult,+)from posthog.temporal.data_imports.sources.common.registry import SourceRegistry+from posthog.temporal.data_imports.sources.common.schema import SourceSchema+from posthog.temporal.data_imports.sources.common.webhook_s3 import WebhookSourceManagerfrom posthog.temporal.data_imports.sources.generated_configs import AttentiveSourceConfigfrom products.data_warehouse.backend.types import ExternalDataSourceType+if TYPE_CHECKING:+ from posthog.cdp.templates.hog_function_template import HogFunctionTemplateDC+++def _webhook_table_transformer(table: pa.Table) -> pa.Table:+ """Add a synthetic ``event_id`` and a ``created_at`` partition column.++ Attentive webhook payloads carry no top-level event id, so we derive a+ stable hash of the full payload — identical retried deliveries dedupe to+ the same row. ``created_at`` (Unix seconds) is derived from Attentive's+ millisecond ``timestamp`` for datetime partitioning.+ """+ rows: list[dict[str, Any]] = []+ for row in table.to_pylist():+ row = dict(row)+ # nosemgrep: python.lang.security.insecure-hash-algorithms-md5.insecure-hash-algorithm-md5+ row["event_id"] = hashlib.md5(orjson.dumps(row, option=orjson.OPT_SORT_KEYS, default=str)).hexdigest()+ timestamp_ms = row.get("timestamp")+ if isinstance(timestamp_ms, int) and not isinstance(timestamp_ms, bool):+ row["created_at"] = timestamp_ms // 1000+ rows.append(row)++ return table_from_py_list(rows)+@SourceRegistry.register-class AttentiveSource(SimpleSource[AttentiveSourceConfig]):+class AttentiveSource(+ SimpleSource[AttentiveSourceConfig],+ WebhookSource[AttentiveSourceConfig],+):@propertydef source_type(self) -> ExternalDataSourceType:return ExternalDataSourceType.ATTENTIVE+ @property+ def webhook_template(self) -> Optional["HogFunctionTemplateDC"]:+ from posthog.temporal.data_imports.sources.attentive.webhook_template import template++ return template++ @property+ def webhook_resource_map(self) -> dict[str, str]:+ return RESOURCE_TO_ATTENTIVE_EVENT_TYPE+@propertydef get_source_config(self) -> SourceConfig:return SourceConfig(name=SchemaExternalDataSourceType.ATTENTIVE,label="Attentive",+ caption=(+ "Connect your Attentive account using a private app API key (Marketplace > Create app). "+ "Attentive's API has no bulk read endpoints, so all tables are populated from webhook "+ "events as they happen — history before the connection date is not backfilled."+ ),iconPath="/static/services/attentive.com.png",- fields=cast(list[FieldType], []),- unreleasedSource=True,+ docsUrl="https://posthog.com/docs/cdp/sources/attentive",+ releaseStatus=ReleaseStatus.ALPHA,+ fields=cast(+ list[FieldType],+ [+ SourceFieldInputConfig(+ name="api_key",+ label="API key",+ type=SourceFieldInputConfigType.PASSWORD,+ required=True,+ placeholder="Attentive private app API key",+ secret=True,+ ),+ ],+ ),+ webhookSetupCaption=(+ "PostHog tries to register the webhook for you using your API key. Attentive doesn't "+ "return the signing key in the API response, so you still need to copy it from the "+ "webhook's settings in Attentive and paste it below."+ "\n\n**Manual setup** (only needed if auto-registration failed):\n\n"+ "1. In Attentive, go to **Marketplace** > your private app > **Webhooks**\n"+ "2. Paste the webhook URL shown below into the **Destination URL** field\n"+ "3. Select the events you want to track (SMS, email, custom attributes)\n"+ "4. Save the webhook\n\n"+ "Then copy the webhook's **signing key** into the field below."+ ),+ webhookFields=cast(+ list[FieldType],+ [+ SourceFieldInputConfig(+ name="signing_secret",+ label="Signing key",+ type=SourceFieldInputConfigType.PASSWORD,+ required=True,+ placeholder="Attentive webhook signing key",+ secret=True,+ ),+ ],+ ),+ )++ def validate_credentials(+ self, config: AttentiveSourceConfig, team_id: int, schema_name: Optional[str] = None+ ) -> tuple[bool, str | None]:+ return api_client.validate_credentials(config.api_key)++ def get_non_retryable_errors(self) -> dict[str, str | None]:+ return {+ "401 Client Error: Unauthorized": (+ "Attentive rejected the API key. Create a private app under Marketplace > Create app "+ "in Attentive and reconnect with its API key."+ ),+ "403 Client Error: Forbidden": (+ "The API key doesn't have permission for this endpoint. Make sure the private app has "+ "the Webhooks permission."+ ),+ }++ def get_schemas(+ self,+ config: AttentiveSourceConfig,+ team_id: int,+ with_counts: bool = False,+ names: list[str] | None = None,+ force_refresh: bool = False,+ ) -> list[SourceSchema]:+ # All tables are webhook-only: Attentive's REST API has no list+ # endpoints to poll, so user-facing append/full-refresh toggles don't+ # apply and there is nothing for the polling sync to fetch.+ schemas = [+ SourceSchema(+ name=name,+ supports_incremental=False,+ supports_append=False,+ supports_webhooks=True,+ incremental_fields=[],+ )+ for name in ATTENTIVE_WEBHOOK_SCHEMA_NAMES+ ]+ 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_webhook_source_manager(self, inputs: SourceInputs) -> WebhookSourceManager:+ return WebhookSourceManager(inputs, inputs.logger)++ def create_webhook(self, config: AttentiveSourceConfig, webhook_url: str, team_id: int) -> WebhookCreationResult:+ return api_client.create_webhook(+ api_key=config.api_key,+ webhook_url=webhook_url,+ resource_names=list(RESOURCE_TO_ATTENTIVE_EVENT_TYPE.keys()),+ )++ def webhook_inputs_updated(+ self, config: AttentiveSourceConfig, webhook_url: str, team_id: int, inputs: dict[str, Any]+ ) -> tuple[bool, str | None]:+ # The webhook is disabled right after creation so Attentive doesn't+ # fire events at PostHog before we can verify them with the signing+ # key. Now that the user has provided the key, enable the webhook.+ if not inputs.get("signing_secret"):+ return True, None+ return api_client.enable_webhook(config.api_key, webhook_url)++ def get_desired_webhook_events(+ self, config: AttentiveSourceConfig, eligible_schema_names: list[str]+ ) -> list[str] | None:+ return [+ RESOURCE_TO_ATTENTIVE_EVENT_TYPE[name]+ for name in eligible_schema_names+ if name in RESOURCE_TO_ATTENTIVE_EVENT_TYPE+ ]++ def sync_webhook_events(+ self,+ config: AttentiveSourceConfig,+ webhook_url: str,+ team_id: int,+ eligible_schema_names: list[str],+ ) -> WebhookSyncResult:+ return api_client.sync_webhook_events(config.api_key, webhook_url, eligible_schema_names)++ def get_external_webhook_info(+ self, config: AttentiveSourceConfig, webhook_url: str, team_id: int+ ) -> ExternalWebhookInfo | None:+ return api_client.get_external_webhook_info(config.api_key, webhook_url)++ def delete_webhook(self, config: AttentiveSourceConfig, webhook_url: str, team_id: int) -> WebhookDeletionResult:+ return api_client.delete_webhook(config.api_key, webhook_url)++ def source_for_pipeline(self, config: AttentiveSourceConfig, inputs: SourceInputs) -> SourceResponse:+ webhook_source_manager = self.get_webhook_source_manager(inputs)+ webhook_enabled = async_to_sync(webhook_source_manager.webhook_enabled)(True)++ def items() -> Iterable[Any] | AsyncIterable[Any]:+ if webhook_enabled:+ return webhook_source_manager.get_items(table_transformer=_webhook_table_transformer)+ return iter([])++ return SourceResponse(+ items=items,+ primary_keys=["event_id"],+ name=inputs.schema_name,+ sort_mode="asc",+ partition_count=1,+ partition_size=1,+ partition_mode="datetime",+ partition_format="week",+ partition_keys=["created_at"],)diff --git a/posthog/temporal/data_imports/sources/attentive/tests/test_attentive_api_client.py b/posthog/temporal/data_imports/sources/attentive/tests/test_attentive_api_client.pynew file mode 100644index 000000000000..16f535d89bee--- /dev/null+++ b/posthog/temporal/data_imports/sources/attentive/tests/test_attentive_api_client.py@@ -0,0 +1,289 @@+from typing import Any++import pytest+from unittest import mock++import requests++from posthog.temporal.data_imports.sources.attentive import api_client++_MODULE = "posthog.temporal.data_imports.sources.attentive.api_client"+++def _response(status_code: int = 200, body: Any = None) -> mock.MagicMock:+ resp = mock.MagicMock()+ resp.status_code = status_code+ resp.json.return_value = body if body is not None else {}+ if status_code >= 400:+ error = requests.HTTPError(response=resp)+ resp.raise_for_status.side_effect = error+ else:+ resp.raise_for_status.return_value = None+ return resp+++class TestEventsForResources:+ def test_maps_resources_to_event_types(self):+ events = api_client._events_for_resources(["sms_sent", "email_opened"])+ assert events == ["sms.sent", "email.opened"]++ def test_unknown_resources_are_skipped(self):+ assert api_client._events_for_resources(["nope", "sms_sent"]) == ["sms.sent"]++ def test_duplicates_collapse(self):+ assert api_client._events_for_resources(["sms_sent", "sms_sent"]) == ["sms.sent"]+++class TestValidateCredentials:+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_valid_token(self, mock_session):+ mock_session.return_value.get.return_value = _response(200, {"companyId": "c1"})++ ok, error = api_client.validate_credentials("key")++ assert ok is True+ assert error is None++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_invalid_token(self, mock_session):+ mock_session.return_value.get.return_value = _response(401)++ ok, error = api_client.validate_credentials("key")++ assert ok is False+ assert "rejected the API key" in (error or "")++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_falls_back_to_v1_me_on_404(self, mock_session):+ mock_session.return_value.get.side_effect = [_response(404), _response(200)]++ ok, _error = api_client.validate_credentials("key")++ assert ok is True+ urls = [call.args[0] for call in mock_session.return_value.get.call_args_list]+ assert urls == ["https://api.attentivemobile.com/v2/me", "https://api.attentivemobile.com/v1/me"]+++class TestCreateWebhook:+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_creates_then_disables_until_signing_key_provided(self, mock_session):+ mock_session.return_value.get.return_value = _response(200, {"webhooks": []})+ mock_session.return_value.post.return_value = _response(201, {"id": "wh-1"})+ mock_session.return_value.put.return_value = _response(200, {"id": "wh-1"})++ result = api_client.create_webhook("key", "https://ph.example/webhook", ["sms_sent", "email_opened"])++ assert result.success is True+ assert result.pending_inputs == ["signing_secret"]+ post_body = mock_session.return_value.post.call_args.kwargs["json"]+ assert post_body == {"url": "https://ph.example/webhook", "events": ["sms.sent", "email.opened"]}+ put_body = mock_session.return_value.put.call_args.kwargs["json"]+ assert put_body["disabled"] is True++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_existing_webhook_short_circuits(self, mock_session):+ mock_session.return_value.get.return_value = _response(+ 200, {"webhooks": [{"id": "wh-1", "url": "https://ph.example/webhook"}]}+ )++ result = api_client.create_webhook("key", "https://ph.example/webhook", ["sms_sent"])++ assert result.success is True+ assert result.pending_inputs == ["signing_secret"]+ mock_session.return_value.post.assert_not_called()++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_looks_up_id_when_create_response_omits_it(self, mock_session):+ # First GET checks for an existing webhook (none); second GET is the+ # fallback lookup after the create response omits the id.+ mock_session.return_value.get.side_effect = [+ _response(200, {"webhooks": []}),+ _response(200, {"webhooks": [{"id": "wh-9", "url": "https://ph.example/webhook"}]}),+ ]+ mock_session.return_value.post.return_value = _response(201, {})+ mock_session.return_value.put.return_value = _response(200)++ result = api_client.create_webhook("key", "https://ph.example/webhook", ["sms_sent"])++ assert result.success is True+ put_url = mock_session.return_value.put.call_args.args[0]+ assert put_url.endswith("/wh-9")+ assert mock_session.return_value.put.call_args.kwargs["json"]["disabled"] is True++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_fails_when_created_webhook_cannot_be_disabled(self, mock_session):+ mock_session.return_value.get.side_effect = [+ _response(200, {"webhooks": []}),+ _response(200, {"webhooks": []}),+ ]+ mock_session.return_value.post.return_value = _response(201, {})++ result = api_client.create_webhook("key", "https://ph.example/webhook", ["sms_sent"])++ assert result.success is False+ assert "could not be disabled" in (result.error or "")+ mock_session.return_value.put.assert_not_called()++ def test_no_mappable_resources_fails(self):+ result = api_client.create_webhook("key", "https://ph.example/webhook", ["unknown_table"])+ assert result.success is False+ assert "None of the selected tables" in (result.error or "")++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_http_error_surfaces_friendly_message(self, mock_session):+ mock_session.return_value.get.return_value = _response(200, {"webhooks": []})+ mock_session.return_value.post.return_value = _response(403)++ result = api_client.create_webhook("key", "https://ph.example/webhook", ["sms_sent"])++ assert result.success is False+ assert "denied the request" in (result.error or "")+++class TestEnableWebhook:+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_enables_matching_webhook(self, mock_session):+ mock_session.return_value.get.return_value = _response(+ 200, {"webhooks": [{"id": "wh-1", "url": "https://ph.example/webhook", "events": ["sms.sent"]}]}+ )+ mock_session.return_value.put.return_value = _response(200)++ ok, error = api_client.enable_webhook("key", "https://ph.example/webhook")++ assert ok is True+ assert error is None+ put_body = mock_session.return_value.put.call_args.kwargs["json"]+ assert put_body == {"url": "https://ph.example/webhook", "events": ["sms.sent"], "disabled": False}++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_missing_webhook_fails(self, mock_session):+ mock_session.return_value.get.return_value = _response(200, {"webhooks": []})++ ok, error = api_client.enable_webhook("key", "https://ph.example/webhook")++ assert ok is False+ assert "No webhook found" in (error or "")+++class TestSyncWebhookEvents:+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_noop_when_events_already_match(self, mock_session):+ mock_session.return_value.get.return_value = _response(+ 200, {"webhooks": [{"id": "wh-1", "url": "https://ph.example/webhook", "events": ["sms.sent"]}]}+ )++ result = api_client.sync_webhook_events("key", "https://ph.example/webhook", ["sms_sent"])++ assert result.success is True+ mock_session.return_value.put.assert_not_called()++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_updates_events_when_drifted(self, mock_session):+ mock_session.return_value.get.return_value = _response(+ 200, {"webhooks": [{"id": "wh-1", "url": "https://ph.example/webhook", "events": ["sms.sent"]}]}+ )+ mock_session.return_value.put.return_value = _response(200)++ result = api_client.sync_webhook_events("key", "https://ph.example/webhook", ["sms_sent", "email_opened"])++ assert result.success is True+ put_body = mock_session.return_value.put.call_args.kwargs["json"]+ assert put_body == {+ "url": "https://ph.example/webhook",+ "events": ["sms.sent", "email.opened"],+ "disabled": False,+ }++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_preserves_disabled_state_when_drifted(self, mock_session):+ mock_session.return_value.get.return_value = _response(+ 200,+ {+ "webhooks": [+ {+ "id": "wh-1",+ "url": "https://ph.example/webhook",+ "events": ["sms.sent"],+ "disabledAt": "2024-01-01 00:00:00",+ }+ ]+ },+ )+ mock_session.return_value.put.return_value = _response(200)++ result = api_client.sync_webhook_events("key", "https://ph.example/webhook", ["sms_sent", "email_opened"])++ assert result.success is True+ assert mock_session.return_value.put.call_args.kwargs["json"]["disabled"] is True++ def test_no_mappable_schemas_fails(self):+ result = api_client.sync_webhook_events("key", "https://ph.example/webhook", [])+ assert result.success is False+++class TestDeleteWebhook:+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_deletes_matching_webhook(self, mock_session):+ mock_session.return_value.get.return_value = _response(+ 200, {"webhooks": [{"id": "wh-1", "url": "https://ph.example/webhook"}]}+ )+ mock_session.return_value.delete.return_value = _response(204)++ result = api_client.delete_webhook("key", "https://ph.example/webhook")++ assert result.success is True+ delete_url = mock_session.return_value.delete.call_args.args[0]+ assert delete_url == "https://api.attentivemobile.com/v1/webhooks/wh-1"++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_missing_webhook_is_success(self, mock_session):+ mock_session.return_value.get.return_value = _response(200, {"webhooks": []})++ assert api_client.delete_webhook("key", "https://ph.example/webhook").success is True++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_404_on_delete_is_success(self, mock_session):+ mock_session.return_value.get.return_value = _response(+ 200, {"webhooks": [{"id": "wh-1", "url": "https://ph.example/webhook"}]}+ )+ delete_resp = mock.MagicMock()+ delete_resp.status_code = 404+ mock_session.return_value.delete.return_value = delete_resp++ assert api_client.delete_webhook("key", "https://ph.example/webhook").success is True+++class TestGetExternalWebhookInfo:+ @pytest.mark.parametrize(+ "webhook, expected_status",+ [+ ({"id": "wh-1", "url": "https://ph.example/webhook", "events": ["sms.sent"]}, "enabled"),+ (+ {+ "id": "wh-1",+ "url": "https://ph.example/webhook",+ "events": ["sms.sent"],+ "disabledAt": "2024-01-01 00:00:00",+ },+ "disabled",+ ),+ ],+ )+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_reports_status(self, mock_session, webhook, expected_status):+ mock_session.return_value.get.return_value = _response(200, {"webhooks": [webhook]})++ info = api_client.get_external_webhook_info("key", "https://ph.example/webhook")++ assert info.exists is True+ assert info.status == expected_status+ assert info.enabled_events == ["sms.sent"]++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_missing_webhook(self, mock_session):+ mock_session.return_value.get.return_value = _response(200, {"webhooks": []})++ info = api_client.get_external_webhook_info("key", "https://ph.example/webhook")++ assert info.exists is False+ assert info.error is Nonediff --git a/posthog/temporal/data_imports/sources/attentive/tests/test_attentive_source.py b/posthog/temporal/data_imports/sources/attentive/tests/test_attentive_source.pynew file mode 100644index 000000000000..2fe4cb07fd31--- /dev/null+++ b/posthog/temporal/data_imports/sources/attentive/tests/test_attentive_source.py@@ -0,0 +1,152 @@+from collections.abc import Iterable+from typing import Any, cast++from unittest import mock++from posthog.schema import ReleaseStatus, SourceFieldInputConfig, SourceFieldInputConfigType++from posthog.temporal.data_imports.pipelines.pipeline.utils import table_from_py_list+from posthog.temporal.data_imports.sources.attentive.constants import (+ ATTENTIVE_WEBHOOK_SCHEMA_NAMES,+ RESOURCE_TO_ATTENTIVE_EVENT_TYPE,+)+from posthog.temporal.data_imports.sources.attentive.source import AttentiveSource, _webhook_table_transformer+from posthog.temporal.data_imports.sources.generated_configs import AttentiveSourceConfig++from products.data_warehouse.backend.types import ExternalDataSourceType+++class TestWebhookTableTransformer:+ def test_adds_stable_event_id_and_created_at(self):+ row = {"type": "sms.sent", "timestamp": 1632945178104, "subscriber": {"phone": "+15555555555"}}+ table = table_from_py_list([row])++ result = _webhook_table_transformer(table).to_pylist()++ assert len(result) == 1+ assert result[0]["created_at"] == 1632945178+ assert result[0]["event_id"]+ # Identical retried deliveries hash to the same event_id.+ rerun = _webhook_table_transformer(table_from_py_list([row])).to_pylist()+ assert rerun[0]["event_id"] == result[0]["event_id"]++ def test_different_payloads_get_different_event_ids(self):+ rows = [+ {"type": "sms.sent", "timestamp": 1632945178104},+ {"type": "sms.sent", "timestamp": 1632945178105},+ ]+ result = _webhook_table_transformer(table_from_py_list(rows)).to_pylist()+ assert result[0]["event_id"] != result[1]["event_id"]++ def test_missing_timestamp_omits_created_at(self):+ result = _webhook_table_transformer(table_from_py_list([{"type": "sms.sent"}])).to_pylist()+ assert result[0].get("created_at") is None+++class TestAttentiveSource:+ def setup_method(self):+ self.source = AttentiveSource()+ self.team_id = 123+ self.config = AttentiveSourceConfig(api_key="key")++ def test_source_type(self):+ assert self.source.source_type == ExternalDataSourceType.ATTENTIVE++ def test_get_source_config(self):+ config = self.source.get_source_config++ assert config.name.value == "Attentive"+ assert config.label == "Attentive"+ assert config.releaseStatus == ReleaseStatus.ALPHA+ assert config.unreleasedSource is None+ assert config.iconPath == "/static/services/attentive.com.png"++ field_names = [f.name for f in config.fields]+ assert field_names == ["api_key"]++ webhook_field_names = [f.name for f in (config.webhookFields or [])]+ assert webhook_field_names == ["signing_secret"]++ def test_api_key_field_is_secret_password(self):+ config = self.source.get_source_config+ key_field = next(f for f in config.fields if isinstance(f, SourceFieldInputConfig) and f.name == "api_key")+ assert key_field.type == SourceFieldInputConfigType.PASSWORD+ assert key_field.secret is True+ assert key_field.required is True++ def test_webhook_template_registered(self):+ template = self.source.webhook_template+ assert template is not None+ assert template.id == "template-warehouse-source-attentive"+ assert template.type == "warehouse_source_webhook"++ def test_webhook_resource_map(self):+ assert self.source.webhook_resource_map == RESOURCE_TO_ATTENTIVE_EVENT_TYPE++ def test_get_schemas_are_webhook_only(self):+ schemas = self.source.get_schemas(self.config, self.team_id)++ assert {schema.name for schema in schemas} == set(ATTENTIVE_WEBHOOK_SCHEMA_NAMES)+ assert all(schema.supports_webhooks for schema in schemas)+ assert all(not schema.supports_incremental for schema in schemas)+ assert all(not schema.supports_append for schema in schemas)++ def test_get_schemas_filtered_by_names(self):+ schemas = self.source.get_schemas(self.config, self.team_id, names=["sms_sent"])+ assert len(schemas) == 1+ assert schemas[0].name == "sms_sent"++ def test_get_desired_webhook_events_maps_eligible_schemas(self):+ events = self.source.get_desired_webhook_events(self.config, ["sms_sent", "email_opened", "not_a_schema"])+ assert events == ["sms.sent", "email.opened"]++ @mock.patch("posthog.temporal.data_imports.sources.attentive.source.api_client.validate_credentials")+ def test_validate_credentials_delegates(self, mock_validate):+ mock_validate.return_value = (True, None)++ assert self.source.validate_credentials(self.config, self.team_id) == (True, None)+ mock_validate.assert_called_once_with("key")++ @mock.patch("posthog.temporal.data_imports.sources.attentive.source.api_client.create_webhook")+ def test_create_webhook_subscribes_all_event_types(self, mock_create):+ self.source.create_webhook(self.config, "https://ph.example/webhook", self.team_id)++ mock_create.assert_called_once_with(+ api_key="key",+ webhook_url="https://ph.example/webhook",+ resource_names=list(RESOURCE_TO_ATTENTIVE_EVENT_TYPE.keys()),+ )++ @mock.patch("posthog.temporal.data_imports.sources.attentive.source.api_client.enable_webhook")+ def test_webhook_inputs_updated_enables_once_secret_provided(self, mock_enable):+ mock_enable.return_value = (True, None)++ ok, _ = self.source.webhook_inputs_updated(+ self.config, "https://ph.example/webhook", self.team_id, {"signing_secret": "sek"}+ )++ assert ok is True+ mock_enable.assert_called_once_with("key", "https://ph.example/webhook")++ @mock.patch("posthog.temporal.data_imports.sources.attentive.source.api_client.enable_webhook")+ def test_webhook_inputs_updated_noop_without_secret(self, mock_enable):+ ok, _ = self.source.webhook_inputs_updated(self.config, "https://ph.example/webhook", self.team_id, {})++ assert ok is True+ mock_enable.assert_not_called()++ @mock.patch("posthog.temporal.data_imports.sources.attentive.source.async_to_sync")+ def test_source_for_pipeline_metadata(self, mock_async_to_sync):+ mock_async_to_sync.return_value = mock.MagicMock(return_value=False)+ inputs = mock.MagicMock()+ inputs.schema_name = "sms_sent"++ response = self.source.source_for_pipeline(self.config, inputs)++ assert response.name == "sms_sent"+ assert response.primary_keys == ["event_id"]+ assert response.partition_mode == "datetime"+ assert response.partition_format == "week"+ assert response.partition_keys == ["created_at"]+ # Webhook disabled -> empty iterator.+ assert list(cast(Iterable[Any], response.items())) == []diff --git a/posthog/temporal/data_imports/sources/attentive/tests/test_attentive_webhook_template.py b/posthog/temporal/data_imports/sources/attentive/tests/test_attentive_webhook_template.pynew file mode 100644index 000000000000..dade44890f6a--- /dev/null+++ b/posthog/temporal/data_imports/sources/attentive/tests/test_attentive_webhook_template.py@@ -0,0 +1,174 @@+import hmac+import json+import hashlib++from posthog.cdp.templates.helpers import BaseHogFunctionTemplateTest+from posthog.temporal.data_imports.sources.attentive.webhook_template import template++SOURCE_ID = "source_test_123"+++class TestAttentiveWarehouseWebhookTemplate(BaseHogFunctionTemplateTest):+ template = template++ def createHogGlobals(self, globals=None) -> dict:+ data: dict = {+ "request": {+ "method": "POST",+ "headers": {},+ "body": {},+ "query": {},+ "stringBody": "",+ "ip": "127.0.0.1",+ },+ }+ if globals and globals.get("request"):+ data["request"].update(globals["request"])+ return data++ def _make_signed_request(self, secret: str, body: dict | None = None, method: str = "POST") -> dict:+ payload = json.dumps(+ body+ or {+ "type": "sms.sent",+ "timestamp": 1632945178104,+ "company": {"display_name": "Acme", "company_id": "c1"},+ "subscriber": {"phone": "+15555555555"},+ }+ )+ signature = hmac.new(secret.encode(), payload.encode(), hashlib.sha256).hexdigest()+ return {+ "request": {+ "method": method,+ "headers": {"x-attentive-hmac-sha256": signature},+ "body": json.loads(payload),+ "stringBody": payload,+ "query": {},+ }+ }++ def test_valid_signed_webhook(self):+ secret = "attentive_signing_key_test"+ globals = self._make_signed_request(secret)+ self.run_function(+ {+ "signing_secret": secret,+ "bypass_signature_check": False,+ "schema_mapping": {"sms.sent": "schema_abc"},+ "source_id": SOURCE_ID,+ },+ globals=globals,+ )+ self.mock_produce_to_warehouse_webhooks.assert_called_once_with(globals["request"]["body"], "schema_abc")++ def test_non_post_request_returns_405(self):+ globals = self._make_signed_request("attentive_signing_key_test", method="GET")+ res = self.run_function(+ {+ "signing_secret": "attentive_signing_key_test",+ "bypass_signature_check": False,+ "source_id": SOURCE_ID,+ },+ globals=globals,+ )+ assert res.result == {"httpResponse": {"status": 405, "body": "Method not allowed"}}++ def test_invalid_signature_returns_400(self):+ globals = self._make_signed_request("wrong_secret")+ res = self.run_function(+ {+ "signing_secret": "correct_secret",+ "bypass_signature_check": False,+ "source_id": SOURCE_ID,+ },+ globals=globals,+ )+ assert res.result == {"httpResponse": {"status": 400, "body": "Bad signature"}}+ self.mock_produce_to_warehouse_webhooks.assert_not_called()++ def test_missing_signature_returns_400(self):+ body = {"type": "sms.sent"}+ globals = {+ "request": {+ "method": "POST",+ "headers": {},+ "body": body,+ "stringBody": json.dumps(body),+ "query": {},+ }+ }+ res = self.run_function(+ {+ "signing_secret": "secret",+ "bypass_signature_check": False,+ "source_id": SOURCE_ID,+ },+ globals=globals,+ )+ assert res.result == {"httpResponse": {"status": 400, "body": "Missing signature"}}++ def test_missing_signing_secret_returns_400(self):+ globals = self._make_signed_request("secret")+ res = self.run_function(+ {+ "signing_secret": "",+ "bypass_signature_check": False,+ "source_id": SOURCE_ID,+ },+ globals=globals,+ )+ assert res.result == {"httpResponse": {"status": 400, "body": "Signing secret not configured"}}++ def test_bypass_signature_check(self):+ body = {"type": "email.opened", "timestamp": 1632945178104}+ globals = {+ "request": {+ "method": "POST",+ "headers": {},+ "body": body,+ "stringBody": json.dumps(body),+ "query": {},+ }+ }+ self.run_function(+ {+ "signing_secret": "",+ "bypass_signature_check": True,+ "schema_mapping": {"email.opened": "schema_email"},+ "source_id": SOURCE_ID,+ },+ globals=globals,+ )+ self.mock_produce_to_warehouse_webhooks.assert_called_once_with(body, "schema_email")++ def test_missing_event_type_returns_200_and_skips(self):+ secret = "attentive_signing_key_test"+ globals = self._make_signed_request(secret, body={"timestamp": 1632945178104})+ res = self.run_function(+ {+ "signing_secret": secret,+ "bypass_signature_check": False,+ "schema_mapping": {"sms.sent": "schema_abc"},+ "source_id": SOURCE_ID,+ },+ globals=globals,+ )+ assert res.result == {"httpResponse": {"status": 200, "body": "No event type found, skipping"}}+ self.mock_produce_to_warehouse_webhooks.assert_not_called()++ def test_unmapped_event_type_returns_200_and_skips(self):+ secret = "attentive_signing_key_test"+ globals = self._make_signed_request(secret, body={"type": "sms.subscribed"})+ res = self.run_function(+ {+ "signing_secret": secret,+ "bypass_signature_check": False,+ "schema_mapping": {"sms.sent": "schema_abc"},+ "source_id": SOURCE_ID,+ },+ globals=globals,+ )+ assert res.result == {+ "httpResponse": {"status": 200, "body": "No schema mapping for event type: sms.subscribed, skipping"}+ }+ self.mock_produce_to_warehouse_webhooks.assert_not_called()diff --git a/posthog/temporal/data_imports/sources/attentive/webhook_template.py b/posthog/temporal/data_imports/sources/attentive/webhook_template.pynew file mode 100644index 000000000000..9a2ca1846bf2--- /dev/null+++ b/posthog/temporal/data_imports/sources/attentive/webhook_template.py@@ -0,0 +1,118 @@+from posthog.cdp.templates.hog_function_template import HogFunctionTemplateDC++template: HogFunctionTemplateDC = HogFunctionTemplateDC(+ status="alpha",+ free=False,+ type="warehouse_source_webhook",+ id="template-warehouse-source-attentive",+ name="Attentive warehouse source webhook",+ description="Receive Attentive webhook events for data warehouse ingestion",+ icon_url="/static/services/attentive.com.png",+ category=["Data warehouse"],+ code_language="hog",+ code="""\+if (request.method != 'POST') {+ return {+ 'httpResponse': {+ 'status': 405,+ 'body': 'Method not allowed'+ }+ }+}++if (not inputs.bypass_signature_check) {+ if (empty(inputs.signing_secret)) {+ return {+ 'httpResponse': {+ 'status': 400,+ 'body': 'Signing secret not configured',+ }+ }+ }++ let body := request.stringBody+ let signatureHeader := request.headers['x-attentive-hmac-sha256']++ if (empty(signatureHeader)) {+ return {+ 'httpResponse': {+ 'status': 400,+ 'body': 'Missing signature',+ }+ }+ }++ let computedSignature := sha256HmacChainHex([inputs.signing_secret, body])++ if (computedSignature != signatureHeader) {+ return {+ 'httpResponse': {+ 'status': 400,+ 'body': 'Bad signature',+ }+ }+ }+}++let eventType := request.body.type++if (empty(eventType)) {+ return {+ 'httpResponse': {+ 'status': 200,+ 'body': 'No event type found, skipping'+ }+ }+}++let schemaId := inputs.schema_mapping?.[eventType]++if (empty(schemaId)) {+ return {+ 'httpResponse': {+ 'status': 200,+ 'body': f'No schema mapping for event type: {eventType}, skipping'+ }+ }+}++produceToWarehouseWebhooks(request.body, schemaId)""",+ inputs_schema=[+ {+ "type": "string",+ "key": "signing_secret",+ "label": "Signing key",+ "required": False,+ "secret": True,+ "hidden": False,+ "description": "Used to validate the webhook came from Attentive",+ },+ {+ "type": "boolean",+ "key": "bypass_signature_check",+ "label": "Bypass signature check",+ "description": "If set, the x-attentive-hmac-sha256 header will not be checked. This is not recommended.",+ "default": False,+ "required": False,+ "secret": False,+ },+ {+ "type": "json",+ "key": "schema_mapping",+ "label": "Schema mapping",+ "description": "Maps Attentive event types to ExternalDataSchema IDs",+ "required": True,+ "secret": False,+ "hidden": True,+ },+ {+ "type": "string",+ "key": "source_id",+ "label": "Source ID",+ "description": "The ExternalDataSource ID this webhook is associated with",+ "required": True,+ "secret": False,+ "hidden": True,+ },+ ],+)diff --git a/posthog/temporal/data_imports/sources/generated_configs.py b/posthog/temporal/data_imports/sources/generated_configs.pyindex d876bec6f206..5cf1b68cd081 100644--- a/posthog/temporal/data_imports/sources/generated_configs.py+++ b/posthog/temporal/data_imports/sources/generated_configs.py@@ -233,7 +233,7 @@ class AshbySourceConfig(config.Config):@config.configclass AttentiveSourceConfig(config.Config):- pass+ api_key: str@config.config