Skip to content

Commit

Permalink
chore(release): pull release/v1.64.0 into main (#3321)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSudip authored Apr 30, 2024
2 parents 616683f + ce9f5db commit 129a0a1
Show file tree
Hide file tree
Showing 57 changed files with 7,988 additions and 8,689 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.19.1
18.20.1
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

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.64.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.63.0...v1.64.0) (2024-04-29)


### Features

* adding custom properties support to bluecore ([#3282](https://github.com/rudderlabs/rudder-transformer/issues/3282)) ([8592e66](https://github.com/rudderlabs/rudder-transformer/commit/8592e664eb568e70a00261e275ab2faed8f6f618))
* onboard Yandex Metrica Offline Events Destination ([#3232](https://github.com/rudderlabs/rudder-transformer/issues/3232)) ([8f79f53](https://github.com/rudderlabs/rudder-transformer/commit/8f79f53d30326e07fc92dd624e799015ff9f87c2))
* transactional custom property support for awin ([#3325](https://github.com/rudderlabs/rudder-transformer/issues/3325)) ([fdecaf3](https://github.com/rudderlabs/rudder-transformer/commit/fdecaf36d91db7540d6f68a013e4f7fb2a36ebaa))


### Bug Fixes

* algolia enhancement ( adding currency, price, subType and objectData support ) ([#3290](https://github.com/rudderlabs/rudder-transformer/issues/3290)) ([f06ebde](https://github.com/rudderlabs/rudder-transformer/commit/f06ebde110693fe32f8e450dc395f1f4019defab))
* **delighted:** replace myAxios utility with handleHttpRequest utility ([#3237](https://github.com/rudderlabs/rudder-transformer/issues/3237)) ([bac3cc5](https://github.com/rudderlabs/rudder-transformer/commit/bac3cc5670c149454a6063a55a4b901043b0ff02))
* handle empty userId ([5402b21](https://github.com/rudderlabs/rudder-transformer/commit/5402b219ccdeaafb710c8c2828e983e9864a415f))
* handle empty userId (movable ink, bloomreach) ([#3300](https://github.com/rudderlabs/rudder-transformer/issues/3300)) ([038c1aa](https://github.com/rudderlabs/rudder-transformer/commit/038c1aa04049aaa1caa1bf82cf6c69611b5d3fd9))
* send content_ids as a string if there is only one value ([#3317](https://github.com/rudderlabs/rudder-transformer/issues/3317)) ([54eca32](https://github.com/rudderlabs/rudder-transformer/commit/54eca3220ea48fae64c655813fe4430dd704639e))

## [1.63.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.62.2...v1.63.0) (2024-04-25)


Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.4
FROM node:18.19.1-alpine3.18 AS base
FROM node:18.20.1-alpine3.18 AS base
ENV HUSKY 0

RUN apk update
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.63.0",
"version": "1.64.0",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
25 changes: 24 additions & 1 deletion src/cdk/v2/destinations/algolia/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ bindings:
- path: ../../../../v0/destinations/algolia/config
- name: removeUndefinedAndNullValues
path: ../../../../v0/util
- name: isDefinedAndNotNull
path: ../../../../v0/util
- path: ../../bindings/jsontemplate
- path: '@rudderstack/integrations-lib'

steps:
- name: validateInput
Expand All @@ -24,6 +27,7 @@ steps:
let eventTypeMap = $.eventTypeMapping(.destination.Config);
let event = .message.event.trim().toLowerCase();
let eventType = .message.properties.eventType ?? eventTypeMap[event];
let eventSubType = .message.properties.eventSubtype && eventType === 'conversion' && (.message.properties.eventSubtype in $.ALLOWED_EVENT_SUBTYPES) ? .message.properties.eventSubtype;
$.assert(eventType, "eventType is mandatory for track call");
let payload = .message.().({
index: .properties.index,
Expand All @@ -32,12 +36,28 @@ steps:
filters: .properties.filters,
objectIDs: .properties.objectIds,
positions: .properties.positions,
value: $.isDefinedAndNotNull(.properties.currency) ? .properties.value,
currency: .properties.currency,
userToken: {{{{$.getGenericPaths("userId", "||")}}}},
eventName: event,
eventType: eventType
eventType: eventType,
eventSubtype: eventSubType
});
$.context.payload = $.genericpayloadValidator(payload);
- name: prepareObjectDataBlock
condition: $.context.payload.eventType === "conversion" && $.isDefinedAndNotNull(^.message.properties.products) && Array.isArray(^.message.properties.products)
description: |
Populate list of objectData
template: |
const products = ^.message.properties.products
products.($.removeUndefinedAndNullValues({
"queryID" : $.isDefinedAndNotNull(.queryID) ? String(.queryID) : null,
"price": $.isDefinedAndNotNull(.price) && $.isDefinedAndNotNull(^.message.properties.currency) ? String(.price) : null,
"quantity": $.isDefinedAndNotNull(.quantity)? Number(.quantity) : null,
"discount": $.isDefinedAndNotNull(.discount) ? String(.discount) : null
}))[]
- name: populateProductsData
condition: |
.message.properties.products &&
Expand All @@ -55,11 +75,14 @@ steps:
const products = .message.properties.products;
const objectIDs = ~r products.objectId;
$.context.payload.objectIDs = Array.isArray(objectIDs) ? objectIDs[:20]:$.context.payload.objectIDs;
$.context.payload.objectData = $.outputs.prepareObjectDataBlock
$.validatePayload($.context.payload)
- name: validateDestPayload
template: |
const filters = $.context.payload.filters;
const objectIDs = $.context.payload.objectIDs;
const objectData = $.context.payload.objectData;
$.assert(!(filters && objectIDs), "event can't have both objectIds and filters at the same time.");
$.assert(filters.length || objectIDs.length, "Either filters or objectIds is required and must be non empty.");
Expand Down
6 changes: 3 additions & 3 deletions src/cdk/v2/destinations/bloomreach/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ steps:
const userId = .message.().(
{{{{$.getGenericPaths("userIdOnly")}}}};
);
$.assert(userId ?? .message.anonymousId, "Either one of userId or anonymousId is required. Aborting");
$.assert(userId || .message.anonymousId, "Either one of userId or anonymousId is required. Aborting");
- name: prepareIdentifyPayload
condition: $.context.messageType === {{$.EventType.IDENTIFY}}
Expand All @@ -64,7 +64,7 @@ steps:
- name: pageEventName
condition: $.context.messageType === {{$.EventType.PAGE}}
template: |
const category = .message.category ?? .message.properties.category;
const category = .message.category || .message.properties.category;
const name = .message.name || .message.properties.name;
const eventNameArray = ["Viewed"];
category ? eventNameArray.push(category);
Expand All @@ -74,7 +74,7 @@ steps:
- name: screenEventName
condition: $.context.messageType === {{$.EventType.SCREEN}}
template: |
const category = .message.category ?? .message.properties.category;
const category = .message.category || .message.properties.category;
const name = .message.name || .message.properties.name;
const eventNameArray = ["Viewed"];
category ? eventNameArray.push(category);
Expand Down
22 changes: 21 additions & 1 deletion src/cdk/v2/destinations/bluecore/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { getMappingConfig } = require('../../../../v0/util');

const BASE_URL = 'https://api.bluecore.com/api/track/mobile/v1';
const BASE_URL = 'https://api.bluecore.app/api/track/mobile/v1';

const CONFIG_CATEGORIES = {
IDENTIFY: {
Expand Down Expand Up @@ -46,11 +46,31 @@ const EVENT_NAME_MAPPING = [

const BLUECORE_EXCLUSION_FIELDS = ['query', 'order_id', 'total'];

const IDENTIFY_EXCLUSION_LIST = [
'name',
'firstName',
'first_name',
'firstname',
'lastName',
'last_name',
'lastname',
'email',
'age',
'sex',
'address',
'action',
'event',
];

const TRACK_EXCLUSION_LIST = [...IDENTIFY_EXCLUSION_LIST, 'query', 'order_id', 'total', 'products'];

const MAPPING_CONFIG = getMappingConfig(CONFIG_CATEGORIES, __dirname);
module.exports = {
CONFIG_CATEGORIES,
MAPPING_CONFIG,
EVENT_NAME_MAPPING,
BASE_URL,
BLUECORE_EXCLUSION_FIELDS,
IDENTIFY_EXCLUSION_LIST,
TRACK_EXCLUSION_LIST,
};
6 changes: 3 additions & 3 deletions src/cdk/v2/destinations/bluecore/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ steps:
condition: $.outputs.messageType === {{$.EventType.IDENTIFY}}
template: |
const payload = $.constructProperties(.message);
payload.token = .destination.Config.bluecoreNamespace;
payload.properties.token = .destination.Config.bluecoreNamespace;
$.verifyPayload(payload, .message);
payload.event = payload.event ?? 'customer_patch';
payload.properties.distinct_id = $.populateAccurateDistinctId(payload, .message);
Expand All @@ -50,7 +50,7 @@ steps:
const temporaryProductArray = newPayload.properties.products ?? $.createProductForStandardEcommEvent(^.message, eventName);
newPayload.properties.products = $.normalizeProductArray(temporaryProductArray);
newPayload.event = eventName;
newPayload.token = ^.destination.Config.bluecoreNamespace;
newPayload.properties.token = ^.destination.Config.bluecoreNamespace;
$.verifyPayload(newPayload, ^.message);
$.removeUndefinedNullValuesAndEmptyObjectArray(newPayload)
)[];
Expand All @@ -61,7 +61,7 @@ steps:
const response = $.defaultRequestConfig();
response.body.JSON = .;
response.method = "POST";
response.endpoint = "https://api.bluecore.com/api/track/mobile/v1";
response.endpoint = "https://api.bluecore.app/api/track/mobile/v1";
response.headers = {
"Content-Type": "application/json"
};
Expand Down
45 changes: 43 additions & 2 deletions src/cdk/v2/destinations/bluecore/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const {
validateEventName,
constructPayload,
getDestinationExternalID,
extractCustomFields,
} = require('../../../../v0/util');
const { CommonUtils } = require('../../../../util/common');
const { EVENT_NAME_MAPPING } = require('./config');
const { EVENT_NAME_MAPPING, IDENTIFY_EXCLUSION_LIST, TRACK_EXCLUSION_LIST } = require('./config');
const { EventType } = require('../../../../constants');
const { MAPPING_CONFIG, CONFIG_CATEGORIES } = require('./config');

Expand Down Expand Up @@ -167,6 +168,41 @@ const normalizeProductArray = (products) => {
return finalProductArray;
};

const mapCustomProperties = (message) => {
let customerProperties;
const customProperties = { properties: {} };
const messageType = message.type.toUpperCase();
switch (messageType) {
case 'IDENTIFY':
customerProperties = extractCustomFields(
message,
{},
['traits', 'context.traits'],
IDENTIFY_EXCLUSION_LIST,
);
customProperties.properties.customer = customerProperties;
break;
case 'TRACK':
customerProperties = extractCustomFields(
message,
{},
['traits', 'context.traits'],
IDENTIFY_EXCLUSION_LIST,
);
customProperties.properties = extractCustomFields(
message,
{},
['properties'],
TRACK_EXCLUSION_LIST,
);
customProperties.properties.customer = customerProperties;
break;
default:
break;
}
return customProperties;
};

/**
* Constructs properties based on the given message.
*
Expand All @@ -178,7 +214,12 @@ const constructProperties = (message) => {
const commonPayload = constructPayload(message, MAPPING_CONFIG[commonCategory.name]);
const category = CONFIG_CATEGORIES[message.type.toUpperCase()];
const typeSpecificPayload = constructPayload(message, MAPPING_CONFIG[category.name]);
const finalPayload = lodash.merge(commonPayload, typeSpecificPayload);
const typeSpecificCustomProperties = mapCustomProperties(message);
const finalPayload = lodash.merge(
commonPayload,
typeSpecificPayload,
typeSpecificCustomProperties,
);
return finalPayload;
};

Expand Down
4 changes: 2 additions & 2 deletions src/cdk/v2/destinations/movable_ink/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ steps:
{{{{$.getGenericPaths("email")}}}};
);
$.assert(userId ?? email ?? .message.anonymousId, "Either one of userId or email or anonymousId is required. Aborting");
$.assert(userId || email || .message.anonymousId, "Either one of userId or email or anonymousId is required. Aborting");
$.validateEventPayload(.message);
- name: preparePayload
Expand All @@ -50,7 +50,7 @@ steps:
));
$.context.payload = {
...(.message),
userId: userId ?? email,
userId: userId || email,
timestamp: timestampInUnix,
anonymousId: .message.anonymousId
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const YANDEX_METRICA_OFFLINE_EVENTS = 'yandex_metrica_offline_events';

module.exports = {
YANDEX_METRICA_OFFLINE_EVENTS,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
bindings:
- name: EventType
path: ../../../../constants
- path: ../../bindings/jsontemplate
exportAll: true
- path: ./config
- name: removeUndefinedAndNullValues
path: ../../../../v0/util
- name: defaultRequestConfig
path: ../../../../v0/util
- path: ./utils

steps:
- name: validateInput
template: |
let messageType = .message.type;
$.assert(messageType, "message Type is not present. Aborting message.");
$.assert(.message.type.toLowerCase() ==='identify', "Event type " + .message.type.toLowerCase() + " is not supported. Aborting message.");
$.assert(.message.traits || .message.properties, "Message traits/properties not present. Aborting message.");
- name: prepareData
template: |
let data = .message.traits
let identifierType = .message.context.externalId[0].identifierType;
let identifierValue = .message.context.externalId[0].id;
identifierValue = String(identifierValue);
data = $.setIdentifier(data, identifierType, identifierValue)
data = $.validateData(data)
data
- name: buildResponseForProcessTransformation
description: build response
template: |
const response = $.defaultRequestConfig();
response.body.JSON = $.outputs.prepareData
response
51 changes: 51 additions & 0 deletions src/cdk/v2/destinations/yandex_metrica_offline_events/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* eslint-disable no-param-reassign */
const { InstrumentationError, isDefinedNotNullNotEmpty } = require('@rudderstack/integrations-lib');
const moment = require('moment');

const setIdentifier = (data, identifierType, identifierValue) => {
const updatedData = data;
if (identifierType === 'ClientId') {
updatedData.ClientId = identifierValue;
} else if (identifierType === 'YCLID') {
updatedData.Yclid = identifierValue;
} else if (identifierType === 'UserId') {
updatedData.UserId = identifierValue;
} else {
throw new InstrumentationError(
'Invalid identifier type passed in external Id. Valid types are ClientId, YCLID, UserId. Aborting!',
);
}
return updatedData;
};

function isUnixTimestamp(datetime) {
if (moment.unix(datetime).isValid()) {
return datetime;
}
const unixTimestamp = moment(datetime).unix();
if (moment.unix(unixTimestamp).isValid()) {
return unixTimestamp;
}
throw new InstrumentationError('Invalid timestamp. Aborting!');
}

const validateData = (data) => {
const { Price, DateTime } = data;
if (!isDefinedNotNullNotEmpty(data)) {
throw new InstrumentationError('No traits found in the payload. Aborting!');
}
if (Price && typeof Price !== 'number') {
throw new InstrumentationError('Price can only be a numerical value. Aborting!');
}
if (!isDefinedNotNullNotEmpty(DateTime)) {
throw new InstrumentationError('DateTime cannot be empty. Aborting!');
}
data.DateTime = String(isUnixTimestamp(DateTime));
return data;
};

module.exports = {
setIdentifier,
validateData,
isUnixTimestamp,
};
Loading

0 comments on commit 129a0a1

Please sign in to comment.