: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): add 4 missing tables to the Planhat source (#119016)
Tom Owers45d47e82f6a8
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.mdindex 6d9cd4c21729..e6400b2d461b 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@@ -9466,10 +9466,10 @@ Today (6): `assets`, `companies`, `endusers`, `licenses`, `nps`, `users`Diffed against: <https://docs.planhat.com/developers/api/planhat-models>-- [ ] `conversation` — customer conversation records, the core engagement signal in Planhat (high)-- [ ] `ticket` — support tickets tied to companies, needed for health scoring (high)-- [ ] `invoice` — billed revenue per company (high)-- [ ] `sale` — closed revenue transactions (high)+- [x] `conversation` — customer conversation records, the core engagement signal in Planhat (high)+- [x] `ticket` — support tickets tied to companies, needed for health scoring (high)+- [x] `invoice` — billed revenue per company (high)+- [x] `sale` — closed revenue transactions (high)- [ ] `churn` — churn records, the headline customer-success metric (high)- [ ] `metrics` — time-series usage and health metrics per company; Planhat's central analytical object (high)- [ ] `product` — lookup resolving the product IDs carried on synced licenses and on line items (high)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/canonical_descriptions.pyindex 3b498eee9878..668fb54cefd5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/canonical_descriptions.py@@ -89,4 +89,88 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"date": "When the response was submitted.",},},+ "conversations": {+ "description": "A customer conversation in Planhat, such as an email, chat, call, ticket or logged note.",+ "docs_url": "https://docs.planhat.com/developers/api/conversation",+ "columns": {+ "_id": "The unique ID of the conversation.",+ "subject": "The title of the conversation.",+ "companyId": "The ID of the company the conversation relates to.",+ "companyName": "The name of the company the conversation relates to.",+ "description": "The description of the conversation.",+ "snippet": "The formatted content of the conversation.",+ "date": "When the conversation was created.",+ "outDate": "When the conversation was sent.",+ "createDate": "When the conversation record was created in Planhat.",+ "type": "The conversation type, for example email, chat, ticket, call or a custom type.",+ "users": "The Planhat users involved in the conversation.",+ "endusers": "The IDs of the end users involved in the conversation.",+ "externalId": "Your own identifier for the conversation.",+ "isOpen": "Whether the conversation or ticket is open.",+ "archived": "Whether the conversation is archived.",+ "sentiment": "The AI-generated sentiment of the conversation: positive, neutral or negative.",+ "category": "The AI-generated classification of the conversation.",+ "custom": "Custom properties set on the conversation.",+ },+ },+ "tickets": {+ "description": "A support ticket tied to a customer company, usually synced from a helpdesk such as Zendesk.",+ "docs_url": "https://docs.planhat.com/developers/api/ticket",+ "columns": {+ "_id": "The unique ID of the ticket.",+ "source": "The name of the system the ticket comes from, for example Zendesk.",+ "sourceId": "The ID of the ticket in the source system.",+ "companyId": "The ID of the company the ticket relates to.",+ "email": "The email of the person who submitted the ticket.",+ "title": "The title or main subject of the ticket.",+ "description": "The description of the ticket.",+ "url": "A URL with more information about the ticket.",+ "tags": "The tags on the ticket.",+ "type": "The ticket type, for example bug, feature request or training.",+ "severity": "The severity of the ticket.",+ "product": "The name of the product the ticket relates to.",+ "timeSpent": "The time spent on the ticket, in minutes.",+ "status": "The ticket status, for example new, pending, open, resolved or closed.",+ "history": "The status history of the ticket.",+ },+ },+ "invoices": {+ "description": "An invoice record for a customer company, usually generated when a license is created or renewed.",+ "docs_url": "https://docs.planhat.com/developers/api/invoice",+ "columns": {+ "_id": "The unique ID of the invoice.",+ "currency": "The currency code of the invoice, for example USD.",+ "product": "The name of the product on the invoice.",+ "cId": "The ID of the company the invoice belongs to.",+ "cName": "The name of the company the invoice belongs to.",+ "extId": "Your own identifier for the invoice.",+ "sourceId": "The ID of the invoice in an integration such as Salesforce or HubSpot.",+ "invoiceDate": "When the invoice was created, as days since the Unix epoch.",+ "dueDate": "When the invoice is due, as days since the Unix epoch.",+ "paidDate": "When the invoice was paid, as days since the Unix epoch.",+ "invoiceNo": "The invoice number.",+ "amountTotal": "The total invoice amount.",+ "status": "The invoice status, for example pending, paid or overdue.",+ "lineItems": "The line items on the invoice.",+ "invoiceCycle": "The invoice cycle: monthly, quarterly, yearly, semiAnnual, once or custom.",+ "lastUpdated": "When the invoice was last modified.",+ "custom": "Custom properties set on the invoice.",+ },+ },+ "sales": {+ "description": "A non-recurring revenue (NRR) sale, such as an onboarding fee or a one-off services project.",+ "docs_url": "https://docs.planhat.com/developers/api/sale",+ "columns": {+ "_id": "The unique ID of the sale.",+ "_currency": "The currency code of the sale, for example USD.",+ "product": "The name of the product sold.",+ "companyId": "The ID of the company the sale belongs to.",+ "companyName": "The name of the company the sale belongs to.",+ "externalId": "Your own identifier for the sale.",+ "sourceId": "The ID of the sale in an integration such as Salesforce or HubSpot.",+ "salesDate": "When the sale happened.",+ "value": "The total value of the sale.",+ "custom": "Custom properties set on the sale.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/settings.pyindex 88d8c25cd9b1..ea63d6784c54 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/settings.py@@ -22,6 +22,10 @@ PLANHAT_ENDPOINTS: dict[str, PlanhatEndpointConfig] = {"licenses": PlanhatEndpointConfig(name="licenses", path="/licenses"),"assets": PlanhatEndpointConfig(name="assets", path="/assets"),"nps": PlanhatEndpointConfig(name="nps", path="/nps"),+ "conversations": PlanhatEndpointConfig(name="conversations", path="/conversations"),+ "tickets": PlanhatEndpointConfig(name="tickets", path="/tickets"),+ "invoices": PlanhatEndpointConfig(name="invoices", path="/invoices"),+ "sales": PlanhatEndpointConfig(name="sales", path="/sales"),}ENDPOINTS = tuple(PLANHAT_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/source.pyindex 02f9801a675d..71b889cc9c02 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/source.py@@ -56,7 +56,7 @@ class PlanhatSource(ResumableSource[PlanhatSourceConfig, PlanhatResumeConfig]):releaseStatus=ReleaseStatus.ALPHA,caption="""Enter your Planhat API access token to pull your customer success data into the PostHog Data warehouse.-You can create an API access token from a Private App under **Settings → Service Accounts** in [Planhat](https://app.planhat.com). The token is shown once, so copy it immediately. It grants read access to your companies, end users, users, licenses, assets, and NPS responses.+You can create an API access token from a Private App under **Settings → Service Accounts** in [Planhat](https://app.planhat.com). The token is shown once, so copy it immediately. It grants read access to your companies, end users, users, licenses, assets, NPS responses, conversations, tickets, invoices, and sales.""",iconPath="/static/services/planhat.png",docsUrl="https://posthog.com/docs/cdp/sources/planhat",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/tests/test_planhat.py b/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/tests/test_planhat.pyindex 8cc7dfbed8b8..0a6f54aa9fb1 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/tests/test_planhat.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/planhat/tests/test_planhat.py@@ -99,11 +99,25 @@ class TestValidateCredentials:class TestPlanhatSourceResponse:- @parameterized.expand([(endpoint,) for endpoint in ENDPOINTS])- def test_source_response_shape(self, endpoint: str) -> None:+ @parameterized.expand(+ [+ ("companies", "/companies"),+ ("endusers", "/endusers"),+ ("users", "/users"),+ ("licenses", "/licenses"),+ ("assets", "/assets"),+ ("nps", "/nps"),+ ("conversations", "/conversations"),+ ("tickets", "/tickets"),+ ("invoices", "/invoices"),+ ("sales", "/sales"),+ ]+ )+ def test_source_response_shape(self, endpoint: str, expected_path: str) -> None:result = _driver().run(endpoint, [ScriptedResponse(json=[])])assert result.raised is None+ assert result.paths == [expected_path]assert result.response is not Noneassert result.response.name == endpointassert result.response.primary_keys == ["_id"]