Skip to content

Commit

Permalink
Merge branch 'feat.onboard_gladly' of github.com:rudderlabs/rudder-tr…
Browse files Browse the repository at this point in the history
…ansformer into feat.onboard_gladly
  • Loading branch information
mihir-4116 committed Nov 6, 2023
2 parents bdd8380 + a438c45 commit 091109d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/v0/destinations/customerio/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
adduserIdFromExternalId,
getFieldValueFromMessage,
handleRtTfSingleEventError,
validateEventName,
} = require('../../util');

const logger = require('../../../logger');
Expand Down Expand Up @@ -101,6 +102,7 @@ function processSingleMessage(message, destination) {
break;
case EventType.TRACK:
evType = 'event';
validateEventName(message.event);
evName = message.event;
break;
case EventType.ALIAS:
Expand All @@ -113,6 +115,7 @@ function processSingleMessage(message, destination) {
logger.error(`could not determine type ${messageType}`);
throw new InstrumentationError(`could not determine type ${messageType}`);
}
evName = evName ? String(evName) : evName;
const response = responseBuilder(message, evType, evName, destination, messageType);

// replace default domain with EU data center domainc for EU based account
Expand Down
2 changes: 0 additions & 2 deletions src/v0/destinations/customerio/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const {
defaultDeleteRequestConfig,
isAppleFamily,
validateEmail,
validateEventType,
} = require('../../util');

const { EventType, SpecedTraits, TraitsMapping } = require('../../../constants');
Expand Down Expand Up @@ -288,7 +287,6 @@ const defaultResponseBuilder = (message, evName, userId, evType, destination, me
// 100 - len(`Viewed Screen`) = 86
trimmedEvName = `Viewed ${truncate(message.event || message.properties.name, 86)} Screen`;
} else {
validateEventType(evName);
trimmedEvName = truncate(evName, 100);
}
// anonymous_id needs to be sent for anon track calls to provide information on which anon user is being tracked
Expand Down
7 changes: 2 additions & 5 deletions src/v0/destinations/freshsales/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
defaultPostRequestConfig,
getValidDynamicFormConfig,
simpleProcessRouterDest,
validateEventType,
validateEventName,
} = require('../../util');
const { InstrumentationError, TransformationError } = require('../../util/errorTypes');
const { CONFIG_CATEGORIES, MAPPING_CONFIG } = require('./config');
Expand Down Expand Up @@ -67,7 +67,6 @@ const identifyResponseBuilder = (message, { Config }) => {
* @returns
*/
const trackResponseBuilder = async (message, { Config }, event) => {
validateEventType(event);
let payload;

const response = defaultRequestConfig();
Expand Down Expand Up @@ -125,9 +124,6 @@ const groupResponseBuilder = async (message, { Config }) => {
// Checks if there are any mapping events for the track event and returns them
function eventMappingHandler(message, destination) {
const event = get(message, 'event');
if (!event) {
throw new InstrumentationError('Event name is required');
}

let { rudderEventsToFreshsalesEvents } = destination.Config;
const mappedEvents = new Set();
Expand Down Expand Up @@ -161,6 +157,7 @@ const processEvent = async (message, destination) => {
response = identifyResponseBuilder(message, destination);
break;
case EventType.TRACK: {
validateEventName(message.event);
const mappedEvents = eventMappingHandler(message, destination);
if (mappedEvents.length > 0) {
const respList = await Promise.all(
Expand Down
6 changes: 0 additions & 6 deletions src/v0/destinations/klaviyo/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const { handleHttpRequest } = require('../../../adapters/network');
const { JSON_MIME_TYPE, HTTP_STATUS_CODES } = require('../../util/constant');
const { NetworkError, InstrumentationError } = require('../../util/errorTypes');
const { getDynamicErrorType } = require('../../../adapters/utils/networkUtils');
const { client: errNotificationClient } = require('../../../util/errorNotifier');
const { BASE_ENDPOINT, MAPPING_CONFIG, CONFIG_CATEGORIES, MAX_BATCH_SIZE } = require('./config');

const REVISION_CONSTANT = '2023-02-22';
Expand Down Expand Up @@ -69,11 +68,6 @@ const getIdFromNewOrExistingProfile = async (endpoint, payload, requestOptions)
let statusCode = resp.status;
if (resp.status === 201 || resp.status === 409) {
// retryable error if the profile id is not found in the response
errNotificationClient.notify(
new Error('Klaviyo: ProfileId not found'),
'Profile Id not Found in the response',
JSON.stringify(resp.response),
);
statusCode = 500;
}

Expand Down
4 changes: 2 additions & 2 deletions src/v0/destinations/monday/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
removeUndefinedAndNullValues,
simpleProcessRouterDest,
getDestinationExternalID,
validateEventType,
validateEventName,
} = require('../../util');
const {
ConfigurationError,
Expand Down Expand Up @@ -42,7 +42,7 @@ const trackResponseBuilder = async (message, { Config }) => {
const { apiToken } = Config;
let boardId = getDestinationExternalID(message, 'boardId');
const event = get(message, 'event');
validateEventType(event);
validateEventName(event);
if (!boardId) {
boardId = Config.boardId;
}
Expand Down
4 changes: 2 additions & 2 deletions src/v0/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@ const isValidInteger = (value) => {
// Use a regular expression to check if the string is a valid integer or a valid floating-point number
return typeof value === 'string' ? /^-?\d+$/.test(value) : false;
};
const validateEventType = (event) => {
const validateEventName = (event) => {
if (!event || typeof event !== 'string') {
throw new InstrumentationError('Event is a required field and should be a string');
}
Expand Down Expand Up @@ -2177,7 +2177,7 @@ module.exports = {
getDestAuthCacheInstance,
refinePayload,
validateEmail,
validateEventType,
validateEventName,
validatePhoneWithCountryCode,
getEventReqMetadata,
isHybridModeEnabled,
Expand Down

0 comments on commit 091109d

Please sign in to comment.