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(data-warehouse): add adobe analytics users and annotations tables (#116115)

Tom Owersa3d895d4879c
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
index 19f6b831d682..51d10920ee85 100644
--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
@@ -216,7 +216,6 @@
1 products/warehouse_sources/backend/temporal/data_imports/sources/adjust/adjust.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/adjust/settings.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/adobe_analytics.py
-1 products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/settings.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/settings.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/adroll/adroll.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/adroll/settings.py
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 9f79e47d453d..e4798f83a893 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
@@ -161,8 +161,8 @@ Today (6): `calculated_metrics`, `dimensions`, `metrics`, `report`, `report_suit
Diffed against: <https://raw.githubusercontent.com/AdobeDocs/analytics-2.0-apis/main/static/swagger.json>
-- [ ] `Users (GET /api/{globalCompanyId}/users)` — resolve owner login IDs in segments and calculated metrics to identifiable users (high)
-- [ ] `Annotations (GET /api/{globalCompanyId}/annotations)` — explain traffic and conversion changes with recorded launches, incidents, and campaign dates (medium)
+- [x] `Users (GET /api/{globalCompanyId}/users)` — resolve owner login IDs in segments and calculated metrics to identifiable users (high)
+- [x] `Annotations (GET /api/{globalCompanyId}/annotations)` — explain traffic and conversion changes with recorded launches, incidents, and campaign dates (medium)
- [ ] `Usage logs (GET /api/{globalCompanyId}/auditlogs/usage)` — analyze report adoption, user activity, and access across report suites (medium)
Note: Parsed all collection GET operations in the official Adobe Swagger reference. The configurable report table already accepts a dimension and metrics, so equivalent report variants were excluded. Users resolve component owner IDs; annotations and usage logs need separate tables. The usage endpoint requires an IMS user token, unlike the source server credential.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/adobe_analytics.py b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/adobe_analytics.py
index 8144900a4f4e..f3d9e25e341a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/adobe_analytics.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/adobe_analytics.py
@@ -286,7 +286,7 @@ def _metadata_batches(
resume: Optional[AdobeAnalyticsResumeConfig],
) -> Iterator[list[dict[str, Any]]]:
config = ADOBE_ANALYTICS_ENDPOINTS[endpoint]
- params: dict[str, Any] = {}
+ params: dict[str, Any] = dict(config.extra_params)
if config.report_suite_param:
params[config.report_suite_param] = report_suite_id
@@ -303,6 +303,13 @@ def _metadata_batches(
page = resume.page if resume is not None else 0
while True:
payload = client.get_json(config.path, {**params, "limit": METADATA_PAGE_SIZE, "page": page})
+ # The spec documents `/users` as a bare array while the live API wraps it in a page
+ # envelope, so accept either shape.
+ if isinstance(payload, list):
+ if payload:
+ yield payload
+ break
+
items = list((payload or {}).get(config.data_key) or [])
if items:
yield items
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/canonical_descriptions.py
index 43c3f9312e51..b6ed0715a22f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/canonical_descriptions.py
@@ -81,6 +81,48 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"precision": "Number of decimal places the metric is reported to.",
},
},
+ "users": {
+ "description": "An Adobe Analytics user in the login company, used to resolve component owner ids.",
+ "docs_url": "https://developer.adobe.com/analytics-apis/docs/2.0/apis/",
+ "columns": {
+ "loginId": "Unique identifier for the user, matching the `owner.id` of segments and calculated metrics.",
+ "login": "Login name of the user.",
+ "companyid": "Login company id the user belongs to.",
+ "email": "Email address of the user.",
+ "firstName": "First name of the user.",
+ "lastName": "Last name of the user.",
+ "fullName": "Full display name of the user.",
+ "title": "Job title entered for the user.",
+ "imsUserId": "Adobe Identity Management System id of the user.",
+ "disabled": "Whether the user account is disabled.",
+ "createDate": "Timestamp the user was created.",
+ "lastAccess": "Timestamp the user last accessed Adobe Analytics.",
+ "tempLoginEnd": "Timestamp a temporary login expires, if the user is temporary.",
+ },
+ },
+ "annotations": {
+ "description": "An annotation: a note pinned to a date range to explain changes in report data.",
+ "docs_url": "https://developer.adobe.com/analytics-apis/docs/2.0/guides/endpoints/annotations/",
+ "columns": {
+ "id": "Unique identifier for the annotation.",
+ "name": "Name of the annotation.",
+ "description": "The annotation's description.",
+ "dateRange": "ISO 8601 date range the annotation covers, in the report suite's time zone.",
+ "color": "Display color of the annotation, `STANDARD1` through `STANDARD9`.",
+ "applyToAllReports": "Whether the annotation applies to all report suites.",
+ "scope": "The metrics and filters the annotation is limited to.",
+ "createdDate": "Timestamp the annotation was created.",
+ "modifiedDate": "Timestamp the annotation was last modified.",
+ "modifiedById": "Id of the user who last modified the annotation.",
+ "tags": "Tags applied to the annotation.",
+ "shares": "Shares applied to the annotation.",
+ "approved": "Whether an admin approved the annotation.",
+ "owner": "Id, name, and login of the user who created the annotation.",
+ "companyId": "Login company id of the annotation.",
+ "reportSuiteName": "Friendly name of the annotation's report suite.",
+ "rsid": "Report suite id the annotation belongs to.",
+ },
+ },
"report": {
"description": (
"Daily report rows from the Adobe Analytics reporting API: one row per report suite, day, "
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/settings.py
index 70b033f1b22f..69215131691d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/settings.py
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
-from typing import Optional
+from typing import Any, Optional
from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType
@@ -15,8 +15,27 @@ REPORT_PAGE_SIZE = 400
DEFAULT_REPORT_DIMENSION = "variables/daterangeday"
DEFAULT_REPORT_METRICS = "metrics/visits,metrics/visitors,metrics/pageviews"
+ANNOTATION_EXPANSIONS = (
+ "name",
+ "description",
+ "dateRange",
+ "color",
+ "applyToAllReports",
+ "scope",
+ "createdDate",
+ "modifiedDate",
+ "modifiedById",
+ "tags",
+ "shares",
+ "approved",
+ "owner",
+ "companyId",
+ "reportSuiteName",
+ "rsid",
+)
-@dataclass
+
+@dataclass(frozen=True)
class AdobeAnalyticsEndpointConfig:
name: str
# Path under https://analytics.adobe.io/api/{globalCompanyId}
@@ -27,6 +46,7 @@ class AdobeAnalyticsEndpointConfig:
data_key: Optional[str] = None
# Query param used to scope the request to the configured report suite, if any.
report_suite_param: Optional[str] = None
+ extra_params: dict[str, Any] = field(default_factory=dict)
incremental_fields: list[IncrementalField] = field(default_factory=list)
@@ -63,6 +83,24 @@ ADOBE_ANALYTICS_ENDPOINTS: dict[str, AdobeAnalyticsEndpointConfig] = {
primary_key=["rsid", "id"],
report_suite_param="rsid",
),
+ "users": AdobeAnalyticsEndpointConfig(
+ name="users",
+ path="/users",
+ primary_key=["loginId"],
+ data_key="content",
+ ),
+ "annotations": AdobeAnalyticsEndpointConfig(
+ name="annotations",
+ path="/annotations",
+ primary_key=["id"],
+ data_key="content",
+ extra_params={
+ # Without `expansion` Adobe returns only the annotation id, and without `includeType`
+ # only annotations the technical account itself owns.
+ "expansion": ",".join(ANNOTATION_EXPANSIONS),
+ "includeType": "all",
+ },
+ ),
REPORT_ENDPOINT: AdobeAnalyticsEndpointConfig(
name=REPORT_ENDPOINT,
path="/reports",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/tests/test_adobe_analytics.py b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/tests/test_adobe_analytics.py
index af11f25f20ef..0ecd14f6f1ad 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/tests/test_adobe_analytics.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_analytics/tests/test_adobe_analytics.py
@@ -292,6 +292,31 @@ class TestMetadataEndpoints:
assert result.requests[1].query == {suite_param: ("rs1",)}
assert result.final_state is None
+ def test_annotations_request_expanded_fields_across_all_owners_on_every_page(self) -> None:
+ result = _driver().run(
+ "annotations",
+ [
+ _token(),
+ ScriptedResponse(json={"content": [{"id": "a1", "name": "Launch"}], "lastPage": False}),
+ ScriptedResponse(json={"content": [{"id": "a2", "name": "Outage"}], "lastPage": True}),
+ ],
+ )
+
+ assert result.raised is None
+ assert result.items == [[{"id": "a1", "name": "Launch"}], [{"id": "a2", "name": "Outage"}]]
+ assert result.params("includeType") == [None, "all", "all"]
+ for expansion in result.params("expansion")[1:]:
+ assert expansion is not None
+ assert {"name", "dateRange", "modifiedDate", "rsid"} <= set(expansion.split(","))
+
+ def test_users_served_as_a_bare_array_are_yielded_once(self) -> None:
+ result = _driver().run("users", [_token(), ScriptedResponse(json=[{"loginId": 1, "login": "jane"}])])
+
+ assert result.raised is None
+ assert result.items == [[{"loginId": 1, "login": "jane"}]]
+ assert result.paths == ["/ims/token/v3", "/api/gcid/users"]
+ assert result.final_state is None
+
class TestReportEndpoint:
@mock.patch(f"{_MODULE}._today", return_value=date(2024, 1, 3))