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(warehouse_sources): add canny opportunities, insights, ideas and groups tables (#101610)

Tom Owersd7e29b46a6c2
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 96761402a61b..3729e9f9449b 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
@@ -1249,14 +1249,14 @@ Note: Campfire has no public OpenAPI (docs.campfire.ai/openapi.json 404s) but sh
## Canny — gaps
-Today (10): `boards`, `categories`, `changelog_entries`, `comments`, `companies`, `posts`, `status_changes`, `tags`, `users`, `votes`
+Today (14): `boards`, `categories`, `changelog_entries`, `comments`, `companies`, `groups`, `ideas`, `insights`, `opportunities`, `posts`, `status_changes`, `tags`, `users`, `votes`
Diffed against: <https://developers.canny.io/api-reference>
-- [ ] `opportunities/list` — revenue opportunities linked to posts - the headline prioritization metric Canny sells (high)
-- [ ] `insights/list` — extracted customer feedback insights tied to posts and users (high)
-- [ ] `ideas/list` — the Autopilot idea objects that feed posts, a whole content type missing (medium)
-- [ ] `groups/list` — lookup table resolving the group IDs attached to users and companies (medium)
+- [x] `opportunities/list` — revenue opportunities linked to posts - the headline prioritization metric Canny sells (high)
+- [x] `insights/list` — extracted customer feedback insights tied to posts and users (high)
+- [x] `ideas/list` — the Autopilot idea objects that feed posts, a whole content type missing (medium)
+- [x] `groups/list` — lookup table for the groups that organize ideas, including the parent group hierarchy (medium)
Note: Roadmaps are documented as an object but Canny explicitly says roadmap data is only exposed through post data - there is no roadmaps list endpoint, so it is not a gap. Everything else on the reference (boards, categories, entries, comments, companies, posts, status changes, tags, users, votes) is already covered.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/canny/canny.py b/products/warehouse_sources/backend/temporal/data_imports/sources/canny/canny.py
index 0d15e5a4d491..6c2e8d2ba9cf 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/canny/canny.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/canny/canny.py
@@ -5,6 +5,8 @@ from typing import Any, Optional
import requests
from requests import PreparedRequest, Response
+from posthog.dataclasses import frozen
+
from products.warehouse_sources.backend.temporal.data_imports.sources.canny.settings import (
CANNY_API_VERSION_V2,
CANNY_ENDPOINTS,
@@ -150,10 +152,23 @@ class CannyCursorPaginator(BasePaginator):
self._has_next_page = True
-def _use_v2_cursor(config: CannyEndpointConfig, api_version: str) -> bool:
+@frozen
+class CannyWire:
+ """How to request one endpoint's list under a resolved version pin."""
+
+ path: str
+ data_key: str
+ cursor_paginated: bool
+
+
+def _resolve_wire(config: CannyEndpointConfig, api_version: str) -> CannyWire:
# v2 moves only the endpoints Canny reimplemented behind cursor pagination (those with a
- # `v2_path`); every other endpoint stays on its v1 skip/limit wire even under a v2 pin.
- return api_version == CANNY_API_VERSION_V2 and config.v2_path is not None
+ # `v2_path`); every other endpoint stays on its v1 path even under a v2 pin. A v1 path may
+ # still be cursor-paginated in its own right — Canny shipped the Ideas-era endpoints that way.
+ if api_version == CANNY_API_VERSION_V2 and config.v2_path is not None:
+ assert config.v2_data_key is not None
+ return CannyWire(path=config.v2_path, data_key=config.v2_data_key, cursor_paginated=True)
+ return CannyWire(path=config.path, data_key=config.data_key, cursor_paginated=config.cursor_paginated)
def canny_source(
@@ -165,21 +180,17 @@ def canny_source(
api_version: str,
) -> SourceResponse:
config = CANNY_ENDPOINTS[endpoint]
- use_cursor = _use_v2_cursor(config, api_version)
- if use_cursor:
- # _use_v2_cursor only returns True when both v2 fields are set.
- assert config.v2_path is not None and config.v2_data_key is not None
- path, data_key = config.v2_path, config.v2_data_key
- else:
- path, data_key = config.path, config.data_key
+ wire = _resolve_wire(config, api_version)
def extract_records(body: dict[str, Any]) -> list[dict[str, Any]]:
# Canny nests the record array under a per-endpoint key; anything else (missing key,
# non-list value) is treated as an empty page, matching how the source always behaved.
- records = body.get(data_key)
+ records = body.get(wire.data_key)
return records if isinstance(records, list) else []
- paginator: BasePaginator = CannyCursorPaginator() if use_cursor else CannyPaginator(paginated=config.paginated)
+ paginator: BasePaginator = (
+ CannyCursorPaginator() if wire.cursor_paginated else CannyPaginator(paginated=config.paginated)
+ )
rest_config: RESTAPIConfig = {
"client": {
@@ -190,7 +201,7 @@ def canny_source(
{
"name": endpoint,
"endpoint": {
- "path": path,
+ "path": wire.path,
"method": "post",
"paginator": paginator,
},
@@ -205,14 +216,14 @@ def canny_source(
if resumable_source_manager.can_resume():
resume = resumable_source_manager.load_state()
if resume is not None:
- initial_paginator_state = {"cursor": resume.cursor} if use_cursor else {"offset": resume.skip}
+ initial_paginator_state = {"cursor": resume.cursor} if wire.cursor_paginated else {"offset": resume.skip}
def save_checkpoint(state: Optional[dict[str, Any]]) -> None:
# Persist only when a next page remains; save AFTER a page is yielded so a crash re-yields
# the last page (the merge dedupes on the primary key) rather than skipping it.
if not state:
return
- if use_cursor:
+ if wire.cursor_paginated:
if state.get("cursor") is not None:
resumable_source_manager.save_state(CannyResumeConfig(cursor=str(state["cursor"])))
elif state.get("offset") is not None:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/canny/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/canny/canonical_descriptions.py
index 756798f9fb74..605294bb88f8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/canny/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/canny/canonical_descriptions.py
@@ -82,6 +82,67 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"name": "The company's name.",
},
},
+ "groups": {
+ "description": "A group is a higher-level initiative or product area that houses ideas, and can nest under a parent group.",
+ "docs_url": "https://developers.canny.io/api-reference#groups",
+ "columns": {
+ "id": "A unique identifier for the group.",
+ "name": "The name of the group.",
+ "description": "A short description of what this group represents.",
+ "parentID": "The ID of the parent group, if any.",
+ "urlName": "A URL-friendly identifier for the group.",
+ },
+ },
+ "ideas": {
+ "description": "An idea is a feature or improvement tracked in Canny Ideas, optionally grouped and nested under a parent idea.",
+ "docs_url": "https://developers.canny.io/api-reference#ideas",
+ "columns": {
+ "id": "A unique identifier for the idea.",
+ "childCount": "The number of child ideas (ideas that have this idea as their parent).",
+ "author": "The user who authored the idea, if any.",
+ "created": "Time at which the idea was created, in ISO 8601 format.",
+ "description": "The description of the idea.",
+ "group": "The group this idea belongs to, if any.",
+ "owner": "The user who is assigned as owner of this idea, if any.",
+ "parent": "The parent idea, if this idea is a child of another idea.",
+ "source": "The source where the idea was created from.",
+ "status": "The status of the idea.",
+ "title": "The title of the idea.",
+ "updatedAt": "Time at which the idea was last updated, in ISO 8601 format.",
+ "urlName": "The URL name of the idea.",
+ },
+ },
+ "insights": {
+ "description": "An insight is a piece of customer feedback or context attached to an idea, captured manually or from comments, votes and other sources.",
+ "docs_url": "https://developers.canny.io/api-reference#insights",
+ "columns": {
+ "id": "A unique identifier for the insight.",
+ "author": "The user who created the insight, if available.",
+ "company": "The company associated with the insight, if available.",
+ "created": "Time at which the insight was created, in ISO 8601 format.",
+ "ideaID": "The ID of the idea associated with the insight.",
+ "priority": "The priority level of the insight, if set. One of nice-to-have, important, must-have or no-priority.",
+ "source": "The source of the insight (e.g. canny, webhook).",
+ "url": "A URL associated with the insight, if available.",
+ "users": "The users mentioned or associated with the insight.",
+ "value": "The text content of the insight.",
+ },
+ },
+ "opportunities": {
+ "description": "An opportunity is a revenue deal, synced from your CRM, linked to the posts and ideas it depends on.",
+ "docs_url": "https://developers.canny.io/api-reference#opportunities",
+ "columns": {
+ "id": "A unique identifier for the opportunity.",
+ "closed": "Whether the opportunity is closed.",
+ "ideaIDs": "The list of idea ids this opportunity is linked to.",
+ "name": "The name of the opportunity.",
+ "postIDs": "The list of post ids this opportunity is linked to.",
+ "salesforceOpportunityID": "The unique identifier for the opportunity in Salesforce.",
+ "stage": "The current pipeline stage of the opportunity, as labeled in the source CRM (e.g. Discovery, Closed Won).",
+ "value": "The value of the opportunity.",
+ "won": "Whether the opportunity has been won.",
+ },
+ },
"posts": {
"description": "A post is a piece of feedback (feature request, bug, idea) on a board.",
"docs_url": "https://developers.canny.io/api-reference#posts",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/canny/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/canny/settings.py
index 29fe8c155451..9a4cd97da455 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/canny/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/canny/settings.py
@@ -3,11 +3,12 @@ from typing import Optional
from products.warehouse_sources.backend.types import IncrementalField
-# Canny exposes every resource through a POST `/list` endpoint. v1 endpoints use skip/limit
-# offset pagination with a `hasMore` flag; v2 endpoints (users, companies, comments) use cursor
-# pagination with a `cursor` string and a `hasNextPage` flag. The secret API key is sent as the
-# `apiKey` POST body parameter for both. There is no server-side updated-since filter on any list
-# endpoint, so every stream is full refresh only (see source.py / canny.py).
+# Canny exposes every resource through a POST `/list` endpoint. Most v1 endpoints use skip/limit
+# offset pagination with a `hasMore` flag; the Ideas-era v1 endpoints (groups, ideas, insights) and
+# every v2 endpoint (users, companies, comments) use cursor pagination with a `cursor` string and a
+# `hasNextPage` flag. The secret API key is sent as the `apiKey` POST body parameter for all of them.
+# There is no server-side updated-since filter on any list endpoint, so every stream is full refresh
+# only (see source.py / canny.py).
# Vendor API version labels. v1 is the long-standing wire; v2 is Canny's newer cursor-paginated
# implementation, offered so far only for the endpoints that set `v2_path` below.
@@ -24,6 +25,10 @@ class CannyEndpointConfig:
# Whether the endpoint supports skip/limit pagination. `boards/list` returns
# every board in one response with no pagination params or `hasMore` flag.
paginated: bool = True
+ # Whether the v1 `path` above is itself cursor-paginated. Canny shipped the Ideas-era
+ # endpoints (groups, ideas, insights) on the v1 base with the cursor wire rather than
+ # skip/limit, so cursor pagination is not a v2-only trait and cannot be inferred from the pin.
+ cursor_paginated: bool = False
# Stable creation timestamp present on every Canny object — safe to partition on
# because it never changes after a record is created (unlike a `lastSaved` field).
partition_key: Optional[str] = "created"
@@ -49,6 +54,11 @@ CANNY_ENDPOINTS: dict[str, CannyEndpointConfig] = {
"companies": CannyEndpointConfig(
path="/v1/companies/list", data_key="companies", v2_path="/v2/companies/list", v2_data_key="companies"
),
+ "groups": CannyEndpointConfig(path="/v1/groups/list", data_key="items", cursor_paginated=True, partition_key=None),
+ "ideas": CannyEndpointConfig(path="/v1/ideas/list", data_key="items", cursor_paginated=True),
+ "insights": CannyEndpointConfig(path="/v1/insights/list", data_key="items", cursor_paginated=True),
+ # Opportunities carry no timestamp at all, so there is nothing stable to partition on.
+ "opportunities": CannyEndpointConfig(path="/v1/opportunities/list", data_key="opportunities", partition_key=None),
"posts": CannyEndpointConfig(path="/v1/posts/list", data_key="posts"),
"status_changes": CannyEndpointConfig(path="/v1/status_changes/list", data_key="statusChanges"),
"tags": CannyEndpointConfig(path="/v1/tags/list", data_key="tags"),
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/canny/tests/test_canny.py b/products/warehouse_sources/backend/temporal/data_imports/sources/canny/tests/test_canny.py
index b12b0fe1d8d2..1d83a682c5d6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/canny/tests/test_canny.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/canny/tests/test_canny.py
@@ -327,14 +327,22 @@ class TestValidateCredentials:
class TestCannySource:
+ # Opportunities and groups are the only Canny objects the API returns with no timestamp field
+ # at all, so partitioning them would key on a column that never arrives.
+ UNPARTITIONED_ENDPOINTS = {"groups", "opportunities"}
+
@pytest.mark.parametrize("endpoint", list(ENDPOINTS))
def test_source_response_shape(self, endpoint: str) -> None:
response = _source(endpoint, _make_manager())
assert response.name == endpoint
assert response.primary_keys == ["id"]
- # Every Canny object carries a stable `created` timestamp we partition on.
- assert response.partition_mode == "datetime"
- assert response.partition_keys == ["created"]
+
+ if endpoint in self.UNPARTITIONED_ENDPOINTS:
+ assert response.partition_mode is None
+ assert response.partition_keys is None
+ else:
+ assert response.partition_mode == "datetime"
+ assert response.partition_keys == ["created"]
class TestV2CursorPagination:
@@ -413,3 +421,69 @@ class TestV2CursorPagination:
assert bodies[0].get("skip") == 0
assert "cursor" not in bodies[0]
assert [r["id"] for r in rows] == ["c1"]
+
+
+class TestIdeasEraEndpoints:
+ # Canny shipped the Ideas-era endpoints on the v1 base but with the cursor wire, so the
+ # pagination style cannot be inferred from the version pin.
+ CURSOR_V1_ENDPOINTS = ["groups", "ideas", "insights"]
+
+ @pytest.mark.parametrize("api_version", [CANNY_API_VERSION_V1, CANNY_API_VERSION_V2])
+ @pytest.mark.parametrize("endpoint", CURSOR_V1_ENDPOINTS)
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_cursor_paginates_on_v1_path_under_either_pin(self, MockSession, endpoint: str, api_version: str) -> None:
+ session = MockSession.return_value
+ urls, bodies = _capture(
+ session,
+ [
+ _cursor_page("items", ["a", "b"], cursor="cur-1", has_next=True),
+ _cursor_page("items", ["c"], cursor=None, has_next=False),
+ ],
+ )
+
+ manager = _make_manager()
+ rows = _rows(_source(endpoint, manager, api_version=api_version))
+
+ assert [r["id"] for r in rows] == ["a", "b", "c"]
+ # These have no v2 implementation; a guessed /v2/ path would 404, and skip/limit would
+ # silently re-read page one forever.
+ assert all(url == f"https://canny.io/api/v1/{endpoint}/list" for url in urls)
+ assert "skip" not in bodies[0]
+ assert bodies[0].get("limit") == PAGE_SIZE
+ assert "cursor" not in bodies[0]
+ assert bodies[1].get("cursor") == "cur-1"
+ saved = [call.args[0] for call in manager.save_state.call_args_list]
+ assert saved == [CannyResumeConfig(cursor="cur-1")]
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_resume_seeds_cursor_under_v1_pin(self, MockSession) -> None:
+ # A v1 pin used to imply offset resume; these endpoints must read the saved cursor instead.
+ session = MockSession.return_value
+ _, bodies = _capture(session, [_cursor_page("items", ["x"], cursor=None, has_next=False)])
+
+ manager = _make_manager(CannyResumeConfig(cursor="cur-77"))
+ rows = _rows(_source("ideas", manager, api_version=CANNY_API_VERSION_V1))
+
+ assert bodies[0].get("cursor") == "cur-77"
+ assert "skip" not in bodies[0]
+ assert [r["id"] for r in rows] == ["x"]
+
+ @pytest.mark.parametrize("api_version", [CANNY_API_VERSION_V1, CANNY_API_VERSION_V2])
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_opportunities_stay_on_the_skip_wire(self, MockSession, api_version: str) -> None:
+ # Opportunities is the one Ideas-era endpoint Canny left on skip/limit with `hasMore`.
+ session = MockSession.return_value
+ urls, bodies = _capture(
+ session,
+ [_full_page("opportunities", 0), _page("opportunities", ["final"], has_more=False)],
+ )
+
+ manager = _make_manager()
+ rows = _rows(_source("opportunities", manager, api_version=api_version))
+
+ assert [r["id"] for r in rows] == [*(str(i) for i in range(PAGE_SIZE)), "final"]
+ assert urls == ["https://canny.io/api/v1/opportunities/list"] * 2
+ assert [b.get("skip") for b in bodies] == [0, PAGE_SIZE]
+ assert "cursor" not in bodies[0]
+ saved = [call.args[0] for call in manager.save_state.call_args_list]
+ assert saved == [CannyResumeConfig(skip=PAGE_SIZE)]