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 browserbase import source (#69990)

Tom Owers450eaa5ecb35
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 54df75f1cb66..e9997e0516f5 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
@@ -85,6 +85,7 @@ the row lists both.
| breezometer | HTTP | requests | ✅ |
| brevo | HTTP | requests | ✅ |
| brex | HTTP | requests | ✅ |
+| browserbase | HTTP | requests | ✅ |
| bugsnag | HTTP | requests | ✅ |
| buildbetter | HTTP | requests | ✅ |
| buildkite | HTTP | requests | ✅ |
@@ -506,7 +507,6 @@ doesn't conflict with concurrent PRs.
- breezy_hr
- browse_ai
- browser_use
-- browserbase
- cal_com
- campaign_manager_360
- captain_data
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/browserbase.py b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/browserbase.py
new file mode 100644
index 000000000000..34d2814751cd
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/browserbase.py
@@ -0,0 +1,102 @@
+from collections.abc import Iterator
+from typing import Any
+
+import requests
+from structlog.types import FilteringBoundLogger
+from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter
+
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import SourceResponse
+from products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.settings import BROWSERBASE_ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
+
+BROWSERBASE_BASE_URL = "https://api.browserbase.com/v1"
+
+
+class BrowserbaseRetryableError(Exception):
+ pass
+
+
+def _get_headers(api_key: str) -> dict[str, str]:
+ return {
+ "X-BB-API-Key": api_key,
+ "Accept": "application/json",
+ }
+
+
+@retry(
+ retry=retry_if_exception_type(
+ (
+ BrowserbaseRetryableError,
+ requests.ReadTimeout,
+ requests.ConnectionError,
+ requests.exceptions.ChunkedEncodingError,
+ )
+ ),
+ stop=stop_after_attempt(5),
+ wait=wait_exponential_jitter(initial=1, max=30),
+ reraise=True,
+)
+def _fetch(session: requests.Session, url: str, headers: dict[str, str], logger: FilteringBoundLogger) -> Any:
+ response = session.get(url, headers=headers, timeout=60)
+
+ # 429 (rate limited) and 5xx are transient; retry with backoff. Browserbase sends standard
+ # x-ratelimit-* / retry-after headers, but exponential jitter is a safe default without them.
+ if response.status_code == 429 or response.status_code >= 500:
+ raise BrowserbaseRetryableError(f"Browserbase API error (retryable): status={response.status_code}, url={url}")
+
+ if not response.ok:
+ # Log only status and url — the response body can echo imported third-party data.
+ logger.error(f"Browserbase API error: status={response.status_code}, url={url}")
+ response.raise_for_status()
+
+ return response.json()
+
+
+def validate_credentials(api_key: str) -> bool:
+ # `/projects` is the cheapest authenticated probe: a project-scoped key can always list at least
+ # its own project, so a 200 confirms the key is genuine without needing any session data.
+ # `redact_values` masks the key in tracked logs/samples. `capture=False` keeps response bodies out
+ # of HTTP sample storage — project objects can carry arbitrary customer fields the name-based
+ # scrubbers can't recognise. Transport errors (timeout, DNS, reset) propagate rather than being
+ # swallowed as False, so a temporary outage isn't reported as a bad key.
+ url = f"{BROWSERBASE_BASE_URL}/projects"
+ response = make_tracked_session(redact_values=(api_key,), capture=False).get(
+ url, headers=_get_headers(api_key), timeout=10
+ )
+ return response.status_code == 200
+
+
+def get_rows(api_key: str, endpoint: str, logger: FilteringBoundLogger) -> Iterator[list[dict[str, Any]]]:
+ config = BROWSERBASE_ENDPOINTS[endpoint]
+ # `capture=False`: session objects carry arbitrary `userMetadata` (and projects can carry other
+ # customer-defined fields) that the name-based sample scrubbers can't recognise, so keep response
+ # bodies out of HTTP sample storage entirely. Requests are still metered and logged (status + url).
+ session = make_tracked_session(redact_values=(api_key,), capture=False)
+ headers = _get_headers(api_key)
+
+ # Browserbase list endpoints return a plain JSON array with no pagination, page, or cursor params,
+ # so a single request yields the whole collection. The pipeline batches the yielded rows for us.
+ data = _fetch(session, f"{BROWSERBASE_BASE_URL}{config.path}", headers, logger)
+
+ # A non-list success body is an unexpected/error shape. Raise so the sync fails loudly instead of
+ # finishing "successfully" with zero rows and silently hiding the bad response.
+ if not isinstance(data, list):
+ raise ValueError(f"Browserbase: expected a list for endpoint {endpoint}, got {type(data).__name__}")
+
+ if data:
+ yield data
+
+
+def browserbase_source(api_key: str, endpoint: str, logger: FilteringBoundLogger) -> SourceResponse:
+ endpoint_config = BROWSERBASE_ENDPOINTS[endpoint]
+
+ return SourceResponse(
+ name=endpoint,
+ items=lambda: get_rows(api_key=api_key, endpoint=endpoint, logger=logger),
+ primary_keys=endpoint_config.primary_keys,
+ partition_count=1,
+ partition_size=1,
+ partition_mode="datetime" if endpoint_config.partition_key else None,
+ partition_format="month" if endpoint_config.partition_key else None,
+ partition_keys=[endpoint_config.partition_key] if endpoint_config.partition_key else None,
+ )
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/canonical_descriptions.py
new file mode 100644
index 000000000000..70d7a487df0e
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/canonical_descriptions.py
@@ -0,0 +1,42 @@
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
+
+# Descriptions taken from the public Browserbase API reference (https://docs.browserbase.com/reference/api).
+CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
+ "sessions": {
+ "description": "A browser session run on Browserbase, including its lifecycle timestamps, "
+ "resource usage, and region.",
+ "docs_url": "https://docs.browserbase.com/reference/api/list-sessions",
+ "columns": {
+ "id": "Unique identifier for the session.",
+ "createdAt": "Timestamp when the session was created.",
+ "updatedAt": "Timestamp when the session was last updated.",
+ "startedAt": "Timestamp when the session started running.",
+ "endedAt": "Timestamp when the session ended.",
+ "expiresAt": "Timestamp when the session is scheduled to expire.",
+ "projectId": "Identifier of the project the session belongs to.",
+ "status": "Current status of the session (RUNNING, ERROR, TIMED_OUT, or COMPLETED).",
+ "proxyBytes": "Number of bytes transferred through the Browserbase proxy during the session.",
+ "avgCpuUsage": "Average CPU usage over the session's lifetime.",
+ "memoryUsage": "Memory used by the session.",
+ "keepAlive": "Whether the session is kept alive after the automation disconnects.",
+ "contextId": "Identifier of the context (persisted cookies/cache) attached to the session.",
+ "region": "Region the session ran in (for example us-west-2, us-east-1, eu-central-1, ap-southeast-1).",
+ "userMetadata": "Arbitrary user-supplied metadata attached to the session.",
+ },
+ },
+ "projects": {
+ "description": "A Browserbase project reachable by the connected API key.",
+ "docs_url": "https://docs.browserbase.com/reference/api/list-projects",
+ "columns": {
+ "id": "Unique identifier for the project.",
+ "name": "Human-readable name of the project.",
+ "ownerId": "Identifier of the project owner.",
+ "createdAt": "Timestamp when the project was created.",
+ "updatedAt": "Timestamp when the project was last updated.",
+ "defaultTimeout": "Default session timeout, in seconds, for the project.",
+ "concurrency": "Maximum number of concurrent sessions allowed for the project.",
+ },
+ },
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/settings.py
new file mode 100644
index 000000000000..61842d2ee9dd
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/settings.py
@@ -0,0 +1,40 @@
+from dataclasses import dataclass, field
+
+from products.warehouse_sources.backend.types import IncrementalField
+
+
+@dataclass
+class BrowserbaseEndpointConfig:
+ name: str
+ path: str
+ # Field to partition Delta files by. Must be a stable creation-time timestamp so a row never
+ # moves between partitions (Browserbase mutates `updatedAt`/`endedAt`, so those are unsafe).
+ partition_key: str | None = None
+ # Incremental cursor candidates. Left empty for every Browserbase endpoint: the list endpoints
+ # expose no server-side timestamp filter (only `status`/`q` on sessions), so an "incremental"
+ # sync would still fetch the whole collection each run. Full refresh is the honest strategy.
+ incremental_fields: list[IncrementalField] = field(default_factory=list)
+ primary_keys: list[str] = field(default_factory=lambda: ["id"])
+ should_sync_default: bool = True
+
+
+BROWSERBASE_ENDPOINTS: dict[str, BrowserbaseEndpointConfig] = {
+ "sessions": BrowserbaseEndpointConfig(
+ name="sessions",
+ path="/sessions",
+ partition_key="createdAt",
+ primary_keys=["id"],
+ ),
+ "projects": BrowserbaseEndpointConfig(
+ name="projects",
+ path="/projects",
+ partition_key="createdAt",
+ primary_keys=["id"],
+ ),
+}
+
+ENDPOINTS = tuple(BROWSERBASE_ENDPOINTS.keys())
+
+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {
+ name: config.incremental_fields for name, config in BROWSERBASE_ENDPOINTS.items()
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/source.py
index d4ed8f71e613..d5d8a5645f73 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/source.py
@@ -1,19 +1,41 @@
-from typing import cast
+from typing import Optional, cast
from posthog.schema import (
DataWarehouseSourceCategory,
ExternalDataSourceType as SchemaExternalDataSourceType,
+ ReleaseStatus,
SourceConfig,
+ SourceFieldInputConfig,
+ SourceFieldInputConfigType,
)
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import (
+ SourceInputs,
+ SourceResponse,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.browserbase import (
+ browserbase_source,
+ validate_credentials as validate_browserbase_credentials,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.settings import (
+ BROWSERBASE_ENDPOINTS,
+ ENDPOINTS,
+ INCREMENTAL_FIELDS,
+)
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
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import BrowserbaseSourceConfig
from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
class BrowserbaseSource(SimpleSource[BrowserbaseSourceConfig]):
+ lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
+
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.BROWSERBASE
@@ -24,8 +46,80 @@ class BrowserbaseSource(SimpleSource[BrowserbaseSourceConfig]):
name=SchemaExternalDataSourceType.BROWSERBASE,
category=DataWarehouseSourceCategory.ENGINEERING___MONITORING,
label="Browserbase",
- iconPath="/static/services/browserbase.png",
+ releaseStatus=ReleaseStatus.ALPHA,
+ caption="""Enter your Browserbase API key to sync your Browserbase sessions and projects into the PostHog Data warehouse.
+
+You can find your project API key in your [Browserbase dashboard](https://www.browserbase.com/settings). API keys are scoped to a single project.""",
+ iconPath="/static/services/browserbase.svg",
+ docsUrl="https://posthog.com/docs/cdp/sources/browserbase",
keywords=["browser", "automation", "agents", "sessions"],
- fields=cast(list[FieldType], []),
- unreleasedSource=True,
+ fields=cast(
+ list[FieldType],
+ [
+ SourceFieldInputConfig(
+ name="api_key",
+ label="API key",
+ type=SourceFieldInputConfigType.PASSWORD,
+ required=True,
+ placeholder="bb_...",
+ secret=True,
+ ),
+ ],
+ ),
+ )
+
+ def get_canonical_descriptions(self) -> CanonicalDescriptions:
+ from products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.canonical_descriptions import (
+ CANONICAL_DESCRIPTIONS,
+ )
+
+ return CANONICAL_DESCRIPTIONS
+
+ def get_non_retryable_errors(self) -> dict[str, str | None]:
+ return {
+ # An invalid or revoked key surfaces as an HTTPError from `raise_for_status()`. Retrying
+ # can never satisfy a credential problem, so stop the sync. Match the stable status text
+ # and base host, not the per-request path.
+ "401 Client Error: Unauthorized for url: https://api.browserbase.com": "Your Browserbase API key is invalid or has been revoked. Create a new key in your Browserbase project settings, then reconnect.",
+ "403 Client Error: Forbidden for url: https://api.browserbase.com": "Your Browserbase API key does not have access to this data. Check the key's project scope, then reconnect.",
+ }
+
+ def get_schemas(
+ self,
+ config: BrowserbaseSourceConfig,
+ team_id: int,
+ with_counts: bool = False,
+ names: list[str] | None = None,
+ force_refresh: bool = False,
+ ) -> list[SourceSchema]:
+ # Every Browserbase list endpoint is full refresh: there is no server-side timestamp filter,
+ # so nothing can be synced incrementally (see settings.py).
+ schemas = [
+ SourceSchema(
+ name=endpoint,
+ supports_incremental=False,
+ supports_append=False,
+ incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),
+ should_sync_default=BROWSERBASE_ENDPOINTS[endpoint].should_sync_default,
+ )
+ for endpoint in ENDPOINTS
+ ]
+ if names is not None:
+ names_set = set(names)
+ schemas = [s for s in schemas if s.name in names_set]
+ return schemas
+
+ def validate_credentials(
+ self, config: BrowserbaseSourceConfig, team_id: int, schema_name: Optional[str] = None
+ ) -> tuple[bool, str | None]:
+ if validate_browserbase_credentials(config.api_key):
+ return True, None
+
+ return False, "Invalid Browserbase API key"
+
+ def source_for_pipeline(self, config: BrowserbaseSourceConfig, inputs: SourceInputs) -> SourceResponse:
+ return browserbase_source(
+ api_key=config.api_key,
+ endpoint=inputs.schema_name,
+ logger=inputs.logger,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/tests/test_browserbase.py b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/tests/test_browserbase.py
new file mode 100644
index 000000000000..b6528ca577be
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/tests/test_browserbase.py
@@ -0,0 +1,176 @@
+from typing import Any
+
+import pytest
+from unittest.mock import MagicMock, patch
+
+import requests
+from parameterized import parameterized
+from tenacity import wait_none
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.browserbase import browserbase
+from products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.browserbase import (
+ BROWSERBASE_BASE_URL,
+ BrowserbaseRetryableError,
+ _fetch,
+ browserbase_source,
+ get_rows,
+ validate_credentials,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.settings import ENDPOINTS
+
+
+def _response(status_code: int, json_body: Any = None) -> MagicMock:
+ response = MagicMock()
+ response.status_code = status_code
+ response.ok = 200 <= status_code < 300
+ response.text = "" if json_body is None else str(json_body)
+ response.json.return_value = json_body
+
+ def _raise() -> None:
+ if not response.ok:
+ raise requests.HTTPError(f"{status_code} Client Error", response=response)
+
+ response.raise_for_status.side_effect = _raise
+ return response
+
+
+class TestFetch:
+ def setup_method(self) -> None:
+ # Drop the exponential backoff so retryable-status tests don't actually sleep.
+ _fetch.retry.wait = wait_none() # type: ignore[attr-defined]
+
+ def test_returns_parsed_json_on_success(self) -> None:
+ session = MagicMock()
+ session.get.return_value = _response(200, [{"id": "sess_1"}])
+
+ result = _fetch(session, f"{BROWSERBASE_BASE_URL}/sessions", {}, MagicMock())
+
+ assert result == [{"id": "sess_1"}]
+ assert session.get.call_count == 1
+
+ @parameterized.expand([("rate_limited", 429), ("server_error", 500), ("bad_gateway", 503)])
+ def test_retryable_status_raises_retryable_error(self, _name: str, status_code: int) -> None:
+ session = MagicMock()
+ session.get.return_value = _response(status_code, {"error": "nope"})
+
+ with pytest.raises(BrowserbaseRetryableError):
+ _fetch(session, f"{BROWSERBASE_BASE_URL}/sessions", {}, MagicMock())
+
+ # 5 attempts before giving up (stop_after_attempt(5)).
+ assert session.get.call_count == 5
+
+ def test_recovers_after_transient_error(self) -> None:
+ session = MagicMock()
+ session.get.side_effect = [_response(500, {}), _response(200, [{"id": "sess_1"}])]
+
+ result = _fetch(session, f"{BROWSERBASE_BASE_URL}/sessions", {}, MagicMock())
+
+ assert result == [{"id": "sess_1"}]
+ assert session.get.call_count == 2
+
+ @parameterized.expand([("unauthorized", 401), ("forbidden", 403), ("not_found", 404)])
+ def test_client_error_raises_immediately(self, _name: str, status_code: int) -> None:
+ session = MagicMock()
+ session.get.return_value = _response(status_code, {"error": "nope"})
+
+ with pytest.raises(requests.HTTPError):
+ _fetch(session, f"{BROWSERBASE_BASE_URL}/sessions", {}, MagicMock())
+
+ # Client errors are not retried - they can never succeed on retry.
+ assert session.get.call_count == 1
+
+
+class TestGetRows:
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.browserbase._fetch")
+ def test_yields_list_of_rows(self, mock_fetch: MagicMock) -> None:
+ rows = [{"id": "sess_1"}, {"id": "sess_2"}]
+ mock_fetch.return_value = rows
+
+ result = list(get_rows("bb_key", "sessions", MagicMock()))
+
+ assert result == [rows]
+
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.browserbase._fetch")
+ def test_empty_list_yields_nothing(self, mock_fetch: MagicMock) -> None:
+ mock_fetch.return_value = []
+
+ assert list(get_rows("bb_key", "sessions", MagicMock())) == []
+
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.browserbase._fetch")
+ def test_non_list_response_raises(self, mock_fetch: MagicMock) -> None:
+ # Browserbase list endpoints return arrays; a dict means an unexpected/error shape. Raise so the
+ # sync fails loudly instead of finishing "successfully" with zero rows.
+ mock_fetch.return_value = {"statusCode": 500}
+
+ with pytest.raises(ValueError):
+ list(get_rows("bb_key", "sessions", MagicMock()))
+
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.browserbase._fetch")
+ def test_requests_the_endpoint_path(self, mock_fetch: MagicMock) -> None:
+ mock_fetch.return_value = [{"id": "proj_1"}]
+
+ list(get_rows("bb_key", "projects", MagicMock()))
+
+ called_url = mock_fetch.call_args.args[1]
+ assert called_url == f"{BROWSERBASE_BASE_URL}/projects"
+
+
+class TestKeyRedaction:
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.browserbase._fetch")
+ @patch.object(browserbase, "make_tracked_session")
+ def test_get_rows_redacts_key(self, mock_session_factory: MagicMock, mock_fetch: MagicMock) -> None:
+ # The API key must be masked in tracked HTTP logs/samples, not left recoverable from a bucket.
+ mock_fetch.return_value = []
+ mock_session_factory.return_value = MagicMock()
+
+ list(get_rows("bb_secret", "sessions", MagicMock()))
+
+ assert mock_session_factory.call_args.kwargs["redact_values"] == ("bb_secret",)
+ # Response bodies carry arbitrary customer userMetadata the scrubbers can't recognise.
+ assert mock_session_factory.call_args.kwargs["capture"] is False
+
+ @patch.object(browserbase, "make_tracked_session")
+ def test_validate_credentials_redacts_key(self, mock_session_factory: MagicMock) -> None:
+ session = MagicMock()
+ session.get.return_value = _response(200)
+ mock_session_factory.return_value = session
+
+ validate_credentials("bb_secret")
+
+ assert mock_session_factory.call_args.kwargs["redact_values"] == ("bb_secret",)
+ assert mock_session_factory.call_args.kwargs["capture"] is False
+
+
+class TestValidateCredentials:
+ @parameterized.expand([("ok", 200, True), ("unauthorized", 401, False), ("forbidden", 403, False)])
+ @patch.object(browserbase, "make_tracked_session")
+ def test_maps_status_to_bool(
+ self, _name: str, status_code: int, expected: bool, mock_session_factory: MagicMock
+ ) -> None:
+ session = MagicMock()
+ session.get.return_value = _response(status_code)
+ mock_session_factory.return_value = session
+
+ assert validate_credentials("bb_key") is expected
+
+ @patch.object(browserbase, "make_tracked_session")
+ def test_network_error_propagates(self, mock_session_factory: MagicMock) -> None:
+ # A transport failure is transient - it must surface, not be reported as an invalid key.
+ session = MagicMock()
+ session.get.side_effect = requests.ConnectionError("boom")
+ mock_session_factory.return_value = session
+
+ with pytest.raises(requests.ConnectionError):
+ validate_credentials("bb_key")
+
+
+class TestBrowserbaseSource:
+ @parameterized.expand([(endpoint,) for endpoint in ENDPOINTS])
+ def test_source_response_shape(self, endpoint: str) -> None:
+ response = browserbase_source("bb_key", endpoint, MagicMock())
+
+ assert response.name == endpoint
+ assert response.primary_keys == ["id"]
+ # Partition on the stable creation timestamp, never updatedAt.
+ assert response.partition_keys == ["createdAt"]
+ assert response.partition_mode == "datetime"
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/tests/test_browserbase_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/tests/test_browserbase_source.py
new file mode 100644
index 000000000000..6bcc68720ad1
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/browserbase/tests/test_browserbase_source.py
@@ -0,0 +1,122 @@
+from collections.abc import Iterable
+from typing import Any, cast
+
+from unittest.mock import MagicMock, patch
+
+from parameterized import parameterized
+
+from posthog.schema import DataWarehouseSourceCategory, ReleaseStatus, SourceFieldInputConfig
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.browserbase import (
+ browserbase,
+ source as source_module,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.browserbase.source import BrowserbaseSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import BrowserbaseSourceConfig
+from products.warehouse_sources.backend.types import ExternalDataSourceType
+
+
+def _config() -> BrowserbaseSourceConfig:
+ return BrowserbaseSourceConfig(api_key="bb_test_key")
+
+
+class TestBrowserbaseSourceConfig:
+ def test_source_type(self) -> None:
+ assert BrowserbaseSource().source_type == ExternalDataSourceType.BROWSERBASE
+
+ def test_source_config_basics(self) -> None:
+ config = BrowserbaseSource().get_source_config
+
+ assert config.name == "Browserbase"
+ assert config.category == DataWarehouseSourceCategory.ENGINEERING___MONITORING
+ # Alpha, and visible (no unreleasedSource) - a finished source ships connectable.
+ assert config.releaseStatus == ReleaseStatus.ALPHA
+ assert not config.unreleasedSource
+ assert config.iconPath.endswith(".svg")
+
+ def test_single_required_api_key_field(self) -> None:
+ fields = BrowserbaseSource().get_source_config.fields
+
+ assert len(fields) == 1
+ field = fields[0]
+ assert isinstance(field, SourceFieldInputConfig)
+ assert field.name == "api_key"
+ assert field.required is True
+ # API keys are secrets - must never be echoed back to the client.
+ assert field.secret is True
+
+
+class TestBrowserbaseSchemas:
+ def test_lists_expected_endpoints(self) -> None:
+ names = {s.name for s in BrowserbaseSource().get_schemas(_config(), team_id=1)}
+
+ assert names == {"sessions", "projects"}
+
+ @parameterized.expand([("sessions",), ("projects",)])
+ def test_every_endpoint_is_full_refresh_only(self, endpoint: str) -> None:
+ # No Browserbase list endpoint exposes a server-side timestamp filter, so nothing can sync
+ # incrementally - guarding against a future edit flipping this on without a real filter.
+ schema = next(s for s in BrowserbaseSource().get_schemas(_config(), team_id=1) if s.name == endpoint)
+
+ assert schema.supports_incremental is False
+ assert schema.supports_append is False
+ assert schema.incremental_fields == []
+
+ def test_names_filter(self) -> None:
+ schemas = BrowserbaseSource().get_schemas(_config(), team_id=1, names=["projects"])
+
+ assert [s.name for s in schemas] == ["projects"]
+
+ def test_documented_tables_render_for_public_docs(self) -> None:
+ # lists_tables_without_credentials=True means the public docs <SourceTables /> is fed here.
+ tables = BrowserbaseSource().get_documented_tables()
+
+ by_name = {t["name"]: t for t in tables}
+ assert set(by_name) == {"sessions", "projects"}
+ assert by_name["sessions"]["description"]
+ assert by_name["sessions"]["sync_methods"] == ["Full refresh"]
+
+
+class TestBrowserbaseCredentials:
+ @parameterized.expand([("valid", True, True), ("invalid", False, False)])
+ @patch.object(source_module, "validate_browserbase_credentials")
+ def test_validate_credentials(
+ self, _name: str, probe_result: bool, expected_ok: bool, mock_validate: MagicMock
+ ) -> None:
+ mock_validate.return_value = probe_result
+
+ ok, error = BrowserbaseSource().validate_credentials(_config(), team_id=1)
+
+ assert ok is expected_ok
+ assert (error is None) is expected_ok
+
+ def test_non_retryable_errors_cover_auth_failures(self) -> None:
+ errors = BrowserbaseSource().get_non_retryable_errors()
+
+ assert any("401" in key for key in errors)
+ assert any("403" in key for key in errors)
+
+
+class TestBrowserbasePipelineHandoff:
+ @patch.object(browserbase, "make_tracked_session")
+ def test_source_for_pipeline_plumbs_endpoint_and_key(self, mock_session_factory: MagicMock) -> None:
+ session = MagicMock()
+ response = MagicMock()
+ response.status_code = 200
+ response.ok = True
+ response.json.return_value = [{"id": "sess_1", "createdAt": "2026-01-01T00:00:00Z"}]
+ session.get.return_value = response
+ mock_session_factory.return_value = session
+
+ inputs = MagicMock()
+ inputs.schema_name = "sessions"
+
+ source_response = BrowserbaseSource().source_for_pipeline(_config(), inputs)
+
+ assert source_response.name == "sessions"
+ assert source_response.primary_keys == ["id"]
+
+ # The items thunk should actually pull rows using the configured key/endpoint.
+ rows = list(cast(Iterable[Any], source_response.items()))
+ assert rows == [[{"id": "sess_1", "createdAt": "2026-01-01T00:00:00Z"}]]
+ assert session.get.call_args.kwargs["headers"]["X-BB-API-Key"] == "bb_test_key"
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py
index 9a26500f616f..8994d7848d0f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py
@@ -569,7 +569,7 @@ class BrowserUseSourceConfig(config.Config):
@config.config
class BrowserbaseSourceConfig(config.Config):
- pass
+ api_key: str
@config.config