Skip to content

Commit b5671e3

Browse files
Adding custom property to Epsilon Action (#3217)
1 parent eda430c commit b5671e3

File tree

5 files changed

+102
-2
lines changed

5 files changed

+102
-2
lines changed

packages/destination-actions/src/destinations/epsilon/sendEvent/__tests__/__snapshots__/snapshot.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Object {
2121
"dtmc_tms": 9,
2222
"idfa": "q05uljg*(jGG",
2323
"idfv": "q05uljg*(jGG",
24+
"testType": "q05uljg*(jGG",
2425
},
2526
"version": "q05uljg*(jGG",
2627
},

packages/destination-actions/src/destinations/epsilon/sendEvent/__tests__/index.test.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,85 @@ describe('Epsilon.send', () => {
385385
expect(response.length).toBe(1)
386386
expect(response[0].status).toBe(200)
387387
})
388+
389+
it('Should include customProperties field data correctly', async () => {
390+
const payload2 = {
391+
...payload,
392+
event: 'Custom Event 1',
393+
properties: {
394+
...payload.properties,
395+
dtm_event: 'custom',
396+
custom_properties: {
397+
str: "string",
398+
num: 203,
399+
bool: true
400+
}
401+
}
402+
}
403+
404+
const event = createTestEvent(payload2)
405+
406+
const requestBody = {
407+
id: 'msg_123',
408+
jsonrpc: '2.0',
409+
method: 'syncEvent',
410+
params: {
411+
appId: 'com.test.app',
412+
dtm_event: 'Custom Event 1',
413+
version: '1.0.0',
414+
eventData: {
415+
str: "string",
416+
num: 203,
417+
bool: true,
418+
dtmc_tms: 9,
419+
dtm_cid: 'test_cid',
420+
dtm_cmagic: 'test_cmagic',
421+
dtm_fid: 'test_fid',
422+
dtm_promo_id: 'test_promo_id',
423+
idfa: 'advertising_id_1',
424+
idfv: 'device_id_1',
425+
dtm_user_agent: 'dtm_user_agent_1',
426+
dtm_user_ip: '8.8.8.8',
427+
dtm_email_hash: 'f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a',
428+
dtm_mobile_hash: '4cc4f148d2a6e6d5def6cf6e1205b5b4701f7ff63e298ce5104e0cd6b86b97aa',
429+
dtm_user_id: 'user_id_1',
430+
dtmc_department: 'Test Product Department',
431+
dtmc_category: 'test_product_category_1',
432+
dtmc_sub_category: 'test_product_sub_category_1',
433+
dtmc_product_id: 'test_product_id_1',
434+
dtmc_brand: 'test_product_brand_1',
435+
dtmc_upc: 'test_upc_1',
436+
dtmc_mpn: 'test_mpn_1',
437+
dtmc_transaction_id: 'test_order_id_1',
438+
dtm_conv_val: 100,
439+
dtm_items: [
440+
{
441+
product_id: 'test_product_id_1',
442+
item_amount: 100,
443+
item_quantity: 1,
444+
item_discount: 20
445+
}
446+
],
447+
dtm_conv_curr: 'USD',
448+
dtmc_conv_type: 'test_order_type_1',
449+
dtmc_conv_store_location: 'test_store_location_1'
450+
}
451+
}
452+
}
453+
454+
nock(domain).post(path, requestBody).reply(200)
455+
456+
const response = await testDestination.testAction('sendEvent', {
457+
event,
458+
settings,
459+
useDefaultMappings: true,
460+
mapping: {
461+
...mapping,
462+
customProperties: {'@path': '$.properties.custom_properties'}
463+
}
464+
})
465+
466+
expect(response.length).toBe(1)
467+
expect(response[0].status).toBe(200)
468+
})
388469
})

packages/destination-actions/src/destinations/epsilon/sendEvent/fields.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,14 @@ export const deviceType: InputField = {
414414
default: { '@path': '$.context.device.type' }
415415
}
416416

417+
export const customProperties: InputField = {
418+
label: 'Custom Properties',
419+
description: 'Add custom properties to the event.',
420+
type: 'object',
421+
defaultObjectUI: 'keyvalue',
422+
required: false
423+
}
424+
417425
export const standardFields = {
418426
id,
419427
appId,

packages/destination-actions/src/destinations/epsilon/sendEvent/generated-types.ts

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/destination-actions/src/destinations/epsilon/sendEvent/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
dtm_conv_curr,
1818
dtmc_conv_type,
1919
dtmc_conv_store_location,
20+
customProperties,
2021
customEventName
2122
} from './fields'
2223
import { URL } from './constants'
@@ -41,7 +42,8 @@ const action: ActionDefinition<Settings, Payload> = {
4142
dtm_conv_curr,
4243
dtmc_conv_type,
4344
dtmc_conv_store_location,
44-
customEventName
45+
customEventName,
46+
customProperties
4547
},
4648
perform: (request, { payload, settings }) => {
4749
const {
@@ -66,6 +68,7 @@ const action: ActionDefinition<Settings, Payload> = {
6668
dtmc_conv_type,
6769
dtmc_conv_store_location,
6870
customEventName,
71+
customProperties,
6972
identifiers: {
7073
deviceID,
7174
advertisingId,
@@ -80,6 +83,7 @@ const action: ActionDefinition<Settings, Payload> = {
8083
const { dtm_cid, dtm_cmagic } = settings
8184

8285
let eventData: BaseEventData | NonTransactionEventData | TransactionEventData = {
86+
...customProperties, // Spread customProperties first so it can't override more important attributes
8387
dtmc_tms: 9,
8488
dtm_cid: dtm_cid.trim(),
8589
dtm_cmagic,
@@ -97,7 +101,7 @@ const action: ActionDefinition<Settings, Payload> = {
97101
dtm_mobile_hash: dtm_mobile_hash
98102
? processHashing(dtm_mobile_hash, 'sha256', 'hex', (value: string) => value?.trim().toLowerCase())
99103
: undefined,
100-
dtm_user_id
104+
dtm_user_id,
101105
}
102106

103107
switch (dtm_event) {

0 commit comments

Comments
 (0)