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): implement the trustradius import source (#111871)

Tom Owers6d7ed65e2d76
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
index d9f8fc8fe749..ab73c513b8c3 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
@@ -778,6 +778,7 @@ the row lists both.
| trigger_dev | HTTP | requests | ✅ |
| trunk_io | HTTP | requests + `rest_source.RESTClient` | ✅ |
| trino | HTTP (vendor SDK) | trino | ✅ |
+| trustradius | HTTP | requests | ✅ |
| turso | HTTP | requests + `rest_source.RESTClient` | ✅ |
| tvmaze | HTTP | requests + `rest_source.RESTClient` | ✅ |
| twelve_data | HTTP | requests | ✅ |
@@ -1461,7 +1462,6 @@ doesn't conflict with concurrent PRs.
- tradable_bits
- tremendous
- triple_whale
-- trustradius
- twitch
- two_c2p
- tyntec_sms
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/trustradius.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/trustradius.py
index 37889d34d9e3..62bd0fa3d9fd 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/trustradius.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/trustradius.py
@@ -6,4 +6,4 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common imp
@config.config
class TrustradiusSourceConfig(config.Config):
- pass
+ api_key: str
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/api_inventory.md b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/api_inventory.md
new file mode 100644
index 000000000000..3bc2f0a83710
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/api_inventory.md
@@ -0,0 +1,40 @@
+# TrustRadius API inventory
+
+The source uses the documented `https://api.trustradius.com/v1` server.
+The specification label is `1.1`, but the version sent in requests is `v1`.
+
+Official references:
+
+- [API reference](https://apidocs.trustradius.com/docs/public-api/YXBpOjUxMzgzNjA-trust-radius-api)
+- [Vendor OpenAPI export](https://stoplight.io/api/v1/projects/trustradius/public-api/nodes/reference/api.oas3.yml?fromExportButton=true&snapshotType=http_service)
+
+| Table | GET path | Response | Key | Sync |
+| -------------- | ----------------- | ---------------- | ----- | ------------ |
+| products | `/product-ids` | Array | `_id` | Full refresh |
+| product_scores | `/product-scores` | `products` array | `id` | Full refresh |
+| trustquotes | `/trustquotes` | Array | `id` | Full refresh |
+| tags | `/tags` | Array | `id` | Full refresh |
+
+These endpoints have no documented pagination parameters.
+The source makes one request per table and does not send a record limit.
+TrustQuotes includes anonymous quotes through the documented `include-anonymous` parameter.
+Its `created` field provides a stable partition key.
+
+TrustQuotes accepts date filters, but the specification does not identify the filtered field or guarantee response order.
+The source therefore offers full refresh for this table.
+The other three endpoints have no documented time filters.
+
+The product list covers published products under the vendor profile.
+Product scores cover products licensed for that API.
+The API key and license control access to quotes and tags.
+The security definition directs customers to their Client Success Manager for an API key.
+
+The specification has no `/reviews` endpoint.
+Traffic reports need product identifiers and have separate pagination requirements.
+Intent data has a limited date range and a `more` signal without a documented continuation request.
+These reports are outside this source's initial scope.
+
+On 2026-10-05, requests without credentials and with an invented invalid key returned HTTP 401.
+Successful responses were verified against the official specification and mocked tests.
+No licensed account was available for a live sync.
+The specification does not state a default quote limit or guarantee unrestricted historical coverage.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/canonical_descriptions.py
new file mode 100644
index 000000000000..7cbd6bfc6bc0
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/canonical_descriptions.py
@@ -0,0 +1,56 @@
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.trustradius.settings import API_DOCS_URL
+
+CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
+ "products": {
+ "description": "Published products listed under the vendor profile.",
+ "docs_url": API_DOCS_URL,
+ "columns": {
+ "_id": "The product identifier for other TrustRadius API calls.",
+ "slug": "The product name identifier used in TrustRadius URLs.",
+ "vendor": "The identifier and name of the vendor.",
+ },
+ },
+ "product_scores": {
+ "description": "Product scores and review counts for products licensed for the API.",
+ "docs_url": API_DOCS_URL,
+ "columns": {
+ "id": "The product identifier.",
+ "name": "The product name.",
+ "trScore": "The TrustRadius score and its maximum value.",
+ "starScore": "The star score and its maximum value.",
+ "reviewCount": "The number of reviews.",
+ "ratingCount": "The number of ratings.",
+ "ratingsAndReviewsTotalCount": "The combined number of ratings and reviews.",
+ "url": "The product URL.",
+ },
+ },
+ "trustquotes": {
+ "description": "Quotes from product reviews, with reviewer details and assigned tags.",
+ "docs_url": API_DOCS_URL,
+ "columns": {
+ "id": "The quote identifier.",
+ "created": "The date when the quote was created.",
+ "text": "The quote text.",
+ "review": "The source review, including its rating and publication date.",
+ "product": "The product identifier and name.",
+ "vendor": "The vendor identifier and name.",
+ "isAnonymous": "Whether the quote comes from an anonymous review.",
+ "allTags": "The identifiers of the assigned tags.",
+ "allTagNames": "The names of the assigned tags.",
+ },
+ },
+ "tags": {
+ "description": "Tags and tag groups used to classify TrustQuotes.",
+ "docs_url": API_DOCS_URL,
+ "columns": {
+ "id": "The tag identifier.",
+ "name": "The tag name.",
+ "tagGroup": "The group that contains the tag.",
+ "vendor": "The vendor identifier and name.",
+ "products": "The identifiers and names of products associated with the tag.",
+ },
+ },
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/settings.py
new file mode 100644
index 000000000000..476ed831b4dd
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/settings.py
@@ -0,0 +1,49 @@
+from typing import TypedDict
+
+API_VERSION = "v1"
+BASE_URL = f"https://api.trustradius.com/{API_VERSION}"
+API_DOCS_URL = "https://apidocs.trustradius.com/docs/public-api/YXBpOjUxMzgzNjA-trust-radius-api"
+
+
+class EndpointConfig(TypedDict):
+ path: str
+ data_selector: str
+ primary_keys: list[str]
+ partition_key: str | None
+
+
+ENDPOINTS: dict[str, EndpointConfig] = {
+ "products": {
+ "path": "product-ids",
+ "data_selector": "",
+ "primary_keys": ["_id"],
+ "partition_key": None,
+ },
+ "product_scores": {
+ "path": "product-scores",
+ "data_selector": "products",
+ "primary_keys": ["id"],
+ "partition_key": None,
+ },
+ "trustquotes": {
+ "path": "trustquotes",
+ "data_selector": "",
+ "primary_keys": ["id"],
+ "partition_key": "created",
+ },
+ "tags": {
+ "path": "tags",
+ "data_selector": "",
+ "primary_keys": ["id"],
+ "partition_key": None,
+ },
+}
+
+AUTH_ERROR = "TrustRadius rejected your API key. Check the key with your TrustRadius Client Success Manager."
+PERMISSION_ERROR = (
+ "TrustRadius denied access. Ask your Client Success Manager to check your API license and permissions."
+)
+NON_RETRYABLE_ERRORS = {
+ "401 Client Error": AUTH_ERROR,
+ "403 Client Error": PERMISSION_ERROR,
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/source.py
index 557c9bf1b34d..dae9d90f7a7d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/source.py
@@ -1,27 +1,102 @@
from typing import cast
-from products.warehouse_sources.backend.facade.source_config import DataWarehouseSourceCategory, SourceConfig
+from products.warehouse_sources.backend.facade.source_config import (
+ DataWarehouseSourceCategory,
+ ReleaseStatus,
+ SourceConfig,
+ SourceFieldInputConfig,
+ SourceFieldInputConfigType,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import (
+ SourceSchema,
+ build_endpoint_schemas,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceInputs, SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.trustradius import (
TrustradiusSourceConfig,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.trustradius.canonical_descriptions import (
+ CANONICAL_DESCRIPTIONS,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.trustradius.settings import (
+ API_DOCS_URL,
+ API_VERSION,
+ ENDPOINTS,
+ NON_RETRYABLE_ERRORS,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.trustradius.trustradius import (
+ trustradius_source,
+ validate_credentials,
+)
from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
class TrustradiusSource(SimpleSource[TrustradiusSourceConfig]):
+ lists_tables_without_credentials = True
+ supported_versions = (API_VERSION,)
+ default_version = API_VERSION
+ api_docs_url = API_DOCS_URL
+
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.TRUSTRADIUS
+ def get_non_retryable_errors(self) -> dict[str, str | None]:
+ return dict(NON_RETRYABLE_ERRORS)
+
+ def get_canonical_descriptions(self) -> CanonicalDescriptions:
+ return CANONICAL_DESCRIPTIONS
+
+ def get_schemas(
+ self,
+ config: TrustradiusSourceConfig,
+ team_id: int,
+ with_counts: bool = False,
+ names: list[str] | None = None,
+ force_refresh: bool = False,
+ api_version: str | None = None,
+ ) -> list[SourceSchema]:
+ return build_endpoint_schemas(ENDPOINTS, {}, names)
+
+ def validate_credentials(
+ self,
+ config: TrustradiusSourceConfig,
+ team_id: int,
+ schema_name: str | None = None,
+ api_version: str | None = None,
+ ) -> tuple[bool, str | None]:
+ return validate_credentials(config.api_key)
+
+ def source_for_pipeline(self, config: TrustradiusSourceConfig, inputs: SourceInputs) -> SourceResponse:
+ return trustradius_source(config.api_key, inputs.schema_name, inputs.team_id, inputs.job_id)
+
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.TRUSTRADIUS,
category=DataWarehouseSourceCategory.MARKETING___EMAIL,
label="TrustRadius",
+ caption="Get your API key from your TrustRadius Client Success Manager. "
+ "Your license must include access to the selected tables.",
iconPath="/static/services/trustradius.png",
- fields=cast(list[FieldType], []),
- unreleasedSource=True,
+ releaseStatus=ReleaseStatus.ALPHA,
+ fields=cast(
+ list[FieldType],
+ [
+ SourceFieldInputConfig(
+ name="api_key",
+ label="API key",
+ type=SourceFieldInputConfigType.PASSWORD,
+ required=True,
+ placeholder="",
+ secret=True,
+ ),
+ ],
+ ),
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/tests/test_trustradius.py b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/tests/test_trustradius.py
new file mode 100644
index 000000000000..5a191d4e1c7b
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/tests/test_trustradius.py
@@ -0,0 +1,141 @@
+import json
+from collections.abc import Iterable
+from http import HTTPStatus
+from typing import Any, cast
+from urllib.parse import parse_qs, urlsplit
+
+import pytest
+from unittest.mock import patch
+
+from requests import Response
+from requests.exceptions import HTTPError
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import UnknownResourceError
+from products.warehouse_sources.backend.temporal.data_imports.sources.trustradius.source import TrustradiusSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.trustradius.trustradius import (
+ trustradius_source,
+ validate_credentials,
+)
+
+
+def response(body: object, status: int = 200) -> Response:
+ result = Response()
+ result.status_code = status
+ result.reason = HTTPStatus(status).phrase
+ result.url = "https://api.trustradius.com/v1/product-ids"
+ result._content = json.dumps(body).encode()
+ result.headers["Content-Type"] = "application/json"
+ return result
+
+
+ ("endpoint", "path", "row", "params"),
+ [
+ ("products", "product-ids", {"_id": "product-example", "slug": "example-product"}, {}),
+ ("product_scores", "product-scores", {"id": "product-example", "reviewCount": 42}, {}),
+ (
+ "trustquotes",
+ "trustquotes",
+ {"id": "quote-example", "text": "An invented quote.", "created": "2025-01-01"},
+ {"include-anonymous": ["true"]},
+ ),
+ ("tags", "tags", {"id": "tag-example", "name": "Example tag"}, {}),
+ ],
+)
[email protected]("empty", [False, True])
+def test_full_refresh_selects_rows_and_stops_after_one_request(
+ endpoint: str, path: str, row: dict[str, Any], params: dict[str, list[str]], empty: bool
+) -> None:
+ rows = [] if empty else [row]
+ body = {"products": rows} if endpoint == "product_scores" else rows
+ with patch("requests.adapters.HTTPAdapter.send", return_value=response(body)) as send:
+ result = trustradius_source("example-secret", endpoint, 1, "test-job")
+ assert [item for page in cast(Iterable[Any], result.items()) for item in page] == rows
+
+ send.assert_called_once()
+ request = send.call_args.args[0]
+ assert request.method.upper() == "GET"
+ assert urlsplit(request.url).path == f"/v1/{path}"
+ assert parse_qs(urlsplit(request.url).query) == params
+ assert request.headers["x-api-key"] == "example-secret"
+ assert request.headers["Accept"] == "application/json"
+ assert "example-secret" not in request.url
+ assert send.call_args.kwargs["timeout"] == (10, 60)
+
+
+ ("status", "body", "expected"),
+ [
+ (200, [], (True, None)),
+ (
+ 401,
+ {
+ "name": "NotAuthorized",
+ "status": 401,
+ "message": "You are not authorized to access Unable to verify your identity, please check that your API key is valid",
+ },
+ (
+ False,
+ "TrustRadius rejected your API key. Check the key with your TrustRadius Client Success Manager.",
+ ),
+ ),
+ (
+ 403,
+ {"message": "Forbidden"},
+ (
+ False,
+ "TrustRadius denied access. Ask your Client Success Manager to check your API license and permissions.",
+ ),
+ ),
+ ],
+)
+def test_validate_credentials_uses_one_request_and_maps_auth_errors(
+ status: int, body: object, expected: tuple[bool, str | None]
+) -> None:
+ with patch("requests.adapters.HTTPAdapter.send", return_value=response(body, status)) as send:
+ assert validate_credentials("example-secret") == expected
+ send.assert_called_once()
+ request = send.call_args.args[0]
+ assert request.url == "https://api.trustradius.com/v1/product-ids"
+ assert request.headers["x-api-key"] == "example-secret"
+
+
[email protected]("status", [400, 404])
+def test_validation_does_not_mislabel_other_errors(status: int) -> None:
+ with patch("requests.adapters.HTTPAdapter.send", return_value=response({}, status)) as send:
+ with pytest.raises(HTTPError):
+ validate_credentials("example-secret")
+ send.assert_called_once()
+
+
[email protected]("status", [401, 403])
+def test_sync_auth_errors_match_terminal_messages(status: int) -> None:
+ with patch("requests.adapters.HTTPAdapter.send", return_value=response({}, status)) as send:
+ with pytest.raises(HTTPError) as error:
+ list(cast(Iterable[Any], trustradius_source("example-secret", "products", 1, "test-job").items()))
+ send.assert_called_once()
+ messages = TrustradiusSource().get_non_retryable_errors()
+ assert len([message for pattern, message in messages.items() if pattern in str(error.value)]) == 1
+
+
[email protected]("status", [429, 500, 503])
+def test_transient_failures_retry_and_keep_auth(status: int) -> None:
+ with patch("requests.adapters.HTTPAdapter.send", side_effect=[response({}, status), response([])]) as send:
+ assert list(cast(Iterable[Any], trustradius_source("example-secret", "products", 1, "test-job").items())) == []
+ assert send.call_count == 2
+ assert all(call.args[0].headers["x-api-key"] == "example-secret" for call in send.call_args_list)
+
+
[email protected]("endpoint", ["products", "product_scores", "trustquotes", "tags"])
+def test_unexpected_response_shape_fails_instead_of_erasing_table(endpoint: str) -> None:
+ with patch("requests.adapters.HTTPAdapter.send", return_value=response({"unexpected": []})) as send:
+ with pytest.raises(ValueError, match="Required"):
+ list(cast(Iterable[Any], trustradius_source("example-secret", endpoint, 1, "test-job").items()))
+ send.assert_called_once()
+
+
+def test_unknown_endpoint_fails_before_request() -> None:
+ with patch("requests.adapters.HTTPAdapter.send") as send:
+ with pytest.raises(UnknownResourceError):
+ trustradius_source("example-secret", "unknown", 1, "test-job")
+ send.assert_not_called()
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/trustradius.py b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/trustradius.py
new file mode 100644
index 000000000000..bc1975fe6749
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/trustradius/trustradius.py
@@ -0,0 +1,80 @@
+from requests.exceptions import HTTPError
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (
+ RESTAPIConfig,
+ RESTClient,
+ rest_api_resource,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import APIKeyAuth
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
+ SinglePagePaginator,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import schema_for_resource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
+from products.warehouse_sources.backend.temporal.data_imports.sources.trustradius.settings import (
+ AUTH_ERROR,
+ BASE_URL,
+ ENDPOINTS,
+ PERMISSION_ERROR,
+)
+
+
+def validate_credentials(api_key: str) -> tuple[bool, str | None]:
+ client = RESTClient(
+ base_url=BASE_URL,
+ auth=APIKeyAuth(api_key=api_key, name="x-api-key", location="header"),
+ paginator=SinglePagePaginator(),
+ request_timeout=(10, 60),
+ allow_redirects=False,
+ )
+ try:
+ next(client.paginate("product-ids", data_selector="", data_selector_required=True), None)
+ except HTTPError as error:
+ if error.response is not None:
+ if error.response.status_code == 401:
+ return False, AUTH_ERROR
+ if error.response.status_code == 403:
+ return False, PERMISSION_ERROR
+ raise
+ return True, None
+
+
+def trustradius_source(api_key: str, endpoint: str, team_id: int, job_id: str) -> SourceResponse:
+ settings = schema_for_resource(ENDPOINTS, endpoint)
+ config: RESTAPIConfig = {
+ "client": {
+ "base_url": BASE_URL,
+ "auth": {"type": "api_key", "api_key": api_key, "name": "x-api-key", "location": "header"},
+ "paginator": "single_page",
+ "headers": {"Accept": "application/json"},
+ "request_timeout": (10, 60),
+ "allow_redirects": False,
+ },
+ "resources": [
+ {
+ "name": endpoint,
+ "table_name": endpoint,
+ "table_format": "delta",
+ "write_disposition": "replace",
+ "endpoint": {
+ "path": settings["path"],
+ "data_selector": settings["data_selector"],
+ "data_selector_required": True,
+ "params": {"include-anonymous": "true"} if endpoint == "trustquotes" else {},
+ },
+ }
+ ],
+ }
+ resource = rest_api_resource(config, team_id, job_id, None)
+ partition_key = settings["partition_key"]
+ return SourceResponse(
+ name=endpoint,
+ items=lambda: resource,
+ primary_keys=settings["primary_keys"],
+ column_hints=resource.column_hints,
+ partition_keys=[partition_key] if partition_key else None,
+ partition_mode="datetime" if partition_key else None,
+ partition_format="month" if partition_key else None,
+ sort_mode=None,
+ supports_resume=False,
+ )