: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
fix(cdp): bump Google Ads destination v21 to v24 ahead of Aug 5 sunset (#74075)
Daniel Marchukf9d9a4e371ab
diff --git a/frontend/src/mocks/fixtures/_hogFunctionTemplatesDestinations.json b/frontend/src/mocks/fixtures/_hogFunctionTemplatesDestinations.jsonindex c12144d486be..55b551c142f8 100644--- a/frontend/src/mocks/fixtures/_hogFunctionTemplatesDestinations.json+++ b/frontend/src/mocks/fixtures/_hogFunctionTemplatesDestinations.json@@ -13650,7 +13650,7 @@"type": "destination","id": "template-google-ads","name": "Google Ads Conversions",- "hog": "if (empty(inputs.gclid)) {\n print('Empty `gclid`. Skipping...')\n return\n}\n\nlet body := {\n 'conversions': [\n {\n 'gclid': inputs.gclid,\n 'conversion_action': f'customers/{splitByString('/', inputs.customerId)[1]}/conversionActions/{inputs.conversionActionId}',\n 'conversion_date_time': inputs.conversionDateTime\n }\n ],\n 'partialFailure': true\n}\n\nif (not empty(inputs.conversionValue)) {\n body.conversions[1].conversion_value := inputs.conversionValue\n}\nif (not empty(inputs.currencyCode)) {\n body.conversions[1].currency_code := inputs.currencyCode\n}\nif (not empty(inputs.orderId)) {\n body.conversions[1].order_id := inputs.orderId\n}\n\nlet res := fetch(f'https://googleads.googleapis.com/v18/customers/{splitByString('/', inputs.customerId)[1]}:uploadClickConversions', {\n 'method': 'POST',\n 'headers': {\n 'Authorization': f'Bearer {inputs.oauth.access_token}',\n 'Content-Type': 'application/json',\n 'login-customer-id': splitByString('/', inputs.customerId)[2]\n },\n 'body': body\n})\n\nif (res.status >= 400) {\n throw Error(f'Error from googleads.googleapis.com (status {res.status}): {res.body}')\n} else if (not empty(res.body.partialFailureError)) {\n throw Error(f'Error from googleads.googleapis.com (status {res.status}): {res.body.partialFailureError.message}')\n}",+ "hog": "if (empty(inputs.gclid)) {\n print('Empty `gclid`. Skipping...')\n return\n}\n\nlet body := {\n 'conversions': [\n {\n 'gclid': inputs.gclid,\n 'conversion_action': f'customers/{splitByString('/', inputs.customerId)[1]}/conversionActions/{inputs.conversionActionId}',\n 'conversion_date_time': inputs.conversionDateTime\n }\n ],\n 'partialFailure': true\n}\n\nif (not empty(inputs.conversionValue)) {\n body.conversions[1].conversion_value := inputs.conversionValue\n}\nif (not empty(inputs.currencyCode)) {\n body.conversions[1].currency_code := inputs.currencyCode\n}\nif (not empty(inputs.orderId)) {\n body.conversions[1].order_id := inputs.orderId\n}\n\nlet res := fetch(f'https://googleads.googleapis.com/v24/customers/{splitByString('/', inputs.customerId)[1]}:uploadClickConversions', {\n 'method': 'POST',\n 'headers': {\n 'Authorization': f'Bearer {inputs.oauth.access_token}',\n 'Content-Type': 'application/json',\n 'login-customer-id': splitByString('/', inputs.customerId)[2]\n },\n 'body': body\n})\n\nif (res.status >= 400) {\n throw Error(f'Error from googleads.googleapis.com (status {res.status}): {res.body}')\n} else if (not empty(res.body.partialFailureError)) {\n throw Error(f'Error from googleads.googleapis.com (status {res.status}): {res.body.partialFailureError.message}')\n}","inputs_schema": [{"key": "oauth",diff --git a/nodejs/src/cdp/templates/_destinations/google_ads/google.template.test.ts b/nodejs/src/cdp/templates/_destinations/google_ads/google.template.test.tsindex 1c39ac2fead1..dc35d5364dab 100644--- a/nodejs/src/cdp/templates/_destinations/google_ads/google.template.test.ts+++ b/nodejs/src/cdp/templates/_destinations/google_ads/google.template.test.ts@@ -67,7 +67,7 @@ describe('google template', () => {},"method": "POST","type": "fetch",- "url": "https://googleads.googleapis.com/v21/customers/1231231234:uploadClickConversions",+ "url": "https://googleads.googleapis.com/v24/customers/1231231234:uploadClickConversions",}`)@@ -105,7 +105,7 @@ describe('google template', () => {},"method": "POST","type": "fetch",- "url": "https://googleads.googleapis.com/v21/customers/1231231234:uploadClickConversions",+ "url": "https://googleads.googleapis.com/v24/customers/1231231234:uploadClickConversions",}`)@@ -144,7 +144,7 @@ describe('google template', () => {},"method": "POST","type": "fetch",- "url": "https://googleads.googleapis.com/v21/customers/1231231234:uploadClickConversions",+ "url": "https://googleads.googleapis.com/v24/customers/1231231234:uploadClickConversions",}`)diff --git a/nodejs/src/cdp/templates/_destinations/google_ads/google.template.ts b/nodejs/src/cdp/templates/_destinations/google_ads/google.template.tsindex 64085701128d..fad2fa3d77aa 100644--- a/nodejs/src/cdp/templates/_destinations/google_ads/google.template.ts+++ b/nodejs/src/cdp/templates/_destinations/google_ads/google.template.ts@@ -1,7 +1,7 @@import { HogFunctionInputSchemaType } from '~/cdp/types'import { HogFunctionTemplate } from '~/cdp/types'-// Based on https://developers.google.com/google-ads/api/reference/rpc/v21/ClickConversion+// Based on https://developers.google.com/google-ads/api/reference/rpc/v24/ClickConversionconst build_inputs = (): HogFunctionInputSchemaType[] => {return [@@ -104,7 +104,7 @@ if (not empty(inputs.orderId)) {body.conversions[1].order_id := inputs.orderId}-let res := fetch(f'https://googleads.googleapis.com/v21/customers/{splitByString('/', inputs.customerId)[1]}:uploadClickConversions', {+let res := fetch(f'https://googleads.googleapis.com/v24/customers/{splitByString('/', inputs.customerId)[1]}:uploadClickConversions', {'method': 'POST','headers': {'Authorization': f'Bearer {inputs.oauth.access_token}',diff --git a/posthog/management/commands/test/test_update_hog_function_code.py b/posthog/management/commands/test/test_update_hog_function_code.pyindex c3d7d41a709d..54af42076c5b 100644--- a/posthog/management/commands/test/test_update_hog_function_code.py+++ b/posthog/management/commands/test/test_update_hog_function_code.py@@ -188,6 +188,54 @@ class TestUpdateHogFunctionCode(BaseTest):self.assertIn("Updated: 1", output)self.assertIn("Update completed", output)+ @patch("posthog.management.commands.update_hog_function_code.compile_hog")+ def test_update_google_ads_api_version_bumps_whole_stale_range(self, mock_compile_hog):+ """Google Ads uses a multi-version replacement range; destinations on different stale+ versions (v18, v21) must all land on v24, and a v24 one is left untouched."""+ mock_compile_hog.return_value = "compiled_bytecode"+ base = (+ "let res := fetch(f'https://googleads.googleapis.com/{version}/customers/1:uploadClickConversions', {{}})"+ )+ with patch("products.cdp.backend.models.hog_functions.hog_function.reload_hog_functions_on_workers"):+ g_v18 = HogFunction.objects.create(+ team=self.team,+ name="G v18",+ type="destination",+ template_id="template-google-ads",+ hog=base.replace("{version}", "v18"),+ enabled=True,+ )+ g_v21 = HogFunction.objects.create(+ team=self.team,+ name="G v21",+ type="destination",+ template_id="template-google-ads",+ hog=base.replace("{version}", "v21"),+ enabled=True,+ )+ g_v24 = HogFunction.objects.create(+ team=self.team,+ name="G v24",+ type="destination",+ template_id="template-google-ads",+ hog=base.replace("{version}", "v24"),+ enabled=True,+ )++ out = StringIO()+ call_command("update_hog_function_code", replace_key="google-ads-api-version-update", stdout=out)++ g_v18.refresh_from_db()+ g_v21.refresh_from_db()+ g_v24.refresh_from_db()+ assert "googleads.googleapis.com/v24/" in g_v18.hog and "/v18/" not in g_v18.hog+ assert "googleads.googleapis.com/v24/" in g_v21.hog and "/v21/" not in g_v21.hog+ assert g_v24.hog == base.replace("{version}", "v24") # unchanged++ output = out.getvalue()+ self.assertIn("Found 3 destinations to process", output)+ self.assertIn("Updated: 2", output)+@patch("posthog.management.commands.update_hog_function_code.compile_hog")def test_update_skips_destinations_that_fail_to_compile(self, mock_compile_hog):"""A destination with uncompilable hog is skipped and logged, not fatal to the whole run."""diff --git a/posthog/management/commands/update_hog_function_code.py b/posthog/management/commands/update_hog_function_code.pyindex c048f73f6eb7..f9ec6a7865bb 100644--- a/posthog/management/commands/update_hog_function_code.py+++ b/posthog/management/commands/update_hog_function_code.py@@ -61,6 +61,17 @@ class Command(BaseCommand):},],},+ # Google Ads API v21 sunsets 2026-08-05 (VERSION_SUNSET). Bump the pinned version in+ # existing destinations to v24 (current major, sunsets ~2027-05). Covers the whole stale+ # range v18-v23 since destinations carry whatever version the template pinned when created;+ # only one matches per destination, and a v24 no-op is skipped.+ "google-ads-api-version-update": {+ "template_id": "template-google-ads",+ "replacements": [+ {"from_string": f"googleads.googleapis.com/v{v}/", "to_string": "googleads.googleapis.com/v24/"}+ for v in range(18, 24)+ ],+ },# Microsoft migrated Teams/Power Automate HTTP triggers to environment.api.powerplatform.com.# The current template accepts that host, but functions created earlier keep their frozen code# and reject the new URL. These swap the stale validation block for the current one: thediff --git a/posthog/models/integration.py b/posthog/models/integration.pyindex bd0111d2fd16..86fee7d7a9d4 100644--- a/posthog/models/integration.py+++ b/posthog/models/integration.py@@ -1835,7 +1835,7 @@ class GoogleAdsIntegration:def list_google_ads_conversion_actions(self, customer_id, parent_id=None) -> list[dict]:response = requests.request("POST",- f"https://googleads.googleapis.com/v21/customers/{customer_id}/googleAds:searchStream",+ f"https://googleads.googleapis.com/v24/customers/{customer_id}/googleAds:searchStream",json={"query": "SELECT conversion_action.id, conversion_action.name FROM conversion_action WHERE conversion_action.status != 'REMOVED'"},@@ -1880,7 +1880,7 @@ class GoogleAdsIntegration:def list_google_ads_accessible_accounts(self) -> list[dict[str, Any]]:response = requests.request("GET",- "https://googleads.googleapis.com/v21/customers:listAccessibleCustomers",+ "https://googleads.googleapis.com/v24/customers:listAccessibleCustomers",headers={"Content-Type": "application/json","Authorization": f"Bearer {self.integration.sensitive_config['access_token']}",@@ -1920,7 +1920,7 @@ class GoogleAdsIntegration:accounts = []response = requests.request("POST",- f"https://googleads.googleapis.com/v21/customers/{account_id}/googleAds:searchStream",+ f"https://googleads.googleapis.com/v24/customers/{account_id}/googleAds:searchStream",json={"query": "SELECT customer_client.descriptive_name, customer_client.client_customer, customer_client.level, customer_client.manager, customer_client.status FROM customer_client WHERE customer_client.level <= 5"},