Skip to content

Commit

Permalink
Merge branch 'develop' into onboard-revenuecat-source
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvibajpai authored Nov 6, 2023
2 parents 00229e2 + 570532c commit 0e77707
Show file tree
Hide file tree
Showing 262 changed files with 115,838 additions and 92,668 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest

# Only allow release stakeholders to initiate releases
if: (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/')) && (github.actor == 'ItsSudip' || github.actor == 'krishna2020' || github.actor == 'saikumarrs' || github.actor == 'sandeepdsvs' || github.actor == 'shrouti1507' || github.actor == 'anantjain45823' || github.actor == 'chandumlg' || github.actor == 'mihir-4116') && (github.triggering_actor == 'ItsSudip' || github.triggering_actor == 'krishna2020' || github.triggering_actor == 'saikumarrs' || github.triggering_actor == 'sandeepdsvs' || github.triggering_actor == 'shrouti1507' || github.triggering_actor == 'anantjain45823' || github.triggering_actor == 'chandumlg' || github.triggering_actor == 'mihir-4116')
if: (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/hotfix/')) && (github.actor == 'ItsSudip' || github.actor == 'krishna2020' || github.actor == 'saikumarrs' || github.actor == 'sandeepdsvs' || github.actor == 'shrouti1507' || github.actor == 'anantjain45823' || github.actor == 'chandumlg' || github.actor == 'mihir-4116' || github.actor == 'yashasvibajpai' || github.actor == 'sanpj2292') && (github.triggering_actor == 'ItsSudip' || github.triggering_actor == 'krishna2020' || github.triggering_actor == 'saikumarrs' || github.triggering_actor == 'sandeepdsvs' || github.triggering_actor == 'shrouti1507' || github.triggering_actor == 'anantjain45823' || github.triggering_actor == 'chandumlg' || github.triggering_actor == 'mihir-4116' || github.triggering_actor == 'yashasvibajpai' || github.triggering_actor == 'sanpj2292')
steps:
- name: Checkout
uses: actions/[email protected]
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

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.48.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.47.0...v1.48.0) (2023-11-02)


### Features

* add support to add custom network policies for specific workspaces in faas pods ([bc1a760](https://github.com/rudderlabs/rudder-transformer/commit/bc1a76066c0aeb43776ded0b266ec48f5e69aa16))

## [1.47.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.46.5...v1.47.0) (2023-10-30)


### Features

* add custom utm parameters to mixpanel ([#2771](https://github.com/rudderlabs/rudder-transformer/issues/2771)) ([9c4fcd3](https://github.com/rudderlabs/rudder-transformer/commit/9c4fcd3595534a8b563df3467e23c94c580f08a6))
* add support filtering component tests by feature and index ([#2748](https://github.com/rudderlabs/rudder-transformer/issues/2748)) ([146f1c6](https://github.com/rudderlabs/rudder-transformer/commit/146f1c63db4e895c7d5ce2848a1b60e7c5bb9fb6))
* onboard destination ortto ([#2730](https://github.com/rudderlabs/rudder-transformer/issues/2730)) ([9be5740](https://github.com/rudderlabs/rudder-transformer/commit/9be5740d8670890b0318da3d37f258ddc5e35445))
* onboard facebook custom audience to transformer proxy ([#2769](https://github.com/rudderlabs/rudder-transformer/issues/2769)) ([14c5e40](https://github.com/rudderlabs/rudder-transformer/commit/14c5e40284af7df9e4f5b262ad226dd3afef226e))
* add custom event name support in pinterest v5 ([#2773](https://github.com/rudderlabs/rudder-transformer/pull/2773)) ([a586a92](https://github.com/rudderlabs/rudder-transformer/commit/a586a92bf410679d0f3aa7012d4d10f8e2f515d5))


### Bug Fixes

* bugsnag error for salesforce ([#2753](https://github.com/rudderlabs/rudder-transformer/issues/2753)) ([a2ccdad](https://github.com/rudderlabs/rudder-transformer/commit/a2ccdad52a1fb88f962745800cb45d605b5e0bf3))
* oom kill while stringifying large response json ([#2754](https://github.com/rudderlabs/rudder-transformer/issues/2754)) ([c8baf5b](https://github.com/rudderlabs/rudder-transformer/commit/c8baf5b2b6325d9e30200339055dcbefd780936c))
* salesforce: handle ECONNABORTED error ([#2732](https://github.com/rudderlabs/rudder-transformer/issues/2732)) ([6b23a9b](https://github.com/rudderlabs/rudder-transformer/commit/6b23a9b33acd28fdacaa2390c1970a1fa4415ffa))

### [1.46.5](https://github.com/rudderlabs/rudder-transformer/compare/v1.46.4...v1.46.5) (2023-10-23)


Expand Down
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ module.exports = {
coverageThreshold: {
global: {
branches: 60,
functions: 80,
lines: 80,
statements: 80,
functions: 75,
lines: 75,
statements: 75,
},
},

Expand Down
6 changes: 3 additions & 3 deletions jest.default.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ module.exports = {
coverageThreshold: {
global: {
branches: 60,
functions: 80,
lines: 80,
statements: 80,
functions: 75,
lines: 75,
statements: 75,
},
},

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.46.5",
"version": "1.48.0",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
6 changes: 6 additions & 0 deletions src/cdk/v2/bindings/default.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const crypto = require('crypto');
const {
InstrumentationError,
ConfigurationError,
Expand Down Expand Up @@ -47,7 +48,12 @@ function assertHttpResp(processedResponse, message) {
}
}

function MD5(data) {
return crypto.createHash('md5').update(data).digest('hex');
}

module.exports = {
MD5,
isValidEventType,
assert,
assertConfig,
Expand Down
38 changes: 38 additions & 0 deletions src/cdk/v2/destinations/ortto/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const IDENTIFY_ENDPOINT = {
au: 'https://api.au.ap3api.com/v1/person/merge',
eu: 'https://api.eu.ap3api.com/v1/person/merge',
other: 'https://api.ap3api.com/v1/person/merge',
};
// https://help.ortto.com/developer/latest/api-reference/person/merge.html#person-fields
const TRACK_ENDPOINT = {
au: 'https://api.au.ap3api.com/v1/activities/create',
eu: 'https://api.eu.ap3api.com/v1/activities/create',
other: 'https://api.ap3api.com/v1/activities/create',
};
// https://help.ortto.com/a-271-create-a-custom-activity-event-create

const maxBatchSize = 1;

const fieldTypeMap = {
text: 'str',
email: 'str',
longText: 'txt',
number: 'int',
decimalNumber: 'int',
currency: 'int',
date: 'dtz',
timeAndDate: 'tme',
boolean: 'bol',
phone: 'phn',
singleSelect: 'str',
multiSelect: 'sst',
link: 'str',
object: 'obj',
};

module.exports = {
IDENTIFY_ENDPOINT,
TRACK_ENDPOINT,
fieldTypeMap,
maxBatchSize,
};
126 changes: 126 additions & 0 deletions src/cdk/v2/destinations/ortto/procWorkflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
bindings:
- name: EventType
path: ../../../../constants
- path: ../../bindings/jsontemplate
exportAll: true
- path: ./config
- name: removeUndefinedAndNullValues
path: ../../../../v0/util
- name: defaultRequestConfig
path: ../../../../v0/util
- path: ./utils

steps:
- name: validateInput
template: |
let messageType = .message.type;
$.assert(.message.type, "message Type is not present. Aborting message.");
$.assertConfig(.destination.Config.privateApiKey, "Private Api Key is not present");
$.assertConfig(.destination.Config.instanceRegion, "Instance Region is not present");
$.assert(messageType in {{$.EventType.([.IDENTIFY, .TRACK])}}, "message type " + messageType + " is not supported");
$.assert(.message.().({{{{$.getGenericPaths("email")}}}}) || .message.().({{{{$.getGenericPaths("userId")}}}}), "Either of email or userId is required. Aborting message.");
- name: messageType
template: |
.message.type.toLowerCase()
- name: validateInputForTrack
description: Additional validation for Track events
condition: $.outputs.messageType === {{$.EventType.TRACK}}
template: |
$.assert(.message.event, "event is not present. Aborting.")
- name: commonFields
description: |
Builds common fields in destination payload.
template: |
let commonFields = .message.().({
"fields": {
"str::first": {{{{$.getGenericPaths("firstName")}}}},
"str::last": {{{{$.getGenericPaths("lastName")}}}},
"str::email": {{{{$.getGenericPaths("email")}}}},
"geo::city": {"name":{{{{$.getGenericPaths("city")}}}}},
"geo::country": {"name":{{{{$.getGenericPaths("country")}}}}},
"geo::region": {"name":{{{{$.getGenericPaths("region")}}}}},
"str::postal": {{{{$.getGenericPaths("zipcode")}}}},
"dtz::b": $.getBirthdayObj({{{{$.getGenericPaths("birthday")}}}}),
"str::ei": {{{{$.getGenericPaths("userId")}}}},
"str::language": .context.traits.language || .context.locale,
"phn::phone": {"n": {{{{$.getGenericPaths("phone")}}}}},
"bol::gdpr": .context.traits.gdpr ?? true,
"bol::p": .context.traits.emailConsent || false,
"bol::sp": .context.traits.smsConsent || false,
},
"location": {"source_ip": .context.ip}
});
.destination.Config.orttoPersonAttributes@attribute.(
const trimmedOrttoAttribute = attribute.orttoAttribute.trim().toLowerCase().replace(new RegExp('\\s+', 'g'),'-');
commonFields.fields[$.fieldTypeMap[attribute.type]+":cm:"+trimmedOrttoAttribute] = $.originalInput.message.context.traits[attribute.rudderTraits]
)[]
commonFields.fields = $.removeUndefinedAndNullValues(commonFields.fields)
$.removeUndefinedAndNullValues(commonFields)
- name: prepareIdentifyPayload
condition: $.outputs.messageType === {{$.EventType.IDENTIFY}}
template: |
const peopleObj = {
"fields": $.outputs.commonFields.fields,
"tags": .message.context.traits.tags || .message.traits.tags,
"unset_tags": .message.context.traits.unset_tags || .message.traits.unset_tags
}
const identifyPayoad = {
"people":[peopleObj],
"merge_by": ["str::ei", "str::email"]
}
$.removeUndefinedAndNullValues(identifyPayoad)
- name: prepareTrackPayload
condition: $.outputs.messageType === {{$.EventType.TRACK}}
steps:
- name: getTrimmedEvent
template: |
let customEvent = "";
const event = .message.event;
.destination.Config.orttoEventsMapping@order.(
customEvent = event === .rsEventName ? .orttoEventName : null;
)
$.assert(customEvent, "Event names is not mapped");
"act:cm:"+customEvent.trim().toLowerCase().replace(new RegExp('\\s+', 'g'),'-');
- name: getAttributes
template: |
let attributes = {};
[email protected]@prop.(
attributes[$.fieldTypeMap[prop.type]+":cm:"+prop.orttoProperty.trim().toLowerCase().replace(new RegExp('\\s+', 'g'),'-')] = $.originalInput.message.properties[prop.rudderProperty]
)
$.removeUndefinedAndNullValues(attributes)
- name: preparePayload
template: |
const activityObj = {
"fields": $.outputs.commonFields.fields,
"activity_id": $.outputs.prepareTrackPayload.getTrimmedEvent,
"attributes": $.outputs.prepareTrackPayload.getAttributes,
"location": {"source_ip": .message.context.ip}
};
{
"activities":[activityObj],
"merge_by": ["str::ei", "str::email"]
}
- name: payload
template: |
$.outputs.messageType === {{$.EventType.IDENTIFY}} ? $.outputs.prepareIdentifyPayload : $.outputs.prepareTrackPayload
- name: buildResponseForProcessTransformation
description: build response
template: |
const response = $.defaultRequestConfig();
const instanceRegion = $.originalInput.destination.Config.instanceRegion;
response.body.JSON = $.outputs.payload;
response.endpoint = response.body.JSON.people? $.IDENTIFY_ENDPOINT[instanceRegion] : $.TRACK_ENDPOINT[instanceRegion];
response.headers = {
"X-Api-Key": .destination.Config.privateApiKey,
"Content-Type": "application/json"
};
response;
70 changes: 70 additions & 0 deletions src/cdk/v2/destinations/ortto/rtWorkflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
bindings:
- path: ./utils
- path: ./config

steps:
- name: validateInput
template: |
$.assert(Array.isArray(^) && ^.length > 0, "Invalid event array")
- name: transform
externalWorkflow:
path: ./procWorkflow.yaml
bindings:
- name: batchMode
value: true
loopOverInput: true
- name: successfulEvents
template: |
$.outputs.transform#idx.output.({
"message": .[],
"destination": ^ [idx].destination,
"metadata": ^ [idx].metadata
})[]
- name: failedEvents
template: |
$.outputs.transform#idx.error.({
"metadata": ^[idx].metadata[],
"destination": ^[idx].destination,
"batched": false,
"statusCode": .status,
"error": .message,
"statTags": .originalError.statTags
})[]
- name: batchSuccessfulEvents
description: Batches the successfulEvents using V3 API
condition: $.outputs.successfulEvents.length
template: |
let batches = $.batchEvents($.outputs.successfulEvents);
batches@batch.({
"batchedRequest": {
"body": {
"JSON": batch.message,
"JSON_ARRAY": {},
"XML": {},
"FORM": {}
},
"version": "1",
"type": "REST",
"method": "POST",
"endpoint": batch.message.people ? $.IDENTIFY_ENDPOINT[$.originalInput[0].destination.Config.instanceRegion] : $.TRACK_ENDPOINT[$.originalInput[0].destination.Config.instanceRegion],
"headers": {
"X-Api-Key": .destination.Config.privateApiKey,
"Content-Type": "application/json",
},
"params": {},
"files": {}
},
"metadata": batch.metadata,
"batched": true,
"statusCode": 200,
"destination": batch.destination
})[];
else:
name: returnEmptyOuput
template: '[]'

- name: finalPayload
template: |
[...$.outputs.batchSuccessfulEvents, ...$.outputs.failedEvents]
Loading

0 comments on commit 0e77707

Please sign in to comment.