Skip to content

Commit

Permalink
Merge branch 'develop' into enhance.garl
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 authored Jan 4, 2024
2 parents 9fe5e14 + e002093 commit 423f716
Show file tree
Hide file tree
Showing 41 changed files with 541 additions and 121 deletions.
34 changes: 15 additions & 19 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@

Write a brief explainer on your code changes.

## Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, **mandatorily** mention them here

### Type of change
## What is the related Linear task?

If the pull request is a **bug-fix**, **enhancement** or a **refactor**, please fill in the details on the changes made.
Resolves INT-XXX

- Existing capabilities/behavior

- New capabilities/behavior
## Please explain the objectives of your changes below

If the pull request is a **new feature**,
Put down any required details on the broader aspect of your changes. If there are any dependent changes, **mandatorily** mention them here

### Any technical or performance related pointers to consider with the change?
### Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

N/A

Expand All @@ -28,25 +22,27 @@ N/A

N/A

### If the PR has changes in more than 10 files, please mention why the changes were not split into multiple PRs.

N/A

### If multiple linear tasks are associated with the PR changes, please elaborate on the reason:
### Any technical or performance related pointers to consider with the change?

N/A

<hr>

### Developer checklist

- [ ] My code follows the style guidelines of this project

- [ ] **No breaking changes are being introduced.**

- [ ] Are all related docs linked with the PR?
- [ ] All related docs linked with the PR?

- [ ] All changes manually tested?

- [ ] Any documentation changes needed with this change?

- [ ] Are all changes manually tested?
- [ ] Is the PR limited to 10 file changes?

- [ ] Does this change require any documentation changes?
- [ ] Is the PR limited to one linear task?

- [ ] Are relevant unit and component test-cases added?

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,6 @@ dist

# Others
**/.DS_Store


.idea
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.16.0
18.19.0
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

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


### Bug Fixes

* send empty string instead of null when the schema data is undefined ([#2955](https://github.com/rudderlabs/rudder-transformer/issues/2955)) ([511741e](https://github.com/rudderlabs/rudder-transformer/commit/511741ed356b365f52e0335ce6a1fc953ccbc465))

### [1.52.3](https://github.com/rudderlabs/rudder-transformer/compare/v1.52.2...v1.52.3) (2023-12-18)


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.17-alpine3.17 AS base
FROM node:18.19.0-alpine3.18 AS base
ENV HUSKY 0

RUN apk update
Expand Down
39 changes: 2 additions & 37 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.52.3",
"version": "1.52.4",
"description": "",
"homepage": "https://github.com/rudderlabs/rudder-transformer#readme",
"bugs": {
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/bulkUpload.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable global-require, import/no-dynamic-require, @typescript-eslint/no-unused-vars */
import { client as errNotificationClient } from '../util/errorNotifier';
import logger from '../logger';
import { CatchErr } from '../util/types';
import { CatchErr, ContextBodySimple } from '../util/types';
// TODO: To be refactored and redisgned

const getDestFileUploadHandler = (version, dest) =>
Expand Down Expand Up @@ -45,7 +45,7 @@ export const fileUpload = async (ctx) => {
return {};
};

const { destType } = ctx.request.body;
const { destType }: ContextBodySimple = ctx.request.body;
const destFileUploadHandler = getDestFileUploadHandler('v0', destType.toLowerCase());

if (!destFileUploadHandler || !destFileUploadHandler.processFileData) {
Expand Down Expand Up @@ -82,7 +82,7 @@ export const pollStatus = async (ctx) => {
JSON.stringify(ctx.request.body),
);

const { destType } = ctx.request.body;
const { destType }: ContextBodySimple = ctx.request.body;
const destFileUploadHandler = getPollStatusHandler('v0', destType.toLowerCase());
let response;
if (!destFileUploadHandler || !destFileUploadHandler.processPolling) {
Expand Down Expand Up @@ -117,7 +117,7 @@ export const getWarnJobStatus = async (ctx) => {
JSON.stringify(ctx.request.body),
);

const { destType } = ctx.request.body;
const { destType }: ContextBodySimple = ctx.request.body;
const destFileUploadHandler = getJobStatusHandler('v0', destType.toLowerCase());

if (!destFileUploadHandler || !destFileUploadHandler.processJobStatus) {
Expand Down Expand Up @@ -153,7 +153,7 @@ export const getFailedJobStatus = async (ctx) => {
JSON.stringify(ctx.request.body),
);

const { destType } = ctx.request.body;
const { destType }: ContextBodySimple = ctx.request.body;
const destFileUploadHandler = getJobStatusHandler('v0', destType.toLowerCase());

if (!destFileUploadHandler || !destFileUploadHandler.processJobStatus) {
Expand Down
3 changes: 2 additions & 1 deletion src/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"GLADLY": true,
"ONE_SIGNAL": true,
"TIKTOK_AUDIENCE": true,
"REDDIT": true
"REDDIT": true,
"INTERCOM": true
},
"supportSourceTransformV1": true,
"supportTransformerProxyV1": false
Expand Down
3 changes: 3 additions & 0 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ export type FixMe = any;

export type CatchErr = any;

export type ContextBodySimple = {
destType: string;
};
export interface Config {
cdkEnabled?: boolean;
cdkV2Enabled?: boolean;
Expand Down
32 changes: 20 additions & 12 deletions src/v0/destinations/active_campaign/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const responseBuilderSimple = (payload, category, destination) => {
};

const syncContact = async (contactPayload, category, destination) => {
const endpoint = `${destination.Config.apiUrl}${category.endPoint}`;
const { endPoint } = category;
const endpoint = `${destination.Config.apiUrl}${endPoint}`;
const requestData = {
contact: contactPayload,
};
Expand All @@ -60,6 +61,7 @@ const syncContact = async (contactPayload, category, destination) => {
const res = await httpPOST(endpoint, requestData, requestOptions, {
destType: 'active_campaign',
feature: 'transformation',
endpointPath: endPoint,
});
if (res.success === false) {
errorHandler(res, 'Failed to create new contact');
Expand All @@ -78,6 +80,7 @@ const customTagProcessor = async (message, category, destination, contactId) =>
let endpoint;
let requestOptions;
let requestData;
const { tagEndPoint, mergeTagWithContactUrl } = category;
// Here we extract the tags which are to be mapped to the created contact from the message
const msgTags = get(message?.context?.traits, 'tags') || get(message?.traits, 'tags');

Expand All @@ -89,13 +92,14 @@ const customTagProcessor = async (message, category, destination, contactId) =>
// Step - 1
// Fetch already created tags from dest, so that we avoid duplicate tag creation request
// Ref - https://developers.activecampaign.com/reference/retrieve-all-tags
endpoint = `${destination.Config.apiUrl}${`${category.tagEndPoint}?limit=100`}`;
endpoint = `${destination.Config.apiUrl}${`${tagEndPoint}?limit=100`}`;
requestOptions = {
headers: getHeader(destination),
};
res = await httpGET(endpoint, requestOptions, {
destType: 'active_campaign',
feature: 'transformation',
tagEndPoint,
});
if (res.success === false) {
errorHandler(res, 'Failed to fetch already created tags');
Expand All @@ -117,15 +121,14 @@ const customTagProcessor = async (message, category, destination, contactId) =>
if (parseInt(get(res, TOTAL_RECORDS_KEY), 10) > 100) {
const limit = Math.floor(parseInt(get(res, TOTAL_RECORDS_KEY), 10) / 100);
for (let i = 0; i < limit; i += 1) {
endpoint = `${destination.Config.apiUrl}${category.tagEndPoint}?limit=100&offset=${
100 * (i + 1)
}`;
endpoint = `${destination.Config.apiUrl}${tagEndPoint}?limit=100&offset=${100 * (i + 1)}`;
requestOptions = {
headers: getHeader(destination),
};
const resp = httpGET(endpoint, requestOptions, {
destType: 'active_campaign',
feature: 'transformation',
endpointPath: `/api/3/tags`,
});
promises.push(resp);
}
Expand Down Expand Up @@ -153,7 +156,7 @@ const customTagProcessor = async (message, category, destination, contactId) =>
if (tagsToBeCreated.length > 0) {
await Promise.all(
tagsToBeCreated.map(async (tag) => {
endpoint = `${destination.Config.apiUrl}${category.tagEndPoint}`;
endpoint = `${destination.Config.apiUrl}${tagEndPoint}`;
requestData = {
tag: {
tag,
Expand Down Expand Up @@ -182,7 +185,7 @@ const customTagProcessor = async (message, category, destination, contactId) =>
// Ref - https://developers.activecampaign.com/reference/create-contact-tag
const responsesArr = await Promise.all(
tagIds.map(async (tagId) => {
endpoint = `${destination.Config.apiUrl}${category.mergeTagWithContactUrl}`;
endpoint = `${destination.Config.apiUrl}${mergeTagWithContactUrl}`;
requestData = {
contactTag: {
contact: contactId,
Expand All @@ -207,6 +210,7 @@ const customTagProcessor = async (message, category, destination, contactId) =>

const customFieldProcessor = async (message, category, destination) => {
const responseStaging = [];
const { fieldEndPoint } = category;
// Step - 1
// Extract the custom field info from the message
const fieldInfo = get(message?.context?.traits, 'fieldInfo') || get(message.traits, 'fieldInfo');
Expand All @@ -219,7 +223,7 @@ const customFieldProcessor = async (message, category, destination) => {
// Step - 2
// Get the existing field data from dest and store it in responseStaging
// Ref - https://developers.activecampaign.com/reference/retrieve-fields
let endpoint = `${destination.Config.apiUrl}${category.fieldEndPoint}?limit=100`;
let endpoint = `${destination.Config.apiUrl}${fieldEndPoint}?limit=100`;
const requestOptions = {
headers: {
'Api-Token': destination.Config.apiKey,
Expand All @@ -228,6 +232,7 @@ const customFieldProcessor = async (message, category, destination) => {
const res = await httpGET(endpoint, requestOptions, {
destType: 'active_campaign',
feature: 'transformation',
fieldEndPoint,
});
if (res.success === false) {
errorHandler(res, 'Failed to get existing field data');
Expand All @@ -238,9 +243,7 @@ const customFieldProcessor = async (message, category, destination) => {
const limit = Math.floor(parseInt(get(res, TOTAL_RECORDS_KEY), 10) / 100);
if (parseInt(get(res, TOTAL_RECORDS_KEY), 10) > 100) {
for (let i = 0; i < limit; i += 1) {
endpoint = `${destination.Config.apiUrl}${category.fieldEndPoint}?limit=100&offset=${
100 * (i + 1)
}`;
endpoint = `${destination.Config.apiUrl}${fieldEndPoint}?limit=100&offset=${100 * (i + 1)}`;
const requestOpt = {
headers: {
'Api-Token': destination.Config.apiKey,
Expand All @@ -249,6 +252,7 @@ const customFieldProcessor = async (message, category, destination) => {
const resp = httpGET(endpoint, requestOpt, {
destType: 'active_campaign',
feature: 'transformation',
endpointPath: `/api/3/fields`,
});
promises.push(resp);
}
Expand Down Expand Up @@ -308,6 +312,7 @@ const customFieldProcessor = async (message, category, destination) => {
};

const customListProcessor = async (message, category, destination, contactId) => {
const { mergeListWithContactUrl } = category;
// Here we extract the list info from the message
const listInfo = get(message?.context?.traits, 'lists')
? get(message.context.traits, 'lists')
Expand All @@ -331,7 +336,7 @@ const customListProcessor = async (message, category, destination, contactId) =>
// eslint-disable-next-line no-restricted-syntax
for (const li of listArr) {
if (li.status === 'subscribe' || li.status === 'unsubscribe') {
const endpoint = `${destination.Config.apiUrl}${category.mergeListWithContactUrl}`;
const endpoint = `${destination.Config.apiUrl}${mergeListWithContactUrl}`;
const requestData = {
contactList: {
list: li.id,
Expand All @@ -345,6 +350,7 @@ const customListProcessor = async (message, category, destination, contactId) =>
const res = httpPOST(endpoint, requestData, requestOptions, {
destType: 'active_campaign',
feature: 'transformation',
endpointPath: mergeListWithContactUrl,
});
promises.push(res);
}
Expand Down Expand Up @@ -402,6 +408,7 @@ const screenRequestHandler = async (message, category, destination) => {
res = await httpGET(endpoint, requestOptions, {
destType: 'active_campaign',
feature: 'transformation',
endpointPath: `/api/3/eventTrackingEvents`,
});
if (res.success === false) {
errorHandler(res, 'Failed to retrieve events');
Expand Down Expand Up @@ -465,6 +472,7 @@ const trackRequestHandler = async (message, category, destination) => {
let res = await httpGET(endpoint, requestOptions, {
destType: 'active_campaign',
feature: 'transformation',
endpointPath: `/api/3/eventTrackingEvents`,
});

if (res.success === false) {
Expand Down
1 change: 1 addition & 0 deletions src/v0/destinations/af/deleteUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const deleteUser = async (config, endpoint, body, identityType, identityValue) =
{
destType: 'af',
feature: 'deleteUsers',
endpointPath: `appsflyer.com/api/gdpr/v1/opendsr_requests`,
},
);
const handledDelResponse = processAxiosResponse(response);
Expand Down
Loading

0 comments on commit 423f716

Please sign in to comment.