Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepdsvs committed Feb 28, 2024
2 parents 3bc2900 + d619c97 commit 698ade0
Show file tree
Hide file tree
Showing 6 changed files with 399 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/algolia/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ steps:
const filters = $.context.payload.filters;
const objectIDs = $.context.payload.objectIDs;
$.assert(!(filters && objectIDs), "event can't have both objectIds and filters at the same time.");
$.assert(filters || objectIDs, "Either filters or objectIds is required.");
$.assert(filters.length || objectIDs.length, "Either filters or objectIds is required and must be non empty.");
- name: validatePayloadForClickEvent
condition: $.context.payload.eventType === "click"
Expand Down
8 changes: 4 additions & 4 deletions src/v0/destinations/gainsight_px/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const { getDynamicErrorType } = require('../../../adapters/utils/networkUtils');
const { JSON_MIME_TYPE } = require('../../util/constant');

const handleErrorResponse = (error, customErrMessage, expectedErrStatus, defaultStatus = 400) => {
let destResp;
let errMessage = '';
let errorStatus = defaultStatus;

if (error.response && error.response.data) {
errMessage = error.response.data.externalapierror
? JSON.stringify(error.response.data.externalapierror)
: JSON.stringify(error.response.data);
destResp = error.response?.data?.externalapierror ?? error.response?.data;
errMessage = JSON.stringify(destResp);

errorStatus = error.response.status;

Expand All @@ -26,7 +26,7 @@ const handleErrorResponse = (error, customErrMessage, expectedErrStatus, default
{
[tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(errorStatus),
},
error,
destResp,
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/sfmc/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const ENDPOINTS = {
GET_TOKEN: `auth.marketingcloudapis.com/v2/token`,
CONTACTS: `rest.marketingcloudapis.com/contacts/v1/contacts`,
INSERT_CONTACTS: `rest.marketingcloudapis.com/hub/v1/dataevents/key:`,
EVENT: "rest.marketingcloudapis.com/interaction/v1/events",
EVENT: 'rest.marketingcloudapis.com/interaction/v1/events',
};

const CONFIG_CATEGORIES = {
Expand Down
212 changes: 211 additions & 1 deletion test/integrations/destinations/algolia/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export const data = [
body: [
{
error:
'Either filters or objectIds is required.: Workflow: procWorkflow, Step: validateDestPayload, ChildStep: undefined, OriginalError: Either filters or objectIds is required.',
'Either filters or objectIds is required and must be non empty.: Workflow: procWorkflow, Step: validateDestPayload, ChildStep: undefined, OriginalError: Either filters or objectIds is required and must be non empty.',
statTags: {
destType: 'ALGOLIA',
errorCategory: 'dataValidation',
Expand Down Expand Up @@ -1417,4 +1417,214 @@ export const data = [
},
},
},
{
name: 'algolia',
description: 'Eventype must be one of click, conversion pr view',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
channel: 'web',
context: {
app: {
build: '1.0.0',
name: 'RudderLabs JavaScript SDK',
namespace: 'com.rudderlabs.javascript',
version: '1.0.0',
},
traits: {
email: '[email protected]',
firstName: 'test',
lastName: 'one',
},
library: {
name: 'RudderLabs JavaScript SDK',
version: '1.0.0',
},
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',
locale: 'en-US',
ip: '0.0.0.0',
os: {
name: '',
version: '',
},
screen: {
density: 2,
},
page: {
path: '/destinations/ometria',
referrer: '',
search: '',
title: '',
url: 'https://docs.rudderstack.com/destinations/ometria',
category: 'destination',
initial_referrer: 'https://docs.rudderstack.com',
initial_referring_domain: 'docs.rudderstack.com',
},
},
type: 'track',
messageId: '84e26acc-56a5-4835-8233-591137fca468',
session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22',
originalTimestamp: '2019-10-14T09:03:17.562Z',
anonymousId: '123456',
event: 'product clicked',
userId: 'testuserId1',
properties: {
index: 'products',
filters: ['field1:hello', 'val1:val2'],
},
integrations: {
All: true,
},
sentAt: '2019-10-14T09:03:22.563Z',
},
destination: {
DestinationDefinition: {
Config: {
cdkV2Enabled: true,
excludeKeys: [],
includeKeys: [],
},
},
Config: {
apiKey: 'dummyApiKey',
applicationId: 'O2YARRI15I',
eventTypeSettings: [
{
from: 'product clicked',
to: 'abcd',
},
],
},
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
error:
'eventType can be either click, view or conversion: Workflow: procWorkflow, Step: preparePayload, ChildStep: undefined, OriginalError: eventType can be either click, view or conversion',
statTags: {
destType: 'ALGOLIA',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
feature: 'processor',
implementation: 'cdkV2',
module: 'destination',
destinationId: 'destId',
workspaceId: 'wspId',
},
statusCode: 400,
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
},
{
name: 'algolia',
description: 'filters or objectIds must be non empty',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
type: 'track',
event: 'product clicked',
sentAt: '2024-02-25T17:55:36.882Z',
userId: '12345',
channel: 'web',
properties: {
index: 'products',
list_id: 'search_results_page',
queryId: '8e737',
products: [],
eventName: 'productListView',
list_name: 'Search Results Page',
objectIds: [],
positions: [],
userToken: 'e494',
additional_attributes: {},
},
receivedAt: '2024-02-25T17:55:38.089Z',
request_ip: '107.130.37.100',
anonymousId: '68e9f4b8-fd4d-4c56-8ca4-858de2fd1df8',
integrations: {
All: true,
},
originalTimestamp: '2024-02-25T17:55:36.880Z',
},
destination: {
DestinationDefinition: {
Config: {
cdkV2Enabled: true,
excludeKeys: [],
includeKeys: [],
},
},
Config: {
apiKey: 'dummyApiKey',
applicationId: 'O2YARRI15I',
eventTypeSettings: [
{
from: 'product clicked',
to: 'cLick ',
},
],
},
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
error:
'Either filters or objectIds is required and must be non empty.: Workflow: procWorkflow, Step: validateDestPayload, ChildStep: undefined, OriginalError: Either filters or objectIds is required and must be non empty.',
statTags: {
destType: 'ALGOLIA',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
feature: 'processor',
implementation: 'cdkV2',
module: 'destination',
destinationId: 'destId',
workspaceId: 'wspId',
},
statusCode: 400,
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
},
];
29 changes: 29 additions & 0 deletions test/integrations/destinations/gainsight_px/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,33 @@ export const networkCallsData = [
status: 200,
},
},
// Axios Error
{
httpReq: {
url: 'https://api.aptrinsic.com/v1/users/myUId',
headers: { 'X-APTRINSIC-API-KEY': 'sample-api-key', 'Content-Type': 'application/json' },
method: 'GET',
},
httpRes: {
message: 'Request failed with status code 403',
name: 'AxiosError',
stack:
'AxiosError: Request failed with status code 403\n at settle (/Users/saisankeerth/rudderstack/rudder-transformer/node_modules/axios/lib/core/settle.js:19:12)\n at IncomingMessage.handleStreamEnd (/Users/saisankeerth/rudderstack/rudder-transformer/node_modules/axios/lib/adapters/http.js:589:11)\n at IncomingMessage.emit (node:events:529:35)\n at IncomingMessage.emit (node:domain:489:12)\n at endReadableNT (node:internal/streams/readable:1400:12)\n at processTicksAndRejections (node:internal/process/task_queues:82:21)',
config: {
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
'X-APTRINSIC-API-KEY': 'sample-api-key',
'User-Agent': 'axios/1.6.5',
'Accept-Encoding': 'gzip, compress, deflate, br',
},
method: 'get',
dummy: 'upgrade required', // keyword
url: 'https://api.aptrinsic.com/v1/users/myUId',
},
code: 'FORBIDDEN',
status: 403,
data: '\u003c!doctype html\u003e\u003cmeta charset="utf-8"\u003e\u003cmeta name=viewport content="width=device-width, initial-scale=1"\u003e\u003ctitle\u003e403\u003c/title\u003e403 Forbidden',
},
},
];
Loading

0 comments on commit 698ade0

Please sign in to comment.