Skip to content

Commit

Permalink
fix: comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik committed Jan 2, 2024
1 parent 54cd350 commit 1ccff68
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/v0/destinations/factorsai/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ const { ConfigCategories, mappingConfig, BASE_URL } = require('./config');

function populateIpDetails(requestJson, message) {
const payload = requestJson;
if (message.context && requestJson.context) {
payload.context.ip = message.context?.ip || message.request_ip;
if (message.context || message.request_ip) {
payload.context = { ...(payload.context || {}), ip: message.context?.ip || message.request_ip };
}

return payload;
}

Expand Down
73 changes: 73 additions & 0 deletions test/integrations/destinations/factorsai/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,4 +737,77 @@ export const data = [
},
},
},
{
name: 'factorsai',
description: 'IP fetched from request_ip withput context in payload',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
destination: {
Config: {
factorsAIApiKey: 'sdgerghsdfhsdhsdh432141dfgdfsg',
},
},
message: {
event: 'finalPageTest',
properties: {
title: 'Intro to Test final segemt context page added context last',
},
userId: 'PageTestAnonymousUser',
type: 'track',
messageId: '3c0abc14-96a2-4aed-9dfc-ee463832cc24',
originalTimestamp: '2022-10-17T15:32:44.202+05:30',
request_ip: '1.1.1.1',
},
},
],
method: 'POST',
},
},
output: {
response: {
status: 200,
body: [
{
output: {
body: {
XML: {},
FORM: {},
JSON: {
type: 'track',
event: 'finalPageTest',
context: {
ip: '1.1.1.1',
},
messageId: '3c0abc14-96a2-4aed-9dfc-ee463832cc24',
timestamp: '2022-10-17T15:32:44.202+05:30',
properties: {
title: 'Intro to Test final segemt context page added context last',
},
userId: 'PageTestAnonymousUser',
},
JSON_ARRAY: {},
},
type: 'REST',
files: {},
userId: '',
method: 'POST',
params: {},
headers: {
'Content-Type': 'application/json',
Authorization: 'Basic c2RnZXJnaHNkZmhzZGhzZGg0MzIxNDFkZmdkZnNnOg==',
},
version: '1',
endpoint: 'https://api.factors.ai/integrations/rudderstack_platform',
},
statusCode: 200,
},
],
},
},
},
];

0 comments on commit 1ccff68

Please sign in to comment.