Skip to content

Commit

Permalink
fix(cdp): Salesforce destinations url (PostHog#24218)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite authored and silentninja committed Aug 8, 2024
1 parent aa2227c commit abf4341
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions posthog/cdp/templates/salesforce/template_salesforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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': {
Expand Down
6 changes: 4 additions & 2 deletions posthog/cdp/templates/salesforce/test_template_salesforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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/[email protected]",
Expand All @@ -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/[email protected]",
"https://example.my.salesforce.com/services/data/v61.0/sobjects/Lead/Email/[email protected]",
{
"body": {"foo": "bar"},
"method": "PATCH",
Expand Down

0 comments on commit abf4341

Please sign in to comment.