-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(release): pull hotfix-release/v1.57.0 into main (#3145)
- Loading branch information
Showing
9 changed files
with
315 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters