Skip to content

Commit

Permalink
Merge branch 'develop' into feat.custom_mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
koladilip committed Jun 10, 2024
2 parents a6cf547 + 775e8ee commit 448cf20
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/v0/destinations/splitio/data/EventConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,17 @@
"type": "toFloat"
},
"required": false
},
{
"destKey": "trafficTypeName",
"sourceKeys": [
"traits.trafficTypeName",
"context.traits.trafficTypeName",
"properties.trafficTypeName"
],
"metadata": {
"type": "toString"
},
"required": false
}
]
8 changes: 7 additions & 1 deletion src/v0/destinations/splitio/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function prepareResponse(message, destination, category) {

let outputPayload = {};

// ref: https://docs.split.io/reference/events-overview
outputPayload = constructPayload(message, MAPPING_CONFIG[category.name]);
outputPayload.eventTypeId = outputPayload.eventTypeId.replace(/ /g, '_');
if (EVENT_TYPE_ID_REGEX.test(outputPayload.eventTypeId)) {
Expand Down Expand Up @@ -93,7 +94,12 @@ function prepareResponse(message, destination, category) {
if (isDefinedAndNotNullAndNotEmpty(environment)) {
outputPayload.environmentName = environment;
}
outputPayload.trafficTypeName = trafficType;

// in case traffic type could not be mapped from the input payloads, falls back to the UI configured default traffic type.
if (!isDefinedAndNotNullAndNotEmpty(outputPayload.trafficTypeName)) {
outputPayload.trafficTypeName = trafficType;
}

outputPayload.properties = removeUndefinedNullValuesAndEmptyObjectArray(
flattenJson(bufferProperty),
);
Expand Down
4 changes: 4 additions & 0 deletions src/v0/destinations/zendesk/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
NetworkInstrumentationError,
InstrumentationError,
NetworkError,
isDefinedAndNotNull,
} = require('@rudderstack/integrations-lib');
const myAxios = require('../../../util/myAxios');

Expand Down Expand Up @@ -405,6 +406,9 @@ async function getUserMembershipPayload(message, headers, orgId, destinationConf
}

async function createOrganization(message, category, headers, destinationConfig, baseEndpoint) {
if (!isDefinedAndNotNull(message.traits)) {
throw new InstrumentationError('Organisation Traits are missing. Aborting.');
}
await checkAndCreateUserFields(
message.traits,
category.organizationFieldsEndpoint,
Expand Down
9 changes: 6 additions & 3 deletions test/integrations/destinations/splitio/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const data = [
Config: {
apiKey: 'abcde',
environment: 'staging',
trafficType: 'user',
trafficType: 'anonymous',
},
},
},
Expand Down Expand Up @@ -246,7 +246,7 @@ export const data = [
Config: {
apiKey: 'abcde',
environment: 'production',
trafficType: 'user',
trafficType: 'anonymous',
},
},
},
Expand Down Expand Up @@ -847,6 +847,9 @@ export const data = [
library: {
name: 'http',
},
traits: {
trafficTypeName: 'user',
},
},
type: 'identify',
timestamp: '2020-01-21T00:21:34.208Z',
Expand All @@ -858,7 +861,7 @@ export const data = [
Config: {
apiKey: 'abcde',
environment: 'staging',
trafficType: 'user',
trafficType: 'anonymous',
},
},
},
Expand Down
85 changes: 85 additions & 0 deletions test/integrations/destinations/zendesk/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2370,4 +2370,89 @@ export const data = [
},
},
},
{
name: 'zendesk',
description: 'Group Call : If message.traits are not present, aborting the call.',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
destination: {
Config: {
apiToken: 'myDummyApiToken4',
createUsersAsVerified: true,
domain: 'rudderlabshelp',
email: 'myDummyUserName1',
password: 'myDummyPwd1',
removeUsersFromOrganization: true,
sendGroupCallsWithoutUserId: true,
},
DestinationDefinition: {
DisplayName: 'Zendesk',
ID: '1YknZ1ENqB8UurJQJE2VrEA61tr',
Name: 'ZENDESK',
},
Enabled: true,
ID: 'xxxxxxxxxxxxxxxxxxxxxxxO51P',
Name: 'zendesk',
Transformations: [],
},
message: {
anonymousId: '297b0750-934b-4411-b66c-9b418cdbc0c9',
channel: 'web',
context: {
app: {
build: '1.0.0',
name: 'RudderLabs JavaScript SDK',
namespace: 'com.rudderlabs.javascript',
version: '1.1.0-beta.2',
},
ip: '0.0.0.0',
library: { name: 'RudderLabs JavaScript SDK', version: '1.1.0-beta.2' },
locale: 'en-GB',
os: { name: '', version: '' },
screen: { density: 2 },
traits: { email: '[email protected]', name: 'abcd124' },
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
},
groupId: 'group-124',
integrations: { All: true },
messageId: '2d54ba80-ce5f-4bcb-b1d7-7587e7a865fc',
originalTimestamp: '2020-03-23T18:27:28.983Z',
receivedAt: '2020-03-23T23:57:29.022+05:30',
request_ip: '[::1]:51574',
sentAt: '2020-03-23T18:27:28.983Z',
timestamp: '2020-03-23T23:57:29.022+05:30',
type: 'group',
userId: 'abcd-124',
},
},
],
method: 'POST',
},
},
output: {
response: {
status: 200,
body: [
{
error: 'Organisation Traits are missing. Aborting.',
statTags: {
destType: 'ZENDESK',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
feature: 'processor',
implementation: 'native',
module: 'destination',
},
statusCode: 400,
},
],
},
},
},
];

0 comments on commit 448cf20

Please sign in to comment.