-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(release): pulling release/3.8.0 into main (#1712)
- Loading branch information
Showing
34 changed files
with
569 additions
and
2,173 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,13 @@ | |
|
||
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). | ||
|
||
## [3.2.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-05-10) | ||
|
||
|
||
### Features | ||
|
||
* **criteo:** add support of sha256 hashing method for email ([#1680](https://github.com/rudderlabs/rudder-sdk-js/issues/1680)) ([66e0122](https://github.com/rudderlabs/rudder-sdk-js/commit/66e0122d2bcdb536ab0d69745e05d49806a5348b)) | ||
|
||
## [3.1.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/[email protected]...@rudderstack/[email protected]) (2024-04-26) | ||
|
||
### Dependency Updates | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
## [3.1.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-integrations@3.0.4...@rudderstack/analytics-js-integrations@3.1.0) (2024-04-26) | ||
## [3.2.0](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js-integrations@3.1.0...@rudderstack/analytics-js-integrations@3.2.0) (2024-05-10) | ||
|
||
### Dependency Updates | ||
|
||
* `@rudderstack/analytics-js-common` updated to version `3.0.4` | ||
|
||
### Features | ||
|
||
* add autoConfig support in FBPixel, add tests ([#1702](https://github.com/rudderlabs/rudder-sdk-js/issues/1702)) ([607c381](https://github.com/rudderlabs/rudder-sdk-js/commit/607c3815128a606efe7cee3c867028a62f1f19c9)) | ||
* added custom domain support in ga4 ([#1697](https://github.com/rudderlabs/rudder-sdk-js/issues/1697)) ([3543cc1](https://github.com/rudderlabs/rudder-sdk-js/commit/3543cc1a1f6dc770381c0a6be75646b183f63afa)) | ||
* supporting add to cart for criteo ([#1696](https://github.com/rudderlabs/rudder-sdk-js/issues/1696)) ([bb7e1df](https://github.com/rudderlabs/rudder-sdk-js/commit/bb7e1df9a1e5a1ffe4e8a81c3d9fdf18d9ef2744)) | ||
* **criteo:** add support of sha256 hashing method for email ([#1680](https://github.com/rudderlabs/rudder-sdk-js/issues/1680)) ([66e0122](https://github.com/rudderlabs/rudder-sdk-js/commit/66e0122d2bcdb536ab0d69745e05d49806a5348b)) | ||
|
298 changes: 174 additions & 124 deletions
298
packages/analytics-js-integrations/__tests__/integrations/Criteo/utils.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,177 @@ | ||
import { handleProductAdded } from '../../../src/integrations/Criteo/utils'; | ||
import md5 from 'md5'; | ||
import { handleCommonFields, handleProductAdded } from '../../../src/integrations/Criteo/utils'; | ||
|
||
describe('handleCommonFields', () => { | ||
const inputEvent = { | ||
message: { | ||
userId: 'u1', | ||
anonymousId: 'a1', | ||
properties: { | ||
email: '[email protected]', | ||
}, | ||
}, | ||
}; | ||
const defaultExpected = [ | ||
{ event: 'setCustomerId', id: md5('u1').toString() }, | ||
{ event: 'setRetailerVisitorId', id: md5('a1').toString() }, | ||
]; | ||
it('when properties.email is present, for md5 hashmethod the relevant mapping should be included', () => { | ||
const out = handleCommonFields(inputEvent, 'md5'); | ||
expect(out).toEqual([ | ||
...defaultExpected, | ||
{ | ||
email: '3f009d72559f51e7e454b16e5d0687a1', | ||
hash_method: 'md5', | ||
event: 'setEmail', | ||
}, | ||
]); | ||
}); | ||
it('when properties.email is present, for sha256 hashmethod the relevant mapping should be included', () => { | ||
const output = handleCommonFields(inputEvent, 'sha256'); | ||
expect(output).toEqual([ | ||
...defaultExpected, | ||
{ | ||
email: '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08', | ||
hash_method: 'sha256', | ||
event: 'setEmail', | ||
}, | ||
]); | ||
}); | ||
it('when properties.email is present, for random hashmethod the relevant mapping should be included', () => { | ||
const output = handleCommonFields(inputEvent, 'random'); | ||
expect(output).toEqual([ | ||
...defaultExpected, | ||
{ | ||
email: '[email protected]', | ||
hash_method: 'random', | ||
event: 'setEmail', | ||
}, | ||
]); | ||
}); | ||
}); | ||
|
||
describe('handleProductAdded', () => { | ||
// The function correctly extracts the 'properties' object from the 'message' parameter. | ||
it('should correctly extract properties object from message parameter', () => { | ||
const message = { | ||
properties: { | ||
product_id: '123', | ||
price: '9.99', | ||
quantity: '5', | ||
currency: 'USD', | ||
}, | ||
}; | ||
const finalPayload = []; | ||
|
||
handleProductAdded(message, finalPayload); | ||
|
||
expect(finalPayload.length).toBe(1); | ||
expect(finalPayload[0].event).toBe('addToCart'); | ||
expect(finalPayload[0].currency).toBe('USD'); | ||
expect(finalPayload[0].item.length).toBe(1); | ||
expect(finalPayload[0].item[0].id).toBe('123'); | ||
expect(finalPayload[0].item[0].price).toBe(9.99); | ||
expect(finalPayload[0].item[0].quantity).toBe(5); | ||
}); | ||
|
||
// When the 'message' parameter is undefined, the function throws an error. | ||
it('should throw an error when message parameter is undefined', () => { | ||
const message = undefined; | ||
const finalPayload = []; | ||
|
||
expect(() => { | ||
handleProductAdded(message, finalPayload); | ||
}).toThrow(); | ||
}); | ||
|
||
// When the 'properties' object is valid, the function creates an 'addToCartObject' with the correct structure. | ||
it('should create addToCartObject with correct structure when properties object is valid', () => { | ||
const message = { | ||
properties: { | ||
product_id: '123', | ||
price: '9.99', | ||
quantity: '5', | ||
currency: 'USD', | ||
}, | ||
}; | ||
const finalPayload = []; | ||
|
||
handleProductAdded(message, finalPayload); | ||
|
||
expect(finalPayload.length).toBe(1); | ||
expect(finalPayload[0].event).toBe('addToCart'); | ||
expect(finalPayload[0].currency).toBe('USD'); | ||
expect(finalPayload[0].item.length).toBe(1); | ||
expect(finalPayload[0].item[0].id).toBe('123'); | ||
expect(finalPayload[0].item[0].price).toBe(9.99); | ||
expect(finalPayload[0].item[0].quantity).toBe(5); | ||
}); | ||
|
||
// When the product is valid, the function adds the product object to the 'item' property of the 'addToCartObject'. | ||
it("should add product object to 'item' property when product is valid", () => { | ||
const message = { | ||
properties: { | ||
product_id: '123', | ||
price: '9.99', | ||
quantity: '5', | ||
currency: 'USD', | ||
}, | ||
}; | ||
const finalPayload = []; | ||
|
||
handleProductAdded(message, finalPayload); | ||
|
||
expect(finalPayload.length).toBe(1); | ||
expect(finalPayload[0].event).toBe('addToCart'); | ||
expect(finalPayload[0].currency).toBe('USD'); | ||
expect(finalPayload[0].item.length).toBe(1); | ||
expect(finalPayload[0].item[0].id).toBe('123'); | ||
expect(finalPayload[0].item[0].price).toBe(9.99); | ||
expect(finalPayload[0].item[0].quantity).toBe(5); | ||
}); | ||
|
||
// The function correctly pushes the 'addToCartObject' to the 'finalPayload' array. | ||
it("should correctly push 'addToCartObject' to 'finalPayload' array", () => { | ||
const message = { | ||
properties: { | ||
product_id: '123', | ||
price: '9.99', | ||
quantity: '5', | ||
currency: 'USD', | ||
}, | ||
}; | ||
const finalPayload = []; | ||
|
||
handleProductAdded(message, finalPayload); | ||
|
||
expect(finalPayload.length).toBe(1); | ||
expect(finalPayload[0].event).toBe('addToCart'); | ||
expect(finalPayload[0].currency).toBe('USD'); | ||
expect(finalPayload[0].item.length).toBe(1); | ||
expect(finalPayload[0].item[0].id).toBe('123'); | ||
expect(finalPayload[0].item[0].price).toBe(9.99); | ||
expect(finalPayload[0].item[0].quantity).toBe(5); | ||
}); | ||
|
||
// When the 'properties' object is missing the 'currency' property, the function creates an 'addToCartObject' without the 'currency' property. | ||
it("should create 'addToCartObject' without 'currency' property when 'properties' object is missing 'currency'", () => { | ||
const message = { | ||
properties: { | ||
product_id: '123', | ||
price: '9.99', | ||
quantity: '5', | ||
}, | ||
}; | ||
const finalPayload = []; | ||
|
||
// The function correctly extracts the 'properties' object from the 'message' parameter. | ||
it('should correctly extract properties object from message parameter', () => { | ||
const message = { | ||
properties: { | ||
product_id: '123', | ||
price: '9.99', | ||
quantity: '5', | ||
currency: 'USD', | ||
}, | ||
}; | ||
const finalPayload = []; | ||
|
||
handleProductAdded(message, finalPayload); | ||
|
||
expect(finalPayload.length).toBe(1); | ||
expect(finalPayload[0].event).toBe('addToCart'); | ||
expect(finalPayload[0].currency).toBe('USD'); | ||
expect(finalPayload[0].item.length).toBe(1); | ||
expect(finalPayload[0].item[0].id).toBe('123'); | ||
expect(finalPayload[0].item[0].price).toBe(9.99); | ||
expect(finalPayload[0].item[0].quantity).toBe(5); | ||
}); | ||
|
||
// When the 'message' parameter is undefined, the function throws an error. | ||
it('should throw an error when message parameter is undefined', () => { | ||
const message = undefined; | ||
const finalPayload = []; | ||
|
||
expect(() => { | ||
handleProductAdded(message, finalPayload); | ||
|
||
expect(finalPayload.length).toBe(1); | ||
expect(finalPayload[0].event).toBe('addToCart'); | ||
expect(finalPayload[0].currency).toBeUndefined(); | ||
expect(finalPayload[0].item.length).toBe(1); | ||
expect(finalPayload[0].item[0].id).toBe('123'); | ||
expect(finalPayload[0].item[0].price).toBe(9.99); | ||
expect(finalPayload[0].item[0].quantity).toBe(5); | ||
}); | ||
}); | ||
}).toThrow(); | ||
}); | ||
|
||
// When the 'properties' object is valid, the function creates an 'addToCartObject' with the correct structure. | ||
it('should create addToCartObject with correct structure when properties object is valid', () => { | ||
const message = { | ||
properties: { | ||
product_id: '123', | ||
price: '9.99', | ||
quantity: '5', | ||
currency: 'USD', | ||
}, | ||
}; | ||
const finalPayload = []; | ||
|
||
handleProductAdded(message, finalPayload); | ||
|
||
expect(finalPayload.length).toBe(1); | ||
expect(finalPayload[0].event).toBe('addToCart'); | ||
expect(finalPayload[0].currency).toBe('USD'); | ||
expect(finalPayload[0].item.length).toBe(1); | ||
expect(finalPayload[0].item[0].id).toBe('123'); | ||
expect(finalPayload[0].item[0].price).toBe(9.99); | ||
expect(finalPayload[0].item[0].quantity).toBe(5); | ||
}); | ||
|
||
// When the product is valid, the function adds the product object to the 'item' property of the 'addToCartObject'. | ||
it("should add product object to 'item' property when product is valid", () => { | ||
const message = { | ||
properties: { | ||
product_id: '123', | ||
price: '9.99', | ||
quantity: '5', | ||
currency: 'USD', | ||
}, | ||
}; | ||
const finalPayload = []; | ||
|
||
handleProductAdded(message, finalPayload); | ||
|
||
expect(finalPayload.length).toBe(1); | ||
expect(finalPayload[0].event).toBe('addToCart'); | ||
expect(finalPayload[0].currency).toBe('USD'); | ||
expect(finalPayload[0].item.length).toBe(1); | ||
expect(finalPayload[0].item[0].id).toBe('123'); | ||
expect(finalPayload[0].item[0].price).toBe(9.99); | ||
expect(finalPayload[0].item[0].quantity).toBe(5); | ||
}); | ||
|
||
// The function correctly pushes the 'addToCartObject' to the 'finalPayload' array. | ||
it("should correctly push 'addToCartObject' to 'finalPayload' array", () => { | ||
const message = { | ||
properties: { | ||
product_id: '123', | ||
price: '9.99', | ||
quantity: '5', | ||
currency: 'USD', | ||
}, | ||
}; | ||
const finalPayload = []; | ||
|
||
handleProductAdded(message, finalPayload); | ||
|
||
expect(finalPayload.length).toBe(1); | ||
expect(finalPayload[0].event).toBe('addToCart'); | ||
expect(finalPayload[0].currency).toBe('USD'); | ||
expect(finalPayload[0].item.length).toBe(1); | ||
expect(finalPayload[0].item[0].id).toBe('123'); | ||
expect(finalPayload[0].item[0].price).toBe(9.99); | ||
expect(finalPayload[0].item[0].quantity).toBe(5); | ||
}); | ||
|
||
// When the 'properties' object is missing the 'currency' property, the function creates an 'addToCartObject' without the 'currency' property. | ||
it("should create 'addToCartObject' without 'currency' property when 'properties' object is missing 'currency'", () => { | ||
const message = { | ||
properties: { | ||
product_id: '123', | ||
price: '9.99', | ||
quantity: '5', | ||
}, | ||
}; | ||
const finalPayload = []; | ||
|
||
handleProductAdded(message, finalPayload); | ||
|
||
expect(finalPayload.length).toBe(1); | ||
expect(finalPayload[0].event).toBe('addToCart'); | ||
expect(finalPayload[0].currency).toBeUndefined(); | ||
expect(finalPayload[0].item.length).toBe(1); | ||
expect(finalPayload[0].item[0].id).toBe('123'); | ||
expect(finalPayload[0].item[0].price).toBe(9.99); | ||
expect(finalPayload[0].item[0].quantity).toBe(5); | ||
}); | ||
}); |
Oops, something went wrong.