Skip to content

Commit

Permalink
fix: ninetailed: modify parameter requirements and add default values (
Browse files Browse the repository at this point in the history
…#3364)

* fix: ninetailed: modify parameter requirements and add default values

* chore: add default value for userId
  • Loading branch information
anantjain45823 authored May 13, 2024
1 parent a347ab1 commit 265a71d
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 32 deletions.
1 change: 0 additions & 1 deletion src/cdk/v2/destinations/ninetailed/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const ConfigCategories = {
},
};

// MAX_BATCH_SIZE : // Maximum number of events to send in a single batch
const mappingConfig = getMappingConfig(ConfigCategories, __dirname);
const batchEndpoint =
'https://experience.ninetailed.co/v2/organizations/{{organisationId}}/environments/{{environment}}/events';
Expand Down
13 changes: 7 additions & 6 deletions src/cdk/v2/destinations/ninetailed/data/contextMapping.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"sourceKeys": "app.name",
"required": true,
"destKey": "app.name"
},
{
"sourceKeys": "app.version",
"required": true,
"destKey": "app.version"
},
{
Expand All @@ -15,12 +13,16 @@
},
{
"sourceKeys": "library.name",
"required": true,
"destKey": "library.name"
"destKey": "library.name",
"metadata": {
"defaultValue": "Rudderstack Ninetailed Destination"
}
},
{
"sourceKeys": "library.version",
"required": true,
"metadata": {
"defaultValue": "1"
},
"destKey": "library.version"
},
{
Expand All @@ -37,7 +39,6 @@
},
{
"sourceKeys": "location",
"required": false,
"metadata": {
"defaultValue": {}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
},
{
"sourceKeys": "channel",
"required": true,
"metadata": {
"defaultValue": "server"
},
"destKey": "channel"
},
{
Expand Down
5 changes: 3 additions & 2 deletions src/cdk/v2/destinations/ninetailed/data/identifyMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
{
"sourceKeys": "traits",
"sourceFromGenericMap": true,
"required": true,
"metadata": {
"defaultValue": {}
},
"destKey": "traits"
},
{
"sourceKeys": "userIdOnly",
"sourceFromGenericMap": true,
"required": true,
"destKey": "userId"
}
]
4 changes: 3 additions & 1 deletion src/cdk/v2/destinations/ninetailed/data/trackMapping.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[
{
"sourceKeys": "properties",
"required": true,
"metadata": {
"defaultValue": {}
},
"destKey": "properties"
},
{
Expand Down
1 change: 0 additions & 1 deletion src/cdk/v2/destinations/ninetailed/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ steps:
template: |
const payload = $.constructFullPayload(.message);
$.context.payload = $.removeUndefinedAndNullValues(payload);
- name: buildResponse
template: |
const response = $.defaultRequestConfig();
Expand Down
1 change: 1 addition & 0 deletions src/cdk/v2/destinations/ninetailed/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const constructFullPayload = (message) => {
message,
config.mappingConfig[config.ConfigCategories.IDENTIFY.name],
);
typeSpecifcPayload.userId = typeSpecifcPayload.userId || '';
break;
default:
break;
Expand Down
3 changes: 1 addition & 2 deletions test/integrations/destinations/ninetailed/commonConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ export const contextWithNoLocation = {
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
};
export const commonInputWithNoLocation = {
export const commonInputWithNoLocationAndChannel = {
anonymousId: 'anon_123',
messageId: 'dummy_msg_id',
context: contextWithNoLocation,
channel: 'web',
integrations: {
All: true,
},
Expand Down
64 changes: 52 additions & 12 deletions test/integrations/destinations/ninetailed/processor/identify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import {
destination,
traits,
commonInput,
commonInputWithNoLocation,
commonInputWithNoLocationAndChannel,
metadata,
processInstrumentationErrorStatTags,
} from '../commonConfig';
import { transformResultBuilder } from '../../../testUtils';
export const identify = [
Expand Down Expand Up @@ -110,12 +109,12 @@ export const identify = [
},
},
{
id: 'ninetailed-test-identify-failure-1',
id: 'ninetailed-test-identify-success-2',
name: 'ninetailed',
description: 'identify call with no userId available',
scenario: 'Framework',
successCriteria:
'Error should be thrown for required field userId not present and status code should be 200',
'No Error should be thrown for field userId not present but default empty string should be provided to userId and status code should be 200',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand All @@ -125,9 +124,8 @@ export const identify = [
{
destination,
message: {
...commonInput,
...commonInputWithNoLocationAndChannel,
type: 'identify',
channel: 'mobile',
messageId: 'dummy_msg_id',
traits: traits,
},
Expand All @@ -141,13 +139,55 @@ export const identify = [
status: 200,
body: [
{
error:
'Missing required value from "userIdOnly": Workflow: procWorkflow, Step: preparePayload, ChildStep: undefined, OriginalError: Missing required value from "userIdOnly"',
metadata: {
destinationId: 'dummyDestId',
},
statTags: processInstrumentationErrorStatTags,
statusCode: 400,
output: transformResultBuilder({
method: 'POST',
endpoint:
'https://experience.ninetailed.co/v2/organizations/dummyOrganisationId/environments/main/events',
JSON: {
events: [
{
context: {
app: {
name: 'RudderLabs JavaScript SDK',
version: '1.0.0',
},
campaign: {
name: 'campign_123',
source: 'social marketing',
medium: 'facebook',
term: '1 year',
},
library: {
name: 'RudderstackSDK',
version: 'Ruddderstack SDK version',
},
locale: 'en-US',
page: {
path: '/signup',
referrer: 'https://rudderstack.medium.com/',
search: '?type=freetrial',
url: 'https://app.rudderstack.com/signup?type=freetrial',
},
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
location: {},
},
type: 'identify',
userId: '',
channel: 'server',
messageId: 'dummy_msg_id',
traits: traits,
anonymousId: 'anon_123',
originalTimestamp: '2021-01-25T15:32:56.409Z',
},
],
},
userId: '',
}),
statusCode: 200,
},
],
},
Expand All @@ -169,7 +209,7 @@ export const identify = [
destination,
message: {
type: 'identify',
...commonInputWithNoLocation,
...commonInputWithNoLocationAndChannel,
userId: 'sajal12',
traits: traits,
integrations: {
Expand Down Expand Up @@ -224,7 +264,7 @@ export const identify = [
location: {},
},
type: 'identify',
channel: 'web',
channel: 'server',
userId: 'sajal12',
messageId: 'dummy_msg_id',
traits: traits,
Expand Down
23 changes: 17 additions & 6 deletions test/integrations/destinations/ninetailed/router/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
destination,
commonOutput,
routerInstrumentationErrorStatTags,
context,
} from '../commonConfig';
import { trackProperties, pageProperties, traits } from './basicProperties';
import { defaultMockFns } from '../mocks';
Expand Down Expand Up @@ -137,9 +138,14 @@ export const data = [
{
message: {
type: 'identify',
...commonInput,
messageId: 'dummy_msg_id',
context,
channel: 'web',
integrations: {
All: true,
},
originalTimestamp: '2021-01-25T15:32:56.409Z',
traits,
integrations: { All: true },
},
metadata: { jobId: 3, userId: 'u1' },
destination,
Expand All @@ -158,7 +164,7 @@ export const data = [
{
batched: false,
destination,
error: 'Missing required value from "userIdOnly"',
error: 'Missing required value from "anonymousId"',
metadata: [{ jobId: 3, userId: 'u1' }],
statTags: routerInstrumentationErrorStatTags,
statusCode: 400,
Expand Down Expand Up @@ -259,9 +265,14 @@ export const data = [
{
message: {
type: 'identify',
...commonInput,
messageId: 'dummy_msg_id',
context,
channel: 'web',
integrations: {
All: true,
},
originalTimestamp: '2021-01-25T15:32:56.409Z',
traits,
integrations: { All: true },
},
metadata: { jobId: 4, userId: 'u1' },
destination,
Expand All @@ -280,7 +291,7 @@ export const data = [
{
batched: false,
destination,
error: 'Missing required value from "userIdOnly"',
error: 'Missing required value from "anonymousId"',
metadata: [{ jobId: 4, userId: 'u1' }],
statTags: routerInstrumentationErrorStatTags,
statusCode: 400,
Expand Down

0 comments on commit 265a71d

Please sign in to comment.