: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(cdp): add a native pinterest conversions destination (#105627)
Daniel Marchuk4d05de444628
diff --git a/nodejs/src/cdp/templates/_destinations/pinterest_ads/pinterest.template.test.ts b/nodejs/src/cdp/templates/_destinations/pinterest_ads/pinterest.template.test.tsnew file mode 100644index 000000000000..5d1676166ad8--- /dev/null+++ b/nodejs/src/cdp/templates/_destinations/pinterest_ads/pinterest.template.test.ts@@ -0,0 +1,205 @@+import { DateTime } from 'luxon'++import { parseJSON } from '~/common/utils/json-parse'++import { TemplateTester, createAdDestinationPayload } from '../../test/test-helpers'+import { template } from './pinterest.template'++jest.setTimeout(2 * 60 * 1000)++const settings = { adAccountId: 'ad-account-id', conversionToken: 'conversion-token' }+const sentRequest = (response: any): { url: string; body: string } => response.invocation.queueParameters+const sentBody = (response: any): string => sentRequest(response).body+const sentEvent = (response: any): any => parseJSON(sentBody(response)).data[0]++describe('pinterest template', () => {+ const tester = new TemplateTester(template)++ beforeEach(async () => {+ await tester.beforeEach()+ const fixedTime = DateTime.fromISO('2025-01-01T00:00:00Z').toJSDate()+ jest.spyOn(Date, 'now').mockReturnValue(fixedTime.getTime())+ })++ it('sends a product event with content fields and hashed user data', async () => {+ const response = await tester.invokeMapping(+ 'Product viewed',+ settings,+ createAdDestinationPayload({+ event: {+ event: 'Product Viewed',+ properties: {+ sku: '43431-18',+ name: 'Trail shoe 🥾 "Pro"',+ brand: 'Café Nørd',+ category: 'Footwear',+ price: 30.5,+ quantity: 2,+ currency: 'EUR',+ $current_url: 'https://example.com/shoes?epik=abc',+ $ip: '203.0.113.7',+ $raw_user_agent: 'Mozilla/5.0 (Macintosh)',+ },+ },+ person: {+ properties: {+ email: ' [email protected] ',+ phone: '+1 (234) 567-890',+ first_name: 'Zoë',+ $geoip_city_name: 'St. Louis',+ $geoip_country_code: 'US',+ epik: 'epik-click-id',+ },+ },+ })+ )++ expect(response.error).toBeUndefined()+ expect(response.finished).toEqual(false)+ expect(response.invocation.queueParameters).toMatchInlineSnapshot(`+ {+ "body": "{"data":[{"event_name":"view_content","action_source":"web","event_time":1735689600,"event_id":"event-id","user_data":{"em":["3d4eee8538a4bbbe2ef7912f90ee494c1280f74dd7fd81232e58deb9cb9997e3"],"ph":["c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646"],"fn":["2752b88686847fa5c86f47b94ce652b7b3f22a91c37617d451a4db9afa431450"],"ln":["32e83e92d45d71f69dcf9d214688f0375542108631b45d344e5df2eb91c11566"],"ct":["8ba24bdf99947996f3000259be455de791b06fcc0e802ce05031030df1ee8ea3"],"country":["79adb2a2fce5c6ba215fe5f27f532d4e7edbac4b6a5e09e1ef3a08084a904621"],"external_id":["b5400f5d931b20e0e905cc4a009a428ce3427b3110e3a2a1cfc7e6349beabc10"],"client_ip_address":"203.0.113.7","client_user_agent":"Mozilla/5.0 (Macintosh)","click_id":"epik-click-id"},"event_source_url":"https://example.com/shoes?epik=abc","custom_data":{"currency":"EUR","value":"30.5","content_ids":["43431-18"],"contents":[{"id":"43431-18","item_price":"30.5","quantity":2,"item_name":"Trail shoe 🥾 \\"Pro\\"","item_brand":"Café Nørd","item_category":"Footwear"}],"num_items":2,"content_name":"Trail shoe 🥾 \\"Pro\\"","content_brand":"Café Nørd","content_category":"Footwear"}}]}",+ "headers": {+ "Authorization": "Bearer conversion-token",+ "Content-Type": "application/json",+ },+ "method": "POST",+ "type": "fetch",+ "url": "https://api.pinterest.com/v5/ad_accounts/ad-account-id/events",+ }+ `)++ const fetchResponse = await tester.invokeFetchResponse(response.invocation, {+ status: 200,+ body: { num_events_received: 1, num_events_processed: 1, events: [{ status: 'processed' }] },+ })+ expect(fetchResponse.finished).toBe(true)+ expect(fetchResponse.error).toBeUndefined()+ })++ it('sends a multi product order in test mode, keeping a value of 0', async () => {+ const response = await tester.invokeMapping(+ 'Order completed',+ { ...settings, testMode: true },+ createAdDestinationPayload({+ event: {+ properties: {+ order_id: 'order-1',+ value: 0,+ products: [+ { sku: '18499-12', price: 30, quantity: 1 },+ { product_id: 101, price: 15 },+ { sku: '', product_id: 'p-3' },+ { name: 'no id' },+ ],+ },+ },+ })+ )++ expect(sentRequest(response).url).toEqual(+ 'https://api.pinterest.com/v5/ad_accounts/ad-account-id/events?test=true'+ )++ expect(sentEvent(response)).toMatchObject({+ event_name: 'checkout',+ custom_data: {+ value: '0',+ order_id: 'order-1',+ content_ids: ['18499-12', '101', 'p-3'],+ contents: [+ { id: '18499-12', item_price: '30', quantity: 1 },+ { id: '101', item_price: '15' },+ { id: 'p-3' },+ ],+ num_items: 4,+ },+ })+ })++ it.each([+ ['no email', { email: null }, ['client_ip_address', 'client_user_agent', 'external_id', 'fn', 'ln', 'ph']],+ ['an email list with a null in it', { email: [null, ''] }, ['client_ip_address', 'client_user_agent']],+ ])('sends by IP and user agent for a person with %s', async (_, personProperties, expectedKeys) => {+ const response = await tester.invokeMapping(+ 'Order completed',+ settings,+ createAdDestinationPayload({+ event: { properties: { $ip: '203.0.113.7', $raw_user_agent: 'Mozilla/5.0' } },+ person: { properties: personProperties },+ })+ )++ expect(response.error).toBeUndefined()+ const event = sentEvent(response)+ expect(event.user_data.em).toBeUndefined()+ expect(Object.keys(event.user_data)).toEqual(expect.arrayContaining(expectedKeys))+ expect(event.custom_data).toBeUndefined()+ expect(sentBody(response)).not.toContain('undefined')+ expect(sentBody(response)).not.toContain('null')+ })++ it('does not hash a value twice', async () => {+ const hashed = '3d4eee8538a4bbbe2ef7912f90ee494c1280f74dd7fd81232e58deb9cb9997e3'+ const response = await tester.invokeMapping(+ 'Page viewed',+ settings,+ createAdDestinationPayload({ person: { properties: { email: hashed.toUpperCase() } } })+ )++ expect(sentEvent(response).user_data.em).toEqual([hashed])+ })++ it('skips a person Pinterest cannot match', async () => {+ const response = await tester.invokeMapping(+ 'Order completed',+ settings,+ createAdDestinationPayload({+ event: { properties: { $raw_user_agent: 'Mozilla/5.0' } },+ person: { properties: { email: null } },+ })+ )++ expect(response.error).toBeUndefined()+ expect(response.finished).toBe(true)+ expect(response.invocation.queueParameters).toBeUndefined()+ expect(response.logs.map((log) => log.message)).toContainEqual(+ 'Skipping event: Pinterest needs an email (em), a mobile ad ID (hashed_maids), or both an IP address and a user agent.'+ )+ })++ it.each([+ [+ 'an error status',+ { status: 401, body: { code: 2, message: 'Authentication failed.' } },+ "Error from api.pinterest.com (status 401): {'code': 2, 'message': 'Authentication failed.'}",+ ],+ [+ 'a rejected event in a 200 response',+ {+ status: 200,+ body: {+ num_events_received: 1,+ num_events_processed: 0,+ events: [{ status: 'failed', error_message: 'Invalid event_name: purchase.' }],+ },+ },+ 'Pinterest rejected the event: Invalid event_name: purchase.',+ ],+ ])('fails on %s', async (_, fetchResult, expectedError) => {+ const response = await tester.invokeMapping('Order completed', settings, createAdDestinationPayload())++ const fetchResponse = await tester.invokeFetchResponse(response.invocation, fetchResult)+ expect(fetchResponse.finished).toBe(true)+ expect(fetchResponse.error).toEqual(expectedError)+ })++ it.each([+ ['missing ad account ID', { conversionToken: 'conversion-token' }],+ ['missing conversion token', { adAccountId: 'ad-account-id' }],+ ])('fails on %s', async (_, incompleteSettings) => {+ const response = await tester.invokeMapping('Order completed', incompleteSettings, createAdDestinationPayload())+ expect(response.error).toMatchInlineSnapshot(`"Ad account ID and conversion token are required"`)+ expect(response.finished).toEqual(true)+ })+})diff --git a/nodejs/src/cdp/templates/_destinations/pinterest_ads/pinterest.template.ts b/nodejs/src/cdp/templates/_destinations/pinterest_ads/pinterest.template.tsnew file mode 100644index 000000000000..fde21ee29a75--- /dev/null+++ b/nodejs/src/cdp/templates/_destinations/pinterest_ads/pinterest.template.ts@@ -0,0 +1,408 @@+import { HogFunctionInputSchemaType, HogFunctionTemplate } from '~/cdp/types'++// Based on https://developers.pinterest.com/docs/api/v5/events-create++const EVENT_NAMES: { value: string; label: string }[] = [+ { value: 'add_payment_info', label: 'Add payment info' },+ { value: 'add_to_cart', label: 'Add to cart' },+ { value: 'add_to_wishlist', label: 'Add to wishlist' },+ { value: 'app_install', label: 'App install' },+ { value: 'app_open', label: 'App open' },+ { value: 'checkout', label: 'Checkout' },+ { value: 'contact', label: 'Contact' },+ { value: 'custom', label: 'Custom' },+ { value: 'customize_product', label: 'Customize product' },+ { value: 'find_location', label: 'Find location' },+ { value: 'initiate_checkout', label: 'Initiate checkout' },+ { value: 'lead', label: 'Lead' },+ { value: 'page_visit', label: 'Page visit' },+ { value: 'schedule', label: 'Schedule' },+ { value: 'search', label: 'Search' },+ { value: 'signup', label: 'Sign up' },+ { value: 'start_trial', label: 'Start trial' },+ { value: 'submit_application', label: 'Submit application' },+ { value: 'subscribe', label: 'Subscribe' },+ { value: 'view_category', label: 'View category' },+ { value: 'view_content', label: 'View content' },+ { value: 'watch_video', label: 'Watch video' },+]++const build_inputs = (eventName: string, customData: Record<string, string>): HogFunctionInputSchemaType[] => {+ return [+ {+ key: 'eventName',+ type: 'choice',+ label: 'Event name',+ description:+ 'The Pinterest conversion event. For an event Pinterest does not list, choose "Custom". See https://developers.pinterest.com/docs/api/v5/events-create',+ choices: EVENT_NAMES,+ default: eventName,+ secret: false,+ required: true,+ },+ {+ key: 'customData',+ type: 'dictionary',+ label: 'Custom data',+ description:+ 'Event details such as value, currency and products. Add any other key Pinterest accepts, for example content_name or opt_out_type. Empty values are left out. See https://developers.pinterest.com/docs/api/v5/events-create',+ default: customData,+ secret: false,+ required: false,+ },+ ]+}++const currency = '{event.properties.currency}'+const value = '{event.properties.value ?? event.properties.revenue ?? event.properties.price}'+const singleContentIds =+ '{not empty(event.properties.sku) ? [event.properties.sku] : (not empty(event.properties.product_id) ? [event.properties.product_id] : [])}'+const singleContents =+ "{not empty(event.properties.sku) or not empty(event.properties.product_id) ? [{'id': not empty(event.properties.sku) ? event.properties.sku : event.properties.product_id, 'item_price': event.properties.price, 'quantity': event.properties.quantity, 'item_name': event.properties.name, 'item_brand': event.properties.brand, 'item_category': event.properties.category}] : []}"+const multiContentIds =+ '{arrayMap(x -> not empty(x.sku) ? x.sku : x.product_id, arrayFilter(x -> not empty(x.sku) or not empty(x.product_id), event.properties.products ?? []))}'+const multiContents =+ "{arrayMap(x -> ({'id': not empty(x.sku) ? x.sku : x.product_id, 'item_price': x.price, 'quantity': x.quantity, 'item_name': x.name, 'item_brand': x.brand, 'item_category': x.category}), arrayFilter(x -> not empty(x.sku) or not empty(x.product_id), event.properties.products ?? []))}"+const multiNumItems =+ '{not empty(event.properties.products) ? arrayReduce((acc, curr) -> acc + toInt(curr.quantity ?? 1), event.properties.products, 0) : null}'++const singleProduct = {+ currency,+ value,+ content_ids: singleContentIds,+ contents: singleContents,+ num_items: '{event.properties.quantity}',+ content_name: '{event.properties.name}',+ content_brand: '{event.properties.brand}',+ content_category: '{event.properties.category}',+}++const multiProduct = {+ currency,+ value,+ content_ids: multiContentIds,+ contents: multiContents,+ num_items: multiNumItems,+}++export const template: HogFunctionTemplate = {+ free: false,+ status: 'alpha',+ type: 'destination',+ id: 'template-pinterest-ads',+ name: 'Pinterest Ads Conversions',+ description: 'Send conversion events to Pinterest Ads',+ icon_url: '/static/services/pinterest.com.png',+ category: ['Advertisement'],+ code_language: 'hog',+ code: `+if (empty(inputs.adAccountId) or empty(inputs.conversionToken)) {+ throw Error('Ad account ID and conversion token are required')+}++let HASHED_USER_KEYS := ['em', 'ph', 'fn', 'ln', 'ct', 'st', 'zp', 'country', 'external_id', 'hashed_maids', 'ge', 'db']++fn normalize(key, value) {+ let normalized := lower(trim(toString(value)))+ if (key == 'ph') {+ for (let symbol in ['+', '-', ' ', '(', ')', '.']) {+ normalized := replaceAll(normalized, symbol, '')+ }+ } else if (key == 'ct') {+ for (let symbol in [' ', '.', ',', '-', '\\'']) {+ normalized := replaceAll(normalized, symbol, '')+ }+ } else if (key == 'zp') {+ normalized := replaceAll(normalized, ' ', '')+ }+ return normalized+}++// Pinterest takes a list of hashes per field. A value that is already a SHA-256 hash is sent as is,+// so a mapping that hashes before sending does not get hashed twice.+fn hashAll(key, value) {+ let hashes := []+ for (let item in (typeof(value) == 'array' ? value : [value])) {+ let normalized := empty(item) ? '' : normalize(key, item)+ if (not empty(normalized)) {+ hashes := arrayPushBack(hashes, match(normalized, '^[a-f0-9]{64}$') ? normalized : sha256Hex(normalized))+ }+ }+ return hashes+}++fn cleanContent(item) {+ let cleaned := {}+ for (let key, value in item) {+ if ((key == 'item_price' or key == 'id') and not empty(value)) {+ cleaned[key] := toString(value)+ } else if (key == 'quantity' and not empty(value)) {+ cleaned[key] := toInt(value)+ } else if (not empty(value)) {+ cleaned[key] := value+ }+ }+ return cleaned+}++let payload := {+ 'event_name': inputs.eventName,+ 'action_source': inputs.actionSource,+ 'event_time': toInt(inputs.eventTime),+ 'event_id': toString(inputs.eventId),+ 'user_data': {}+}++if (not empty(inputs.eventSourceUrl)) {+ payload.event_source_url := inputs.eventSourceUrl+}++for (let key, value in inputs.userData) {+ if (has(HASHED_USER_KEYS, key)) {+ let hashes := hashAll(key, value)+ if (not empty(hashes)) {+ payload.user_data[key] := hashes+ }+ } else if (not empty(value)) {+ payload.user_data[key] := toString(value)+ }+}++fn cleanCustomValue(key, value) {+ if (key == 'value' or key == 'predicted_ltv') {+ return toString(value)+ } else if (key == 'num_items') {+ return toInt(value)+ } else if (key == 'content_ids') {+ let ids := []+ for (let id in (typeof(value) == 'array' ? value : [value])) {+ if (not empty(id)) {+ ids := arrayPushBack(ids, toString(id))+ }+ }+ return ids+ } else if (key == 'contents') {+ let contents := []+ for (let item in value) {+ let cleaned := cleanContent(item)+ if (not empty(cleaned)) {+ contents := arrayPushBack(contents, cleaned)+ }+ }+ return contents+ }+ return value+}++let customData := {}+for (let key, value in inputs.customData) {+ let cleaned := empty(value) ? null : cleanCustomValue(key, value)+ if (not empty(cleaned)) {+ customData[key] := cleaned+ }+}+if (not empty(customData)) {+ payload.custom_data := customData+}++let userData := payload.user_data+if (empty(userData.em) and empty(userData.hashed_maids) and (empty(userData.client_ip_address) or empty(userData.client_user_agent))) {+ print('Skipping event: Pinterest needs an email (em), a mobile ad ID (hashed_maids), or both an IP address and a user agent.')+ return+}++let res := fetch(f'https://api.pinterest.com/v5/ad_accounts/{inputs.adAccountId}/events{inputs.testMode ? '?test=true' : ''}', {+ 'method': 'POST',+ 'headers': {+ 'Authorization': f'Bearer {inputs.conversionToken}',+ 'Content-Type': 'application/json',+ },+ 'body': {'data': [payload]}+})++if (res.status >= 400) {+ throw Error(f'Error from api.pinterest.com (status {res.status}): {res.body}')+}++// Pinterest answers 200 even when it rejects an event, and reports the rejection per event.+let result := typeof(res.body) == 'object' and not empty(res.body.events) ? res.body.events[1] : null+if (result?.status == 'failed') {+ throw Error(f'Pinterest rejected the event: {result.error_message}')+}+if (not empty(result?.warning_message)) {+ print(f'Pinterest accepted the event with a warning: {result.warning_message}')+}+`,+ inputs_schema: [+ {+ key: 'adAccountId',+ type: 'string',+ label: 'Ad account ID',+ description:+ 'The ID of your Pinterest ad account. See https://help.pinterest.com/en/business/article/conversions-api',+ secret: false,+ required: true,+ },+ {+ key: 'conversionToken',+ type: 'string',+ label: 'Conversion token',+ description:+ 'The conversion access token generated in Pinterest Ads Manager, under Conversions. See https://help.pinterest.com/en/business/article/conversions-api',+ secret: true,+ required: true,+ },+ {+ key: 'actionSource',+ type: 'choice',+ label: 'Action source',+ description: 'Where the conversion happened.',+ choices: [+ { label: 'Web', value: 'web' },+ { label: 'Android app', value: 'app_android' },+ { label: 'iOS app', value: 'app_ios' },+ { label: 'Offline', value: 'offline' },+ ],+ default: 'web',+ secret: false,+ required: true,+ },+ {+ key: 'eventId',+ type: 'string',+ label: 'Event ID',+ description:+ 'A unique ID for the event. Pinterest uses it to deduplicate events sent by both the Pinterest tag and the Conversions API, so use the same ID in both.',+ default: '{event.uuid}',+ secret: false,+ required: true,+ },+ {+ key: 'eventTime',+ type: 'string',+ label: 'Event time',+ description: 'A Unix timestamp in seconds of when the event happened.',+ default: '{toInt(toUnixTimestamp(event.timestamp))}',+ secret: false,+ required: true,+ },+ {+ key: 'eventSourceUrl',+ type: 'string',+ label: 'Event source URL',+ description: 'The URL of the page where the event happened.',+ default: '{event.properties.$current_url}',+ secret: false,+ required: false,+ },+ {+ key: 'userData',+ type: 'dictionary',+ label: 'User data',+ description:+ 'Customer information used for matching. Enter raw values: em, ph, fn, ln, ct, st, zp, country, external_id, hashed_maids, ge and db are lowercased, trimmed and SHA-256 hashed before sending. Empty values are left out. Pinterest needs em, hashed_maids, or both client_ip_address and client_user_agent. See https://developers.pinterest.com/docs/api/v5/events-create',+ default: {+ em: '{person.properties.email}',+ ph: '{person.properties.phone}',+ fn: '{person.properties.first_name}',+ ln: '{person.properties.last_name}',+ ct: '{person.properties.$geoip_city_name}',+ st: '{person.properties.$geoip_subdivision_1_code}',+ zp: '{person.properties.$geoip_postal_code}',+ country: '{person.properties.$geoip_country_code}',+ external_id: '{person.id}',+ client_ip_address: '{event.properties.$ip}',+ client_user_agent: '{event.properties.$raw_user_agent}',+ click_id: '{person.properties.epik ?? person.properties.$initial_epik}',+ },+ secret: false,+ required: true,+ },+ {+ key: 'testMode',+ type: 'boolean',+ label: 'Test mode',+ description:+ 'Send events as test events. Pinterest validates them and shows them under Test events in Ads Manager, but does not record them. Turn this off to send real traffic.',+ default: false,+ secret: false,+ required: false,+ },+ ],+ mapping_templates: [+ {+ name: 'Page viewed',+ include_by_default: true,+ filters: { events: [{ id: '$pageview', name: 'Pageview', type: 'events' }] },+ inputs_schema: build_inputs('page_visit', {}),+ },+ {+ name: 'Product viewed',+ include_by_default: true,+ filters: { events: [{ id: 'Product Viewed', type: 'events' }] },+ inputs_schema: build_inputs('view_content', singleProduct),+ },+ {+ name: 'Product list viewed',+ include_by_default: true,+ filters: { events: [{ id: 'Product List Viewed', type: 'events' }] },+ inputs_schema: build_inputs('view_category', {+ content_category: '{event.properties.category}',+ content_ids: multiContentIds,+ }),+ },+ {+ name: 'Products searched',+ include_by_default: true,+ filters: { events: [{ id: 'Products Searched', type: 'events' }] },+ inputs_schema: build_inputs('search', {+ search_string: '{event.properties.query ?? event.properties.search_string}',+ }),+ },+ {+ name: 'Product added',+ include_by_default: true,+ filters: { events: [{ id: 'Product Added', type: 'events' }] },+ inputs_schema: build_inputs('add_to_cart', singleProduct),+ },+ {+ name: 'Product added to wishlist',+ include_by_default: true,+ filters: { events: [{ id: 'Product Added to Wishlist', type: 'events' }] },+ inputs_schema: build_inputs('add_to_wishlist', singleProduct),+ },+ {+ name: 'Checkout started',+ include_by_default: true,+ filters: { events: [{ id: 'Checkout Started', type: 'events' }] },+ inputs_schema: build_inputs('initiate_checkout', multiProduct),+ },+ {+ name: 'Payment info entered',+ include_by_default: true,+ filters: { events: [{ id: 'Payment Info Entered', type: 'events' }] },+ inputs_schema: build_inputs('add_payment_info', multiProduct),+ },+ {+ name: 'Order completed',+ include_by_default: true,+ filters: { events: [{ id: 'Order Completed', type: 'events' }] },+ inputs_schema: build_inputs('checkout', {+ ...multiProduct,+ order_id: '{event.properties.order_id ?? event.properties.orderId ?? event.properties.transaction_id}',+ }),+ },+ {+ name: 'Signed up',+ include_by_default: true,+ filters: { events: [{ id: 'Signed Up', type: 'events' }] },+ inputs_schema: build_inputs('signup', {}),+ },+ {+ name: 'Lead generated',+ include_by_default: true,+ filters: { events: [{ id: 'Lead Generated', type: 'events' }] },+ inputs_schema: build_inputs('lead', { currency, value }),+ },+ ],+}diff --git a/nodejs/src/cdp/templates/index.ts b/nodejs/src/cdp/templates/index.tsindex 0c09192a5101..cee24f97c760 100644--- a/nodejs/src/cdp/templates/index.ts+++ b/nodejs/src/cdp/templates/index.ts@@ -22,6 +22,7 @@ import { template as microsoftAdsTemplate } from './_destinations/microsoft_ads/import { template as nativeWebhookTemplate } from './_destinations/native_webhook/webhook.template'import { template as openaiAdsTemplate } from './_destinations/openai_ads/openai.template'import { template as pagerdutyTemplate } from './_destinations/pagerduty/pagerduty.template'+import { template as pinterestAdsTemplate } from './_destinations/pinterest_ads/pinterest.template'import { template as posthogCaptureTemplate } from './_destinations/posthog_capture/posthog-capture.template'import { template as posthogGroupIdentifyTemplate } from './_destinations/posthog_capture/posthog-group-identify.template'import { template as posthogUpdatePersonPropertiesTemplate } from './_destinations/posthog_capture/posthog-update-person-properties.template'@@ -92,6 +93,7 @@ export const HOG_FUNCTION_TEMPLATES_DESTINATIONS: HogFunctionTemplate[] = [microsoftAdsTemplate,openaiAdsTemplate,redditAdsTemplate,+ pinterestAdsTemplate,twilioTemplate,whatsappTemplate,googleSheetsTemplate,diff --git a/nodejs/tests/fixtures/hog-bytecode/1012a8564b2eaab750a349c934ccfd0872f867bbe4ddf83f945d416f902f7dc1.json b/nodejs/tests/fixtures/hog-bytecode/1012a8564b2eaab750a349c934ccfd0872f867bbe4ddf83f945d416f902f7dc1.jsonnew file mode 100644index 000000000000..173cb9e52147--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/1012a8564b2eaab750a349c934ccfd0872f867bbe4ddf83f945d416f902f7dc1.json@@ -0,0 +1 @@+["_H",1,52,"lambda",1,0,63,32,"id",36,0,32,"sku",45,2,"empty",1,5,40,7,36,0,32,"sku",45,39,5,36,0,32,"product_id",45,32,"item_price",36,0,32,"price",45,32,"quantity",36,0,32,"quantity",45,32,"item_name",36,0,32,"name",45,32,"item_brand",36,0,32,"brand",45,32,"item_category",36,0,32,"category",45,42,6,38,53,0,52,"lambda",1,0,21,36,0,32,"sku",45,2,"empty",1,5,36,0,32,"product_id",45,2,"empty",1,5,4,2,38,53,0,32,"products",32,"properties",32,"event",1,3,47,3,35,43,0,2,"arrayFilter",2,2,"arrayMap",2,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/17992392caa1f5bdd9a81b1b37b0f3b7a0e216c6bdc30fbd8e346d1492c1fe0a.json b/nodejs/tests/fixtures/hog-bytecode/17992392caa1f5bdd9a81b1b37b0f3b7a0e216c6bdc30fbd8e346d1492c1fe0a.jsonnew file mode 100644index 000000000000..61bdc28ff4c0--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/17992392caa1f5bdd9a81b1b37b0f3b7a0e216c6bdc30fbd8e346d1492c1fe0a.json@@ -0,0 +1 @@+["_H",1,32,"$geoip_subdivision_1_code",32,"properties",32,"person",1,3,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/357a1767caa88e54476e966acb0a2115a6dfea508128270f8be311d06a7d73e8.json b/nodejs/tests/fixtures/hog-bytecode/357a1767caa88e54476e966acb0a2115a6dfea508128270f8be311d06a7d73e8.jsonnew file mode 100644index 000000000000..213a73510804--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/357a1767caa88e54476e966acb0a2115a6dfea508128270f8be311d06a7d73e8.json@@ -0,0 +1 @@+["_H",1,32,"products",32,"properties",32,"event",1,3,2,"empty",1,5,40,39,52,"lambda",2,0,17,36,1,32,"quantity",45,47,3,35,33,1,2,"toInt",1,36,0,6,38,53,0,32,"products",32,"properties",32,"event",1,3,33,0,2,"arrayReduce",3,39,1,31,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/56ed83f6ef36c8b67c512ece0974ba8b942000aca9664a1cf6697458f1ec84a2.json b/nodejs/tests/fixtures/hog-bytecode/56ed83f6ef36c8b67c512ece0974ba8b942000aca9664a1cf6697458f1ec84a2.jsonnew file mode 100644index 000000000000..854b463b5b76--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/56ed83f6ef36c8b67c512ece0974ba8b942000aca9664a1cf6697458f1ec84a2.json@@ -0,0 +1 @@+["_H",1,52,"lambda",1,0,24,36,0,32,"sku",45,2,"empty",1,5,40,7,36,0,32,"sku",45,39,5,36,0,32,"product_id",45,38,53,0,52,"lambda",1,0,21,36,0,32,"sku",45,2,"empty",1,5,36,0,32,"product_id",45,2,"empty",1,5,4,2,38,53,0,32,"products",32,"properties",32,"event",1,3,47,3,35,43,0,2,"arrayFilter",2,2,"arrayMap",2,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/58459510bcdff4a0c4d5b7c258a42d06d5a43acb22c0b82f6b3e8d642328c70d.json b/nodejs/tests/fixtures/hog-bytecode/58459510bcdff4a0c4d5b7c258a42d06d5a43acb22c0b82f6b3e8d642328c70d.jsonnew file mode 100644index 000000000000..92377c862f64--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/58459510bcdff4a0c4d5b7c258a42d06d5a43acb22c0b82f6b3e8d642328c70d.json@@ -0,0 +1 @@+["_H",1,32,"value",32,"properties",32,"event",1,3,47,9,35,32,"revenue",32,"properties",32,"event",1,3,47,9,35,32,"price",32,"properties",32,"event",1,3,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/5f5eb2c4e2770b5d41decba1521f3ba6a96bca48e546204e5a2932c7c197d2c8.json b/nodejs/tests/fixtures/hog-bytecode/5f5eb2c4e2770b5d41decba1521f3ba6a96bca48e546204e5a2932c7c197d2c8.jsonnew file mode 100644index 000000000000..572504454cae--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/5f5eb2c4e2770b5d41decba1521f3ba6a96bca48e546204e5a2932c7c197d2c8.json@@ -0,0 +1 @@+["_H",1,32,"order_id",32,"properties",32,"event",1,3,47,9,35,32,"orderId",32,"properties",32,"event",1,3,47,9,35,32,"transaction_id",32,"properties",32,"event",1,3,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/6983b9d977f199af5fe66c85908040de39a91b0f0b1850fab6246680c7b1b449.json b/nodejs/tests/fixtures/hog-bytecode/6983b9d977f199af5fe66c85908040de39a91b0f0b1850fab6246680c7b1b449.jsonnew file mode 100644index 000000000000..62db44aa9877--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/6983b9d977f199af5fe66c85908040de39a91b0f0b1850fab6246680c7b1b449.json@@ -0,0 +1 @@+["_H",1,32,"page_visit",38]diff --git a/nodejs/tests/fixtures/hog-bytecode/6b92e09fabb1b55c4a12c97c907f3c1c7a09171a38d930921c93b6f4c4aa97f9.json b/nodejs/tests/fixtures/hog-bytecode/6b92e09fabb1b55c4a12c97c907f3c1c7a09171a38d930921c93b6f4c4aa97f9.jsonnew file mode 100644index 000000000000..2edd72caf149--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/6b92e09fabb1b55c4a12c97c907f3c1c7a09171a38d930921c93b6f4c4aa97f9.json@@ -0,0 +1 @@+["_H",1,32,"sku",32,"properties",32,"event",1,3,2,"empty",1,5,32,"product_id",32,"properties",32,"event",1,3,2,"empty",1,5,4,2,40,90,32,"id",32,"sku",32,"properties",32,"event",1,3,2,"empty",1,5,40,10,32,"sku",32,"properties",32,"event",1,3,39,8,32,"product_id",32,"properties",32,"event",1,3,32,"item_price",32,"price",32,"properties",32,"event",1,3,32,"quantity",32,"quantity",32,"properties",32,"event",1,3,32,"item_name",32,"name",32,"properties",32,"event",1,3,32,"item_brand",32,"brand",32,"properties",32,"event",1,3,32,"item_category",32,"category",32,"properties",32,"event",1,3,42,6,43,1,39,2,43,0,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/6beb48ac2721ecd06dc78b002f3a7161b1d7a86396a8e23f698f7c5caab42bd5.json b/nodejs/tests/fixtures/hog-bytecode/6beb48ac2721ecd06dc78b002f3a7161b1d7a86396a8e23f698f7c5caab42bd5.jsonnew file mode 100644index 000000000000..df8687a10c06--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/6beb48ac2721ecd06dc78b002f3a7161b1d7a86396a8e23f698f7c5caab42bd5.json@@ -0,0 +1 @@+["_H",1,32,"$geoip_postal_code",32,"properties",32,"person",1,3,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/76ba7a18e2bb7fae019ef29f0baab9a321ef1b69456d58443e0ac9fbb028d8aa.json b/nodejs/tests/fixtures/hog-bytecode/76ba7a18e2bb7fae019ef29f0baab9a321ef1b69456d58443e0ac9fbb028d8aa.jsonnew file mode 100644index 000000000000..957f7f74fe56--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/76ba7a18e2bb7fae019ef29f0baab9a321ef1b69456d58443e0ac9fbb028d8aa.json@@ -0,0 +1 @@+["_H",1,32,"conversion-token",38]diff --git a/nodejs/tests/fixtures/hog-bytecode/7d53be5f2394a27ad38c4aad09cd8618c09ae497b8f89aca048ee908bd3704ad.json b/nodejs/tests/fixtures/hog-bytecode/7d53be5f2394a27ad38c4aad09cd8618c09ae497b8f89aca048ee908bd3704ad.jsonnew file mode 100644index 000000000000..e576bee99b6b--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/7d53be5f2394a27ad38c4aad09cd8618c09ae497b8f89aca048ee908bd3704ad.json@@ -0,0 +1 @@+["_H",1,32,"checkout",38]diff --git a/nodejs/tests/fixtures/hog-bytecode/804d2f4c572585ea61fac7e3c0183321d70a8bd49dcdea54df4dadd5b2f1370b.json b/nodejs/tests/fixtures/hog-bytecode/804d2f4c572585ea61fac7e3c0183321d70a8bd49dcdea54df4dadd5b2f1370b.jsonnew file mode 100644index 000000000000..ed4df95699dd--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/804d2f4c572585ea61fac7e3c0183321d70a8bd49dcdea54df4dadd5b2f1370b.json@@ -0,0 +1 @@+["_H",1,32,"brand",32,"properties",32,"event",1,3,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/8768e71d66f9edff52067f5facff6b3b602c0771874d32cb750ce5464b1b1f8a.json b/nodejs/tests/fixtures/hog-bytecode/8768e71d66f9edff52067f5facff6b3b602c0771874d32cb750ce5464b1b1f8a.jsonnew file mode 100644index 000000000000..00c6457eec4c--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/8768e71d66f9edff52067f5facff6b3b602c0771874d32cb750ce5464b1b1f8a.json@@ -0,0 +1 @@+["_H",1,32,"view_content",38]diff --git a/nodejs/tests/fixtures/hog-bytecode/943cd97941684643d52bef0d860535dcc0d0769cf428d281b9b09b379758e658.json b/nodejs/tests/fixtures/hog-bytecode/943cd97941684643d52bef0d860535dcc0d0769cf428d281b9b09b379758e658.jsonnew file mode 100644index 000000000000..da1cf5371e8b--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/943cd97941684643d52bef0d860535dcc0d0769cf428d281b9b09b379758e658.json@@ -0,0 +1 @@+["_H",1,32,"ad-account-id",38]diff --git a/nodejs/tests/fixtures/hog-bytecode/b35788c15727be2be06b9cc6f1c7490cbf2c2971346921e2285aa9c377eff257.json b/nodejs/tests/fixtures/hog-bytecode/b35788c15727be2be06b9cc6f1c7490cbf2c2971346921e2285aa9c377eff257.jsonnew file mode 100644index 000000000000..ab3a37aafa10--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/b35788c15727be2be06b9cc6f1c7490cbf2c2971346921e2285aa9c377eff257.json@@ -0,0 +1 @@+["_H",1,32,"epik",32,"properties",32,"person",1,3,47,9,35,32,"$initial_epik",32,"properties",32,"person",1,3,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/d0b1d24afcc8508ced6509be908061cc5fb7b40a4e9fc9526eae4047b462563c.json b/nodejs/tests/fixtures/hog-bytecode/d0b1d24afcc8508ced6509be908061cc5fb7b40a4e9fc9526eae4047b462563c.jsonnew file mode 100644index 000000000000..c138f4463ecc--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/d0b1d24afcc8508ced6509be908061cc5fb7b40a4e9fc9526eae4047b462563c.json@@ -0,0 +1 @@+["_H",1,32,"$geoip_country_code",32,"properties",32,"person",1,3,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/ee38e8eb2cf2b6a53b0e6fbcebf2c4c91881e6ecd0d7aebab5c90f8c57966aa1.json b/nodejs/tests/fixtures/hog-bytecode/ee38e8eb2cf2b6a53b0e6fbcebf2c4c91881e6ecd0d7aebab5c90f8c57966aa1.jsonnew file mode 100644index 000000000000..42462ab874fe--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/ee38e8eb2cf2b6a53b0e6fbcebf2c4c91881e6ecd0d7aebab5c90f8c57966aa1.json@@ -0,0 +1 @@+["_H",1,32,"id",32,"person",1,2,38]diff --git a/nodejs/tests/fixtures/hog-bytecode/f21932acac2707328b3ea52f8b841df49d33569ba4fc3f0e68fe5358b4958a2c.json b/nodejs/tests/fixtures/hog-bytecode/f21932acac2707328b3ea52f8b841df49d33569ba4fc3f0e68fe5358b4958a2c.jsonnew file mode 100644index 000000000000..2d34500f173d--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/f21932acac2707328b3ea52f8b841df49d33569ba4fc3f0e68fe5358b4958a2c.json@@ -0,0 +1 @@+["_H",1,32,"adAccountId",32,"inputs",1,2,2,"empty",1,32,"conversionToken",32,"inputs",1,2,2,"empty",1,4,2,40,6,32,"Ad account ID and conversion token are required",2,"Error",1,49,32,"em",32,"ph",32,"fn",32,"ln",32,"ct",32,"st",32,"zp",32,"country",32,"external_id",32,"hashed_maids",32,"ge",32,"db",43,12,52,"normalize",2,0,181,36,1,2,"toString",1,2,"trim",1,2,"lower",1,32,"ph",36,0,11,40,68,32,"+",32,"-",32," ",32,"(",32,")",32,".",43,6,36,3,2,"values",1,33,1,36,4,2,"length",1,31,36,6,36,5,16,40,27,36,4,36,5,45,37,7,36,2,36,7,32,"",2,"replaceAll",3,37,2,36,5,33,1,6,37,5,39,-34,35,35,35,35,35,39,91,32,"ct",36,0,11,40,66,32," ",32,".",32,",",32,"-",32,"'",43,5,36,3,2,"values",1,33,1,36,4,2,"length",1,31,36,6,36,5,16,40,27,36,4,36,5,45,37,7,36,2,36,7,32,"",2,"replaceAll",3,37,2,36,5,33,1,6,37,5,39,-34,35,35,35,35,35,39,18,32,"zp",36,0,11,40,11,36,2,32," ",32,"",2,"replaceAll",3,37,2,36,2,38,35,53,0,52,"hashAll",2,1,118,43,0,32,"array",36,1,2,"typeof",1,11,40,4,36,1,39,4,36,1,43,1,36,3,2,"values",1,33,1,36,4,2,"length",1,31,36,6,36,5,16,40,69,36,4,36,5,45,37,7,36,7,2,"empty",1,40,4,32,"",39,8,36,0,36,7,55,0,54,2,36,8,2,"empty",1,5,40,25,36,2,36,8,32,"^[a-f0-9]{64}$",2,"match",2,40,4,36,8,39,5,36,8,2,"sha256Hex",1,2,"arrayPushBack",2,37,2,35,36,5,33,1,6,37,5,39,-76,35,35,35,35,35,36,2,38,35,53,1,true,1,52,"cleanContent",1,0,140,42,0,36,0,36,2,2,"keys",1,36,2,2,"values",1,33,1,36,4,2,"length",1,31,31,36,6,36,5,16,40,99,36,3,36,5,45,37,7,36,4,36,5,45,37,8,32,"item_price",36,7,11,32,"id",36,7,11,4,2,36,8,2,"empty",1,5,3,2,40,12,36,1,36,7,36,8,2,"toString",1,46,39,42,32,"quantity",36,7,11,36,8,2,"empty",1,5,3,2,40,12,36,1,36,7,36,8,2,"toInt",1,46,39,15,36,8,2,"empty",1,5,40,7,36,1,36,7,36,8,46,36,5,33,1,6,37,5,39,-106,35,35,35,35,35,35,35,36,1,38,35,53,0,32,"event_name",32,"eventName",32,"inputs",1,2,32,"action_source",32,"actionSource",32,"inputs",1,2,32,"event_time",32,"eventTime",32,"inputs",1,2,2,"toInt",1,32,"event_id",32,"eventId",32,"inputs",1,2,2,"toString",1,32,"user_data",42,0,42,5,32,"eventSourceUrl",32,"inputs",1,2,2,"empty",1,5,40,11,36,4,32,"event_source_url",32,"eventSourceUrl",32,"inputs",1,2,46,32,"userData",32,"inputs",1,2,36,5,2,"keys",1,36,5,2,"values",1,33,1,36,7,2,"length",1,31,31,36,9,36,8,16,40,82,36,6,36,8,45,37,10,36,7,36,8,45,37,11,36,0,36,10,2,"has",2,40,29,36,10,36,11,36,2,54,2,36,12,2,"empty",1,5,40,10,36,4,32,"user_data",45,36,10,36,12,46,35,39,21,36,11,2,"empty",1,5,40,13,36,4,32,"user_data",45,36,10,36,11,2,"toString",1,46,36,8,33,1,6,37,8,39,-89,35,35,35,35,35,35,35,52,"cleanCustomValue",2,1,214,32,"value",36,0,11,32,"predicted_ltv",36,0,11,4,2,40,8,36,1,2,"toString",1,38,39,189,32,"num_items",36,0,11,40,8,36,1,2,"toInt",1,38,39,174,32,"content_ids",36,0,11,40,87,43,0,32,"array",36,1,2,"typeof",1,11,40,4,36,1,39,4,36,1,43,1,36,3,2,"values",1,33,1,36,4,2,"length",1,31,36,6,36,5,16,40,36,36,4,36,5,45,37,7,36,7,2,"empty",1,5,40,12,36,2,36,7,2,"toString",1,2,"arrayPushBack",2,37,2,36,5,33,1,6,37,5,39,-43,35,35,35,35,35,36,2,38,35,39,80,32,"contents",36,0,11,40,73,43,0,36,1,36,3,2,"values",1,33,1,36,4,2,"length",1,31,36,6,36,5,16,40,40,36,4,36,5,45,37,7,36,7,55,0,54,1,36,8,2,"empty",1,5,40,9,36,2,36,8,2,"arrayPushBack",2,37,2,35,36,5,33,1,6,37,5,39,-47,35,35,35,35,35,36,2,38,35,36,1,38,53,1,true,3,42,0,32,"customData",32,"inputs",1,2,36,7,2,"keys",1,36,7,2,"values",1,33,1,36,9,2,"length",1,31,31,36,11,36,10,16,40,57,36,8,36,10,45,37,12,36,9,36,10,45,37,13,36,13,2,"empty",1,40,3,31,39,8,36,12,36,13,36,5,54,2,36,14,2,"empty",1,5,40,7,36,6,36,12,36,14,46,35,36,10,33,1,6,37,10,39,-64,35,35,35,35,35,35,35,36,6,2,"empty",1,5,40,7,36,4,32,"custom_data",36,6,46,36,4,32,"user_data",45,36,7,32,"em",45,2,"empty",1,36,7,32,"hashed_maids",45,2,"empty",1,36,7,32,"client_ip_address",45,2,"empty",1,36,7,32,"client_user_agent",45,2,"empty",1,4,2,3,3,40,8,32,"Skipping event: Pinterest needs an email (em), a mobile ad ID (hashed_maids), or both an IP address and a user agent.",2,"print",1,35,31,38,32,"https://api.pinterest.com/v5/ad_accounts/",32,"adAccountId",32,"inputs",1,2,32,"/events",32,"testMode",32,"inputs",1,2,40,4,32,"?test=true",39,2,32,"",2,"concat",4,32,"method",32,"POST",32,"headers",32,"Authorization",32,"Bearer ",32,"conversionToken",32,"inputs",1,2,2,"concat",2,32,"Content-Type",32,"application/json",42,2,32,"body",32,"data",36,4,43,1,42,1,42,3,2,"fetch",2,33,400,36,8,32,"status",45,14,40,21,32,"Error from api.pinterest.com (status ",36,8,32,"status",45,32,"): ",36,8,32,"body",45,2,"concat",4,2,"Error",1,49,32,"object",36,8,32,"body",45,2,"typeof",1,11,36,8,32,"body",45,32,"events",45,2,"empty",1,5,3,2,40,13,36,8,32,"body",45,32,"events",45,33,1,45,39,1,31,32,"failed",36,9,32,"status",48,11,40,14,32,"Pinterest rejected the event: ",36,9,32,"error_message",45,2,"concat",2,2,"Error",1,49,36,9,32,"warning_message",48,2,"empty",1,5,40,14,32,"Pinterest accepted the event with a warning: ",36,9,32,"warning_message",45,2,"concat",2,2,"print",1,35,35,35,35,35,35,35,57,35,57,35]diff --git a/nodejs/tests/fixtures/hog-bytecode/ff8c997e4b0fa0277b82359dcd6ccfcc1a9fb8064bfa9c3e71b010e1493d2dc8.json b/nodejs/tests/fixtures/hog-bytecode/ff8c997e4b0fa0277b82359dcd6ccfcc1a9fb8064bfa9c3e71b010e1493d2dc8.jsonnew file mode 100644index 000000000000..c3e9c64c2b7c--- /dev/null+++ b/nodejs/tests/fixtures/hog-bytecode/ff8c997e4b0fa0277b82359dcd6ccfcc1a9fb8064bfa9c3e71b010e1493d2dc8.json@@ -0,0 +1 @@+["_H",1,32,"$geoip_city_name",32,"properties",32,"person",1,3,38]