Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/github_actions/slackapi/slack-…
Browse files Browse the repository at this point in the history
…github-action-1.27.0
  • Loading branch information
sanpj2292 authored Sep 3, 2024
2 parents b1dc9a3 + 441fb57 commit 3e36e20
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/webhook_v2/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const excludeMappedFields = (payload, mapping) => {

// Traverse to the parent of the key to be removed
keys.slice(0, -1).forEach((key) => {
if (current && current[key]) {
if (current?.[key]) {
current = current[key];
} else {
current = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ const responseHandler = (responseParams) => {
// Ref - https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
if (partialFailureError && partialFailureError.code !== 0) {
throw new NetworkError(
`[Google Adwords Enhanced Conversions]:: partialFailureError - ${JSON.stringify(
partialFailureError,
)}`,
JSON.stringify(partialFailureError),
400,
{
[tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(400),
Expand Down
6 changes: 6 additions & 0 deletions src/v0/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2268,6 +2268,11 @@ const validateEventAndLowerCaseConversion = (event, isMandatory, convertToLowerC
const applyCustomMappings = (message, mappings) =>
JsonTemplateEngine.createAsSync(mappings, { defaultPathType: PathType.JSON }).evaluate(message);

const applyJSONStringTemplate = (message, template) =>
JsonTemplateEngine.createAsSync(template.replace(/{{/g, '${').replace(/}}/g, '}'), {
defaultPathType: PathType.JSON,
}).evaluate(message);

/**
* Gets url path omitting the hostname & protocol
*
Expand All @@ -2293,6 +2298,7 @@ module.exports = {
addExternalIdToTraits,
adduserIdFromExternalId,
applyCustomMappings,
applyJSONStringTemplate,
base64Convertor,
batchMultiplexedEvents,
checkEmptyStringInarray,
Expand Down
24 changes: 24 additions & 0 deletions src/v0/util/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
combineBatchRequestsWithSameJobIds,
validateEventAndLowerCaseConversion,
} = require('./index');
const exp = require('constants');

// Names of the utility functions to test
const functionNames = [
Expand Down Expand Up @@ -691,6 +692,29 @@ describe('extractCustomFields', () => {
});
});

describe('applyJSONStringTemplate', () => {
it('should apply JSON string template to the payload', () => {
const payload = {
domain: 'abc',
};
const template = '`https://{{$.domain}}.com`';

const result = utilities.applyJSONStringTemplate(payload, template);
expect(result).toEqual('https://abc.com');
});

it('should apply JSON string template to the payload multiple times', () => {
const payload = {
domain: 'abc',
subdomain: 'def',
};
const template = '`https://{{$.subdomain}}.{{$.domain}}.com`';

const result = utilities.applyJSONStringTemplate(payload, template);
expect(result).toEqual('https://def.abc.com');
});
});

describe('get relative path from url', () => {
test('valid url', () => {
expect(utilities.getRelativePathFromURL('https://google.com/a/b/c')).toEqual('/a/b/c');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export const testScenariosForV0API = [
'Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]',
},
message:
'[Google Adwords Enhanced Conversions]:: partialFailureError - {"code":3,"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]","details":[{"@type":"type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure","errors":[{"errorCode":{"conversionAdjustmentUploadError":"CONVERSION_ALREADY_ENHANCED"},"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again.","location":{"fieldPathElements":[{"fieldName":"conversion_adjustments","index":0}]}}]}]}',
'{"code":3,"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]","details":[{"@type":"type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure","errors":[{"errorCode":{"conversionAdjustmentUploadError":"CONVERSION_ALREADY_ENHANCED"},"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again.","location":{"fieldPathElements":[{"fieldName":"conversion_adjustments","index":0}]}}]}]}',
statTags: expectedStatTags,
status: 400,
},
Expand Down Expand Up @@ -262,11 +262,11 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
body: {
output: {
message:
'[Google Adwords Enhanced Conversions]:: partialFailureError - {"code":3,"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]","details":[{"@type":"type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure","errors":[{"errorCode":{"conversionAdjustmentUploadError":"CONVERSION_ALREADY_ENHANCED"},"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again.","location":{"fieldPathElements":[{"fieldName":"conversion_adjustments","index":0}]}}]}]}',
'{"code":3,"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]","details":[{"@type":"type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure","errors":[{"errorCode":{"conversionAdjustmentUploadError":"CONVERSION_ALREADY_ENHANCED"},"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again.","location":{"fieldPathElements":[{"fieldName":"conversion_adjustments","index":0}]}}]}]}',
response: [
{
error:
'[Google Adwords Enhanced Conversions]:: partialFailureError - {"code":3,"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]","details":[{"@type":"type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure","errors":[{"errorCode":{"conversionAdjustmentUploadError":"CONVERSION_ALREADY_ENHANCED"},"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again.","location":{"fieldPathElements":[{"fieldName":"conversion_adjustments","index":0}]}}]}]}',
'{"code":3,"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]","details":[{"@type":"type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure","errors":[{"errorCode":{"conversionAdjustmentUploadError":"CONVERSION_ALREADY_ENHANCED"},"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again.","location":{"fieldPathElements":[{"fieldName":"conversion_adjustments","index":0}]}}]}]}',
metadata: generateMetadata(1),
statusCode: 400,
},
Expand Down

0 comments on commit 3e36e20

Please sign in to comment.