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

fix: use correct endpoint for custom events #3954

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/v0/destinations/branch/data/eventMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const CommerceEventConfig = {
'Spend Credits': 'SPEND_CREDITS',
'Promotion Viewed': 'VIEW_AD',
'Promotion Clicked': 'CLICK_AD',
Purchase: 'PURCHASE',
Reserve: 'RESERVE',
},
event_data: ['transaction_id', 'currency', 'revenue', 'shipping', 'tax', 'coupon', 'description'],
Expand Down
8 changes: 5 additions & 3 deletions src/v0/destinations/branch/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function getCategoryAndName(rudderEventName) {
if (
typeof branchKey === 'string' &&
typeof rudderEventName === 'string' &&
branchKey.toLowerCase() === rudderEventName.toLowerCase()
(branchKey.toLowerCase() === rudderEventName.toLowerCase() ||
category.name[branchKey].toLowerCase() === rudderEventName.toLowerCase())
) {
requiredName = category.name[branchKey];
requiredCategory = category;
Expand Down Expand Up @@ -217,16 +218,17 @@ function getCommonPayload(message, category, evName) {
function processMessage(message, destination) {
let evName;
let category;
let updatedEventName = message.event;
switch (message.type) {
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;
updatedEventName = eventNameFromConfig;
}
({ evName, category } = getCategoryAndName(updatedEventName));
break;
}
case EventType.IDENTIFY:
Expand Down
4 changes: 2 additions & 2 deletions test/integrations/destinations/branch/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ export const data = [
branchKey: 'test_branch_key',
eventsMapping: [
{
from: 'Order Completed',
from: 'Some Random Event',
to: 'PURCHASE',
},
],
Expand Down Expand Up @@ -1561,7 +1561,7 @@ export const data = [
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',
event: 'Some Random Event',
integrations: {
All: true,
},
Expand Down
Loading