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 seven missing Asana tables (#100940)

Tom Owers1533a97a43df
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 2ee8ee2bd013..1fd887948a42 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
@@ -503,7 +503,7 @@ Note: Diffed against the upstream swagger spec (82 paths). PostHog's deployment_
## Asana — gaps
-Today (15): `ai_studio_runs`, `ai_studio_seats`, `custom_fields`, `goals`, `parent_goals`, `project_memberships`, `projects`, `sections`, `stories`, `tags`, `tasks`, `teams`, `time_tracking_entries`, `users`, `workspaces`
+Today (22): `ai_studio_runs`, `ai_studio_seats`, `custom_field_settings`, `custom_fields`, `goal_status_updates`, `goals`, `parent_goals`, `portfolio_items`, `portfolio_status_updates`, `portfolios`, `project_memberships`, `project_status_updates`, `projects`, `sections`, `stories`, `tags`, `tasks`, `team_memberships`, `teams`, `time_tracking_entries`, `users`, `workspaces`
Diffed against: <https://raw.githubusercontent.com/Asana/openapi/master/defs/asana_oas.yaml>
@@ -513,10 +513,10 @@ Diffed against: <https://raw.githubusercontent.com/Asana/openapi/master/defs/asa
- [x] `projects/{project_gid}/project_memberships` — who is on which project and in what role; joins users to projects we already sync (high)
- [x] `goals (+ goals/{gid}/parentGoals)` — Asana's headline OKR object with progress/status, entirely absent today (high)
- [x] `time_tracking_entries` — actual hours logged per task/user, the basis of any effort or capacity analysis (high)
-- [ ] `projects/{project_gid}/custom_field_settings` — lookup mapping synced custom_fields to the projects/portfolios that use them (high)
-- [ ] `status_updates` — project/goal/portfolio status history (color + narrative) over time (medium)
-- [ ] `team_memberships` — user-to-team membership lookup joining synced users and teams (medium)
-- [ ] `portfolios (+ portfolios/{gid}/items)` — program-level rollup grouping projects we already sync (medium)
+- [x] `projects/{project_gid}/custom_field_settings` — lookup mapping synced custom_fields to the projects/portfolios that use them; lands as `custom_field_settings`, covering the project endpoint only (high)
+- [x] `status_updates` — project/goal/portfolio status history (color + narrative) over time; the endpoint takes one `parent` gid, so it lands as `project_status_updates`, `goal_status_updates` and `portfolio_status_updates` (medium)
+- [x] `team_memberships` — user-to-team membership lookup joining synced users and teams (medium)
+- [x] `portfolios (+ portfolios/{gid}/items)` — program-level rollup grouping projects we already sync (medium)
- [ ] `tasks/{task_gid}/dependencies and /dependents` — task dependency graph for blocked-work and critical-path analysis (medium)
- [ ] `goal_relationships` — resolves goal hierarchy and which projects contribute to which goal (medium)
- [ ] `time_tracking_categories` — lookup resolving the category ID carried on time tracking entries (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/asana/asana.py b/products/warehouse_sources/backend/temporal/data_imports/sources/asana/asana.py
index 8a8cd79e8150..63d435a81142 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/asana/asana.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/asana/asana.py
@@ -94,6 +94,12 @@ _PARENTS: dict[FanOut, _ParentSpec] = {
"task": _ParentSpec(name="tasks", param="task_gid", path="/tasks?project={project_gid}", fan_out="project"),
"goal": _ParentSpec(name="goals", param="goal_gid", path="/goals?workspace={workspace_gid}", fan_out="workspace"),
"user": _ParentSpec(name="users", param="user_gid", path="/users"),
+ "team": _ParentSpec(
+ name="teams", param="team_gid", path="/organizations/{workspace_gid}/teams", fan_out="organization"
+ ),
+ "portfolio": _ParentSpec(
+ name="portfolios", param="portfolio_gid", path="/portfolios?workspace={workspace_gid}", fan_out="workspace"
+ ),
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/asana/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/asana/canonical_descriptions.py
index c7f93905204d..027486175566 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/asana/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/asana/canonical_descriptions.py
@@ -21,6 +21,24 @@ def _columns(**overrides: str) -> dict[str, str]:
return {**_COMMON_COLUMNS, **overrides}
+# /status_updates returns one object shape, but which `status_type` values are valid depends on the
+# parent kind — and each status-update table fans out over exactly one kind.
+def _status_update_columns(parent: str, status_types: str) -> dict[str, str]:
+ return _columns(
+ title="Title of the status update.",
+ text="Plain-text body of the status update.",
+ html_text="Body of the status update, as HTML.",
+ status_type=f"Overall state the update reports ({status_types}).",
+ resource_subtype=f"Subtype of the update, always `{parent}_status_update` in this table.",
+ author="The user who wrote the status update.",
+ created_at="Time at which the status update was posted.",
+ created_by="The user who posted the status update.",
+ modified_at="Time at which the status update was last edited.",
+ parent=f"The {parent} the update was posted on.",
+ num_likes="Number of users who liked the status update.",
+ )
+
+
CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"workspaces": {
"description": "A workspace or organization — the highest-level container for all Asana data.",
@@ -234,6 +252,69 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
description="Free-form description of the entry.",
),
},
+ "custom_field_settings": {
+ "description": "One row per custom-field-to-project link, recording how a custom field is applied to that project.",
+ "docs_url": "https://developers.asana.com/reference/custom-field-settings",
+ "columns": _columns(
+ custom_field="The custom field the setting applies.",
+ parent="The project the custom field is applied to. Asana also applies custom fields to portfolios, but this table syncs project settings only.",
+ project="The project the custom field is applied to (deprecated in favor of parent).",
+ is_important="Whether the field is shown in the list and grid views of its project.",
+ ),
+ },
+ "team_memberships": {
+ "description": "One row per user-to-team membership, with the role the user holds on that team.",
+ "docs_url": "https://developers.asana.com/reference/team-memberships",
+ "columns": _columns(
+ user="The member of the team.",
+ team="The team the membership is on.",
+ is_admin="Whether the user is a team admin.",
+ is_guest="Whether the user is a guest of the team.",
+ is_limited_access="Whether the user has limited access to the team.",
+ ),
+ },
+ "portfolios": {
+ "description": "A program-level collection of projects and sub-portfolios, used to roll work up for reporting. A personal access token only sees portfolios its own user owns.",
+ "docs_url": "https://developers.asana.com/reference/portfolios",
+ "columns": _columns(
+ created_at="Time at which the portfolio was created.",
+ created_by="The user who created the portfolio.",
+ owner="The user who owns the portfolio.",
+ color="Color of the portfolio in the Asana UI.",
+ public="Whether the portfolio is public to its workspace.",
+ archived="Whether the portfolio is archived.",
+ workspace="The workspace or organization the portfolio belongs to.",
+ due_on="Date on which the portfolio is due.",
+ start_on="Date on which the portfolio starts.",
+ members="Users who are members of the portfolio.",
+ current_status_update="The most recent status update posted on the portfolio.",
+ privacy_setting="Who can see the portfolio.",
+ default_access_level="Access level new members get when invited to the portfolio.",
+ permalink_url="URL of the portfolio in the Asana web app.",
+ ),
+ },
+ "portfolio_items": {
+ "description": "One row per portfolio-to-item link. The row is the contained project or sub-portfolio; `portfolio_gid` is the portfolio holding it.",
+ "docs_url": "https://developers.asana.com/reference/getitemsforportfolio",
+ "columns": _columns(
+ portfolio_gid="Identifier of the portfolio that contains this item.",
+ ),
+ },
+ "project_status_updates": {
+ "description": "A status update posted on a project, giving its state and a narrative at a point in time.",
+ "docs_url": "https://developers.asana.com/reference/status-updates",
+ "columns": _status_update_columns("project", "on_track, at_risk, off_track, on_hold, complete, dropped"),
+ },
+ "goal_status_updates": {
+ "description": "A status update posted on a goal, giving its state and a narrative at a point in time.",
+ "docs_url": "https://developers.asana.com/reference/status-updates",
+ "columns": _status_update_columns("goal", "on_track, at_risk, off_track, achieved, partial, missed, dropped"),
+ },
+ "portfolio_status_updates": {
+ "description": "A status update posted on a portfolio, giving its state and a narrative at a point in time.",
+ "docs_url": "https://developers.asana.com/reference/status-updates",
+ "columns": _status_update_columns("portfolio", "on_track, at_risk, off_track, on_hold, complete, dropped"),
+ },
"ai_studio_runs": {
"description": "A single AI Studio run (rule execution), with the credits it consumed. Requires an AI Studio-licensed organization.",
"docs_url": "https://developers.asana.com/reference/ai-studio-usage-api",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/asana/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/asana/settings.py
index 289c9b4cc6b1..60cc1d0bb2dc 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/asana/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/asana/settings.py
@@ -13,7 +13,9 @@ from products.warehouse_sources.backend.types import IncrementalField
# "task" -> one request per task across all visible projects
# "goal" -> one request per goal across all visible workspaces
# "user" -> one request per user the token can see
-FanOut = Literal["none", "workspace", "organization", "project", "task", "goal", "user"]
+# "team" -> one request per team across all visible organizations
+# "portfolio" -> one request per portfolio across all visible workspaces
+FanOut = Literal["none", "workspace", "organization", "project", "task", "goal", "user", "team", "portfolio"]
# Every Asana resource is identified by its global id ``gid``.
PRIMARY_KEY = "gid"
@@ -24,8 +26,9 @@ class AsanaEndpointConfig:
name: str
fan_out: FanOut
# Relative path appended to the API base. Fan-out endpoints carry a single ``{workspace_gid}``,
- # ``{project_gid}``, ``{task_gid}``, ``{goal_gid}`` or ``{user_gid}`` placeholder that the
- # framework binds from the parent row per request; top-level endpoints carry no placeholder.
+ # ``{project_gid}``, ``{task_gid}``, ``{goal_gid}``, ``{user_gid}``, ``{team_gid}`` or
+ # ``{portfolio_gid}`` placeholder that the framework binds from the parent row per request;
+ # top-level endpoints carry no placeholder.
path: str
# Asana list endpoints return compact records ({gid, name, resource_type}) by default.
# ``opt_fields`` opts extra properties into the response — keep the partition key here.
@@ -43,6 +46,23 @@ class AsanaEndpointConfig:
paginated: bool = True
+# Every /status_updates fan-out returns the same object, so the opted-in fields are shared.
+STATUS_UPDATE_OPT_FIELDS = [
+ "title",
+ "text",
+ "html_text",
+ "status_type",
+ "resource_subtype",
+ "author",
+ "created_at",
+ "created_by",
+ "modified_at",
+ "parent",
+ "num_likes",
+ "resource_type",
+]
+
+
ASANA_ENDPOINTS: dict[str, AsanaEndpointConfig] = {
"workspaces": AsanaEndpointConfig(
name="workspaces",
@@ -263,6 +283,77 @@ ASANA_ENDPOINTS: dict[str, AsanaEndpointConfig] = {
],
partition_key="created_at",
),
+ "custom_field_settings": AsanaEndpointConfig(
+ name="custom_field_settings",
+ fan_out="project",
+ path="/projects/{project_gid}/custom_field_settings",
+ opt_fields=["custom_field", "parent", "project", "is_important", "resource_type"],
+ ),
+ "team_memberships": AsanaEndpointConfig(
+ name="team_memberships",
+ fan_out="team",
+ path="/teams/{team_gid}/team_memberships",
+ opt_fields=["user", "team", "is_admin", "is_guest", "is_limited_access", "resource_type"],
+ ),
+ # A personal access token only sees portfolios the token's own user owns; a service account sees
+ # every portfolio in the workspace. Nothing in the response marks which case applied.
+ "portfolios": AsanaEndpointConfig(
+ name="portfolios",
+ fan_out="workspace",
+ path="/portfolios?workspace={workspace_gid}",
+ opt_fields=[
+ "name",
+ "created_at",
+ "created_by",
+ "owner",
+ "color",
+ "public",
+ "archived",
+ "workspace",
+ "due_on",
+ "start_on",
+ "members",
+ "current_status_update",
+ "privacy_setting",
+ "default_access_level",
+ "permalink_url",
+ "resource_type",
+ ],
+ partition_key="created_at",
+ ),
+ # One row per portfolio-to-item edge. The row is the contained project (or sub-portfolio), so its
+ # gid repeats across every portfolio holding it — `portfolio_gid` completes the primary key.
+ # The compact item shape is all this endpoint returns; its opt_fields only cover paging metadata.
+ "portfolio_items": AsanaEndpointConfig(
+ name="portfolio_items",
+ fan_out="portfolio",
+ path="/portfolios/{portfolio_gid}/items",
+ parent_fields={"gid": "portfolio_gid"},
+ primary_keys=["portfolio_gid", PRIMARY_KEY],
+ ),
+ # /status_updates takes one `parent` gid that must be a project, goal or portfolio, so each
+ # parent type needs its own fan-out. `resource_subtype` on the row records which kind it was.
+ "project_status_updates": AsanaEndpointConfig(
+ name="project_status_updates",
+ fan_out="project",
+ path="/status_updates?parent={project_gid}",
+ opt_fields=STATUS_UPDATE_OPT_FIELDS,
+ partition_key="created_at",
+ ),
+ "goal_status_updates": AsanaEndpointConfig(
+ name="goal_status_updates",
+ fan_out="goal",
+ path="/status_updates?parent={goal_gid}",
+ opt_fields=STATUS_UPDATE_OPT_FIELDS,
+ partition_key="created_at",
+ ),
+ "portfolio_status_updates": AsanaEndpointConfig(
+ name="portfolio_status_updates",
+ fan_out="portfolio",
+ path="/status_updates?parent={portfolio_gid}",
+ opt_fields=STATUS_UPDATE_OPT_FIELDS,
+ partition_key="created_at",
+ ),
# AI Studio usage endpoints (organization fan-out — AI Studio is an org/division feature, so
# non-organization workspaces are skipped to avoid invalid requests). Both require the
# `admin.ai_studio_usage:read` scope on an AI Studio-licensed org; unlicensed orgs return 403.
@@ -307,12 +398,14 @@ ASANA_ENDPOINTS: dict[str, AsanaEndpointConfig] = {
ENDPOINTS = tuple(ASANA_ENDPOINTS.keys())
-# Asana exposes a server-side `modified_since` filter only on /tasks (and the premium-only
-# task search endpoint). The other endpoints have no usable server-side timestamp filter, so
-# the whole source ships full-refresh-only for now — declaring incremental support without a
-# real server filter would make every "incremental" run cost the same as a full refresh.
-# Incremental tasks (via `modified_since`) and the Events API are tracked as follow-ups; they
-# need a live token to smoke-test the filter behaviour before we can rely on it.
+# Asana exposes a server-side timestamp filter on only two of the endpoints here: `modified_since`
+# on /tasks (and the premium-only task search endpoint), and `created_since` on /status_updates.
+# The rest have no usable server-side filter, so the whole source ships full-refresh-only for now —
+# declaring incremental support without a real server filter would make every "incremental" run cost
+# the same as a full refresh.
+# Incremental tasks (via `modified_since`), incremental status updates (via `created_since`) and the
+# Events API are tracked as follow-ups; they need a live token to smoke-test the filter behaviour and
+# the result ordering `sort_mode` has to match before we can rely on them.
# `ai_studio/runs` does take a `start_at`/`end_at` window, but it filters by an internal metering
# timestamp that the row shape does not expose — so no synced column maps cleanly onto the cursor,
# and the arrival order can't be verified without a live token. It stays full-refresh with the rest.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/asana/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/asana/source.py
index f63867ca2876..40b8a6df041d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/asana/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/asana/source.py
@@ -67,6 +67,8 @@ Grant these read scopes so every table can sync:
- `tags:read`
- `teams:read`
- `custom_fields:read`
+- `team_memberships:read`
+- `portfolios:read`
The AI Studio usage tables (`ai_studio_runs`, `ai_studio_seats`) additionally need the `admin.ai_studio_usage:read` scope on an AI Studio-licensed organization. Skip them if you don't use AI Studio.
""",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/asana/tests/test_asana.py b/products/warehouse_sources/backend/temporal/data_imports/sources/asana/tests/test_asana.py
index ec0cf73d3517..f8f5adef6d95 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/asana/tests/test_asana.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/asana/tests/test_asana.py
@@ -261,6 +261,90 @@ class TestFanOut:
assert len(parent_goal_urls) == 2
assert not any("limit=" in url or "offset=" in url for url in parent_goal_urls)
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_team_memberships_walk_organizations_then_teams(self, MockSession) -> None:
+ session = MockSession.return_value
+ sent = _wire(
+ session,
+ [
+ (
+ "/workspaces?",
+ _page([{"gid": "W1", "is_organization": True}, {"gid": "W2", "is_organization": False}]),
+ ),
+ ("/organizations/W1/teams", _page([{"gid": "TM1"}])),
+ ("/teams/TM1/team_memberships", _page([{"gid": "m1"}])),
+ ],
+ )
+
+ rows = _rows(_source("team_memberships", _make_manager()))
+
+ assert [r["gid"] for r in rows] == ["m1"]
+ # Teams only exist under organizations, so the plain workspace is dropped before the walk.
+ assert not any("/organizations/W2/" in url for url in sent)
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_portfolio_items_carry_the_portfolio_gid(self, MockSession) -> None:
+ session = MockSession.return_value
+ sent = _wire(
+ session,
+ [
+ ("/workspaces?", _page([{"gid": "W1"}])),
+ ("workspace=W1", _page([{"gid": "PF1"}, {"gid": "PF2"}])),
+ ("/portfolios/PF1/items", _page([{"gid": "PR1"}])),
+ ("/portfolios/PF2/items", _page([{"gid": "PR1"}])),
+ ],
+ )
+
+ rows = _rows(_source("portfolio_items", _make_manager()))
+
+ # The same project held by two portfolios — only the composite key keeps both rows.
+ assert [(r["portfolio_gid"], r["gid"]) for r in rows] == [("PF1", "PR1"), ("PF2", "PR1")]
+ assert not any(r for r in rows if "_portfolios_gid" in r)
+ assert all("limit=" in url for url in sent if "/items" in url)
+
+ @pytest.mark.parametrize(
+ "endpoint, parent_gid",
+ [
+ ("project_status_updates", "P1"),
+ ("goal_status_updates", "G1"),
+ ("portfolio_status_updates", "PF1"),
+ ],
+ )
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_status_updates_bind_their_parent_gid(self, MockSession, endpoint, parent_gid) -> None:
+ session = MockSession.return_value
+ sent = _wire(
+ session,
+ [
+ ("/workspaces?", _page([{"gid": "W1"}])),
+ ("workspace=W1", _page([{"gid": parent_gid}])),
+ (f"parent={parent_gid}", _page([{"gid": "su1"}])),
+ ],
+ )
+
+ rows = _rows(_source(endpoint, _make_manager()))
+
+ assert [r["gid"] for r in rows] == ["su1"]
+ # /status_updates rejects a request without `parent`, and the gid must ride that one param.
+ assert all("parent=" in url for url in sent if "/status_updates" in url)
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_custom_field_settings_fan_out_per_project(self, MockSession) -> None:
+ session = MockSession.return_value
+ _wire(
+ session,
+ [
+ ("/workspaces?", _page([{"gid": "W1"}])),
+ ("workspace=W1", _page([{"gid": "P1"}, {"gid": "P2"}])),
+ ("/projects/P1/custom_field_settings", _page([{"gid": "cfs1"}])),
+ ("/projects/P2/custom_field_settings", _page([{"gid": "cfs2"}])),
+ ],
+ )
+
+ rows = _rows(_source("custom_field_settings", _make_manager()))
+
+ assert [r["gid"] for r in rows] == ["cfs1", "cfs2"]
+
@mock.patch(CLIENT_SESSION_PATCH)
def test_project_level_chain_yields_grandchild_rows(self, MockSession) -> None:
session = MockSession.return_value