Skip to content

Commit

Permalink
chore(release): pull release/v1.82.0 into main (#3792)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSudip authored Oct 10, 2024
2 parents 65a9844 + 644e97e commit 8f53316
Show file tree
Hide file tree
Showing 43 changed files with 5,320 additions and 41 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.82.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.81.0...v1.82.0) (2024-10-09)


### Features

* onboard Amazon Audience ([#3727](https://github.com/rudderlabs/rudder-transformer/issues/3727)) ([5ac8186](https://github.com/rudderlabs/rudder-transformer/commit/5ac81860c51f9971343df8c61bfd0b2de8161735))
* onboard intercom v2 destination ([#3721](https://github.com/rudderlabs/rudder-transformer/issues/3721)) ([f8cde8c](https://github.com/rudderlabs/rudder-transformer/commit/f8cde8c072eb9415368fb97f53a3070027a3943b))


### Bug Fixes

* add list of the props, which need to be placed at the root ([#3777](https://github.com/rudderlabs/rudder-transformer/issues/3777)) ([b357dd4](https://github.com/rudderlabs/rudder-transformer/commit/b357dd4e8a49ed66576f731a6aac84da55397475))
* rakuten amount value rounded up to nearest integer ([#3784](https://github.com/rudderlabs/rudder-transformer/issues/3784)) ([f3046f0](https://github.com/rudderlabs/rudder-transformer/commit/f3046f0ae37c113c1239d988d056fc204f2776a0))
* webhook proc workflow object assign bug ([#3775](https://github.com/rudderlabs/rudder-transformer/issues/3775)) ([de8e503](https://github.com/rudderlabs/rudder-transformer/commit/de8e503524c1e8e3320f7458c66b8581f121b9bb))

## [1.81.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.79.1...v1.81.0) (2024-10-04)


Expand Down
10 changes: 8 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-transformer",
"version": "1.81.0",
"version": "1.82.0",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down Expand Up @@ -71,6 +71,7 @@
"ajv": "^8.12.0",
"ajv-draft-04": "^1.0.0",
"ajv-formats": "^2.1.1",
"amazon-dsp-formatter": "^1.0.2",
"axios": "^1.7.3",
"btoa": "^1.2.1",
"component-each": "^0.2.6",
Expand Down
22 changes: 14 additions & 8 deletions src/cdk/v2/destinations/rakuten/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ const constructProperties = (message) => {
return payload;
};

/**
* Calculates the amount for a single product
* @param {Object} product
* @returns {number}
*/
const calculateProductAmount = (product) => {
if (!product?.amount && !product?.price) {
throw new InstrumentationError('Either amount or price is required for every product');
}
return Math.round(product.amount * 100 || (product.quantity || 1) * 100 * product.price);
};

/**
* This fucntion build the item level list
* @param {*} properties
Expand Down Expand Up @@ -52,14 +64,8 @@ const constructLineItems = (properties) => {
});

// Map 'amountList' by evaluating 'amount' or deriving it from 'price' and 'quantity'
const amountList = products.map((product) => {
if (!product?.amount && !product?.price) {
throw new InstrumentationError('Either amount or price is required for every product');
}
return product.amount * 100 || (product.quantity || 1) * 100 * product.price;
});
productList.amtlist = amountList.join('|');
productList.amtlist = products.map(calculateProductAmount).join('|');
return productList;
};

module.exports = { constructProperties, constructLineItems };
module.exports = { constructProperties, constructLineItems, calculateProductAmount };
62 changes: 61 additions & 1 deletion src/cdk/v2/destinations/rakuten/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { constructLineItems } = require('./utils');
const { InstrumentationError } = require('@rudderstack/integrations-lib');
const { constructLineItems, calculateProductAmount } = require('./utils');
describe('constructLineItems', () => {
it('should return a non-empty object when given a valid properties object with at least one product', () => {
const properties = {
Expand Down Expand Up @@ -115,3 +116,62 @@ describe('constructLineItems', () => {
);
});
});

describe('calculateProductAmount', () => {
// Calculates product amount correctly when amount is defined
it('should return the correct product amount when amount is defined', () => {
const product = { amount: 5 };
const result = calculateProductAmount(product);
expect(result).toBe(500);
});

// Throws error when both amount and price are undefined or null
it('should throw an error when both amount and price are undefined or null', () => {
const product = {};
expect(() => calculateProductAmount(product)).toThrow(InstrumentationError);
});

// Calculates product amount correctly when price and quantity are defined
it('should calculate product amount correctly when price and quantity are defined', () => {
const product = { amount: 10, price: 5, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(1000);
});

// Returns correct value when only price is defined and quantity defaults to 1
it('should return correct value when only price is defined and quantity defaults to 1', () => {
const product = { price: 20 };
const result = calculateProductAmount(product);
expect(result).toEqual(2000);
});

// Handles cases where amount is a floating-point number
it('should handle cases where amount is a floating-point number', () => {
const product = { amount: 5.5, price: 10, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(550);
});

it('should handle cases where amount is a floating-point number', () => {
const product = { amount: 5.1, price: 10, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(510);
});

it('should handle cases where amount is a floating-point number', () => {
const product = { amount: 5.19, price: 10, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(519);
});

it('should handle cases where amount is a floating-point number', () => {
const product = { amount: 5.199, price: 10, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(520);
});
it('should handle cases where amount is a floating-point number', () => {
const product = { amount: 5.479, price: 10, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(548);
});
});
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/webhook/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ steps:
template: |
let defaultHeaders = $.context.method in ['POST', 'PUT', 'PATCH'] ? {"content-type": "application/json"} : {}
let configHeaders = $.getHashFromArray(.destination.Config.headers)
let messageHeader = typeof .message.header === "object" ? Object.assign(...Object.entries(.message.header).({[.[0]]:typeof .[1] === 'string' ? .[1] : JSON.stringify(.[1])})[]) : {}
let messageHeader = typeof .message.header === "object" ? Object.assign({}, ...Object.entries(.message.header).({[.[0]]:typeof .[1] === 'string' ? .[1] : JSON.stringify(.[1])})[]) : {}
$.context.finalHeaders = {
...defaultHeaders,
...configHeaders,
Expand Down
1 change: 1 addition & 0 deletions src/constants/destinationCanonicalNames.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const DestHandlerMap = {
ga360: 'ga',
salesforce_oauth: 'salesforce',
salesforce_oauth_sandbox: 'salesforce',
};

const DestCanonicalNames = {
Expand Down
5 changes: 4 additions & 1 deletion src/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"PROFITWELL": true,
"SALESFORCE": true,
"SALESFORCE_OAUTH": true,
"SALESFORCE_OAUTH_SANDBOX": true,
"SFMC": true,
"SNAPCHAT_CONVERSION": true,
"TIKTOK_ADS": true,
Expand Down Expand Up @@ -80,7 +81,9 @@
"X_AUDIENCE": true,
"BLOOMREACH_CATALOG": true,
"SMARTLY": true,
"HTTP": true
"HTTP": true,
"AMAZON_AUDIENCE": true,
"INTERCOM_V2": true
},
"regulations": [
"BRAZE",
Expand Down
27 changes: 14 additions & 13 deletions src/v0/destinations/af/transform.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const get = require('get-value');
const set = require('set-value');

const lodash = require('lodash');
const { InstrumentationError, ConfigurationError } = require('@rudderstack/integrations-lib');
const { EventType } = require('../../../constants');
const {
Expand Down Expand Up @@ -130,28 +130,29 @@ function getEventValueForUnIdentifiedTrackEvent(message) {

function getEventValueMapFromMappingJson(message, mappingJson, isMultiSupport, config) {
let eventValue = {};
const { addPropertiesAtRoot, afCurrencyAtRoot } = config;

const { addPropertiesAtRoot, afCurrencyAtRoot, listOfProps } = config;
const clonedProp = message.properties && lodash.cloneDeep(message.properties);
if (addPropertiesAtRoot) {
eventValue = message.properties;
eventValue = clonedProp;
} else {
set(eventValue, 'properties', message.properties);
if (Array.isArray(listOfProps) && listOfProps.length > 0) {
listOfProps.forEach((prop) => {
eventValue[prop.property] = clonedProp[prop.property];
delete clonedProp[prop.property];
});
}
eventValue.properties = clonedProp;
}

const sourceKeys = Object.keys(mappingJson);
sourceKeys.forEach((sourceKey) => {
set(eventValue, mappingJson[sourceKey], get(message, sourceKey));
});
if (
isMultiSupport &&
message.properties &&
message.properties.products &&
message.properties.products.length > 0
) {
if (isMultiSupport && clonedProp && clonedProp.products && clonedProp.products.length > 0) {
const contentIds = [];
const quantities = [];
const prices = [];
message.properties.products.forEach((product) => {
clonedProp.products.forEach((product) => {
contentIds.push(product.product_id);
quantities.push(product.quantity);
prices.push(product.price);
Expand All @@ -164,7 +165,7 @@ function getEventValueMapFromMappingJson(message, mappingJson, isMultiSupport, c
};
}
if (afCurrencyAtRoot) {
eventValue.af_currency = message.properties.currency;
eventValue.af_currency = clonedProp.currency;
}
eventValue = removeUndefinedValues(eventValue);
if (Object.keys(eventValue).length > 0) {
Expand Down
5 changes: 5 additions & 0 deletions src/v0/destinations/amazon_audience/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const CREATE_USERS_URL = 'https://advertising-api.amazon.com/dp/records/hashed/';
const ASSOCIATE_USERS_URL = 'https://advertising-api.amazon.com/v2/dp/audience';
const MAX_PAYLOAD_SIZE_IN_BYTES = 4000000;
const DESTINATION = 'amazon_audience';
module.exports = { CREATE_USERS_URL, MAX_PAYLOAD_SIZE_IN_BYTES, ASSOCIATE_USERS_URL, DESTINATION };
Loading

0 comments on commit 8f53316

Please sign in to comment.