Skip to content

Commit

Permalink
Merge branch 'develop' into enhance.af
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 authored Jun 3, 2024
2 parents 9f7fa84 + 4b8f9a3 commit fc3c3fa
Show file tree
Hide file tree
Showing 12 changed files with 634 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ N/A

- [ ] Is the PR limited to one linear task?

- [ ] Are relevant unit and component test-cases added?
- [ ] Are relevant unit and component test-cases added in **new readability format**?

### Reviewer checklist

Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

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


### Bug Fixes

* tiktok_v2 assigning value to undefined properties ([#3426](https://github.com/rudderlabs/rudder-transformer/issues/3426)) ([323396b](https://github.com/rudderlabs/rudder-transformer/commit/323396b09fd6b7fda3cce53cc4f1cc443d7a78c1))

## [1.68.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.67.0...v1.68.0) (2024-05-27)


### Features

* add json-data type support in redis ([#3336](https://github.com/rudderlabs/rudder-transformer/issues/3336)) ([0196f20](https://github.com/rudderlabs/rudder-transformer/commit/0196f20cc79e1f470d96a649dd9404c3c9284329))
* facebook custom audience app secret support ([#3357](https://github.com/rudderlabs/rudder-transformer/issues/3357)) ([fce4ef9](https://github.com/rudderlabs/rudder-transformer/commit/fce4ef973500411c7ad812e7949bb1b73dabc3ba))
* filtering unknown events in awin ([#3392](https://github.com/rudderlabs/rudder-transformer/issues/3392)) ([d842da8](https://github.com/rudderlabs/rudder-transformer/commit/d842da87a34cb63023eba288e0c5258e29997dcf))
* **ga4:** component test refactor ([#3220](https://github.com/rudderlabs/rudder-transformer/issues/3220)) ([3ff9a5e](https://github.com/rudderlabs/rudder-transformer/commit/3ff9a5e8e955b929a1b04a89dcf0ccbc49e18648))
* **integrations/auth0:** include Auth0 event type in Rudderstack message ([#3370](https://github.com/rudderlabs/rudder-transformer/issues/3370)) ([e9409fd](https://github.com/rudderlabs/rudder-transformer/commit/e9409fde6063d7eaa8558396b85b5fdf99f964e1))
* onboard koddi destination ([#3359](https://github.com/rudderlabs/rudder-transformer/issues/3359)) ([f74c4a0](https://github.com/rudderlabs/rudder-transformer/commit/f74c4a0bc92ae6ccb0c00ac5b21745e496a015bc))
* onboarding adjust source ([#3395](https://github.com/rudderlabs/rudder-transformer/issues/3395)) ([668d331](https://github.com/rudderlabs/rudder-transformer/commit/668d3311aadacbb92b1873bf43919db7d341afbb))


### Bug Fixes

* fb custom audience html response ([#3402](https://github.com/rudderlabs/rudder-transformer/issues/3402)) ([d1a2bd6](https://github.com/rudder
* standardise hashing for all CAPI integrations ([#3379](https://github.com/rudderlabs/rudder-transformer/issues/3379)) ([c249a69](https://github.com/rudderlabs/rudder-transformer/commit/c249a694d735f6d241a35b6e21f493c54890ac84))
* tiktok_v2 remove default value for content-type for custom events ([#3383](https://github.com/rudderlabs/rudder-transformer/issues/3383)) ([6e7b5a0](https://github.com/rudderlabs/rudder-transformer/commit/6e7b5a0d8bf2c859dfb15b9cad7ed6070bd0892b))
* added step for reconciling openfaas functions for python transformations ([#3420](https://github.com/rudderlabs/rudder-transformer/issues/3420)) ([7a2ab63](https://github.com/rudderlabs/rudder-transformer/commit/7a2ab63674d40870af4d16f0673a2a2594c899e9))

## [1.67.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.66.1...v1.67.0) (2024-05-23)


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.67.0",
"version": "1.68.1",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/emarsys/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const deduceEventId = (message, destConfig) => {
const { eventsMapping } = destConfig;
const { event } = message;
validateEventName(event);
if (eventsMapping.length > 0) {
if (Array.isArray(eventsMapping) && eventsMapping.length > 0) {
const keyMap = getHashFromArray(eventsMapping, 'from', 'to', false);
eventId = keyMap[event];
}
Expand Down
26 changes: 22 additions & 4 deletions src/util/customTransformer-faas.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,26 @@ const {
} = require('./openfaas');
const { getLibraryCodeV1 } = require('./customTransforrmationsStore-v1');

const HASH_SECRET = process.env.OPENFAAS_FN_HASH_SECRET || '';
const libVersionIdsCache = new NodeCache();

function generateFunctionName(userTransformation, libraryVersionIds, testMode) {
function generateFunctionName(userTransformation, libraryVersionIds, testMode, hashSecret = '') {
if (userTransformation.versionId === FAAS_AST_VID) return FAAS_AST_FN_NAME;

if (testMode) {
const funcName = `fn-test-${uuidv4()}`;
return funcName.substring(0, 63).toLowerCase();
}

const ids = [userTransformation.workspaceId, userTransformation.versionId].concat(
let ids = [userTransformation.workspaceId, userTransformation.versionId].concat(
(libraryVersionIds || []).sort(),
);

if (hashSecret !== '') {
ids = ids.concat([hashSecret]);
}

// FIXME: Why the id's are sorted ?!
const hash = crypto.createHash('md5').update(`${ids}`).digest('hex');
return `fn-${userTransformation.workspaceId}-${hash}`.substring(0, 63).toLowerCase();
}
Expand Down Expand Up @@ -90,7 +96,13 @@ async function setOpenFaasUserTransform(
testMode,
};
const functionName =
pregeneratedFnName || generateFunctionName(userTransformation, libraryVersionIds, testMode);
pregeneratedFnName ||
generateFunctionName(
userTransformation,
libraryVersionIds,
testMode,
process.env.OPENFAAS_FN_HASH_SECRET,
);
const setupTime = new Date();

await setupFaasFunction(
Expand Down Expand Up @@ -130,7 +142,13 @@ async function runOpenFaasUserTransform(

const trMetadata = events[0].metadata ? getTransformationMetadata(events[0].metadata) : {};
// check and deploy faas function if not exists
const functionName = generateFunctionName(userTransformation, libraryVersionIds, testMode);
const functionName = generateFunctionName(
userTransformation,
libraryVersionIds,
testMode,
process.env.OPENFAAS_FN_HASH_SECRET,
);

if (testMode) {
await setOpenFaasUserTransform(
userTransformation,
Expand Down
28 changes: 25 additions & 3 deletions src/util/openfaas/faasApi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const axios = require('axios');
const { RespStatusError, RetryRequestError } = require('../utils');

const logger = require('../../logger');

const OPENFAAS_GATEWAY_URL = process.env.OPENFAAS_GATEWAY_URL || 'http://localhost:8080';
const OPENFAAS_GATEWAY_USERNAME = process.env.OPENFAAS_GATEWAY_USERNAME || '';
const OPENFAAS_GATEWAY_PASSWORD = process.env.OPENFAAS_GATEWAY_PASSWORD || '';
Expand All @@ -12,7 +14,7 @@ const basicAuth = {

const parseAxiosError = (error) => {
if (error.response) {
const status = error.response.status || 400;
const status = error.response.status || 500;
const errorData = error.response?.data;
const message =
(errorData && (errorData.message || errorData.error || errorData)) || error.message;
Expand Down Expand Up @@ -61,6 +63,8 @@ const invokeFunction = async (functionName, payload) =>
});

const checkFunctionHealth = async (functionName) => {
logger.debug(`Checking function health: ${functionName}`);

return new Promise((resolve, reject) => {
const url = `${OPENFAAS_GATEWAY_URL}/function/${functionName}`;
axios
Expand All @@ -76,8 +80,10 @@ const checkFunctionHealth = async (functionName) => {
});
};

const deployFunction = async (payload) =>
new Promise((resolve, reject) => {
const deployFunction = async (payload) => {
logger.debug(`Deploying function: ${payload?.name}`);

return new Promise((resolve, reject) => {
const url = `${OPENFAAS_GATEWAY_URL}/system/functions`;
axios
.post(url, payload, { auth: basicAuth })
Expand All @@ -86,6 +92,21 @@ const deployFunction = async (payload) =>
reject(parseAxiosError(err));
});
});
};

const updateFunction = async (fnName, payload) => {
logger.debug(`Updating function: ${fnName}`);

return new Promise((resolve, reject) => {
const url = `${OPENFAAS_GATEWAY_URL}/system/functions`;
axios
.put(url, payload, { auth: basicAuth })
.then((resp) => resolve(resp.data))
.catch((err) => {
reject(parseAxiosError(err));
});
});
};

module.exports = {
deleteFunction,
Expand All @@ -94,4 +115,5 @@ module.exports = {
getFunctionList,
invokeFunction,
checkFunctionHealth,
updateFunction,
};
Loading

0 comments on commit fc3c3fa

Please sign in to comment.