Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: onboard Adobe Analytics to transformer proxy #2858

Merged
merged 8 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/v0/destinations/adobe_analytics/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ module.exports = {
ECOM_PRODUCT_EVENTS,
commonConfig: MAPPING_CONFIG[CONFIG_CATEGORIES.COMMON.name],
formatDestinationConfig,
DESTINATION: 'ADOBE_ANALYTICS'
};
54 changes: 54 additions & 0 deletions src/v0/destinations/adobe_analytics/networkHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { InstrumentationError } = require('@rudderstack/integrations-lib');
const { proxyRequest, prepareProxyRequest } = require('../../../adapters/network');
const {
processAxiosResponse,
} = require('../../../adapters/utils/networkUtils');
const { DESTINATION } = require('./config');


/**
* Extract data inside different tags from an xml payload
* @param {*} xml
* @param {*} tagName
* @returns data inside the tagName
*/
function extractContent(xmlPayload, tagName) {
const pattern = new RegExp(`<${tagName}>(.*?)</${tagName}>`);
const match = xmlPayload.match(pattern);
return match ? match[1] : null;
}

const responseHandler = (destinationResponse, dest) => {
const message = `[${DESTINATION}] - Request Processed Successfully`;
const { response, status } = destinationResponse;

// Extract values between different tags
const responseStatus = extractContent(response, 'status');
const reason = extractContent(response, 'reason');

// if the status tag in XML contains FAILURE, we build and throw an explicit error
if (responseStatus === 'FAILURE') {
sanpj2292 marked this conversation as resolved.
Show resolved Hide resolved
if (reason) {
throw new InstrumentationError(`[${DESTINATION} Response Handler] Request failed for destination ${dest} : ${reason}` )
sanpj2292 marked this conversation as resolved.
Show resolved Hide resolved
} else {
throw new InstrumentationError(`[${DESTINATION} Response Handler] Request failed for destination ${dest} with a general error`)

Check warning on line 34 in src/v0/destinations/adobe_analytics/networkHandler.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/adobe_analytics/networkHandler.js#L32-L34

Added lines #L32 - L34 were not covered by tests
}
}

return {
anantjain45823 marked this conversation as resolved.
Show resolved Hide resolved
status,
message,
destinationResponse,
};
};

function networkHandler() {
this.responseHandler = responseHandler;
this.proxy = proxyRequest;
this.prepareProxy = prepareProxyRequest;
this.processAxiosResponse = processAxiosResponse;
}

module.exports = {
networkHandler,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export const data = [
{
name: 'adobe_analytics',
description: 'Test 0',
anantjain45823 marked this conversation as resolved.
Show resolved Hide resolved
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://adobe.failure.omtrdc.net/b/ss//6',
headers: {
'Content-type': 'application/xml',
},
params: {},
body: {
JSON: {},
JSON_ARRAY: {},
XML: {
payload:
'<?xml version="1.0" encoding="utf-8"?><request><browserHeight>1794</browserHeight><browserWidth>1080</browserWidth><campaign>sales campaign</campaign><channel>web</channel><currencyCode>USD</currencyCode><ipaddress>127.0.0.1</ipaddress><language>en-US</language><userAgent>Dalvik/2.1.0 (Linux; U; Android 9; Android SDK built for x86 Build/PSR1.180720.075)</userAgent><referrer>https://www.google.com/search?q=estore+bestseller</referrer><marketingcloudorgid/><events>prodView</events><products>Games;;11;148.39</products><reportSuiteID>rudderstackfootlockerpoc</reportSuiteID></request>',
},
FORM: {},
},
files: {},
},
method: 'POST',
},
},
output: {
response: {
status: 500,
sanpj2292 marked this conversation as resolved.
Show resolved Hide resolved
statTags: {
errorCategory: 'dataValidation',
errorType: 'instrumentation',
destType: 'ADOBE_ANALYTICS',
module: 'destination',
implementation: 'native',
feature: 'dataDelivery',
destinationId: '2S3s0dFD0DqL7m0UkfBwyblDrzs',
sanpj2292 marked this conversation as resolved.
Show resolved Hide resolved
workspaceId: '1pKWrE6GwAvFwKBikka1SbRgrSN',
},
destinationResponse: '',
authErrorCategory: '',
message:
'[ADOBE_ANALYTICS Response Handler] Request failed for destination adobe_analytics : NO pagename OR pageurl',
ItsSudip marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
];
17 changes: 17 additions & 0 deletions test/integrations/destinations/adobe_analytics/network.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const networkCallsData = [
{
httpReq: {
url: 'https://adobe.failure.omtrdc.net/b/ss//6',
params: {},
headers: {
'Content-type': 'application/xml',
},
method: 'POST',
},
httpRes: {
status: 400,
message:
'[ADOBE_ANALYTICS Response Handler] Request failed for destination adobe_analytics : NO pagename OR pageurl',
sanpj2292 marked this conversation as resolved.
Show resolved Hide resolved
},
},
];
Loading