Skip to content

Commit

Permalink
feat: ninetailed: add default value for context.location as {} (#3197)
Browse files Browse the repository at this point in the history
feat: ninetailed: add a default value to context.location
  • Loading branch information
anantjain45823 authored Mar 20, 2024
1 parent c5cc69b commit 91fc0fb
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/cdk/v2/destinations/ninetailed/data/contextMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
},
{
"sourceKeys": "location",
"required": true,
"required": false,
"metadata": {
"defaultValue": {}
},
"destKey": "location"
}
]
36 changes: 35 additions & 1 deletion test/integrations/destinations/ninetailed/commonConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,41 @@ export const context = {
timezone: 'America/Los_Angeles',
},
};

export const contextWithNoLocation = {
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',
};
export const commonInputWithNoLocation = {
anonymousId: 'anon_123',
messageId: 'dummy_msg_id',
context: contextWithNoLocation,
channel: 'web',
integrations: {
All: true,
},
originalTimestamp: '2021-01-25T15:32:56.409Z',
};
export const commonInput = {
anonymousId: 'anon_123',
messageId: 'dummy_msg_id',
Expand Down
89 changes: 89 additions & 0 deletions test/integrations/destinations/ninetailed/processor/identify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
destination,
traits,
commonInput,
commonInputWithNoLocation,
metadata,
processInstrumentationErrorStatTags,
} from '../commonConfig';
Expand Down Expand Up @@ -152,4 +153,92 @@ export const identify = [
},
},
},
{
id: 'ninetailed-test-identify-success-3',
name: 'ninetailed',
description: 'identify call with no context.location present and {} is used as default',
scenario: 'Framework+Buisness',
successCriteria: 'Response should contain context.location as {} and status code should be 200',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
destination,
message: {
type: 'identify',
...commonInputWithNoLocation,
userId: 'sajal12',
traits: traits,
integrations: {
All: true,
},
originalTimestamp: '2021-01-25T15:32:56.409Z',
},
metadata,
},
],
},
},
output: {
response: {
status: 200,
body: [
{
metadata: {
destinationId: 'dummyDestId',
},
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',
channel: 'web',
userId: 'sajal12',
messageId: 'dummy_msg_id',
traits: traits,
anonymousId: 'anon_123',
originalTimestamp: '2021-01-25T15:32:56.409Z',
},
],
},
userId: '',
}),
statusCode: 200,
},
],
},
},
},
];

0 comments on commit 91fc0fb

Please sign in to comment.