: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): support Bloomerang API version v2 (#86337)
Tom Owers39a87a3a38c7
diff --git a/products/warehouse_sources/backend/migrations/0150_repin_bloomerang_api_version.py b/products/warehouse_sources/backend/migrations/0150_repin_bloomerang_api_version.pynew file mode 100644index 000000000000..20c1ab79ca19--- /dev/null+++ b/products/warehouse_sources/backend/migrations/0150_repin_bloomerang_api_version.py@@ -0,0 +1,37 @@+from django.db import migrations++# Bloomerang has deprecated its v1 REST API. This source has always spoken the current v2 REST API+# on the wire (BASE_URL ends in `/v2`) — the framework label was the unversioned `v1` default. The+# source now declares `v2` as the explicit default and marks the legacy `v1` label deprecated. There+# is no per-version dispatch, so `v1` and `v2` resolve to byte-identical requests; this repins+# existing source-level pins from `v1` to `v2` so they stop carrying a deprecated label. It is a pure+# relabel, not a version move — no data/schema transform is needed.+BLOOMERANG_SOURCE_TYPE = "Bloomerang"+OLD_VERSION = "v1"+NEW_VERSION = "v2"+++def repin_bloomerang_v1_to_v2(apps, schema_editor):+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")++ # Only the source-level pin is touched. Schema-level `ExternalDataSchema.api_version` overrides+ # are user-managed (a customer intentionally pinned that schema) and are left alone — the+ # schema-level deprecation warning prompts the user to migrate those.+ #+ # NULL pins already resolve to the source's `default_version` (now `v2`), so they need no update.+ # Matching only `api_version="v1"` keeps this idempotent: a second run matches nothing.+ ExternalDataSource.objects.filter(source_type=BLOOMERANG_SOURCE_TYPE, api_version=OLD_VERSION).update(+ api_version=NEW_VERSION+ )+++class Migration(migrations.Migration):+ dependencies = [+ ("warehouse_sources", "0149_datawarehousetable_created_via"),+ ]++ operations = [+ # Reverse is a no-op: once repinned, these rows are indistinguishable from natively-created+ # ones, so a blanket downgrade would clobber legitimate `v2` pins made after this ran.+ migrations.RunPython(repin_bloomerang_v1_to_v2, migrations.RunPython.noop, elidable=True),+ ]diff --git a/products/warehouse_sources/backend/migrations/max_migration.txt b/products/warehouse_sources/backend/migrations/max_migration.txtindex acf08b13d912..3f6d952a782f 100644--- a/products/warehouse_sources/backend/migrations/max_migration.txt+++ b/products/warehouse_sources/backend/migrations/max_migration.txt@@ -1 +1 @@-0149_datawarehousetable_created_via+0150_repin_bloomerang_api_versiondiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bloomerang/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bloomerang/source.pyindex 14b60c80ab68..18c6f486f78e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bloomerang/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bloomerang/source.py@@ -18,7 +18,12 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.bloomerangENDPOINTS,INCREMENTAL_FIELDS,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import (+ UNVERSIONED_API_VERSION,+ FieldType,+ ResumableSource,+ VersionDeprecation,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (CanonicalDescriptions,)@@ -39,8 +44,16 @@ from products.warehouse_sources.backend.types import ExternalDataSourceTypeclass BloomerangSource(ResumableSource[BloomerangSourceConfig, BloomerangResumeConfig]):lists_tables_without_credentials = True # static endpoint catalog — safe for public docs- # Bloomerang's v2 REST API has no dated/numbered version token to pin (the "v2" is a fixed- # path segment, not a documented choice among several) — only the docs link is set.+ # The source has always spoken Bloomerang's current v2 REST API on the wire (BASE_URL ends in+ # `/v2`); the framework label was just the unversioned default. Bloomerang has now deprecated+ # its v1 REST API, so `v2` is declared as the explicit default and the legacy unversioned `v1`+ # label is marked deprecated. There is no per-version dispatch — `/v2` is a fixed path segment,+ # not a request input — so both labels resolve to identical requests. Existing `v1`-pinned rows+ # keep working unchanged and are repinned to `v2` by data migration (a pure relabel, not a move).+ # No calendar sunset date is published for v1.+ supported_versions = (UNVERSIONED_API_VERSION, "v2")+ default_version = "v2"+ deprecated_versions = (VersionDeprecation(version=UNVERSIONED_API_VERSION, sunset_at=None),)api_docs_url = "https://bloomerang.com/api/rest-api"@propertydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bloomerang/tests/test_bloomerang_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bloomerang/tests/test_bloomerang_source.pyindex 9276ad841871..3cfb1b8d5e12 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bloomerang/tests/test_bloomerang_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bloomerang/tests/test_bloomerang_source.py@@ -4,6 +4,7 @@ from unittest import mockfrom posthog.schema import ReleaseStatus, SourceFieldInputConfig, SourceFieldInputConfigTypefrom products.warehouse_sources.backend.temporal.data_imports.sources.bloomerang.bloomerang import (+ BASE_URL,BloomerangResumeConfig,)from products.warehouse_sources.backend.temporal.data_imports.sources.bloomerang.settings import (@@ -156,3 +157,22 @@ class TestBloomerangSource:self.source.source_for_pipeline(self.config, mock.MagicMock(), inputs)assert mock_bloomerang_source.call_args.kwargs["db_incremental_field_last_value"] is None++ @pytest.mark.parametrize(+ "pinned, expected_version",+ [("v1", "v1"), ("v2", None), (None, None)],+ )+ def test_deprecation_flags_legacy_v1_only(self, pinned, expected_version):+ deprecation = self.source.get_version_deprecation(pinned)+ if expected_version is None:+ assert deprecation is None+ else:+ assert deprecation is not None+ assert deprecation.version == expected_version+ assert deprecation.sunset_at is None # vendor published no sunset date++ def test_request_layer_stays_on_the_v2_wire(self):+ # No per-version dispatch: `/v2` is a fixed path segment, so a legacy v1 pin rides the same+ # wire as v2. Regressing this URL to v1 would move every v1-pinned source onto the vendor's+ # deprecated API.+ assert BASE_URL == "https://api.bloomerang.co/v2"