Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:rudderlabs/rudder-transformer in…
Browse files Browse the repository at this point in the history
…to feat.zod-validations
  • Loading branch information
Utsab Chowdhury authored and Utsab Chowdhury committed Feb 8, 2024
2 parents 2ac1654 + de3518f commit a1d912d
Show file tree
Hide file tree
Showing 20 changed files with 1,527 additions and 23 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.55.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.54.4...v1.55.0) (2024-02-05)


### Features

* add new stat for access token expired in fb custom audience ([#3043](https://github.com/rudderlabs/rudder-transformer/issues/3043)) ([1e6d540](https://github.com/rudderlabs/rudder-transformer/commit/1e6d540fafc61a84fbbaa63d4bc5b1edc17ec44e))
* **intercom:** upgrade intercom version from 1.4 to 2.10 ([#2976](https://github.com/rudderlabs/rudder-transformer/issues/2976)) ([717639b](https://github.com/rudderlabs/rudder-transformer/commit/717639bcce605109b145eb4cc6836fe1589278fe))
* onboard new destination rakuten ([#3046](https://github.com/rudderlabs/rudder-transformer/issues/3046)) ([c7c3110](https://github.com/rudderlabs/rudder-transformer/commit/c7c3110a4526e31bc296abb33f3246fa8eee049a))
* trade desk real time conversions ([#3023](https://github.com/rudderlabs/rudder-transformer/issues/3023)) ([212d5f0](https://github.com/rudderlabs/rudder-transformer/commit/212d5f09d8addc618d4398029e62c9a18a9512cf))


### Bug Fixes

* adding map for marketo known values and javascript known values ([#3037](https://github.com/rudderlabs/rudder-transformer/issues/3037)) ([64ab555](https://github.com/rudderlabs/rudder-transformer/commit/64ab555d31b4c1c49863794444bd79b2b6a45927))
* mixpanel timestamp in ms ([#3028](https://github.com/rudderlabs/rudder-transformer/issues/3028)) ([5ad55a2](https://github.com/rudderlabs/rudder-transformer/commit/5ad55a27c8b737fd96f65c68ba086769747c5360))
* upgrade ua-parser-js from 1.0.35 to 1.0.37 ([9a4cdef](https://github.com/rudderlabs/rudder-transformer/commit/9a4cdef59ab1c2d9dc95eb8629a7009d8d633297))

### [1.54.4](https://github.com/rudderlabs/rudder-transformer/compare/v1.54.3...v1.54.4) (2024-01-31)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-transformer",
"version": "1.54.4",
"version": "1.55.0",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/intercom/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ steps:
version;
- name: rEtlPayload
condition: .message.context.mappedToDestination === true
condition: .message.context.mappedToDestination
template: |
$.addExternalIdToTraits(.message);
const payload = $.getFieldValueFromMessage(.message, "traits");
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/rakuten/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ steps:
template: |
const properties = $.constructProperties(.message);
const lineItems = $.constructLineItems(.message.properties)
$.context.payload = {...properties,...lineItems,xml:1, mid:.destination.Config.mid}
$.context.payload = {...properties,...lineItems,xml:1,source:'rudderstack', mid:.destination.Config.mid}
$.context.payload = $.removeUndefinedAndNullValues($.context.payload);
- name: buildResponse
Expand Down
9 changes: 7 additions & 2 deletions src/cdk/v2/destinations/the_trade_desk/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ const prepareItemsPayload = (message) => {
let items;
const eventMapInfo = ECOMM_EVENT_MAP[event.toLowerCase()];
if (eventMapInfo?.itemsArray) {
// if event is one of the supported ecommerce events and products array is present
items = prepareItemsFromProducts(message);
} else if (eventMapInfo) {
// if event is one of the supported ecommerce events and products array is not present
items = prepareItemsFromProperties(message);
}
return items;
Expand Down Expand Up @@ -304,14 +306,17 @@ const enrichTrackPayload = (message, payload) => {
if (eventsMapInfo && !eventsMapInfo.itemsArray) {
const itemExclusionList = generateExclusionList(ITEM_CONFIGS);
rawPayload = extractCustomFields(message, rawPayload, ['properties'], itemExclusionList);
} else {
// for custom events
} else if (eventsMapInfo) {
// for ecomm events with products array supports. e.g Order Completed event
rawPayload = extractCustomFields(
message,
rawPayload,
['properties'],
['products', 'revenue', 'value'],
);
} else {
// for custom events
rawPayload = extractCustomFields(message, rawPayload, ['properties'], ['value']);
}
return rawPayload;
};
Expand Down
28 changes: 19 additions & 9 deletions src/cdk/v2/destinations/the_trade_desk/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,25 +635,35 @@ describe('enrichTrackPayload', () => {
order_id: 'ord123',
property1: 'value1',
property2: 'value2',
revenue: 10,
value: 11,
products: [
{
product_id: 'prd123',
test: 'test',
},
],
},
};
const payload = {
order_id: 'ord123',
value: 11,
};
let expectedPayload = {
const expectedPayload = {
order_id: 'ord123',
property1: 'value1',
property2: 'value2',
revenue: 10,
value: 11,
products: [
{
product_id: 'prd123',
test: 'test',
},
],
};

let result = enrichTrackPayload(message, payload);
const result = enrichTrackPayload(message, payload);
expect(result).toEqual(expectedPayload);

expectedPayload = {
order_id: 'ord123',
property1: 'value1',
property2: 'value2',
};
expect(enrichTrackPayload(message, {})).toEqual(expectedPayload);
});
});
53 changes: 53 additions & 0 deletions src/v0/destinations/intercom/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const { getMappingConfig } = require('../../util');

const BASE_ENDPOINT = 'https://api.intercom.io';

// track events | Track
const TRACK_ENDPOINT = `${BASE_ENDPOINT}/events`;
// Create, Update a user with a company | Identify
const IDENTIFY_ENDPOINT = `${BASE_ENDPOINT}/users`;
// create, update, delete a company | Group
const GROUP_ENDPOINT = `${BASE_ENDPOINT}/companies`;

const ConfigCategory = {
TRACK: {
endpoint: TRACK_ENDPOINT,
name: 'INTERCOMTrackConfig',
},
IDENTIFY: {
endpoint: IDENTIFY_ENDPOINT,
name: 'INTERCOMIdentifyConfig',
},
GROUP: {
endpoint: GROUP_ENDPOINT,
name: 'INTERCOMGroupConfig',
},
};

const MappingConfig = getMappingConfig(ConfigCategory, __dirname);

const ReservedTraitsProperties = [
'userId',
'email',
'phone',
'name',
'createdAt',
'firstName',
'lastName',
'firstname',
'lastname',
'company',
];

const ReservedCompanyProperties = ['id', 'name', 'industry'];

// ref:- https://developers.intercom.com/intercom-api-reference/v1.4/reference/event-metadata-types
const MetadataTypes = { richLink: ['url', 'value'], monetaryAmount: ['amount', 'currency'] };

module.exports = {
ConfigCategory,
MappingConfig,
ReservedCompanyProperties,
ReservedTraitsProperties,
MetadataTypes,
};
53 changes: 53 additions & 0 deletions src/v0/destinations/intercom/data/INTERCOMGroupConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[
{
"destKey": "company_id",
"sourceKeys": "groupId",
"required": true
},
{
"destKey": "name",
"sourceKeys": "name",
"sourceFromGenericMap": true,
"required": false
},
{
"destKey": "plan",
"sourceKeys": ["traits.plan", "context.traits.plan"],
"required": false
},
{
"destKey": "size",
"sourceKeys": ["traits.size", "context.traits.size"],
"metadata": {
"type": "toNumber"
},
"required": false
},
{
"destKey": "website",
"sourceKeys": "website",
"sourceFromGenericMap": true,
"required": false
},
{
"destKey": "industry",
"sourceKeys": ["traits.industry", "context.traits.industry"],
"required": false
},
{
"destKey": "monthly_spend",
"sourceKeys": ["traits.monthlySpend", "context.traits.monthlySpend"],
"metadata": {
"type": "toNumber"
},
"required": false
},
{
"destKey": "remote_created_at",
"sourceKeys": ["traits.remoteCreatedAt", "context.traits.remoteCreatedAt"],
"metadata": {
"type": "toNumber"
},
"required": false
}
]
46 changes: 46 additions & 0 deletions src/v0/destinations/intercom/data/INTERCOMIdentifyConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"destKey": "user_id",
"sourceKeys": [
"userId",
"traits.userId",
"traits.id",
"context.traits.userId",
"context.traits.id"
],
"required": false
},
{
"destKey": "email",
"sourceKeys": ["traits.email", "context.traits.email"],
"required": false
},
{
"destKey": "phone",
"sourceKeys": ["traits.phone", "context.traits.phone"],
"required": false
},
{
"destKey": "name",
"sourceKeys": ["traits.name", "context.traits.name"],
"required": false
},
{
"destKey": "signed_up_at",
"sourceKeys": ["traits.createdAt", "context.traits.createdAt"],
"required": false,
"metadata": {
"type": "secondTimestamp"
}
},
{
"destKey": "last_seen_user_agent",
"sourceKeys": "context.userAgent",
"required": false
},
{
"destKey": "custom_attributes",
"sourceKeys": ["traits", "context.traits"],
"required": false
}
]
36 changes: 36 additions & 0 deletions src/v0/destinations/intercom/data/INTERCOMTrackConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[
{
"destKey": "user_id",
"sourceKeys": [
"userId",
"traits.userId",
"traits.id",
"context.traits.userId",
"context.traits.id"
],
"required": false
},
{
"destKey": "email",
"sourceKeys": ["traits.email", "context.traits.email"],
"required": false
},
{
"destKey": "event_name",
"sourceKeys": "event",
"required": true
},
{
"destKey": "created",
"sourceKeys": "timestamp",
"sourceFromGenericMap": true,
"required": true,
"metadata": {
"type": "secondTimestamp"
}
},
{
"destKey": "metadata",
"sourceKeys": "properties"
}
]
Loading

0 comments on commit a1d912d

Please sign in to comment.