Skip to content

Commit

Permalink
Merge branch 'master' into group-type-project
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes authored Oct 29, 2024
2 parents 6915d5d + 483358d commit f04c43b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function HogFunctionFilters(): JSX.Element {
label: 'Run once per interval',
},
{
value: '{person.uuid}',
value: '{person.id}',
label: 'Run once per person per interval',
},
]}
Expand Down
37 changes: 23 additions & 14 deletions posthog/cdp/templates/meta_ads/template_meta_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,31 @@
icon_url="/static/services/meta-ads.png",
category=["Advertisement"],
hog="""
let body := {
'data': [
{
'event_name': inputs.eventName,
'event_time': inputs.eventTime,
'action_source': inputs.actionSource,
'user_data': {}
}
],
'access_token': inputs.accessToken
}
for (let key, value in inputs.userData) {
// e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 is an empty string hashed
if (not empty(value) and value != 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') {
body.data.1.user_data[key] := value
}
}
let res := fetch(f'https://graph.facebook.com/v21.0/{inputs.pixelId}/events', {
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
},
'body': {
'data': [
{
'event_name': inputs.eventName,
'event_time': inputs.eventTime,
'action_source': inputs.actionSource,
'user_data': inputs.userData
}
],
'access_token': inputs.accessToken
}
'body': body
})
if (res.status >= 400) {
throw Error(f'Error from graph.facebook.com (status {res.status}): {res.body}')
Expand Down Expand Up @@ -118,9 +127,9 @@
"label": "User data",
"description": "A map that contains customer information data. See this page for options: https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters",
"default": {
"em": "{sha256Hex(person.properties.email)}",
"fn": "{sha256Hex(person.properties.first_name)}",
"ln": "{sha256Hex(person.properties.last_name)}",
"em": "{sha256Hex(person.properties.email ?? '')}",
"fn": "{sha256Hex(person.properties.first_name ?? '')}",
"ln": "{sha256Hex(person.properties.last_name ?? '')}",
},
"secret": False,
"required": True,
Expand Down
5 changes: 4 additions & 1 deletion posthog/cdp/templates/meta_ads/test_template_meta_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ def _inputs(self, **kwargs):
"eventName": "checkout",
"eventTime": "1728812163",
"actionSource": "website",
"userData": {"em": "3edfaed7454eedb3c72bad566901af8bfbed1181816dde6db91dfff0f0cffa98"},
"userData": {
"em": "3edfaed7454eedb3c72bad566901af8bfbed1181816dde6db91dfff0f0cffa98",
"fn": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
},
}
inputs.update(kwargs)
return inputs
Expand Down

0 comments on commit f04c43b

Please sign in to comment.