Skip to content

: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.

feat(data-warehouse): add gainsight px survey response and event tables (#109921)

Tom Owers74a2cbe063fc
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index a5ab475d276f..621ecd16a7b6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -3509,10 +3509,10 @@ Diffed against: <https://jsapi.apiary.io/apis/gainsightpx.apib>
- [x] `events/pageView` — the core page-view event stream underpinning any adoption or navigation analysis (high)
- [x] `events/session` — session-level events giving visit frequency, duration and stickiness (high)
- [x] `events/engagementView` — who saw and interacted with each engagement — the only way to measure the engagements table's performance (high)
-- [ ] `survey/responses` — NPS/CES/survey answers, a headline reporting object with no substitute (high)
-- [ ] `events/custom` — customer-defined events captured by PX, typically the business-critical ones (high)
-- [ ] `events/segment_match` — segment entry/exit events that resolve the segments table into per-user membership over time (medium)
-- [ ] `events/identify` — identity resolution events tying anonymous activity to the synced users and accounts (medium)
+- [x] `survey/responses` — NPS/CES/survey answers, a headline reporting object with no substitute (high)
+- [x] `events/custom` — customer-defined events captured by PX, typically the business-critical ones (high)
+- [x] `events/segment_match` — segment entry/exit events that resolve the segments table into per-user membership over time (medium)
+- [x] `events/identify` — identity resolution events tying anonymous activity to the synced users and accounts (medium)
- [ ] `events/formSubmit` — in-product form submissions, the conversion event for guides and surveys (medium)
- [ ] `events/email` — email engagement events (send/open/click) for engagements delivered by email (medium)
- [ ] `feature/adoption/{featureId}` — vendor-precomputed adoption statistics per feature — a breakdown dimension that is expensive to recompute (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/canonical_descriptions.py
index 3f51998dac73..cdf0e9e6798b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/canonical_descriptions.py
@@ -209,4 +209,50 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"featureId": "Identifier of the matched feature. Joins to the features table.",
},
},
+ "segment_match_events": {
+ "description": "Segment match events, one row each time a user matches a segment.",
+ "docs_url": _EVENTS_DOCS_URL,
+ "columns": {
+ **_EVENT_COLUMNS,
+ "segmentId": "Identifier of the matched segment. Joins to the segments table.",
+ },
+ },
+ "custom_events": {
+ "description": "Custom events your product sends to Gainsight PX, with the event name and its attributes.",
+ "docs_url": _EVENTS_DOCS_URL,
+ "columns": {
+ **_EVENT_COLUMNS,
+ "eventName": "Name of the custom event.",
+ "attributes": "Custom attributes sent with the event.",
+ "url": "URL of the page the event was captured on.",
+ "referrer": "Referrer of the page the event was captured on.",
+ "remoteHost": "IP address the event came from.",
+ },
+ },
+ "identify_events": {
+ "description": "Identify events, one row each time a user is identified to Gainsight PX.",
+ "docs_url": _EVENTS_DOCS_URL,
+ "columns": {
+ **_EVENT_COLUMNS,
+ "email": "Email address of the identified user.",
+ },
+ },
+ "survey_responses": {
+ "description": "Survey responses (NPS, CES, rating, boolean and multiple-question surveys) users submitted to in-app surveys.",
+ "docs_url": _EVENTS_DOCS_URL,
+ "columns": {
+ **_EVENT_COLUMNS,
+ "engagementId": "Identifier of the survey engagement. Joins to the engagements table.",
+ "contentId": "Identifier of the survey content.",
+ "contentType": "Type of the survey (e.g. IN_APP_SURVEY_NPS, IN_APP_SURVEY_CES).",
+ "executionDate": "Timestamp of the survey view. The same on all events of one view.",
+ "executionId": "Identifier of the survey view. The same on all events of one view.",
+ "surveyState": "State of the survey engagement.",
+ "contactMeAllowed": "Whether the user allowed follow-up contact.",
+ "score": "Score the user gave.",
+ "comment": "Comment the user wrote.",
+ "questionType": "Type of the survey question.",
+ "selectionIds": "Identifiers of the options the user selected.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/settings.py
index 83f1101621b2..93deeb08244b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/settings.py
@@ -73,8 +73,8 @@ class GainsightPxEndpointConfig:
# don't rewrite every sync. `None` for resources the API returns without a creation timestamp.
partition_key: str | None = None
page_size: int = SCROLL_PAGE_SIZE
- # Only the `/events/*` streams expose a server-side date filter; the entity endpoints have no
- # "updated since" filter and stay full refresh.
+ # Only the `/events/*` streams and survey responses expose a server-side date filter; the entity
+ # endpoints have no "updated since" filter and stay full refresh.
incremental_fields: list[IncrementalField] = field(default_factory=list)
@@ -169,6 +169,45 @@ GAINSIGHT_PX_ENDPOINTS: dict[str, GainsightPxEndpointConfig] = {
partition_key=EVENT_DATE_FIELD,
incremental_fields=EVENT_INCREMENTAL_FIELDS,
),
+ "segment_match_events": GainsightPxEndpointConfig(
+ name="segment_match_events",
+ path="/events/segment_match",
+ # The vendor spec wraps segment matches under the same key as feature matches.
+ data_key="featureMatchEvents",
+ pagination="scroll",
+ primary_keys=["eventId"],
+ partition_key=EVENT_DATE_FIELD,
+ incremental_fields=EVENT_INCREMENTAL_FIELDS,
+ ),
+ "custom_events": GainsightPxEndpointConfig(
+ name="custom_events",
+ path="/events/custom",
+ data_key="customEvents",
+ pagination="scroll",
+ primary_keys=["eventId"],
+ partition_key=EVENT_DATE_FIELD,
+ incremental_fields=EVENT_INCREMENTAL_FIELDS,
+ ),
+ "identify_events": GainsightPxEndpointConfig(
+ name="identify_events",
+ path="/events/identify",
+ data_key="identifyEvents",
+ pagination="scroll",
+ primary_keys=["eventId"],
+ partition_key=EVENT_DATE_FIELD,
+ incremental_fields=EVENT_INCREMENTAL_FIELDS,
+ ),
+ # Survey responses are engagement view events filtered to survey content, so they take the same
+ # date window filter and scroll pagination as the `/events/*` streams.
+ "survey_responses": GainsightPxEndpointConfig(
+ name="survey_responses",
+ path="/survey/responses",
+ data_key="results",
+ pagination="scroll",
+ primary_keys=["eventId"],
+ partition_key=EVENT_DATE_FIELD,
+ incremental_fields=EVENT_INCREMENTAL_FIELDS,
+ ),
}
ENDPOINTS = tuple(GAINSIGHT_PX_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/source.py
index be3e32c39697..ea0e20471c74 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/source.py
@@ -68,8 +68,8 @@ class GainsightPxSource(ResumableSource[GainsightPxSourceConfig, GainsightPxResu
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
- # Only the `/events/*` streams expose a server-side date filter; the entity endpoints have
- # no "updated since" filter and stay full refresh.
+ # Only the `/events/*` streams and survey responses expose a server-side date filter; the entity
+ # endpoints have no "updated since" filter and stay full refresh.
schemas = [
SourceSchema(
name=endpoint,
@@ -130,8 +130,9 @@ class GainsightPxSource(ResumableSource[GainsightPxSourceConfig, GainsightPxResu
"Connect Gainsight PX with your project's **API key**. Generate a key with **Read** "
"access under **Administration → REST API** in Gainsight PX, then pick the region your "
"subscription is hosted in.\n\n"
- "Event tables (page views, sessions, engagement views and feature matches) can sync "
- "incrementally on the event `date`. The other tables sync as full refresh because "
+ "Event tables (page views, sessions, engagement views, feature and segment matches, "
+ "custom events, identify events and survey responses) can sync incrementally on the "
+ "event `date`. The other tables sync as full refresh because "
'Gainsight PX doesn\'t expose an "updated since" filter for them.'
),
docsUrl="https://posthog.com/docs/cdp/sources/gainsight-px",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px.py
index ab4b9aa78ec9..429bdc8d6e7a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px.py
@@ -245,6 +245,10 @@ VENDOR_PAGE_SIZE_MAXIMA: dict[str, int] = {
"session_events": 1000,
"engagement_view_events": 1000,
"feature_match_events": 1000,
+ "segment_match_events": 1000,
+ "custom_events": 1000,
+ "identify_events": 1000,
+ "survey_responses": 1000,
}
@@ -280,6 +284,10 @@ VENDOR_EVENT_DATA_KEYS: dict[str, str] = {
"session_events": "sessionInitializedEvents",
"engagement_view_events": "results",
"feature_match_events": "featureMatchEvents",
+ "segment_match_events": "featureMatchEvents",
+ "custom_events": "customEvents",
+ "identify_events": "identifyEvents",
+ "survey_responses": "results",
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px_source.py
index 7497ef8cc409..b510c3399a2d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gainsight_px/tests/test_gainsight_px_source.py
@@ -27,12 +27,12 @@ class TestGainsightPxSource:
@pytest.mark.parametrize(
"endpoint, incremental",
- [(endpoint, endpoint.endswith("_events")) for endpoint in ENDPOINTS],
+ [(endpoint, endpoint.endswith("_events") or endpoint == "survey_responses") for endpoint in ENDPOINTS],
)
def test_only_event_streams_support_incremental(self, endpoint, incremental):
schema = next(s for s in self.source.get_schemas(self.config, self.team_id) if s.name == endpoint)
- # Only the `/events/*` streams have a server-side date filter. Advertising incremental on an
- # entity endpoint would silently corrupt the cursor.
+ # Only the `/events/*` streams and survey responses have a server-side date filter. Advertising
+ # incremental on an entity endpoint would silently corrupt the cursor.
assert schema.supports_incremental is incremental
assert schema.supports_append is incremental