Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): pull main into develop post release v1.57.0 #3146

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

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.57.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.56.1...v1.57.0) (2024-02-29)


### Features

* add event mapping support for branch destination ([#3135](https://github.com/rudderlabs/rudder-transformer/issues/3135)) ([cc94bba](https://github.com/rudderlabs/rudder-transformer/commit/cc94bba682f667877a721f63627adc6ff6a7386a))


### Bug Fixes

* marketo bulk upload zero and null value allowed ([#3134](https://github.com/rudderlabs/rudder-transformer/issues/3134)) ([4dcbf8f](https://github.com/rudderlabs/rudder-transformer/commit/4dcbf8fb189a39bb40b950742425a0b9da2d8d7c))

### [1.56.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.56.0...v1.56.1) (2024-02-21)


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.56.1",
"version": "1.57.0",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
16 changes: 7 additions & 9 deletions src/v0/destinations/branch/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
simpleProcessRouterDest,
} = require('../../util');
const { JSON_MIME_TYPE } = require('../../util/constant');
const { getMappedEventNameFromConfig } = require('./utils');

function responseBuilder(payload, message, destination, category) {
const response = defaultRequestConfig();
Expand Down Expand Up @@ -213,24 +214,21 @@ function getCommonPayload(message, category, evName) {
return rawPayload;
}

// function getTrackPayload(message) {
// const rawPayload = {};
// const { name, category } = getCategoryAndName(message.event);
// rawPayload.name = name;
//
// return commonPayload(message, rawPayload, category);
// }

function processMessage(message, destination) {
let evName;
let category;
switch (message.type) {
case EventType.TRACK:
case EventType.TRACK: {
if (!message.event) {
throw new InstrumentationError('Event name is required');
}
({ evName, category } = getCategoryAndName(message.event));
const eventNameFromConfig = getMappedEventNameFromConfig(message, destination);
if (eventNameFromConfig) {
evName = eventNameFromConfig;
}
break;
}
case EventType.IDENTIFY:
({ evName, category } = getCategoryAndName(message.userId));
break;
Expand Down
24 changes: 24 additions & 0 deletions src/v0/destinations/branch/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { getHashFromArray } = require('../../util');

/**
* Retrieves the mapped event name from the given config.
*
* @param {object} message - The message object containing the event.
* @param {object} destination - The destination object containing the events mapping configuration.
* @returns {string} - The mapped event name, or undefined if not found.
*/
const getMappedEventNameFromConfig = (message, destination) => {
let eventName;
const { event } = message;
const { eventsMapping } = destination.Config;

// if event is mapped on dashboard, use the mapped event name
if (Array.isArray(eventsMapping) && eventsMapping.length > 0) {
const keyMap = getHashFromArray(eventsMapping, 'from', 'to', false);
eventName = keyMap[event];
}

return eventName;
};

module.exports = { getMappedEventNameFromConfig };
18 changes: 18 additions & 0 deletions src/v0/destinations/branch/utils.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { getMappedEventNameFromConfig } = require('./utils');
describe('getMappedEventNameFromConfig', () => {
it('should return the mapped event name when it exists in the events mapping configuration', () => {
const message = { event: 'Order Completed' };
const destination = {
Config: { eventsMapping: [{ from: 'Order Completed', to: 'PURCHASE' }] },
};
const result = getMappedEventNameFromConfig(message, destination);
expect(result).toBe('PURCHASE');
});

it('should return undefined when the event mapping is not created', () => {
const message = { event: 'Order Completed' };
const destination = { Config: {} };
const result = getMappedEventNameFromConfig(message, destination);
expect(result).toBeUndefined();
});
});
4 changes: 2 additions & 2 deletions src/v0/destinations/marketo_bulk_upload/transform.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { InstrumentationError } = require('@rudderstack/integrations-lib');
const { InstrumentationError, isDefined } = require('@rudderstack/integrations-lib');
const {
getHashFromArray,
getFieldValueFromMessage,
Expand Down Expand Up @@ -34,7 +34,7 @@ function responseBuilderSimple(message, destination) {
// columnNames with trait's values from rudder payload
Object.keys(fieldHashmap).forEach((key) => {
const val = traits[fieldHashmap[key]];
if (val) {
if (isDefined(val)) {
payload[key] = val;
}
});
Expand Down
156 changes: 156 additions & 0 deletions test/integrations/destinations/branch/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1490,4 +1490,160 @@ export const data = [
},
},
},
{
name: 'branch',
description: 'Map event name to branch standard event name in track call',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
destination: {
Config: {
branchKey: 'test_branch_key',
eventsMapping: [
{
from: 'Order Completed',
to: 'PURCHASE',
},
],
useNativeSDK: false,
},
DestinationDefinition: {
DisplayName: 'Branch Metrics',
ID: '1WTpBSTiL3iAUHUdW7rHT4sawgU',
Name: 'BRANCH',
},
Enabled: true,
ID: '1WTpIHpH7NTBgjeiUPW1kCUgZGI',
Name: 'branch test',
Transformations: [],
},
message: {
anonymousId: 'anonId123',
channel: 'web',
context: {
app: {
build: '1.0.0',
name: 'RudderLabs JavaScript SDK',
namespace: 'com.rudderlabs.javascript',
version: '1.0.0',
},
device: {
adTrackingEnabled: true,
advertisingId: '3f034872-5e28-45a1-9eda-ce22a3e36d1a',
id: '3f034872-5e28-45a1-9eda-ce22a3e36d1a',
manufacturer: 'Google',
model: 'AOSP on IA Emulator',
name: 'generic_x86_arm',
type: 'ios',
attTrackingStatus: 3,
},
ip: '0.0.0.0',
library: {
name: 'RudderLabs JavaScript SDK',
version: '1.0.0',
},
locale: 'en-US',
os: {
name: 'iOS',
version: '14.4.1',
},
screen: {
density: 2,
},
traits: {
anonymousId: 'anonId123',
email: '[email protected]',
},
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
},
event: 'Order Completed',
integrations: {
All: true,
},
messageId: 'ea5cfab2-3961-4d8a-8187-3d1858c90a9f',
originalTimestamp: '2020-01-17T04:53:51.185Z',
properties: {
name: 't-shirt',
revenue: '10',
currency: 'USD',
key1: 'value1',
key2: 'value2',
order_id: 'order123',
},
receivedAt: '2020-01-17T10:23:52.688+05:30',
request_ip: '[::1]:64059',
sentAt: '2020-01-17T04:53:52.667Z',
timestamp: '2020-01-17T10:23:51.206+05:30',
type: 'track',
userId: 'userId123',
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
output: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://api2.branch.io/v2/event/standard',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
params: {},
body: {
JSON: {
branch_key: 'test_branch_key',
name: 'PURCHASE',
content_items: [
{
$product_name: 't-shirt',
},
],
event_data: {
revenue: '10',
currency: 'USD',
},
custom_data: {
key1: 'value1',
key2: 'value2',
order_id: 'order123',
},
user_data: {
os: 'iOS',
os_version: '14.4.1',
app_version: '1.0.0',
screen_dpi: 2,
developer_identity: 'userId123',
idfa: '3f034872-5e28-45a1-9eda-ce22a3e36d1a',
idfv: '3f034872-5e28-45a1-9eda-ce22a3e36d1a',
limit_ad_tracking: false,
model: 'AOSP on IA Emulator',
user_agent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
},
},
XML: {},
JSON_ARRAY: {},
FORM: {},
},
files: {},
userId: 'anonId123',
},
statusCode: 200,
},
],
},
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -502,4 +502,97 @@ export const data = [
},
},
},
{
name: 'marketo_bulk_upload',
description: 'Test 5: Any null or zero value will be passed through transform payload',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
type: 'identify',
traits: {
name: 'Carlo Lombard',
plan: 0,
id: null,
},
userId: 476335,
context: {
ip: '14.0.2.238',
page: {
url: 'enuffsaid.proposify.com',
path: '/settings',
method: 'POST',
referrer: 'https://enuffsaid.proposify.com/login',
},
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36',
},
rudderId: '786dfec9-jfh',
messageId: '5d9bc6e2-ekjh',
},
destination: {
ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe',
Config: {
munchkinId: 'XXXX',
clientId: 'YYYY',
clientSecret: 'ZZZZ',
columnFieldsMapping: [
{
to: 'name__c',
from: 'name',
},
{
to: 'email__c',
from: 'email',
},
{
to: 'plan__c',
from: 'plan',
},
{
to: 'id',
from: 'id',
},
],
},
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
output: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: '/fileUpload',
headers: {},
params: {},
body: {
JSON: {
name__c: 'Carlo Lombard',
plan__c: 0,
id: null,
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
userId: '',
},
statusCode: 200,
},
],
},
},
},
];
Loading