: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(warehouse-sources): sync asana stories, memberships, goals and time (#99672)
Tom Owers375fd7e7b642
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 239a70360ecd..3e395363559a 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@@ -501,16 +501,16 @@ Note: Diffed against the upstream swagger spec (82 paths). PostHog's deployment_## Asana — gaps-Today (10): `ai_studio_runs`, `ai_studio_seats`, `custom_fields`, `projects`, `sections`, `tags`, `tasks`, `teams`, `users`, `workspaces`+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`Diffed against: <https://raw.githubusercontent.com/Asana/openapi/master/defs/asana_oas.yaml>- [x] `workspaces/{workspace_gid}/ai_studio/runs` — one row per AI Studio run (rule execution) with the credits it consumed; from the AI Studio usage API (not in the OpenAPI spec above)- [x] `workspaces/{workspace_gid}/ai_studio/seats` — current snapshot of who holds an AI Studio seat, at what tier and state; from the AI Studio usage API (not in the OpenAPI spec above)-- [ ] `tasks/{task_gid}/stories` — task activity + comment stream, the only source of state-transition history (assignee/section/due-date changes) (high)-- [ ] `projects/{project_gid}/project_memberships` — who is on which project and in what role; joins users to projects we already sync (high)-- [ ] `goals (+ goals/{gid}/parentGoals)` — Asana's headline OKR object with progress/status, entirely absent today (high)-- [ ] `time_tracking_entries` — actual hours logged per task/user, the basis of any effort or capacity analysis (high)+- [x] `tasks/{task_gid}/stories` — task activity + comment stream, the only source of state-transition history (assignee/section/due-date changes) (high)+- [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)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.pyindex b79ae4ec41c5..8a8cd79e8150 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@@ -1,18 +1,24 @@import dataclassesfrom typing import Any, Optional+from posthog.dataclasses import frozen+from products.warehouse_sources.backend.temporal.data_imports.sources.asana.settings import (ASANA_ENDPOINTS,- PRIMARY_KEY,AsanaEndpointConfig,+ FanOut,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_sessionfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (RESTAPIConfig,rest_api_resources,)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ rename_parent_fields,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (JSONResponsePaginator,+ SinglePagePaginator,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import EndpointResourcefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager@@ -44,65 +50,95 @@ def _paginator() -> JSONResponsePaginator:return JSONResponsePaginator(next_url_path=NEXT_URL_PATH)-def _resource(name: str, path: str, params: dict[str, Any]) -> EndpointResource:+def _resource(name: str, path: str, params: dict[str, Any], *, paginated: bool = True) -> EndpointResource:return {"name": name,"endpoint": {"path": path,"params": params,"data_selector": "data",- "paginator": _paginator(),+ "paginator": _paginator() if paginated else SinglePagePaginator(),},}-def _workspaces_parent(*, filter_organizations: bool) -> EndpointResource:- """Workspaces list used only to resolve child gids. `is_organization` is opted in so the- organization-only fan-out (teams) can drop non-organization workspaces."""- resource = _resource("workspaces", "/workspaces", {"limit": PAGE_SIZE, "opt_fields": "is_organization"})- if filter_organizations:- # `/organizations/{gid}/teams` is only valid for organization workspaces; returning [] drops+@frozen+class _ParentSpec:+ """A resource fetched only to resolve gids for the endpoints that fan out over it."""++ name: str+ # Placeholder the child's path carries, bound from this parent's gid per request.+ param: str+ path: str+ # How this parent is itself reached, so a chain can be built from the deepest level up.+ fan_out: FanOut = "none"+ opt_fields: list[str] = dataclasses.field(default_factory=list)+ organizations_only: bool = False+++_PARENTS: dict[FanOut, _ParentSpec] = {+ # `is_organization` is opted in so the organization-only fan-out can drop plain workspaces.+ "workspace": _ParentSpec(+ name="workspaces", param="workspace_gid", path="/workspaces", opt_fields=["is_organization"]+ ),+ "organization": _ParentSpec(+ name="workspaces",+ param="workspace_gid",+ path="/workspaces",+ opt_fields=["is_organization"],+ organizations_only=True,+ ),+ "project": _ParentSpec(+ name="projects", param="project_gid", path="/projects?workspace={workspace_gid}", fan_out="workspace"+ ),+ "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"),+}+++def _resolve(spec: _ParentSpec) -> dict[str, Any]:+ return {"type": "resolve", "resource": spec.name, "field": "gid"}+++def _parent_chain(fan_out: FanOut) -> list[str | EndpointResource]:+ """Every resource needed to produce the gids a `fan_out` endpoint binds, outermost first."""+ if fan_out == "none":+ return []++ spec = _PARENTS[fan_out]+ params: dict[str, Any] = {"limit": PAGE_SIZE}+ if spec.opt_fields:+ params["opt_fields"] = ",".join(spec.opt_fields)+ if spec.fan_out != "none":+ params[_PARENTS[spec.fan_out].param] = _resolve(_PARENTS[spec.fan_out])++ resource = _resource(spec.name, spec.path, params)+ if spec.organizations_only:+ # `/organizations/{gid}/...` is only valid for organization workspaces; returning [] drops# the row so the child fan-out never requests it.resource["data_map"] = lambda workspace: workspace if workspace.get("is_organization") else []- return resource--def _projects_parent() -> EndpointResource:- """Projects list (one request per workspace) used only to resolve project gids for the- project-level fan-out (tasks, sections)."""- return _resource(- "projects",- "/projects?workspace={workspace_gid}",- {"limit": PAGE_SIZE, "workspace_gid": {"type": "resolve", "resource": "workspaces", "field": "gid"}},- )+ return [*_parent_chain(spec.fan_out), resource]def _build_resources(config: AsanaEndpointConfig) -> list[str | EndpointResource]:"""Build the rest_source resource chain for an endpoint, fanning out over parents as needed.Only the last (target) resource's rows are surfaced; parents exist solely to resolve gids."""- target_params: dict[str, Any] = {"limit": PAGE_SIZE}+ target_params: dict[str, Any] = {"limit": PAGE_SIZE} if config.paginated else {}if config.opt_fields:target_params["opt_fields"] = ",".join(config.opt_fields)- if config.fan_out == "none":- return [_resource(config.name, config.path, target_params)]-- if config.fan_out in ("workspace", "organization"):- target_params["workspace_gid"] = {"type": "resolve", "resource": "workspaces", "field": "gid"}- return [- _workspaces_parent(filter_organizations=config.fan_out == "organization"),- _resource(config.name, config.path, target_params),- ]+ if config.fan_out != "none":+ spec = _PARENTS[config.fan_out]+ target_params[spec.param] = _resolve(spec)- if config.fan_out == "project":- target_params["project_gid"] = {"type": "resolve", "resource": "projects", "field": "gid"}- return [- _workspaces_parent(filter_organizations=False),- _projects_parent(),- _resource(config.name, config.path, target_params),- ]+ target = _resource(config.name, config.path, target_params, paginated=config.paginated)+ if config.parent_fields:+ target["include_from_parent"] = list(config.parent_fields)+ target["data_map"] = rename_parent_fields(_PARENTS[config.fan_out].name, config.parent_fields)- raise ValueError(f"Unknown fan_out mode: {config.fan_out}")+ return [*_parent_chain(config.fan_out), target]def asana_source(@@ -153,7 +189,7 @@ def asana_source(return SourceResponse(name=endpoint,items=lambda: target,- primary_keys=[PRIMARY_KEY],+ primary_keys=config.primary_keys,partition_count=1,partition_size=1,partition_mode="datetime" if config.partition_key else None,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.pyindex c9604d59e29f..c7f93905204d 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@@ -132,6 +132,108 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {created_by="The user who created the custom field.",),},+ "project_memberships": {+ "description": "A record of a user or team being a member of a project, and the access level they hold.",+ "docs_url": "https://developers.asana.com/reference/projectmemberships",+ "columns": _columns(+ parent="The project the member belongs to.",+ member="The member — either a user or a team.",+ access_level="Level of access the member has on the project (admin, editor, commenter, viewer).",+ ),+ },+ "stories": {+ "description": "An entry in a task's activity feed — either a comment someone wrote or a record of a change made to the task.",+ "docs_url": "https://developers.asana.com/reference/stories",+ "columns": _columns(+ created_at="Time at which the story was created.",+ created_by="The user who wrote the comment or made the change.",+ resource_subtype="What the story records (e.g. 'comment_added', 'assigned', 'due_date_changed').",+ text="Plain text of the comment, or a human-readable summary of the change.",+ type="Whether the story is a 'comment' or a 'system' record of a change.",+ source="The part of Asana the user used to trigger the story (web, email, api).",+ target="The resource the story is attached to.",+ task="The task the story refers to.",+ project="The project the story refers to.",+ tag="The tag the story refers to.",+ assignee="The user involved in an assignment change.",+ follower="The user involved in a follower change.",+ dependency="The task involved in a dependency change.",+ duplicate_of="The task this task was marked a duplicate of.",+ duplicated_from="The task that was marked a duplicate of this one.",+ custom_field="The custom field whose value changed.",+ is_pinned="Whether the story is pinned on the task.",+ is_edited="Whether the story text was edited after it was created.",+ num_likes="Number of users who liked the story.",+ sticker_name="Name of the sticker on the story, if any.",+ old_name="The task name before a name change.",+ new_name="The task name after a name change.",+ old_section="The section the task was in before it moved.",+ new_section="The section the task moved into.",+ old_dates="The task's start and due dates before the change.",+ new_dates="The task's start and due dates after the change.",+ old_resource_subtype="The task's subtype before the change.",+ new_resource_subtype="The task's subtype after the change.",+ old_approval_status="Approval status before the change.",+ new_approval_status="Approval status after the change.",+ old_text_value="Value of a text custom field before the change.",+ new_text_value="Value of a text custom field after the change.",+ old_number_value="Value of a number custom field before the change.",+ new_number_value="Value of a number custom field after the change.",+ old_date_value="Value of a date custom field before the change.",+ new_date_value="Value of a date custom field after the change.",+ old_enum_value="Value of a single-select custom field before the change.",+ new_enum_value="Value of a single-select custom field after the change.",+ old_multi_enum_values="Values of a multi-select custom field before the change.",+ new_multi_enum_values="Values of a multi-select custom field after the change.",+ old_people_value="Value of a people custom field before the change.",+ new_people_value="Value of a people custom field after the change.",+ ),+ },+ "goals": {+ "description": "A goal — Asana's objective object, with its target, progress and status.",+ "docs_url": "https://developers.asana.com/reference/goals",+ "columns": _columns(+ notes="Free-form description of the goal.",+ owner="The user who owns the goal.",+ status="Current status of the goal (green, yellow, red when open; achieved, partial, missed, dropped when closed).",+ due_on="Day the goal is due, as YYYY-MM-DD.",+ start_on="Day work on the goal begins, as YYYY-MM-DD.",+ is_workspace_level="Whether the goal belongs to the whole workspace rather than a team.",+ team="The team the goal belongs to.",+ workspace="The workspace the goal belongs to.",+ time_period="The time period the goal is tracked against (e.g. a quarter).",+ metric="The goal's progress measure — target value, current value and unit.",+ current_status_update="The most recent status update posted on the goal.",+ privacy_setting="Who can see the goal.",+ default_access_level="Access level new members get when invited to the goal.",+ followers="Users who are members of the goal.",+ num_likes="Number of users who liked the goal.",+ custom_fields="Custom field values applied to the goal.",+ ),+ },+ "parent_goals": {+ "description": "One row per goal-to-parent-goal link, resolving the goal hierarchy. The row is the parent goal; `goal_gid` is the child it is a parent of.",+ "docs_url": "https://developers.asana.com/reference/getparentgoalsforgoal",+ "columns": _columns(+ goal_gid="Identifier of the child goal this row is a parent of.",+ owner="The user who owns the parent goal.",+ ),+ },+ "time_tracking_entries": {+ "description": "A block of time logged against a task by a user.",+ "docs_url": "https://developers.asana.com/reference/time-tracking-entries",+ "columns": _columns(+ duration_minutes="Time logged by the entry, in minutes.",+ entered_on="Day the time is logged against, as YYYY-MM-DD.",+ created_at="Time at which the entry was created.",+ created_by="The user who logged the time.",+ task="The task the time was logged against.",+ attributable_to="The project the time is attributed to.",+ approval_status="Current approval status of the entry.",+ billable_status="Whether the entry is billable.",+ description="Free-form description of the entry.",+ ),+ },"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.pyindex 7d2ef83fac69..289c9b4cc6b1 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@@ -1,6 +1,8 @@-from dataclasses import dataclass, field+from dataclasses import fieldfrom typing import Literal, Optional+from posthog.dataclasses import frozen+from products.warehouse_sources.backend.types import IncrementalField# How an endpoint's request URLs are derived (drives the rest_source resource chain):@@ -8,16 +10,22 @@ from products.warehouse_sources.backend.types import IncrementalField# "workspace" -> one request per workspace the token can see# "organization" -> one request per workspace that is an organization# "project" -> one request per project across all visible workspaces-FanOut = Literal["none", "workspace", "organization", "project"]+# "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"]++# Every Asana resource is identified by its global id ``gid``.+PRIMARY_KEY = "gid"-@dataclass+@frozenclass AsanaEndpointConfig:name: strfan_out: FanOut- # Relative path appended to the API base. Fan-out endpoints carry a single ``{workspace_gid}``- # or ``{project_gid}`` placeholder that the framework binds from the parent row per request;- # top-level endpoints carry no placeholder.+ # 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.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.@@ -25,11 +33,16 @@ class AsanaEndpointConfig:# Stable creation-time field used for datetime partitioning. Must be present in opt_fields.# Never a ``modified_at``-style field — partitions would rewrite on every sync.partition_key: Optional[str] = None+ # Fan-out parent fields to copy onto every row, mapped to the column they land in. Needed when+ # the row's own gid is not unique table-wide because the same object is returned under several+ # parents.+ parent_fields: dict[str, str] = field(default_factory=dict)+ primary_keys: list[str] = field(default_factory=lambda: [PRIMARY_KEY])+ # A few endpoints return the whole collection in one response — they take no limit/offset and+ # carry no `next_page`. Sending `limit` to those is rejected.+ paginated: bool = True-# Every Asana resource is identified by its global id ``gid``.-PRIMARY_KEY = "gid"-ASANA_ENDPOINTS: dict[str, AsanaEndpointConfig] = {"workspaces": AsanaEndpointConfig(name="workspaces",@@ -72,6 +85,12 @@ ASANA_ENDPOINTS: dict[str, AsanaEndpointConfig] = {],partition_key="created_at",),+ "project_memberships": AsanaEndpointConfig(+ name="project_memberships",+ fan_out="project",+ path="/projects/{project_gid}/project_memberships",+ opt_fields=["member", "access_level", "parent", "resource_type"],+ ),"tasks": AsanaEndpointConfig(name="tasks",fan_out="project",@@ -100,6 +119,57 @@ ASANA_ENDPOINTS: dict[str, AsanaEndpointConfig] = {],partition_key="created_at",),+ "stories": AsanaEndpointConfig(+ name="stories",+ fan_out="task",+ path="/tasks/{task_gid}/stories",+ opt_fields=[+ "created_at",+ "created_by",+ "resource_subtype",+ "resource_type",+ "text",+ "type",+ "source",+ "target",+ "task",+ "project",+ "tag",+ "assignee",+ "follower",+ "dependency",+ "duplicate_of",+ "duplicated_from",+ "custom_field",+ "is_pinned",+ "is_edited",+ "num_likes",+ "sticker_name",+ "old_name",+ "new_name",+ "old_section",+ "new_section",+ "old_dates",+ "new_dates",+ "old_resource_subtype",+ "new_resource_subtype",+ "old_approval_status",+ "new_approval_status",+ "old_text_value",+ "new_text_value",+ "old_number_value",+ "new_number_value",+ "old_date_value",+ "new_date_value",+ "old_enum_value",+ "new_enum_value",+ "old_multi_enum_values",+ "new_multi_enum_values",+ "old_people_value",+ "new_people_value",+ ],+ partition_key="created_at",+ ),"tags": AsanaEndpointConfig(name="tags",fan_out="workspace",@@ -137,6 +207,62 @@ ASANA_ENDPOINTS: dict[str, AsanaEndpointConfig] = {"resource_type",],),+ "goals": AsanaEndpointConfig(+ name="goals",+ fan_out="workspace",+ path="/goals?workspace={workspace_gid}",+ opt_fields=[+ "name",+ "notes",+ "owner",+ "status",+ "due_on",+ "start_on",+ "is_workspace_level",+ "team",+ "workspace",+ "time_period",+ "metric",+ "current_status_update",+ "privacy_setting",+ "default_access_level",+ "followers",+ "num_likes",+ "custom_fields",+ "resource_type",+ ],+ ),+ # One row per goal-to-parent-goal edge. The row is the parent goal, so its gid repeats across+ # every child goal that points at it — `goal_gid` (the child) completes the primary key.+ "parent_goals": AsanaEndpointConfig(+ name="parent_goals",+ fan_out="goal",+ path="/goals/{goal_gid}/parentGoals",+ opt_fields=["name", "owner", "resource_type"],+ parent_fields={"gid": "goal_gid"},+ primary_keys=["goal_gid", PRIMARY_KEY],+ paginated=False,+ ),+ # User fan-out: /time_tracking_entries needs one of its filters, and `user` is the only one that+ # covers every entry without a date window (filtering by workspace requires an entered-on range).+ "time_tracking_entries": AsanaEndpointConfig(+ name="time_tracking_entries",+ fan_out="user",+ path="/time_tracking_entries?user={user_gid}",+ opt_fields=[+ "duration_minutes",+ "entered_on",+ "created_at",+ "created_by",+ "task",+ "attributable_to",+ "approval_status",+ "billable_status",+ "description",+ "resource_type",+ ],+ 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.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.pyindex b8e5cb418245..f63867ca2876 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@@ -61,6 +61,9 @@ Grant these read scopes so every table can sync:- `users:read`- `projects:read`- `tasks:read`+- `stories:read`+- `goals:read`+- `time_tracking_entries:read`- `tags:read`- `teams:read`- `custom_fields:read`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.pyindex b5a9f5220ca9..ec0cf73d3517 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@@ -200,6 +200,67 @@ class TestFanOut:# The non-organization workspace never triggers a teams request.assert not any("/organizations/W2/" in url for url in sent)+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_task_level_chain_yields_stories_per_task(self, MockSession) -> None:+ session = MockSession.return_value+ sent = _wire(+ session,+ [+ ("/workspaces?", _page([{"gid": "W1"}])),+ ("workspace=W1", _page([{"gid": "P1"}])),+ ("project=P1", _page([{"gid": "T1"}, {"gid": "T2"}])),+ ("/tasks/T1/stories", _page([{"gid": "s1"}])),+ ("/tasks/T2/stories", _page([{"gid": "s2"}])),+ ],+ )++ rows = _rows(_source("stories", _make_manager()))++ assert [r["gid"] for r in rows] == ["s1", "s2"]+ # The tasks level is fetched compact — story opt_fields must not leak onto the parent walk.+ assert not any("opt_fields" in url for url in sent if "project=P1" in url)++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_user_fan_out_filters_time_tracking_entries_per_user(self, MockSession) -> None:+ session = MockSession.return_value+ sent = _wire(+ session,+ [+ ("/users", _page([{"gid": "U1"}, {"gid": "U2"}])),+ ("user=U1", _page([{"gid": "e1"}])),+ ("user=U2", _page([])),+ ],+ )++ rows = _rows(_source("time_tracking_entries", _make_manager()))++ assert [r["gid"] for r in rows] == ["e1"]+ # Every entry request is scoped to a user; an unfiltered request would be rejected.+ assert all("user=" in url for url in sent if "/time_tracking_entries" in url)++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_parent_goals_carry_the_child_gid_and_skip_pagination(self, MockSession) -> None:+ session = MockSession.return_value+ # parentGoals takes no limit/offset and returns no next_page — a `limit` param is rejected.+ sent = _wire(+ session,+ [+ ("/workspaces?", _page([{"gid": "W1"}])),+ ("workspace=W1", _page([{"gid": "G1"}, {"gid": "G2"}])),+ ("/goals/G1/parentGoals", _page([{"gid": "P"}], next_uri="ignored")),+ ("/goals/G2/parentGoals", _page([{"gid": "P"}])),+ ],+ )++ rows = _rows(_source("parent_goals", _make_manager()))++ # The same parent goal under two children — only the composite key keeps both rows.+ assert [(r["goal_gid"], r["gid"]) for r in rows] == [("G1", "P"), ("G2", "P")]+ assert not any(r for r in rows if "_goals_gid" in r)+ parent_goal_urls = [url for url in sent if "parentGoals" in url]+ 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_project_level_chain_yields_grandchild_rows(self, MockSession) -> None:session = MockSession.return_value@@ -245,7 +306,7 @@ class TestAsanaSourceResponse:response = _source(endpoint, _make_manager())assert response.name == endpoint- assert response.primary_keys == ["gid"]+ assert response.primary_keys == config.primary_keysif config.partition_key:assert response.partition_mode == "datetime"assert response.partition_format == "week"