Skip to content

Commit 860c3bb

Browse files
akhsuehAustin Hsueh
and
Austin Hsueh
authored
small updates to the default mappings in the Reddit CAPI integration (#2893)
Co-authored-by: Austin Hsueh <[email protected]>
1 parent 512fe02 commit 860c3bb

File tree

5 files changed

+32
-20
lines changed

5 files changed

+32
-20
lines changed

packages/destination-actions/src/destinations/reddit-conversions-api/__tests__/index.test.ts

+10-13
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ describe('Reddit Conversions Api', () => {
2222
userId: 'user_id_1',
2323
properties: {
2424
click_id: 'click_id_1',
25-
conversion_id: 'ea3d01f99e303d2338cfb4e71f182441eb57c9a3cb129c40bcae9f5d641a7375',
2625
currency: 'USD',
2726
quantity: 10,
28-
total: 100,
27+
revenue: 100,
2928
uuid: 'uuid_1',
3029
products: [
3130
{ product_id: 'product_id_1', category: 'category_1', name: 'name_1' },
@@ -60,7 +59,7 @@ describe('Reddit Conversions Api', () => {
6059
click_id: 'click_id_1',
6160
event_at: '2024-01-08T13:52:50.212Z',
6261
event_metadata: {
63-
conversion_id: '492ebaa71872336ef94c7093b77d2232fdba7e469f716586a816d861367b183f',
62+
conversion_id: '5184171f53a0fd17f59ea50fac8e11d9eb589ed0692920ee4f52a357112e6802',
6463
currency: 'USD',
6564
item_count: 10,
6665
products: [
@@ -99,12 +98,11 @@ describe('Reddit Conversions Api', () => {
9998
const event = createTestEvent({
10099
timestamp: timestamp,
101100
event: 'Some Custom Event Name',
102-
messageId: 'test-message-id-contact',
101+
messageId: '492ebaa71872336ef94c7093b77d2232fdba7e469f716586a816d861367b183f',
103102
type: 'track',
104103
userId: 'user_id_1',
105104
properties: {
106105
click_id: 'click_id_1',
107-
conversion_id: '492ebaa71872336ef94c7093b77d2232fdba7e469f716586a816d861367b183f',
108106
currency: 'USD',
109107
quantity: 10,
110108
total: 100,
@@ -189,10 +187,10 @@ describe('Reddit Conversions Api', () => {
189187
userId: 'user_id_1',
190188
properties: {
191189
click_id: 'click_id_1',
192-
conversion_id: 'ea3d01f99e303d2338cfb4e71f182441eb57c9a3cb129c40bcae9f5d641a7375',
193190
currency: 'USD',
194191
quantity: 10,
195-
total: 100,
192+
revenue: 100,
193+
total: 30,
196194
uuid: 'uuid_1',
197195
products: [
198196
{ product_id: 'product_id_1', category: 'category_1', name: 'name_1' },
@@ -227,7 +225,7 @@ describe('Reddit Conversions Api', () => {
227225
click_id: 'click_id_1',
228226
event_at: '2024-01-08T13:52:50.212Z',
229227
event_metadata: {
230-
conversion_id: '492ebaa71872336ef94c7093b77d2232fdba7e469f716586a816d861367b183f',
228+
conversion_id: '5184171f53a0fd17f59ea50fac8e11d9eb589ed0692920ee4f52a357112e6802',
231229
currency: 'USD',
232230
item_count: 10,
233231
products: [
@@ -270,9 +268,8 @@ describe('Reddit Conversions Api', () => {
270268
userId: 'user_id_1',
271269
properties: {
272270
click_id: 'click_id_1',
273-
conversion_id: 'ea3d01f99e303d2338cfb4e71f182441eb57c9a3cb129c40bcae9f5d641a7375',
274271
currency: 'USD',
275-
total: 100,
272+
revenue: 100,
276273
uuid: 'uuid_1',
277274
products: [
278275
{ product_id: 'product_id_1', category: 'category_1', name: 'name_1' },
@@ -307,7 +304,7 @@ describe('Reddit Conversions Api', () => {
307304
click_id: 'click_id_1',
308305
event_at: '2024-01-08T13:52:50.212Z',
309306
event_metadata: {
310-
conversion_id: '492ebaa71872336ef94c7093b77d2232fdba7e469f716586a816d861367b183f',
307+
conversion_id: '5184171f53a0fd17f59ea50fac8e11d9eb589ed0692920ee4f52a357112e6802',
311308
currency: 'USD',
312309
products: [
313310
{
@@ -344,12 +341,11 @@ describe('Reddit Conversions Api', () => {
344341
const event = createTestEvent({
345342
timestamp: timestamp,
346343
event: 'Lead Generated',
347-
messageId: 'test-message-id-contact',
344+
messageId: 'ea3d01f99e303d2338cfb4e71f182441eb57c9a3cb129c40bcae9f5d641a7375',
348345
type: 'track',
349346
userId: 'user_id_1',
350347
properties: {
351348
click_id: 'click_id_1',
352-
conversion_id: 'ea3d01f99e303d2338cfb4e71f182441eb57c9a3cb129c40bcae9f5d641a7375',
353349
currency: 'USD',
354350
total: 100,
355351
uuid: 'uuid_1',
@@ -466,6 +462,7 @@ describe('Reddit Conversions Api', () => {
466462
event_at: '2024-01-08T13:52:50.212Z',
467463
event_metadata: {
468464
currency: 'USD',
465+
conversion_id: '5184171f53a0fd17f59ea50fac8e11d9eb589ed0692920ee4f52a357112e6802',
469466
products: [
470467
{
471468
category: 'category_1',

packages/destination-actions/src/destinations/reddit-conversions-api/customEvent/generated-types.ts

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/destination-actions/src/destinations/reddit-conversions-api/fields.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ export const click_id: InputField = {
5252

5353
export const conversion_id: InputField = {
5454
label: 'Conversion ID',
55-
description: 'The unique conversion ID that corresponds to a distinct conversion event.',
55+
description:
56+
'The unique conversion ID that corresponds to a distinct conversion event. Use this for event deduplication.',
5657
type: 'string',
5758
required: false,
58-
default: { '@path': '$.properties.conversion_id' },
59+
default: { '@path': '$.messageId' },
5960
category: 'hashedPII'
6061
}
6162

@@ -99,7 +100,11 @@ export const event_metadata: InputField = {
99100
'@path': '$.properties.quantity'
100101
},
101102
value_decimal: {
102-
'@path': '$.properties.total'
103+
'@if': {
104+
exists: { '@path': '$.properties.revenue' },
105+
then: { '@path': '$.properties.revenue' },
106+
else: { '@path': '$.properties.total' }
107+
}
103108
}
104109
}
105110
}

packages/destination-actions/src/destinations/reddit-conversions-api/index.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ const destination: DestinationDefinition<Settings> = {
129129
partnerAction: 'standardEvent',
130130
mapping: {
131131
...defaultValues(standardEvent.fields),
132-
tracking_type: 'AddToCart'
132+
tracking_type: 'AddToCart',
133+
event_metadata: {
134+
currency: { '@path': '$.properties.currency' },
135+
itemCount: { '@path': '$.properties.quantity' },
136+
value: { '@path': '$.properties.price' }
137+
}
133138
},
134139
type: 'automatic'
135140
},
@@ -139,7 +144,12 @@ const destination: DestinationDefinition<Settings> = {
139144
partnerAction: 'standardEvent',
140145
mapping: {
141146
...defaultValues(standardEvent.fields),
142-
tracking_type: 'AddToWishlist'
147+
tracking_type: 'AddToWishlist',
148+
event_metadata: {
149+
currency: { '@path': '$.properties.currency' },
150+
itemCount: { '@path': '$.properties.quantity' },
151+
value: { '@path': '$.properties.price' }
152+
}
143153
},
144154
type: 'automatic'
145155
},

packages/destination-actions/src/destinations/reddit-conversions-api/standardEvent/generated-types.ts

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)