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(chameleon): add interactions, tooltips, tags and properties tables (#102232)

Tom Owersd3e96017a9f4
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 dbf5f0fe5f84..6f159c01ef92 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
@@ -1313,14 +1313,14 @@ Note: Census now lives under the Fivetran Activations docs; the docs are HTML-on
## Chameleon — gaps
-Today (8): `companies`, `event_names`, `launchers`, `profiles`, `responses`, `segments`, `surveys`, `tours`
+Today (12): `companies`, `event_names`, `interactions`, `launchers`, `profiles`, `properties`, `responses`, `segments`, `surveys`, `tags`, `tooltips`, `tours`
Diffed against: <https://developers.chameleon.io/apis/overview.md>
-- [ ] `GET /v3/analyze/interactions (Tour Interactions)` — per-user tour state (displayed/started/completed/exited) - the headline engagement metric and the only way to measure tour performance (high)
-- [ ] `GET /v3/edit/tooltips` — a whole experience type missing alongside tours, launchers and surveys (medium)
-- [ ] `GET /v3/edit/tags` — lookup resolving the tag IDs used to organize experiences (medium)
-- [ ] `GET /v3/edit/properties (Data Properties)` — lookup of the property definitions sent on profiles and companies, needed to interpret their semi-arbitrary property blobs (medium)
+- [x] `GET /v3/analyze/interactions (Tour Interactions)` — per-user tour state (displayed/started/completed/exited) - the headline engagement metric and the only way to measure tour performance (high)
+- [x] `GET /v3/edit/tooltips` — a whole experience type missing alongside tours, launchers and surveys (medium)
+- [x] `GET /v3/edit/tags` — lookup resolving the tag IDs used to organize experiences (medium)
+- [x] `GET /v3/edit/properties (Data Properties)` — lookup of the property definitions sent on profiles and companies, needed to interpret their semi-arbitrary property blobs (medium)
- [ ] `GET /v3/edit/deliveries (Experience Deliveries)` — records of experiences targeted at specific users, the delivery side of the interaction funnel (medium)
Note: Chameleon's published OpenAPI at developers.chameleon.io/api-reference/openapi.json is a stub (it documents a /plants toy API), so the authoritative endpoint table is the markdown overview page. Alert groups, rate limit groups, webhooks, domains and data imports were excluded as config/plumbing. Embeddables, Product Demos and Changes have doc pages in llms.txt but do not appear in the overview endpoint table, so no list endpoint could be confirmed for them - they are not reported as gaps.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/canonical_descriptions.py
index 5d7d7f363193..a74e1e21941c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/canonical_descriptions.py
@@ -121,6 +121,19 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"items": "The array of items that define the Launcher menu contents.",
},
},
+ "tooltips": {
+ "description": "A Tooltip: a small contextual hint attached to an element in your product, shown to end-users who match the configured criteria.",
+ "docs_url": "https://developers.chameleon.io/apis/tooltips",
+ "columns": {
+ "id": _ID,
+ "created_at": _CREATED_AT,
+ "updated_at": _UPDATED_AT,
+ "name": "The name given to the Tooltip by a Chameleon administrator.",
+ "position": "The order this appears in lists (starting from 0).",
+ "published_at": "The time this Tooltip was most recently published.",
+ "tag_ids": "The Chameleon IDs of the Tags attached to this Tooltip.",
+ },
+ },
"event_names": {
"description": "An Event Name: a tracked or custom event configured in your Chameleon account, usable in Segmentation filters.",
"docs_url": "https://developers.chameleon.io/apis/event-names",
@@ -138,6 +151,38 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"dashboard_url": "Direct link to this Event Name in the Chameleon Dashboard.",
},
},
+ "tags": {
+ "description": "A Tag: a label used to organize Experiences (Tours, Microsurveys, Launchers and Tooltips) in Chameleon.",
+ "docs_url": "https://developers.chameleon.io/apis/tags",
+ "columns": {
+ "id": _ID,
+ "created_at": _CREATED_AT,
+ "updated_at": _UPDATED_AT,
+ "uid": "The normalized name, or an external ID.",
+ "name": "The original text entered for the Tag.",
+ "description": "The display description.",
+ "models_count": "The number of Experiences attached to this Tag.",
+ "disabled_at": "When this Tag stopped being displayed in the UI.",
+ "last_seen_at": "The last time this Tag was added to or removed from an Experience.",
+ },
+ },
+ "properties": {
+ "description": "A Data Property definition: one of the custom properties sent to Chameleon on User Profiles or Companies, with the value types and sample values seen for it.",
+ "docs_url": "https://developers.chameleon.io/apis/properties",
+ "columns": {
+ "id": _ID,
+ "created_at": _CREATED_AT,
+ "updated_at": _UPDATED_AT,
+ "name": "The name given to the property by a Chameleon administrator.",
+ "description": "The display description.",
+ "kind": "The kind of record this property is attached to: 'profile' or 'company'.",
+ "prop": "The normalized property key.",
+ "integration": "The source integration this property came from.",
+ "last_seen_at": "When this property was last added to or removed from a User Profile.",
+ "types": "The value types seen for this property (string, integer and so on).",
+ "values": "A sample of the most recent values seen for this property, most recent first.",
+ },
+ },
"responses": {
"description": "A Microsurvey response: a single user's interaction with a Microsurvey, including buttons clicked and text entered.",
"docs_url": "https://developers.chameleon.io/apis/survey-responses",
@@ -156,4 +201,21 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"finished_at": "When the last step of the Microsurvey response was completed.",
},
},
+ "interactions": {
+ "description": "A Tour Interaction: the current state of one Tour for one User Profile, such as whether they saw, started, completed or exited it.",
+ "docs_url": "https://developers.chameleon.io/apis/tour-interactions",
+ "columns": {
+ "id": _ID,
+ "created_at": _CREATED_AT,
+ "updated_at": _UPDATED_AT,
+ "state": "The current state of this Tour Interaction: 'started', 'completed', 'exited' or 'displayed'.",
+ "tour_id": "The Chameleon ID of the Tour this interaction belongs to.",
+ "group_id": "The Chameleon ID of the parent Experience that triggered this Tour to begin (Launcher, Tour and so on).",
+ "group_kind": "The kind of parent Experience that triggered this Tour to begin: 'link', 'api_js', 'launcher', 'experiment' or 'campaign'.",
+ "defer_count": "The number of times this Tour was snoozed until later.",
+ "defer_until": "When the current snooze ends.",
+ "goal_at": "When the configured Goal was met.",
+ "profile": "The User Profile this interaction belongs to.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/chameleon.py b/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/chameleon.py
index cedade892d12..a33ee306ddb8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/chameleon.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/chameleon.py
@@ -1,8 +1,11 @@
-import dataclasses
+import itertools
+from collections.abc import Callable, Iterator
from typing import Any, Optional
from requests import Response
+from posthog.dataclasses import frozen
+
from products.warehouse_sources.backend.temporal.data_imports.sources.chameleon.settings import (
CHAMELEON_ENDPOINTS,
ChameleonEndpointConfig,
@@ -13,8 +16,12 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
rest_api_resource,
rest_api_resources,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.config_setup import (
+ make_parent_key_name,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
JSONResponseCursorPaginator,
+ SinglePagePaginator,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.resource import Resource
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ClientConfig
@@ -28,14 +35,14 @@ CHAMELEON_BASE_URL = "https://api.chameleon.io/v3"
CHAMELEON_ROOT_URL = "https://api.chameleon.io"
+@frozen
class ChameleonResumeConfig:
# Cursor for the next page: the `cursor.before` id from the previous response. None starts at page one.
before: str | None = None
# Pre-framework fan-out bookmark (the Microsurvey being paged through). Kept with a default so
# previously saved state still parses; no longer written — fan-out resume lives in fanout_state.
survey_id: str | None = None
- # Framework fan-out resume state for the responses endpoint:
+ # Framework fan-out resume state for a fan-out endpoint:
# {"completed": [child_path, ...], "current": child_path | None, "child_state": {...} | None}.
fanout_state: dict | None = None
@@ -136,60 +143,71 @@ def _standard_resource(
)
-def _stamp_survey_id(row: dict[str, Any]) -> dict[str, Any]:
- # include_from_parent lands the parent Microsurvey id as `_surveys_id`; rename it to the plain
- # `survey_id` column responses rows carry.
- value = row.pop("_surveys_id", None)
- if value is not None:
- row["survey_id"] = value
- return row
+def _stamp_parent_id(parent_name: str, column: str) -> Callable[[dict[str, Any]], dict[str, Any]]:
+ """Rename the parent id `include_from_parent` injects to the plain join column child rows carry.
+
+ Where the API already returns that column (interactions' `tour_id`) the value is the same one —
+ every row came back from a request filtered to that parent.
+ """
+ injected_key = make_parent_key_name(parent_name, "id")
+
+ def stamp(row: dict[str, Any]) -> dict[str, Any]:
+ value = row.pop(injected_key, None)
+ if value is not None:
+ row[column] = value
+ return row
+
+ return stamp
-def _responses_resource(
+def _fan_out_resource(
account_secret: str,
+ config: ChameleonEndpointConfig,
+ parent_name: str,
+ parent_key_column: str,
team_id: int,
job_id: str,
manager: ResumableSourceManager[ChameleonResumeConfig],
) -> Resource:
- """Fan out over every Microsurvey, listing its responses and stamping the parent `survey_id`.
+ """Fan out over every parent record, listing this endpoint per parent and stamping the parent id.
- /analyze/responses requires an `id` (the Microsurvey id), so responses can only be pulled per
- survey. Full refresh — re-pulled rows on resume are deduped by the `id` primary key on merge.
+ /analyze/responses and /analyze/interactions both require an `id` (the Microsurvey and the Tour
+ respectively), so their rows can only be pulled one parent at a time. Full refresh — re-pulled
+ rows on resume are deduped by the `id` primary key on merge.
"""
- surveys_config = CHAMELEON_ENDPOINTS["surveys"]
- responses_config = CHAMELEON_ENDPOINTS["responses"]
+ parent_config = CHAMELEON_ENDPOINTS[parent_name]
rest_config: RESTAPIConfig = {
"client": _client_config(account_secret),
"resources": [
{
- "name": "surveys",
+ "name": parent_name,
"endpoint": {
- "path": surveys_config.path,
- "params": {"limit": surveys_config.page_size},
+ "path": parent_config.path,
+ "params": {"limit": parent_config.page_size},
"paginator": ChameleonBeforeCursorPaginator(),
- "data_selector": surveys_config.data_key,
+ "data_selector": parent_config.data_key,
},
},
{
- "name": "responses",
+ "name": config.name,
"endpoint": {
- # The survey id is a required QUERY param; the framework binds resolve params via
+ # The parent id is a required QUERY param; the framework binds resolve params via
# path templating, so the query string rides in the path (requests merges the
# remaining params into it).
- "path": f"{responses_config.path}?id={{id}}",
+ "path": f"{config.path}?id={{id}}",
"params": {
- "id": {"type": "resolve", "resource": "surveys", "field": "id"},
- "limit": responses_config.page_size,
+ "id": {"type": "resolve", "resource": parent_name, "field": "id"},
+ "limit": config.page_size,
},
"paginator": ChameleonBeforeCursorPaginator(),
- "data_selector": responses_config.data_key,
- # A survey deleted between enumeration and this fetch 404s. Skip it rather than
- # failing the whole sync — the responses are genuinely gone.
+ "data_selector": config.data_key,
+ # A parent deleted between enumeration and this fetch 404s. Skip it rather than
+ # failing the whole sync — its child records are genuinely gone.
"response_actions": [{"status_code": 404, "action": "ignore"}],
},
"include_from_parent": ["id"],
- "data_map": _stamp_survey_id,
+ "data_map": _stamp_parent_id(parent_name, parent_key_column),
},
],
}
@@ -215,7 +233,47 @@ def _responses_resource(
resume_hook=save_checkpoint,
initial_paginator_state=initial_paginator_state,
)
- return next(r for r in resources if r.name == "responses")
+ return next(r for r in resources if r.name == config.name)
+
+
+def _stamp_kind(kind: str) -> Callable[[dict[str, Any]], dict[str, Any]]:
+ # The documented list payload does not echo `kind` back, and profile and company property
+ # definitions share one table, so stamp the kind each request filtered on.
+ def stamp(row: dict[str, Any]) -> dict[str, Any]:
+ row["kind"] = kind
+ return row
+
+ return stamp
+
+
+def _kind_resources(
+ account_secret: str,
+ config: ChameleonEndpointConfig,
+ team_id: int,
+ job_id: str,
+) -> list[Resource]:
+ """One resource per required `kind` value, read back to back into a single table.
+
+ /edit/properties returns the whole matching set in one response, so each kind is a single page.
+ """
+ resources: list[Resource] = []
+ for kind in config.kinds:
+ rest_config: RESTAPIConfig = {
+ "client": _client_config(account_secret),
+ "resources": [
+ {
+ "name": f"{config.name}_{kind}",
+ "endpoint": {
+ "path": f"{config.path}?kind={kind}",
+ "paginator": SinglePagePaginator(),
+ "data_selector": config.data_key,
+ },
+ "data_map": _stamp_kind(kind),
+ }
+ ],
+ }
+ resources.append(rest_api_resource(rest_config, team_id, job_id, None))
+ return resources
def chameleon_source(
@@ -227,14 +285,30 @@ def chameleon_source(
) -> SourceResponse:
endpoint_config: ChameleonEndpointConfig = CHAMELEON_ENDPOINTS[endpoint]
- if endpoint_config.fan_out_over_surveys:
- resource = _responses_resource(account_secret, team_id, job_id, resumable_source_manager)
+ resources: list[Resource]
+ if endpoint_config.fan_out_parent is not None and endpoint_config.fan_out_parent_key is not None:
+ resources = [
+ _fan_out_resource(
+ account_secret,
+ endpoint_config,
+ endpoint_config.fan_out_parent,
+ endpoint_config.fan_out_parent_key,
+ team_id,
+ job_id,
+ resumable_source_manager,
+ )
+ ]
+ elif endpoint_config.kinds:
+ resources = _kind_resources(account_secret, endpoint_config, team_id, job_id)
else:
- resource = _standard_resource(account_secret, endpoint_config, team_id, job_id, resumable_source_manager)
+ resources = [_standard_resource(account_secret, endpoint_config, team_id, job_id, resumable_source_manager)]
+
+ def items() -> Iterator[Any]:
+ return itertools.chain.from_iterable(resources)
return SourceResponse(
name=endpoint,
- items=lambda: resource,
+ items=items,
primary_keys=endpoint_config.primary_keys,
partition_count=1,
partition_size=1,
@@ -243,5 +317,5 @@ def chameleon_source(
partition_keys=[endpoint_config.partition_key] if endpoint_config.partition_key else None,
# Chameleon returns records most-recently-created first.
sort_mode="desc",
- column_hints=resource.column_hints,
+ column_hints=resources[0].column_hints,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/settings.py
index 654a1818bdf8..76536a3735d4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/settings.py
@@ -1,8 +1,10 @@
-from dataclasses import dataclass, field
+from dataclasses import field
from typing import Optional
+from posthog.dataclasses import frozen
-@dataclass
+
+@frozen
class ChameleonEndpointConfig:
name: str
# Path appended to the v3 base URL, e.g. "/analyze/profiles" or "/edit/segments".
@@ -14,9 +16,13 @@ class ChameleonEndpointConfig:
page_size: int = 500 # Chameleon caps `limit` at 500
primary_keys: list[str] = field(default_factory=lambda: ["id"]) # Chameleon IDs are globally-unique ObjectIds
should_sync_default: bool = True
- # Microsurvey responses can only be listed per-survey (the `id` param is required), so this endpoint
- # fans out over every Microsurvey and stamps the parent `survey_id` onto each row.
- fan_out_over_surveys: bool = False
+ # Endpoints that require a parent record's `id` query param can only be listed one parent at a
+ # time, so this endpoint fans out over every record of the named parent endpoint.
+ fan_out_parent: Optional[str] = None
+ # Column the parent's id is stamped onto on each child row.
+ fan_out_parent_key: Optional[str] = None
+ # Values of a required `kind` query param to request in turn, unioned into one table.
+ kinds: tuple[str, ...] = ()
CHAMELEON_ENDPOINTS: dict[str, ChameleonEndpointConfig] = {
@@ -26,13 +32,32 @@ CHAMELEON_ENDPOINTS: dict[str, ChameleonEndpointConfig] = {
"tours": ChameleonEndpointConfig(name="tours", path="/edit/tours", data_key="tours"),
"surveys": ChameleonEndpointConfig(name="surveys", path="/edit/surveys", data_key="surveys"),
"launchers": ChameleonEndpointConfig(name="launchers", path="/edit/launchers", data_key="launchers"),
+ "tooltips": ChameleonEndpointConfig(name="tooltips", path="/edit/tooltips", data_key="tooltips"),
+ "tags": ChameleonEndpointConfig(name="tags", path="/edit/tags", data_key="tags"),
"event_names": ChameleonEndpointConfig(name="event_names", path="/edit/event_names", data_key="event_names"),
+ # /edit/properties requires `kind` and returns the whole matching set in one un-paginated
+ # response, so a complete table means one request per documented kind.
+ "properties": ChameleonEndpointConfig(
+ name="properties",
+ path="/edit/properties",
+ data_key="properties",
+ kinds=("profile", "company"),
+ ),
# Fan-out child: one paginated request per Microsurvey against /analyze/responses?id=<survey_id>.
"responses": ChameleonEndpointConfig(
name="responses",
path="/analyze/responses",
data_key="responses",
- fan_out_over_surveys=True,
+ fan_out_parent="surveys",
+ fan_out_parent_key="survey_id",
+ ),
+ # Fan-out child: one paginated request per Tour against /analyze/interactions?id=<tour_id>.
+ "interactions": ChameleonEndpointConfig(
+ name="interactions",
+ path="/analyze/interactions",
+ data_key="interactions",
+ fan_out_parent="tours",
+ fan_out_parent_key="tour_id",
),
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/source.py
index ced86c993318..1f2a12b9ca4d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/source.py
@@ -104,7 +104,11 @@ You can generate an account-specific API secret in your [Chameleon account setti
ENDPOINTS,
{},
names,
- descriptions={"responses": "Microsurvey responses, fanned out across every Microsurvey. Full refresh only"},
+ descriptions={
+ "responses": "Microsurvey responses, fanned out across every Microsurvey. Full refresh only",
+ "interactions": "Per-user Tour state, fanned out across every Tour. Full refresh only",
+ "properties": "Custom data property definitions for both User Profiles and Companies. Full refresh only",
+ },
should_sync_default={
endpoint: config.should_sync_default for endpoint, config in CHAMELEON_ENDPOINTS.items()
},
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/tests/test_chameleon.py b/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/tests/test_chameleon.py
index 991b349b5fa7..d9c3e1c6afac 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/tests/test_chameleon.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/chameleon/tests/test_chameleon.py
@@ -211,32 +211,62 @@ class TestStandardEndpointPagination:
assert session.headers.get("Accept") == "application/json"
-class TestResponsesFanOut:
+class TestFanOut:
+ @parameterized.expand(
+ [
+ ("responses", "responses", "surveys", "survey_id", "/edit/surveys", "/analyze/responses"),
+ ("interactions", "interactions", "tours", "tour_id", "/edit/tours", "/analyze/interactions"),
+ ]
+ )
@mock.patch(CLIENT_SESSION_PATCH)
- def test_fans_out_over_surveys_and_stamps_survey_id(self, MockSession: mock.MagicMock) -> None:
+ def test_fans_out_over_parents_and_stamps_the_parent_id(
+ self,
+ _name: str,
+ endpoint: str,
+ parent_key: str,
+ stamped_column: str,
+ parent_path: str,
+ child_path: str,
+ MockSession: mock.MagicMock,
+ ) -> None:
session = MockSession.return_value
snapshots = _wire(
session,
[
- _response({"surveys": [{"id": "SV1"}, {"id": "SV2"}], "cursor": {}}),
- _response({"responses": [{"id": "R1"}, {"id": "R2"}], "cursor": {}}),
- _response({"responses": [{"id": "R3"}], "cursor": {}}),
+ _response({parent_key: [{"id": "P1"}, {"id": "P2"}], "cursor": {}}),
+ _response({endpoint: [{"id": "C1"}, {"id": "C2"}], "cursor": {}}),
+ _response({endpoint: [{"id": "C3"}], "cursor": {}}),
],
)
- rows = _rows("responses", _make_manager())
+ rows = _rows(endpoint, _make_manager())
assert rows == [
- {"id": "R1", "survey_id": "SV1"},
- {"id": "R2", "survey_id": "SV1"},
- {"id": "R3", "survey_id": "SV2"},
+ {"id": "C1", stamped_column: "P1"},
+ {"id": "C2", stamped_column: "P1"},
+ {"id": "C3", stamped_column: "P2"},
]
assert [s["url"] for s in snapshots] == [
- "https://api.chameleon.io/v3/edit/surveys",
- "https://api.chameleon.io/v3/analyze/responses?id=SV1",
- "https://api.chameleon.io/v3/analyze/responses?id=SV2",
+ f"https://api.chameleon.io/v3{parent_path}",
+ f"https://api.chameleon.io/v3{child_path}?id=P1",
+ f"https://api.chameleon.io/v3{child_path}?id=P2",
]
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_parent_id_overwrites_the_one_the_api_returned(self, MockSession: mock.MagicMock) -> None:
+ # Interactions already carry `tour_id`; stamping must leave one column holding the parent
+ # actually queried, not two conflicting ones.
+ session = MockSession.return_value
+ _wire(
+ session,
+ [
+ _response({"tours": [{"id": "T1"}], "cursor": {}}),
+ _response({"interactions": [{"id": "I1", "tour_id": "T1", "state": "completed"}], "cursor": {}}),
+ ],
+ )
+
+ assert _rows("interactions", _make_manager()) == [{"id": "I1", "tour_id": "T1", "state": "completed"}]
+
@mock.patch(CLIENT_SESSION_PATCH)
def test_paginates_within_a_survey(self, MockSession: mock.MagicMock) -> None:
session = MockSession.return_value
@@ -352,6 +382,50 @@ class TestResponsesFanOut:
assert [r["id"] for r in rows] == ["R1"]
+class TestPropertiesKinds:
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_requests_each_kind_and_stamps_it(self, MockSession: mock.MagicMock) -> None:
+ # /edit/properties requires `kind`, so a complete table is the union of one request per kind,
+ # and the payload doesn't echo the kind back — without stamping the two are indistinguishable.
+ session = MockSession.return_value
+ snapshots = _wire(
+ session,
+ [
+ _response({"properties": [{"id": "P1", "prop": "plan_cost"}]}),
+ _response({"properties": [{"id": "P2", "prop": "arr"}]}),
+ ],
+ )
+
+ rows = _rows("properties", _make_manager())
+
+ assert rows == [
+ {"id": "P1", "prop": "plan_cost", "kind": "profile"},
+ {"id": "P2", "prop": "arr", "kind": "company"},
+ ]
+ assert [s["url"] for s in snapshots] == [
+ "https://api.chameleon.io/v3/edit/properties?kind=profile",
+ "https://api.chameleon.io/v3/edit/properties?kind=company",
+ ]
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_does_not_paginate_a_kind(self, MockSession: mock.MagicMock) -> None:
+ # The endpoint returns the whole set at once. Paginating it on a stray cursor would re-request
+ # the same complete set until the guard trips, once per kind.
+ session = MockSession.return_value
+ _wire(
+ session,
+ [
+ _response({"properties": [{"id": "P1"}], "cursor": {"before": "P1"}}),
+ _response({"properties": [{"id": "P2"}], "cursor": {"before": "P2"}}),
+ ],
+ )
+
+ rows = _rows("properties", _make_manager())
+
+ assert [r["id"] for r in rows] == ["P1", "P2"]
+ assert session.send.call_count == 2
+
+
class TestResumeStateCompatibility:
def test_pre_migration_saved_state_still_parses(self) -> None:
# ResumableSourceManager._load_json does `dataclass(**saved)` — state saved before the