Skip to content

Commit

Permalink
chore(release): pull main into develop post release v1.32.0 (#2264)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSudip authored Jun 13, 2023
2 parents 9dbd0f5 + 51b324d commit 79ffb0a
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 26 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

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.32.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.31.2...v1.32.0) (2023-06-12)


### Features

* update klaviyo api version ([#1981](https://github.com/rudderlabs/rudder-transformer/issues/1981)) ([dd69dbc](https://github.com/rudderlabs/rudder-transformer/commit/dd69dbc6cb55e2e1de9f8c762bb1d8907e347a8d))

### Bug Fixes

* add check for listId for subscribe ([#2263](https://github.com/rudderlabs/rudder-transformer/issues/2263)) ([36a6cad](https://github.com/rudderlabs/rudder-transformer/commit/36a6cad32b98a75c46ecc750c2e9bdac7bda9a2e))


### [1.31.2](https://github.com/rudderlabs/rudder-transformer/compare/v1.31.1...v1.31.2) (2023-06-08)


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

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-transformer",
"version": "1.31.2",
"version": "1.32.0",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
1 change: 1 addition & 0 deletions src/util/redis/redisConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const RedisDB = {
log.error(`Redis is down at ${this.host}:${this.port}`);
return false; // stop retrying
},
tls: {}
});
this.client.on('ready', () => {
log.info(`Connected to redis at ${this.host}:${this.port}`);
Expand Down
7 changes: 5 additions & 2 deletions src/v0/destinations/klaviyo/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ const identifyRequestHandler = async (message, category, destination) => {
// Update Profile
const responseArray = [profileUpdateResponseBuilder(payload, profileId, category, privateApiKey)];

// check if user wants to subscribe profile or not
if (traitsInfo?.properties?.subscribe) {
// check if user wants to subscribe profile or not and listId is present or not
if (
traitsInfo?.properties?.subscribe &&
(traitsInfo.properties?.listId || destination.Config?.listId)
) {
responseArray.push(subscribeUserToList(message, traitsInfo, destination));
return responseArray;
}
Expand Down
21 changes: 0 additions & 21 deletions src/v0/destinations/klaviyo/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,6 @@ const subscribeUserToList = (message, traitsInfo, destination) => {
return response;
};

/**
* This function is used to check if the user needs to be subscribed or not.
* Building and returning response array for subscribe endpoint (for subscribing)
* @param {*} message
* @param {*} traitsInfo
* @param {*} destination
* @returns
*/
const checkForSubscribe = (message, traitsInfo, destination) => {
const responseArray = [];
if (
(traitsInfo.properties?.listId || destination.Config?.listId) &&
traitsInfo.properties?.subscribe === true
) {
const subscribeResponse = subscribeUserToList(message, traitsInfo, destination);
responseArray.push(subscribeResponse);
}
return responseArray;
};

// This function is used for creating and returning customer properties using mapping json
const createCustomerProperties = (message) => {
let customerProperties = constructPayload(
Expand Down Expand Up @@ -271,7 +251,6 @@ const batchSubscribeEvents = (subscribeRespList) => {

module.exports = {
subscribeUserToList,
checkForSubscribe,
createCustomerProperties,
populateCustomFieldsFromTraits,
generateBatchedPaylaodForArray,
Expand Down
109 changes: 109 additions & 0 deletions test/__tests__/data/klaviyo.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,115 @@
}
]
},
{
"description": "Profile updation call listId is not provided for subscribing the user",
"input": {
"destination": {
"Config": {
"publicApiKey": "WJqij9",
"privateApiKey": "pk_b68c7b5163d98807fcb57e6f921216629d"
}
},
"message": {
"type": "identify",
"sentAt": "2021-01-03T17:02:53.195Z",
"userId": "utsabc",
"channel": "web",
"context": {
"os": {
"name": "",
"version": ""
},
"app": {
"name": "RudderLabs JavaScript SDK",
"build": "1.0.0",
"version": "1.1.11",
"namespace": "com.rudderlabs.javascript"
},
"traits": {
"firstName": "Utsab",
"lastName": "Chowdhury",
"email": "[email protected]",
"phone": "+12 345 578 900",
"userId": "utsabc",
"title": "Developer",
"organization": "Rudder",
"city": "Tokyo",
"region": "Kanto",
"country": "JP",
"zip": "100-0001",
"Flagged": false,
"Residence": "Shibuya",
"properties": {
"subscribe": false,
"consent": ["email", "sms"]
}
},
"locale": "en-US",
"screen": {
"density": 2
},
"library": {
"name": "RudderLabs JavaScript SDK",
"version": "1.1.11"
},
"campaign": {},
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0"
},
"rudderId": "8f8fa6b5-8e24-489c-8e22-61f23f2e364f",
"messageId": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff",
"anonymousId": "97c46c81-3140-456d-b2a9-690d70aaca35",
"integrations": {
"All": true
},
"originalTimestamp": "2021-01-03T17:02:53.193Z"
}
},
"output": {
"version": "1",
"type": "REST",
"method": "PATCH",
"endpoint": "https://a.klaviyo.com/api/profiles/01GW3PHVY0MTCDGS0A1612HARX",
"headers": {
"Accept": "application/json",
"Authorization": "Klaviyo-API-Key pk_b68c7b5163d98807fcb57e6f921216629d",
"Content-Type": "application/json",
"revision": "2023-02-22"
},
"params": {},
"body": {
"JSON": {
"data": {
"type": "profile",
"attributes": {
"external_id": "utsabc",
"email": "[email protected]",
"first_name": "Utsab",
"last_name": "Chowdhury",
"phone_number": "+12 345 578 900",
"title": "Developer",
"organization": "Rudder",
"location": {
"city": "Tokyo",
"region": "Kanto",
"country": "JP",
"zip": "100-0001"
}
},
"properties": {
"Flagged": false,
"Residence": "Shibuya"
},
"id": "01GW3PHVY0MTCDGS0A1612HARX"
}
},
"JSON_ARRAY": {},
"XML": {},
"FORM": {}
},
"files": {}
}
},
{
"description": "Identify call with enforceEmailAsPrimary enabled from UI",
"input": {
Expand Down

0 comments on commit 79ffb0a

Please sign in to comment.