From abf434140ec54bab76a0b121cd6d11aa27863f52 Mon Sep 17 00:00:00 2001 From: Ben White Date: Tue, 6 Aug 2024 14:07:30 +0200 Subject: [PATCH] fix(cdp): Salesforce destinations url (#24218) --- posthog/cdp/templates/salesforce/template_salesforce.py | 8 ++++---- .../cdp/templates/salesforce/test_template_salesforce.py | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/posthog/cdp/templates/salesforce/template_salesforce.py b/posthog/cdp/templates/salesforce/template_salesforce.py index 65246e8959e383..8a370c4375a457 100644 --- a/posthog/cdp/templates/salesforce/template_salesforce.py +++ b/posthog/cdp/templates/salesforce/template_salesforce.py @@ -20,11 +20,11 @@ template_create: HogFunctionTemplate = HogFunctionTemplate( status="alpha", id="template-salesforce-create", - name="Salesforce", + name="Create Salesforce objects", description="Create objects in Salesforce", icon_url="/static/services/salesforce.png", hog=""" -let res := fetch(f'https://posthog.my.salesforce.com/services/data/v61.0/sobjects/{inputs.path}', { +let res := fetch(f'{inputs.oauth.instance_url}/services/data/v61.0/sobjects/{inputs.path}', { 'body': inputs.properties, 'method': 'POST', 'headers': { @@ -68,11 +68,11 @@ template_update: HogFunctionTemplate = HogFunctionTemplate( status="alpha", id="template-salesforce-update", - name="Salesforce", + name="Update Salesforce objects", description="Update objects in Salesforce", icon_url="/static/services/salesforce.png", hog=""" -let res := fetch(f'https://posthog.my.salesforce.com/services/data/v61.0/sobjects/{inputs.path}', { +let res := fetch(f'{inputs.oauth.instance_url}/services/data/v61.0/sobjects/{inputs.path}', { 'body': inputs.properties, 'method': 'PATCH', 'headers': { diff --git a/posthog/cdp/templates/salesforce/test_template_salesforce.py b/posthog/cdp/templates/salesforce/test_template_salesforce.py index 7c6929769c0d3e..cc90c96de6893b 100644 --- a/posthog/cdp/templates/salesforce/test_template_salesforce.py +++ b/posthog/cdp/templates/salesforce/test_template_salesforce.py @@ -12,6 +12,7 @@ class TestTemplateSalesforceCreate(BaseHogFunctionTemplateTest): def _inputs(self, **kwargs): inputs = { "oauth": { + "instance_url": "https://example.my.salesforce.com", "access_token": "oauth-1234", }, "path": "Contact", @@ -27,7 +28,7 @@ def test_function_works(self): self.run_function(self._inputs()) assert self.get_mock_fetch_calls()[0] == snapshot( ( - "https://posthog.my.salesforce.com/services/data/v61.0/sobjects/Contact", + "https://example.my.salesforce.com/services/data/v61.0/sobjects/Contact", { "body": {"foo": "bar"}, "method": "POST", @@ -43,6 +44,7 @@ class TestTemplateSalesforceUpdate(BaseHogFunctionTemplateTest): def _inputs(self, **kwargs): inputs = { "oauth": { + "instance_url": "https://example.my.salesforce.com", "access_token": "oauth-1234", }, "path": "Lead/Email/example@posthog.com", @@ -58,7 +60,7 @@ def test_function_works(self): self.run_function(self._inputs()) assert self.get_mock_fetch_calls()[0] == snapshot( ( - "https://posthog.my.salesforce.com/services/data/v61.0/sobjects/Lead/Email/example@posthog.com", + "https://example.my.salesforce.com/services/data/v61.0/sobjects/Lead/Email/example@posthog.com", { "body": {"foo": "bar"}, "method": "PATCH",