Skip to content

Commit

Permalink
Merge branch 'develop' into chore.update-gaec-api
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSudip authored Aug 26, 2024
2 parents 3d04d59 + 78e7a95 commit c71fab8
Show file tree
Hide file tree
Showing 29 changed files with 3,250 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ src/v0/destinations/personalize/scripts/
test/integrations/destinations/testTypes.d.ts
*.config*.js
scripts/skipPrepareScript.js
package-lock.json
package.json
8 changes: 4 additions & 4 deletions .github/workflows/build-push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_PROD_TOKEN }}

- name: Build Docker Image
uses: docker/build-push-action@v6.5.0
uses: docker/build-push-action@v6.7.0
with:
context: .
file: ${{ inputs.dockerfile }}
Expand All @@ -124,7 +124,7 @@ jobs:
docker run ${{ inputs.build_tag }} npm run test:ts:ci
- name: Build and Push Multi-platform Images
uses: docker/build-push-action@v6.5.0
uses: docker/build-push-action@v6.7.0
with:
context: .
file: ${{ inputs.dockerfile }}
Expand Down Expand Up @@ -160,7 +160,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_PROD_TOKEN }}

- name: Build Docker Image
uses: docker/build-push-action@v6.5.0
uses: docker/build-push-action@v6.7.0
with:
context: .
file: ${{ inputs.dockerfile }}
Expand All @@ -177,7 +177,7 @@ jobs:
docker run ${{ inputs.build_tag }} npm run test:ts:ci
- name: Build and Push Multi-platform Images
uses: docker/build-push-action@v6.5.0
uses: docker/build-push-action@v6.7.0
with:
context: .
file: ${{ inputs.dockerfile }}
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ test/**/*.js
src/util/lodash-es-core.js
src/util/url-search-params.min.js
dist
.eslintignore
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

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.75.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.75.0...v1.75.1) (2024-08-14)


### Bug Fixes

* add validation for concurrent_modification error ([#3654](https://github.com/rudderlabs/rudder-transformer/issues/3654)) ([62cdc46](https://github.com/rudderlabs/rudder-transformer/commit/62cdc4641d44d79e21949722660173df4c749f24))
* clevertap bugsnag issue ([#3656](https://github.com/rudderlabs/rudder-transformer/issues/3656)) ([6c51487](https://github.com/rudderlabs/rudder-transformer/commit/6c51487183b6b0b755620aac6cd51c2ffc966102))
* snapchat conversion bugsnag issue ([#3657](https://github.com/rudderlabs/rudder-transformer/issues/3657)) ([31b03fc](https://github.com/rudderlabs/rudder-transformer/commit/31b03fc022ace0cda8df798c50e4764a9703c23b))
* validation for iterable object of HS ([#3653](https://github.com/rudderlabs/rudder-transformer/issues/3653)) ([1cb3f86](https://github.com/rudderlabs/rudder-transformer/commit/1cb3f86c894f30bdf04df870484c6df3a956f36e))

## [1.75.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.74.1...v1.75.0) (2024-08-12)


### Features

* move hubspot to transformer proxy to enable partial batch handling ([#3308](https://github.com/rudderlabs/rudder-transformer/issues/3308)) ([8450021](https://github.com/rudderlabs/rudder-transformer/commit/8450021672c51ac798ec0aeab422f5fceea5e53e))


### Bug Fixes

* handle attentive tag null, undefined properties ([#3647](https://github.com/rudderlabs/rudder-transformer/issues/3647)) ([9327925](https://github.com/rudderlabs/rudder-transformer/commit/932792561c98833baf9881a83ee36ae5000e37b4))
* handle null values for braze dedupe ([#3638](https://github.com/rudderlabs/rudder-transformer/issues/3638)) ([0a9b681](https://github.com/rudderlabs/rudder-transformer/commit/0a9b68118241158623d45ee28896377296bafd91))

### [1.74.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.74.0...v1.74.1) (2024-08-08)


Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-transformer",
"version": "1.74.1",
"version": "1.75.1",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down Expand Up @@ -71,7 +71,7 @@
"ajv": "^8.12.0",
"ajv-draft-04": "^1.0.0",
"ajv-formats": "^2.1.1",
"axios": "^1.6.4",
"axios": "^1.7.3",
"btoa": "^1.2.1",
"component-each": "^0.2.6",
"crypto-js": "^4.2.0",
Expand Down
6 changes: 3 additions & 3 deletions src/v0/destinations/attentive_tag/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {
const {
getDestinationItemProperties,
getExternalIdentifiersMapping,
getPropertiesKeyValidation,
arePropertiesValid,
validateTimestamp,
} = require('./util');
const { JSON_MIME_TYPE } = require('../../util/constant');
Expand Down Expand Up @@ -137,9 +137,9 @@ const trackResponseBuilder = (message, { Config }) => {
payload = constructPayload(message, mappingConfig[ConfigCategory.TRACK.name]);
endpoint = ConfigCategory.TRACK.endpoint;
payload.type = get(message, 'event');
if (!getPropertiesKeyValidation(payload)) {
if (!arePropertiesValid(payload.properties)) {
throw new InstrumentationError(
'[Attentive Tag]:The event name contains characters which is not allowed',
'[Attentive Tag]:The properties contains characters which is not allowed',
);
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/v0/destinations/attentive_tag/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ const { mappingConfig, ConfigCategory } = require('./config');
* The keys should not contain any of the values inside the validationArray.
* STEP 1: Storing keys in the array.
* Checking for the non-valid characters inside the keys of properties.
* ref: https://docs.attentivemobile.com/openapi/reference/tag/Custom-Events/
* @param {*} payload
* @returns
*/
const getPropertiesKeyValidation = (payload) => {
const arePropertiesValid = (properties) => {
if (!isDefinedAndNotNullAndNotEmpty(properties)) {
return true;
}
if (typeof properties !== 'object') {
return false;
}
const validationArray = [`'`, `"`, `{`, `}`, `[`, `]`, ',', `,`];
const keys = Object.keys(payload.properties);
const keys = Object.keys(properties);
for (const key of keys) {
for (const validationChar of validationArray) {
if (key.includes(validationChar)) {
Expand Down Expand Up @@ -134,6 +141,6 @@ const getDestinationItemProperties = (message, isItemsRequired) => {
module.exports = {
getDestinationItemProperties,
getExternalIdentifiersMapping,
getPropertiesKeyValidation,
arePropertiesValid,
validateTimestamp,
};
51 changes: 51 additions & 0 deletions src/v0/destinations/attentive_tag/util.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const { arePropertiesValid } = require('./util');

describe('arePropertiesValid', () => {
// returns true for valid properties object with no special characters in keys
it('should return true when properties object has no special characters in keys', () => {
const properties = { key1: 'value1', key2: 'value2' };
const result = arePropertiesValid(properties);
expect(result).toBe(true);
});

// returns true for null properties input
it('should return true when properties input is null', () => {
const properties = null;
const result = arePropertiesValid(properties);
expect(result).toBe(true);
});

// returns false for properties object with keys containing special characters
it('should return false for properties object with keys containing special characters', () => {
const properties = {
key1: 'value1',
'key,2': 'value2',
key3: 'value3',
};
expect(arePropertiesValid(properties)).toBe(false);
});

// returns true for empty properties object
it('should return true for empty properties object', () => {
const properties = {};
expect(arePropertiesValid(properties)).toBe(true);
});

// returns true for undefined properties input
it('should return true for undefined properties input', () => {
const result = arePropertiesValid(undefined);
expect(result).toBe(true);
});

// returns true for empty string properties input
it('should return true for empty string properties input', () => {
const result = arePropertiesValid('');
expect(result).toBe(true);
});

// returns false for empty string properties input
it('should return false for non object properties input', () => {
const result = arePropertiesValid('1234');
expect(result).toBe(false);
});
});
130 changes: 130 additions & 0 deletions src/v0/destinations/braze/braze.util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,136 @@ describe('dedup utility tests', () => {
const result = BrazeDedupUtility.deduplicate(userData, store);
expect(result).toBeNull();
});

test('deduplicates user data correctly when user data is null and it doesnt exist in stored data', () => {
const userData = {
external_id: '123',
nullProperty: null,
color: 'green',
age: 30,
};
const storeData = {
external_id: '123',
custom_attributes: {
color: 'green',
age: 30,
},
};
store.set('123', storeData);
const result = BrazeDedupUtility.deduplicate(userData, store);
expect(store.size).toBe(1);
expect(result).toEqual(null);
});

test('deduplicates user data correctly when user data is null and it is same in stored data', () => {
const userData = {
external_id: '123',
nullProperty: null,
color: 'green',
age: 30,
};
const storeData = {
external_id: '123',
custom_attributes: {
color: 'green',
age: 30,
nullProperty: null,
},
};
store.set('123', storeData);
const result = BrazeDedupUtility.deduplicate(userData, store);
expect(store.size).toBe(1);
expect(result).toEqual(null);
});

test('deduplicates user data correctly when user data is null and it is different in stored data', () => {
const userData = {
external_id: '123',
nullProperty: null,
color: 'green',
age: 30,
};
const storeData = {
external_id: '123',
custom_attributes: {
color: 'green',
age: 30,
nullProperty: 'valid data',
},
};
store.set('123', storeData);
const result = BrazeDedupUtility.deduplicate(userData, store);
expect(store.size).toBe(1);
expect(result).toEqual({
external_id: '123',
nullProperty: null,
});
});

test('deduplicates user data correctly when user data is undefined and it doesnt exist in stored data', () => {
const userData = {
external_id: '123',
undefinedProperty: undefined,
color: 'green',
age: 30,
};
const storeData = {
external_id: '123',
custom_attributes: {
color: 'green',
age: 30,
},
};
store.set('123', storeData);
const result = BrazeDedupUtility.deduplicate(userData, store);
expect(store.size).toBe(1);
expect(result).toEqual(null);
});

test('deduplicates user data correctly when user data is undefined and it is same in stored data', () => {
const userData = {
external_id: '123',
undefinedProperty: undefined,
color: 'green',
age: 30,
};
const storeData = {
external_id: '123',
custom_attributes: {
color: 'green',
undefinedProperty: undefined,
age: 30,
},
};
store.set('123', storeData);
const result = BrazeDedupUtility.deduplicate(userData, store);
expect(store.size).toBe(1);
expect(result).toEqual(null);
});

test('deduplicates user data correctly when user data is undefined and it is defined in stored data', () => {
const userData = {
external_id: '123',
undefinedProperty: undefined,
color: 'green',
age: 30,
};
const storeData = {
external_id: '123',
custom_attributes: {
color: 'green',
undefinedProperty: 'defined data',
age: 30,
},
};
store.set('123', storeData);
const result = BrazeDedupUtility.deduplicate(userData, store);
expect(store.size).toBe(1);
expect(result).toEqual({
external_id: '123',
undefinedProperty: undefined,
});
});
});
});

Expand Down
9 changes: 8 additions & 1 deletion src/v0/destinations/braze/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,14 @@ const BrazeDedupUtility = {

if (keys.length > 0) {
keys.forEach((key) => {
if (!_.isEqual(userData[key], storedUserData[key])) {
// ref: https://www.braze.com/docs/user_guide/data_and_analytics/custom_data/custom_attributes/#adding-descriptions
// null is a valid value in braze for unsetting, so we need to compare the values only if the key is present in the stored user data
// in case of keys having null values only compare if the key is present in the stored user data
if (userData[key] === null) {
if (isDefinedAndNotNull(storedUserData[key])) {
deduplicatedUserData[key] = userData[key];
}
} else if (!_.isEqual(userData[key], storedUserData[key])) {
deduplicatedUserData[key] = userData[key];
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/clevertap/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ const responseBuilderSimple = (message, category, destination) => {
// For 'Order Completed' type of events we are mapping it as 'Charged'
// Special event in Clevertap.
// Source: https://developer.clevertap.com/docs/concepts-events#recording-customer-purchases
if (get(message.event) && get(message.event).toLowerCase() === 'order completed') {
if (get(message.event) && get(message.event).toString().toLowerCase() === 'order completed') {
eventPayload = {
evtName: 'Charged',
evtData: constructPayload(message, MAPPING_CONFIG[CONFIG_CATEGORIES.ECOM.name]),
Expand Down
Loading

0 comments on commit c71fab8

Please sign in to comment.