diff --git a/.eslintrc.json b/.eslintrc.json index 805e5e7efe..c2614ac5ef 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -28,7 +28,7 @@ ], "unicorn/no-instanceof-array": "error", "unicorn/no-static-only-class": "error", - "unicorn/consistent-destructuring": "off", + "unicorn/consistent-destructuring": "error", "unicorn/better-regex": "error", "unicorn/no-for-loop": "error", "unicorn/prefer-array-some": "error", @@ -40,29 +40,31 @@ "unicorn/no-useless-spread": "error", "unicorn/no-useless-length-check": "error", "unicorn/prefer-export-from": "error", - "import/no-dynamic-require": "warn", - "no-param-reassign": "warn", + "import/no-dynamic-require": "error", + "no-param-reassign": "error", "sonarjs/prefer-immediate-return": "off", "sonarjs/no-nested-template-literals": "off", - "sonarjs/max-switch-cases": "off", - "sonarjs/no-small-switch": "warn", + "sonarjs/max-switch-cases": "error", + "sonarjs/no-small-switch": "error", "sonarjs/cognitive-complexity": ["error", 60], "@typescript-eslint/no-var-requires": "off", - "global-require": "off", - "@typescript-eslint/naming-convention": "off", - "@typescript-eslint/ban-types": "off", + "global-require": "error", + "@typescript-eslint/naming-convention": "error", + "@typescript-eslint/ban-types": "error", + "@typescript-eslint/no-explicit-any": "off", "class-methods-use-this": "off", - "@typescript-eslint/return-await": "off", - "import/prefer-default-export": "off", - "sonarjs/no-ignored-return": "off", - "no-new": "off", - "@typescript-eslint/no-shadow": "off", - "@typescript-eslint/no-loop-func": "off", - "sonarjs/no-same-line-conditional": "off", - "no-restricted-syntax": "off", - "sonarjs/no-duplicate-string": "off", - "sonarjs/no-identical-functions": "off", + "@typescript-eslint/return-await": "error", + "import/prefer-default-export": "error", + "sonarjs/no-ignored-return": "error", + "no-new": "error", + "@typescript-eslint/no-shadow": "error", + "@typescript-eslint/no-loop-func": "error", + "sonarjs/no-same-line-conditional": "error", + "no-restricted-syntax": "error", + "sonarjs/no-duplicate-string": "error", + "sonarjs/no-identical-functions": "error", "no-prototype-builtins": "off", - "@typescript-eslint/dot-notation": "off" + "@typescript-eslint/dot-notation": "error", + "@typescript-eslint/no-unused-vars": "error" } } diff --git a/src/adapters/network.js b/src/adapters/network.js index 5ee62029a3..375d9dc908 100644 --- a/src/adapters/network.js +++ b/src/adapters/network.js @@ -1,7 +1,7 @@ /* eslint-disable no-restricted-syntax */ /* eslint-disable no-undef */ -const _ = require('lodash'); +const lodash = require('lodash'); const http = require('http'); const https = require('https'); const axios = require('axios'); @@ -237,7 +237,7 @@ const getPayloadData = (body) => { let payload; let payloadFormat; Object.entries(body).forEach(([key, value]) => { - if (!_.isEmpty(value)) { + if (!lodash.isEmpty(value)) { payload = value; payloadFormat = key; } diff --git a/src/adapters/utils/networkUtils.js b/src/adapters/utils/networkUtils.js index 39b0e0504a..a88d803fac 100644 --- a/src/adapters/utils/networkUtils.js +++ b/src/adapters/utils/networkUtils.js @@ -1,5 +1,5 @@ /* eslint-disable eqeqeq */ -const _ = require('lodash'); +const lodash = require('lodash'); const { isEmpty } = require('lodash'); const { isHttpStatusRetryable, @@ -100,7 +100,7 @@ const parseDestResponse = (destResponse, destination = '') => { if ( !isDefinedAndNotNull(responseBody) || !isDefinedAndNotNull(status) || - !_.isNumber(status) || + !lodash.isNumber(status) || status === 0 ) { throw new AbortedError( diff --git a/src/cdk/v1/dcm_floodlight/transform.js b/src/cdk/v1/dcm_floodlight/transform.js index 4025c3cc01..d5835d3e2b 100644 --- a/src/cdk/v1/dcm_floodlight/transform.js +++ b/src/cdk/v1/dcm_floodlight/transform.js @@ -1,6 +1,6 @@ /* eslint-disable no-param-reassign */ const get = require('get-value'); -const _ = require('lodash'); +const lodash = require('lodash'); const { removeUndefinedAndNullValues, isDefinedAndNotNull, @@ -44,7 +44,7 @@ const transformCustomVariable = (customFloodlightVariable, message) => { if ( // the value is not null - !_.isNil(itemValue) && + !lodash.isNil(itemValue) && // the value is string and doesn't have any blacklisted characters !( typeof itemValue === 'string' && BLACKLISTED_CHARACTERS.some((k) => itemValue.includes(k)) diff --git a/src/cdk/v1/new_relic/transform.js b/src/cdk/v1/new_relic/transform.js index 67858910ad..43cebd548f 100644 --- a/src/cdk/v1/new_relic/transform.js +++ b/src/cdk/v1/new_relic/transform.js @@ -1,3 +1,4 @@ +/* eslint-disable no-param-reassign */ const { isBoolean } = require('lodash'); const { Utils } = require('rudder-transformer-cdk'); diff --git a/src/cdk/v2/destinations/dcm_floodlight/utils.js b/src/cdk/v2/destinations/dcm_floodlight/utils.js index e50f4f3b40..bee45bdea3 100644 --- a/src/cdk/v2/destinations/dcm_floodlight/utils.js +++ b/src/cdk/v2/destinations/dcm_floodlight/utils.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const { getValueFromPropertiesOrTraits, getHashFromArray } = require('../../../../v0/util'); const { GENERIC_TRUE_VALUES, GENERIC_FALSE_VALUES } = require('../../../../constants'); const { InstrumentationError } = require('../../../../v0/util/errorTypes'); @@ -35,7 +35,7 @@ const transformCustomVariable = (customFloodlightVariable, message) => { if ( // the value is not null - !_.isNil(itemValue) && + !lodash.isNil(itemValue) && // the value is string and doesn't have any blacklisted characters !( typeof itemValue === 'string' && BLACKLISTED_CHARACTERS.some((k) => itemValue.includes(k)) diff --git a/src/cdk/v2/destinations/eloqua/utils.js b/src/cdk/v2/destinations/eloqua/utils.js index baecffc6dc..a8e2afb3f8 100644 --- a/src/cdk/v2/destinations/eloqua/utils.js +++ b/src/cdk/v2/destinations/eloqua/utils.js @@ -1,10 +1,11 @@ const stringifyValues = (data) => { - Object.keys(data).forEach((key) => { - if (typeof data[key] !== 'string') { - data[key] = JSON.stringify(data[key]); + const output = data; + Object.keys(output).forEach((key) => { + if (typeof output[key] !== 'string') { + output[key] = JSON.stringify(output[key]); } }); - return data; + return output; }; module.exports = { stringifyValues, diff --git a/src/cdk/v2/destinations/launchdarkly_audience/utils.js b/src/cdk/v2/destinations/launchdarkly_audience/utils.js index 5bbcdfb6a3..6128fdfbfc 100644 --- a/src/cdk/v2/destinations/launchdarkly_audience/utils.js +++ b/src/cdk/v2/destinations/launchdarkly_audience/utils.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const { ACTION_TYPES, IDENTIFIER_KEY, MAX_IDENTIFIERS } = require('./config'); /** @@ -61,7 +61,7 @@ const batchIdentifiersList = (listData) => { ...audienceList.remove.map((item) => ({ ...item, type: 'remove' })), ]; - const chunkedData = _.chunk(combinedList, MAX_IDENTIFIERS); + const chunkedData = lodash.chunk(combinedList, MAX_IDENTIFIERS); // Group the chunks by action type (add/remove) const groupedData = chunkedData.map((chunk) => { diff --git a/src/cdk/v2/handler.ts b/src/cdk/v2/handler.ts index 898e83f7b8..4b3868b85b 100644 --- a/src/cdk/v2/handler.ts +++ b/src/cdk/v2/handler.ts @@ -5,6 +5,7 @@ import { ExecutionBindings, StepOutput, } from '@rudderstack/workflow-engine'; +import { FixMe } from '../../util/types'; import tags from '../../v0/util/tags'; @@ -25,7 +26,7 @@ export function getEmptyExecutionBindings() { return { outputs: {}, context, - setContext: (key: string, value: any) => { + setContext: (key: string, value: FixMe) => { context[key] = value; }, }; @@ -34,7 +35,7 @@ export function getEmptyExecutionBindings() { export async function getWorkflowEngine( destName: string, feature: string, - bindings: Record = {}, + bindings: Record = {}, ) { const destRootDir = getRootPathForDestination(destName); const workflowPath = await getWorkflowPath(destRootDir, feature); @@ -52,7 +53,7 @@ const workflowEnginePromiseMap = new Map(); export function getCachedWorkflowEngine( destName: string, feature: string, - bindings: Record = {}, + bindings: Record = {}, ): WorkflowEngine { // Create a new instance of the engine for the destination if needed // TODO: Use cache to avoid long living engine objects @@ -63,7 +64,7 @@ export function getCachedWorkflowEngine( return workflowEnginePromiseMap[destName][feature]; } -export async function executeWorkflow(workflowEngine: WorkflowEngine, parsedEvent: any) { +export async function executeWorkflow(workflowEngine: WorkflowEngine, parsedEvent: FixMe) { try { const result = await workflowEngine.execute(parsedEvent); // TODO: Handle remaining output scenarios @@ -75,9 +76,9 @@ export async function executeWorkflow(workflowEngine: WorkflowEngine, parsedEven export async function processCdkV2Workflow( destType: string, - parsedEvent: any, + parsedEvent: FixMe, feature: string, - bindings: Record = {}, + bindings: Record = {}, ) { try { const workflowEngine = await getCachedWorkflowEngine(destType, feature, bindings); @@ -90,7 +91,7 @@ export async function processCdkV2Workflow( export function executeStep( workflowEngine: WorkflowEngine, stepName: string, - input: any, + input: FixMe, bindings?: ExecutionBindings, ): Promise { return workflowEngine diff --git a/src/cdk/v2/utils.ts b/src/cdk/v2/utils.ts index 9d46f3dace..3fb26c07e0 100644 --- a/src/cdk/v2/utils.ts +++ b/src/cdk/v2/utils.ts @@ -1,14 +1,11 @@ import path from 'path'; import fs from 'fs/promises'; -import { - WorkflowExecutionError, - WorkflowCreationError, - StatusError, -} from '@rudderstack/workflow-engine'; +import { WorkflowExecutionError, WorkflowCreationError } from '@rudderstack/workflow-engine'; import logger from '../../logger'; import { generateErrorObject } from '../../v0/util'; import { PlatformError } from '../../v0/util/errorTypes'; import tags from '../../v0/util/tags'; +import { CatchErr } from '../../util/types'; const CDK_V2_ROOT_DIR = __dirname; @@ -83,7 +80,7 @@ export function getWorkflowEngineErrorMessage(err) { * @param {*} defTags default stat tags * @returns Error type object */ -export function getErrorInfo(err: any, isProd: boolean, defTags) { +export function getErrorInfo(err: CatchErr, isProd: boolean, defTags) { // Handle various CDK error types const message = isProd ? getWorkflowEngineErrorMessage(err) : err.message; @@ -91,7 +88,7 @@ export function getErrorInfo(err: any, isProd: boolean, defTags) { logger.error(`Error occurred during workflow step execution: ${message}`, err); // Determine the error instance - let errInstance: any = err; + let errInstance: CatchErr = err; if (err.originalError) { errInstance = err.originalError; errInstance.message = message; diff --git a/src/controllers/bulkUpload.ts b/src/controllers/bulkUpload.ts index e4d60b2021..85c4fe6b4f 100644 --- a/src/controllers/bulkUpload.ts +++ b/src/controllers/bulkUpload.ts @@ -1,5 +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'; // TODO: To be refactored and redisgned const getDestFileUploadHandler = (version, dest) => @@ -7,6 +9,7 @@ const getDestFileUploadHandler = (version, dest) => const getPollStatusHandler = (version, dest) => require(`../${version}/destinations/${dest}/poll`); const getJobStatusHandler = (version, dest) => require(`../${version}/destinations/${dest}/fetchJobStatus`); +const ERROR_MESSAGE_PROCESSOR_STRING = 'Error occurred while processing payload.'; const getCommonMetadata = (ctx) => // TODO: Parse information such as @@ -16,12 +19,23 @@ const getCommonMetadata = (ctx) => namespace: 'Unknown', cluster: 'Unknown', }); + +const getReqMetadata = (ctx) => { + try { + const reqBody = ctx.request.body; + return { destType: reqBody?.destType, importId: reqBody?.importId }; + } catch (error) { + // Do nothing + } + return {}; +}; + export const fileUpload = async (ctx) => { logger.debug( 'Native(Bulk-Upload): Request to transformer:: /fileUpload route', JSON.stringify(ctx.request.body), ); - const getReqMetadata = () => { + const getReqMetadataFileUpload = () => { try { const reqBody = ctx.request.body; return { destType: reqBody?.destType }; @@ -42,16 +56,16 @@ export const fileUpload = async (ctx) => { let response; try { response = await destFileUploadHandler.processFileData(ctx.request.body); - } catch (error: any) { + } catch (error: CatchErr) { response = { statusCode: error?.response?.status || error?.status || 400, - error: error.message || 'Error occurred while processing payload.', + error: error.message || ERROR_MESSAGE_PROCESSOR_STRING, metadata: error.response ? error.response.metadata : null, }; errNotificationClient.notify(error, 'File Upload', { ...response, ...getCommonMetadata(ctx), - ...getReqMetadata(), + ...getReqMetadata(ctx), }); } ctx.body = response; @@ -67,15 +81,6 @@ export const pollStatus = async (ctx) => { 'Native(Bulk-Upload): Request to transformer:: /pollStatus route', JSON.stringify(ctx.request.body), ); - const getReqMetadata = () => { - try { - const reqBody = ctx.request.body; - return { destType: reqBody?.destType, importId: reqBody?.importId }; - } catch (error) { - // Do nothing - } - return {}; - }; const { destType } = ctx.request.body; const destFileUploadHandler = getPollStatusHandler('v0', destType.toLowerCase()); @@ -87,15 +92,15 @@ export const pollStatus = async (ctx) => { } try { response = await destFileUploadHandler.processPolling(ctx.request.body); - } catch (error: any) { + } catch (error: CatchErr) { response = { - statusCode: error.response?.status || error?.status || 400, - error: error.message || 'Error occurred while processing payload.', + statusCode: error.response?.status || 400, + error: error.message || ERROR_MESSAGE_PROCESSOR_STRING, }; errNotificationClient.notify(error, 'Poll Status', { ...response, ...getCommonMetadata(ctx), - ...getReqMetadata(), + ...getReqMetadata(ctx), }); } ctx.body = response; @@ -111,15 +116,6 @@ export const getWarnJobStatus = async (ctx) => { 'Native(Bulk-Upload): Request to transformer:: /getWarningJobs route', JSON.stringify(ctx.request.body), ); - const getReqMetadata = () => { - try { - const reqBody = ctx.request.body; - return { destType: reqBody?.destType, importId: reqBody?.importId }; - } catch (error) { - // Do nothing - } - return {}; - }; const { destType } = ctx.request.body; const destFileUploadHandler = getJobStatusHandler('v0', destType.toLowerCase()); @@ -132,15 +128,15 @@ export const getWarnJobStatus = async (ctx) => { let response; try { response = await destFileUploadHandler.processJobStatus(ctx.request.body, 'warn'); - } catch (error: any) { + } catch (error: CatchErr) { response = { statusCode: error.response ? error.response.status : 400, - error: error.message || 'Error occurred while processing payload.', + error: error.message || ERROR_MESSAGE_PROCESSOR_STRING, }; errNotificationClient.notify(error, 'Job Status', { ...response, ...getCommonMetadata(ctx), - ...getReqMetadata(), + ...getReqMetadata(ctx), }); } ctx.body = response; @@ -156,15 +152,6 @@ export const getFailedJobStatus = async (ctx) => { 'Native(Bulk-Upload): Request to transformer:: /getFailedJobs route', JSON.stringify(ctx.request.body), ); - const getReqMetadata = () => { - try { - const reqBody = ctx.request.body; - return { destType: reqBody?.destType, importId: reqBody?.importId }; - } catch (error) { - // Do nothing - } - return {}; - }; const { destType } = ctx.request.body; const destFileUploadHandler = getJobStatusHandler('v0', destType.toLowerCase()); @@ -177,15 +164,15 @@ export const getFailedJobStatus = async (ctx) => { let response; try { response = await destFileUploadHandler.processJobStatus(ctx.request.body, 'fail'); - } catch (error: any) { + } catch (error: CatchErr) { response = { statusCode: error.response ? error.response.status : 400, - error: error.message || 'Error occurred while processing payload.', + error: error.message || ERROR_MESSAGE_PROCESSOR_STRING, }; errNotificationClient.notify(error, 'Job Status', { ...response, ...getCommonMetadata(ctx), - ...getReqMetadata(), + ...getReqMetadata(ctx), }); } ctx.body = response; diff --git a/src/controllers/delivery.ts b/src/controllers/delivery.ts index d9a514d961..5dee091c46 100644 --- a/src/controllers/delivery.ts +++ b/src/controllers/delivery.ts @@ -7,6 +7,7 @@ import ControllerUtility from './util'; import logger from '../logger'; import DestinationPostTransformationService from '../services/destination/postTransformation'; import tags from '../v0/util/tags'; +import { FixMe } from '../util/types'; export default class DeliveryController { public static async deliverToDestination(ctx: Context) { @@ -49,7 +50,7 @@ export default class DeliveryController { }: { deliveryPayload: ProcessorTransformationOutput; destinationRequestPayload: ProcessorTransformationOutput; - } = ctx.request.body as any; + } = ctx.request.body as FixMe; const response = await DeliveryTestService.doTestDelivery( destination, destinationRequestPayload, diff --git a/src/controllers/destination.ts b/src/controllers/destination.ts index a5137ba170..60eac8a56c 100644 --- a/src/controllers/destination.ts +++ b/src/controllers/destination.ts @@ -14,7 +14,7 @@ import stats from '../util/stats'; import logger from '../logger'; import { getIntegrationVersion } from '../util/utils'; import tags from '../v0/util/tags'; -import { DynamicConfigParser } from '../util/dynamicConfigParser'; +import DynamicConfigParser from '../util/dynamicConfigParser'; export default class DestinationController { public static async destinationTransformAtProcessor(ctx: Context) { @@ -41,7 +41,9 @@ export default class DestinationController { ctx, ) as ProcessorTransformationRequest[]; const timestampCorrectEvents = ControllerUtility.handleTimestampInEvents(events); - events = DynamicConfigParser.process(timestampCorrectEvents) as ProcessorTransformationRequest[]; + events = DynamicConfigParser.process( + timestampCorrectEvents, + ) as ProcessorTransformationRequest[]; resplist = await integrationService.doProcessorTransformation( events, destination, @@ -194,7 +196,7 @@ export default class DestinationController { stats.timing('dest_transform_request_latency', startTime, { destination, feature: tags.FEATURES.BATCH, - version:"v0", + version: 'v0', }); return ctx; } diff --git a/src/controllers/eventTest.ts b/src/controllers/eventTest.ts index 6faf047d70..db6fc8cb6f 100644 --- a/src/controllers/eventTest.ts +++ b/src/controllers/eventTest.ts @@ -1,16 +1,18 @@ import { Context } from 'koa'; import EventTesterService from '../services/eventTest/eventTester'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { CatchErr, FixMe } from '../util/types'; export default class EventTestController { private static API_VERSION = '1'; public static async testEvent(ctx: Context) { const { version, destination }: { version: string; destination: string } = ctx.params as any; - const { events }: { events: any } = ctx.request.body as any; + const { events }: { events: FixMe } = ctx.request.body as FixMe; try { const respList = await EventTesterService.testEvent(events, version, destination); ctx.body = respList; - } catch (err: any) { + } catch (err: CatchErr) { // fail-safety error response ctx.body = { error: err.message || JSON.stringify(err), diff --git a/src/controllers/profile.ts b/src/controllers/profile.ts index 5f2dce4fe6..984f4ac645 100644 --- a/src/controllers/profile.ts +++ b/src/controllers/profile.ts @@ -1,5 +1,4 @@ import { Context } from 'koa'; -import MiscService from '../services/misc'; import ProfileService from '../services/profile'; import ControllerUtility from './util'; @@ -30,7 +29,6 @@ export default class ProfileController { }' */ public static async profile(ctx: Context) { - const requestMetadata = MiscService.getRequestMetadata(ctx); const format = ctx.request.query.format as string; const { credBucketDetails } = ctx.request.body as any; const response = await ProfileService.profile(credBucketDetails, format); diff --git a/src/controllers/regulation.ts b/src/controllers/regulation.ts index a36f1826b7..cefe1f748a 100644 --- a/src/controllers/regulation.ts +++ b/src/controllers/regulation.ts @@ -5,6 +5,8 @@ import ServiceSelector from '../helpers/serviceSelector'; import tags from '../v0/util/tags'; import stats from '../util/stats'; import PostTransformationDestinationService from '../services/destination/postTransformation'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { CatchErr } from '../util/types'; // TODO: refactor this class to new format export default class RegulationController { @@ -34,13 +36,14 @@ export default class RegulationController { ); ctx.body = resplist; ctx.status = resplist[0].statusCode; - } catch (error: any) { + } catch (error: CatchErr) { const metaTO = integrationService.getTags( userDeletionRequests[0].destType, 'unknown', 'unknown', tags.FEATURES.USER_DELETION, ); + // eslint-disable-next-line @typescript-eslint/no-unused-vars const errResp = PostTransformationDestinationService.handleUserDeletionFailureEvents( error, metaTO, @@ -50,7 +53,7 @@ export default class RegulationController { } stats.timing('dest_transform_request_latency', startTime, { feature: tags.FEATURES.USER_DELETION, - version:"v0", + version: 'v0', }); return ctx; } diff --git a/src/controllers/source.ts b/src/controllers/source.ts index a413426cc7..efb6dc746e 100644 --- a/src/controllers/source.ts +++ b/src/controllers/source.ts @@ -12,7 +12,7 @@ export default class SourceController { JSON.stringify(ctx.request.body), ); const requestMetadata = MiscService.getRequestMetadata(ctx); - const events = ctx.request.body as Object[]; + const events = ctx.request.body as object[]; const { version, source }: { version: string; source: string } = ctx.params; const integrationService = ServiceSelector.getNativeSourceService(); try { diff --git a/src/controllers/userTransform.ts b/src/controllers/userTransform.ts index cc64f5db1b..1592aa4755 100644 --- a/src/controllers/userTransform.ts +++ b/src/controllers/userTransform.ts @@ -1,7 +1,5 @@ import { Context } from 'koa'; -import MiscService from '../services/misc'; import { ProcessorTransformationRequest, UserTransformationServiceResponse } from '../types/index'; -import { compileUserLibrary } from '../util/ivmFactory'; import UserTransformService from '../services/userTransform'; import logger from '../logger'; import { @@ -17,7 +15,6 @@ export default class UserTransformController { '(User transform - router:/customTransform ):: Request to transformer', JSON.stringify(ctx.request.body), ); - const requestMetadata = MiscService.getRequestMetadata(ctx); const events = ctx.request.body as ProcessorTransformationRequest[]; const processedRespone: UserTransformationServiceResponse = await UserTransformService.transformRoutine(events); diff --git a/src/controllers/util/index.ts b/src/controllers/util/index.ts index 67a314bc75..e2071968d7 100644 --- a/src/controllers/util/index.ts +++ b/src/controllers/util/index.ts @@ -18,9 +18,9 @@ export default class ControllerUtility { `context.${RETL_TIMESTAMP}`, `context.traits.${RETL_TIMESTAMP}`, `traits.${RETL_TIMESTAMP}`, - ...genericFieldMap['timestamp'], + ...genericFieldMap.timestamp, ], - [EventType.TRACK]: [`properties.${RETL_TIMESTAMP}`, ...genericFieldMap['timestamp']], + [EventType.TRACK]: [`properties.${RETL_TIMESTAMP}`, ...genericFieldMap.timestamp], }; private static getCompatibleStatusCode(status: number): number { diff --git a/src/helpers/serviceSelector.ts b/src/helpers/serviceSelector.ts index 99f897cedc..bac1a17c16 100644 --- a/src/helpers/serviceSelector.ts +++ b/src/helpers/serviceSelector.ts @@ -8,6 +8,7 @@ import SourceService from '../interfaces/SourceService'; import NativeIntegrationSourceService from '../services/source/nativeIntegration'; import { PlatformError } from '../v0/util/errorTypes'; import ComparatorService from '../services/comparator'; +import { FixMe } from '../util/types'; export default class ServiceSelector { private static serviceMap: Map = new Map(); @@ -19,23 +20,23 @@ export default class ServiceSelector { [INTEGRATION_SERVICE.NATIVE_SOURCE]: NativeIntegrationSourceService, }; - private static isCdkDestination(destinationDefinitionConfig: Object) { - return !!destinationDefinitionConfig?.['cdkEnabled']; + private static isCdkDestination(destinationDefinitionConfig: FixMe) { + return !!destinationDefinitionConfig?.cdkEnabled; } - private static isCdkV2Destination(destinationDefinitionConfig: Object) { - return Boolean(destinationDefinitionConfig?.['cdkV2Enabled']); + private static isCdkV2Destination(destinationDefinitionConfig: FixMe) { + return Boolean(destinationDefinitionConfig?.cdkV2Enabled); } - private static isComparatorEnabled(destinationDefinitionConfig: Object): boolean { + private static isComparatorEnabled(destinationDefinitionConfig: FixMe): boolean { return ( process.env.COMPARATOR_ENABLED === 'true' && - !!destinationDefinitionConfig['comparisonTestEnabeld'] + !!destinationDefinitionConfig.comparisonTestEnabeld ); } - private static getSecondaryServiceName(destinationDefinitionConfig: Object): string { - return destinationDefinitionConfig['comparisonService']; + private static getSecondaryServiceName(destinationDefinitionConfig: FixMe): string { + return destinationDefinitionConfig.comparisonService; } private static fetchCachedService(serviceType: string) { @@ -65,7 +66,7 @@ export default class ServiceSelector { private static getPrimaryDestinationService( events: ProcessorTransformationRequest[] | RouterTransformationRequestData[], ): DestinationService { - const destinationDefinitionConfig: Object = + const destinationDefinitionConfig: FixMe = events[0]?.destination?.DestinationDefinition?.Config; if (this.isCdkDestination(destinationDefinitionConfig)) { return this.fetchCachedService(INTEGRATION_SERVICE.CDK_V1_DEST); @@ -76,6 +77,7 @@ export default class ServiceSelector { return this.fetchCachedService(INTEGRATION_SERVICE.NATIVE_DEST); } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public static getSourceService(arg: unknown) { // Implement source event based descision logic for selecting service } diff --git a/src/interfaces/DestinationService.ts b/src/interfaces/DestinationService.ts index b1cae047f8..123da35292 100644 --- a/src/interfaces/DestinationService.ts +++ b/src/interfaces/DestinationService.ts @@ -26,27 +26,27 @@ export default interface DestinationService { events: ProcessorTransformationRequest[], destinationType: string, version: string, - requestMetadata: Object, + requestMetadata: NonNullable, ): Promise; doRouterTransformation( events: RouterTransformationRequestData[], destinationType: string, version: string, - requestMetadata: Object, + requestMetadata: NonNullable, ): Promise; doBatchTransformation( events: RouterTransformationRequestData[], destinationType: string, version: string, - requestMetadata: Object, + requestMetadata: NonNullable, ): RouterTransformationResponse[]; deliver( event: ProcessorTransformationOutput, destinationType: string, - requestMetadata: Object, + requestMetadata: NonNullable, ): Promise; processUserDeletion( diff --git a/src/interfaces/SourceService.ts b/src/interfaces/SourceService.ts index 28d72ee990..99b29f095b 100644 --- a/src/interfaces/SourceService.ts +++ b/src/interfaces/SourceService.ts @@ -4,9 +4,9 @@ export default interface SourceService { getTags(): MetaTransferObject; sourceTransformRoutine( - sourceEvents: Object[], + sourceEvents: NonNullable[], sourceType: string, version: string, - requestMetadata: Object, + requestMetadata: NonNullable, ): Promise; } diff --git a/src/legacy/router.js b/src/legacy/router.js index 361823a185..a8c2b49a1a 100644 --- a/src/legacy/router.js +++ b/src/legacy/router.js @@ -4,7 +4,7 @@ /* eslint-disable import/no-dynamic-require */ /* eslint-disable global-require */ const Router = require('@koa/router'); -const _ = require('lodash'); +const lodash = require('lodash'); const fs = require('fs'); const path = require('path'); const logger = require('../logger'); @@ -88,7 +88,7 @@ const functionsEnabled = () => { return areFunctionsEnabled === 1; }; -// eslint-disable-next-line no-unused-vars +// eslint-disable-next-line @typescript-eslint/no-unused-vars function getCommonMetadata(ctx) { // TODO: Parse information such as // cluster, namespace, etc information @@ -358,7 +358,7 @@ async function routerHandleDest(ctx) { ctx.body = `${destType} doesn't support router transform`; return null; } - const allDestEvents = _.groupBy(input, (event) => event.destination.ID); + const allDestEvents = lodash.groupBy(input, (event) => event.destination.ID); await Promise.all( Object.values(allDestEvents).map(async (destInputArray) => { const newDestInputArray = processDynamicConfig(destInputArray, 'router'); @@ -389,7 +389,10 @@ async function routerHandleDest(ctx) { // Add default stat tags respEvents - .filter((resp) => 'error' in resp && _.isObject(resp.statTags) && !_.isEmpty(resp.statTags)) + .filter( + (resp) => + 'error' in resp && lodash.isObject(resp.statTags) && !lodash.isEmpty(resp.statTags), + ) .forEach((resp) => { // eslint-disable-next-line no-param-reassign resp.statTags = { @@ -526,13 +529,13 @@ if (startDestTransformer) { }); let groupedEvents; if (processSessions) { - groupedEvents = _.groupBy(events, (event) => { + groupedEvents = lodash.groupBy(events, (event) => { // to have the backward-compatibility and being extra careful. We need to remove this (message.anonymousId) in next release. const rudderId = event.metadata.rudderId || event.message.anonymousId; return `${event.destination.ID}_${event.metadata.sourceId}_${rudderId}`; }); } else { - groupedEvents = _.groupBy( + groupedEvents = lodash.groupBy( events, (event) => `${event.metadata.destinationId}_${event.metadata.sourceId}`, ); @@ -587,7 +590,7 @@ if (startDestTransformer) { return { statusCode: 400, error: ev.error, - metadata: _.isEmpty(ev.metadata) ? commonMetadata : ev.metadata, + metadata: lodash.isEmpty(ev.metadata) ? commonMetadata : ev.metadata, }; } if (!isNonFuncObject(ev.transformedEvent)) { @@ -596,12 +599,12 @@ if (startDestTransformer) { error: `returned event in events from user transformation is not an object. transformationVersionId:${transformationVersionId} and returned event: ${JSON.stringify( ev.transformedEvent, )}`, - metadata: _.isEmpty(ev.metadata) ? commonMetadata : ev.metadata, + metadata: lodash.isEmpty(ev.metadata) ? commonMetadata : ev.metadata, }; } return { output: ev.transformedEvent, - metadata: _.isEmpty(ev.metadata) ? commonMetadata : ev.metadata, + metadata: lodash.isEmpty(ev.metadata) ? commonMetadata : ev.metadata, statusCode: 200, }; }), @@ -995,7 +998,7 @@ const batchHandler = (ctx) => { ctx.body = `${destType} doesn't support batching`; return null; } - const allDestEvents = _.groupBy(input, (event) => event.destination.ID); + const allDestEvents = lodash.groupBy(input, (event) => event.destination.ID); const response = { batchedRequests: [], errors: [] }; Object.entries(allDestEvents).forEach(([, destEvents]) => { diff --git a/src/middlewares/routeActivation.ts b/src/middlewares/routeActivation.ts index bf457b2faa..dfdaef964e 100644 --- a/src/middlewares/routeActivation.ts +++ b/src/middlewares/routeActivation.ts @@ -78,6 +78,7 @@ export default class RouteActivationMiddleware { ); } + // eslint-disable-next-line sonarjs/no-identical-functions public static destinationBatchFilter(ctx: Context, next: Next) { const routerRequest = ctx.request.body as RouterTransformationRequest; const destination = routerRequest.destType; diff --git a/src/routes/bulkUpload.ts b/src/routes/bulkUpload.ts index 386cf78c36..e7aaf897c8 100644 --- a/src/routes/bulkUpload.ts +++ b/src/routes/bulkUpload.ts @@ -12,4 +12,6 @@ router.post('/fileUpload', fileUpload); router.post('/pollStatus', pollStatus); router.post('/getFailedJobs', getFailedJobStatus); router.post('/getWarningJobs', getWarnJobStatus); -export const bulkUploadRoutes = router.routes(); +const bulkUploadRoutes = router.routes(); + +export default bulkUploadRoutes; \ No newline at end of file diff --git a/src/routes/delivery.ts b/src/routes/delivery.ts index de4ec65934..141700fd9f 100644 --- a/src/routes/delivery.ts +++ b/src/routes/delivery.ts @@ -17,4 +17,5 @@ router.post( DeliveryController.testDestinationDelivery, ); -export const proxyRoutes = router.routes(); +const proxyRoutes = router.routes(); +export default proxyRoutes; diff --git a/src/routes/destination.ts b/src/routes/destination.ts index bed2a1af20..ee19fd1246 100644 --- a/src/routes/destination.ts +++ b/src/routes/destination.ts @@ -26,4 +26,5 @@ router.post( router.post('/deleteUsers', RegulationController.deleteUsers); -export const destinationRoutes = router.routes(); +const destinationRoutes = router.routes(); +export default destinationRoutes; \ No newline at end of file diff --git a/src/routes/index.ts b/src/routes/index.ts index cfeb4db9ea..d77584bea3 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -4,20 +4,23 @@ import { existsSync, readFileSync } from 'fs'; import dotenv from 'dotenv'; import { koaSwagger } from 'koa2-swagger-ui'; import path from 'path'; -import { bulkUploadRoutes } from './bulkUpload'; -import { proxyRoutes } from './delivery'; -import { destinationRoutes } from './destination'; -import { miscRoutes } from './misc'; -import { sourceRoutes } from './source'; -import { testEventRoutes } from './testEvents'; +import userTransformRoutes from './userTransform'; +import bulkUploadRoutes from './bulkUpload'; +import proxyRoutes from './delivery'; +import destinationRoutes from './destination'; +import miscRoutes from './misc'; +import sourceRoutes from './source'; +import testEventRoutes from './testEvents'; import { trackingPlanRoutes } from './trackingPlan'; -import { userTransformRoutes } from './userTransform'; import logger from '../logger'; import { isNotEmpty } from '../v0/util'; dotenv.config(); -export function applicationRoutes(app: Koa) { +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const enableSwagger = process.env.ENABLE_SWAGGER === 'true'; + +export function applicationRoutes(app: Koa) { app.use(bulkUploadRoutes); app.use(proxyRoutes); app.use(destinationRoutes); @@ -28,7 +31,7 @@ export function applicationRoutes(app: Koa) { app.use(userTransformRoutes); } -export function addSwaggerRoutes(app: Koa) { +export function addSwaggerRoutes(app: Koa) { // Ading swagger routes, check swagger docs in http://localhost:9090/docs try { diff --git a/src/routes/misc.ts b/src/routes/misc.ts index 3e30b9dd39..750c1194dd 100644 --- a/src/routes/misc.ts +++ b/src/routes/misc.ts @@ -13,4 +13,5 @@ router.get('/features', MiscController.features); router.get('/debug/pprof/profile', MiscController.getCPUProfile); router.get('/debug/pprof/heap', MiscController.getHeapProfile); -export const miscRoutes = router.routes(); +const miscRoutes = router.routes(); +export default miscRoutes; diff --git a/src/routes/source.ts b/src/routes/source.ts index 675e2286ce..ade26c8700 100644 --- a/src/routes/source.ts +++ b/src/routes/source.ts @@ -11,4 +11,5 @@ router.post( SourceController.sourceTransform, ); -export const sourceRoutes = router.routes(); +const sourceRoutes = router.routes(); +export default sourceRoutes; diff --git a/src/routes/testEvents.ts b/src/routes/testEvents.ts index cbfd78f3ec..f842887b91 100644 --- a/src/routes/testEvents.ts +++ b/src/routes/testEvents.ts @@ -6,4 +6,5 @@ const router = new Router({ prefix: '/test-router' }); router.post('/:version/:destination', EventTestController.testEvent); router.get('/:version/health', EventTestController.status); -export const testEventRoutes = router.routes(); +const testEventRoutes = router.routes(); +export default testEventRoutes; \ No newline at end of file diff --git a/src/routes/userTransform.ts b/src/routes/userTransform.ts index 2f6dcd417c..2727d9ef05 100644 --- a/src/routes/userTransform.ts +++ b/src/routes/userTransform.ts @@ -30,4 +30,5 @@ router.post( UserTransformController.extractLibhandle, ); -export const userTransformRoutes = router.routes(); +const userTransformRoutes = router.routes(); +export default userTransformRoutes; \ No newline at end of file diff --git a/src/services/comparator.ts b/src/services/comparator.ts index ae6e1bcf57..3495b7bbfd 100644 --- a/src/services/comparator.ts +++ b/src/services/comparator.ts @@ -1,3 +1,4 @@ +/* eslint-disable class-methods-use-this */ import IntegrationDestinationService from '../interfaces/DestinationService'; import { DeliveryResponse, @@ -62,7 +63,7 @@ export default class ComparatorService implements IntegrationDestinationService } private getTestThreshold(destination: Destination) { - return destination.DestinationDefinition?.Config['camparisonTestThreshold'] || 0; + return destination.DestinationDefinition?.Config?.camparisonTestThreshold || 0; } private getComparisonLogs( @@ -81,6 +82,7 @@ export default class ComparatorService implements IntegrationDestinationService return; } + // eslint-disable-next-line no-restricted-syntax for (const [index, element] of primaryResplist.entries()) { const objectDiff = CommonUtils.objectDiff(element, secondaryResplist[index]); if (Object.keys(objectDiff).length > 0) { @@ -129,6 +131,7 @@ export default class ComparatorService implements IntegrationDestinationService } let hasComparisonFailed = false; + // eslint-disable-next-line no-restricted-syntax for (const [index, element] of primaryResplist.entries()) { const objectDiff = CommonUtils.objectDiff(element, secondaryResplist[index]); if (Object.keys(objectDiff).length > 0) { @@ -156,7 +159,7 @@ export default class ComparatorService implements IntegrationDestinationService secondaryServiceCallback: any, destinationType: string, version: string, - requestMetadata: Object, + requestMetadata: NonNullable, feature: string, destinationId: string, ): Promise { @@ -194,7 +197,7 @@ export default class ComparatorService implements IntegrationDestinationService events: ProcessorTransformationRequest[], destinationType: string, version: string, - requestMetadata: Object, + requestMetadata: NonNullable, ): Promise { const destinationId = events[0].destination.ID; const primaryStartTime = process.hrtime(); @@ -252,7 +255,7 @@ export default class ComparatorService implements IntegrationDestinationService events: RouterTransformationRequestData[], destinationType: string, version: string, - requestMetadata: Object, + requestMetadata: NonNullable, ): Promise { const destinationId = events[0].destination.ID; const primaryStartTime = process.hrtime(); @@ -310,7 +313,7 @@ export default class ComparatorService implements IntegrationDestinationService events: RouterTransformationRequestData[], destinationType: string, version: string, - requestMetadata: Object, + requestMetadata: NonNullable, ): RouterTransformationResponse[] { const destinationId = events[0].destination.ID; const primaryStartTime = process.hrtime(); @@ -367,7 +370,7 @@ export default class ComparatorService implements IntegrationDestinationService public async deliver( event: ProcessorTransformationOutput, destinationType: string, - requestMetadata: Object, + requestMetadata: NonNullable, ): Promise { const primaryResplist = await this.primaryService.deliver( event, diff --git a/src/services/delivertTest/deliveryTest.ts b/src/services/delivertTest/deliveryTest.ts index 051b67b568..e5713073c1 100644 --- a/src/services/delivertTest/deliveryTest.ts +++ b/src/services/delivertTest/deliveryTest.ts @@ -29,6 +29,7 @@ export default class DeliveryTestService { // This is to make sure we encode `~` in the data coming from the router. // The data coming from the router is already a query parameter string const routerDataVal = new URLSearchParams(routerDestReqPayload.data); + // eslint-disable-next-line no-param-reassign routerDestReqPayload.data = routerDataVal; const proxyDataVal = new URLSearchParams(); diff --git a/src/services/destination/cdkV1Integration.ts b/src/services/destination/cdkV1Integration.ts index 44842fdddb..a016665afb 100644 --- a/src/services/destination/cdkV1Integration.ts +++ b/src/services/destination/cdkV1Integration.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import { ConfigFactory, Executor, RudderBaseConfig } from 'rudder-transformer-cdk'; import path from 'path'; import IntegrationDestinationService from '../../interfaces/DestinationService'; @@ -17,6 +18,7 @@ import { TransformationError } from '../../v0/util/errorTypes'; import DestinationPostTransformationService from './postTransformation'; import tags from '../../v0/util/tags'; import { getErrorInfo } from '../../cdk/v1/handler'; +import { CatchErr } from '../../util/types'; export default class CDKV1DestinationService implements IntegrationDestinationService { public init() { @@ -63,7 +65,7 @@ export default class CDKV1DestinationService implements IntegrationDestinationSe events: ProcessorTransformationRequest[], destinationType: string, _version: string, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): Promise { const tfConfig = await ConfigFactory.getConfig(destinationType); const respList: ProcessorTransformationResponse[][] = await Promise.all( @@ -76,7 +78,7 @@ export default class CDKV1DestinationService implements IntegrationDestinationSe transformedPayloads, undefined, ); - } catch (error: any) { + } catch (error: CatchErr) { const metaTO = this.getTags( destinationType, event.metadata.destinationId, @@ -100,7 +102,7 @@ export default class CDKV1DestinationService implements IntegrationDestinationSe _events: RouterTransformationRequestData[], _destinationType: string, _version: string, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): Promise { throw new TransformationError('CDKV1 Does not Implement Router Transform Routine'); } @@ -109,7 +111,7 @@ export default class CDKV1DestinationService implements IntegrationDestinationSe _events: RouterTransformationRequestData[], _destinationType: string, _version: any, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): RouterTransformationResponse[] { throw new TransformationError('CDKV1 Does not Implement Batch Transform Routine'); } @@ -117,7 +119,7 @@ export default class CDKV1DestinationService implements IntegrationDestinationSe public deliver( _event: ProcessorTransformationOutput, _destinationType: string, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): Promise { throw new TransformationError('CDV1 Does not Implement Delivery Routine'); } diff --git a/src/services/destination/cdkV2Integration.ts b/src/services/destination/cdkV2Integration.ts index 04a2dcb799..b4c0a15e87 100644 --- a/src/services/destination/cdkV2Integration.ts +++ b/src/services/destination/cdkV2Integration.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable class-methods-use-this */ import groupBy from 'lodash/groupBy'; import { processCdkV2Workflow } from '../../cdk/v2/handler'; import IntegrationDestinationService from '../../interfaces/DestinationService'; @@ -17,6 +19,7 @@ import { TransformationError } from '../../v0/util/errorTypes'; import tags from '../../v0/util/tags'; import DestinationPostTransformationService from './postTransformation'; import stats from '../../util/stats'; +import { CatchErr } from '../../util/types'; export default class CDKV2DestinationService implements IntegrationDestinationService { public init() {} @@ -49,7 +52,7 @@ export default class CDKV2DestinationService implements IntegrationDestinationSe events: ProcessorTransformationRequest[], destinationType: string, _version: string, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): Promise { // TODO: Change the promise type const respList: ProcessorTransformationResponse[][] = await Promise.all( @@ -78,7 +81,7 @@ export default class CDKV2DestinationService implements IntegrationDestinationSe transformedPayloads, undefined, ); - } catch (error: any) { + } catch (error: CatchErr) { const metaTo = this.getTags( destinationType, event.metadata.destinationId, @@ -105,9 +108,9 @@ export default class CDKV2DestinationService implements IntegrationDestinationSe events: RouterTransformationRequestData[], destinationType: string, _version: string, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): Promise { - const allDestEvents: Object = groupBy( + const allDestEvents: object = groupBy( events, (ev: RouterTransformationRequestData) => ev.destination?.ID, ); @@ -131,7 +134,7 @@ export default class CDKV2DestinationService implements IntegrationDestinationSe tags.IMPLEMENTATIONS.CDK_V2, destinationType.toUpperCase(), ); - } catch (error: any) { + } catch (error: CatchErr) { metaTo.metadatas = destInputArray.map((input) => input.metadata); const erroredResp = DestinationPostTransformationService.handleRouterTransformFailureEvents( @@ -150,7 +153,7 @@ export default class CDKV2DestinationService implements IntegrationDestinationSe _events: RouterTransformationRequestData[], _destinationType: string, _version: string, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): RouterTransformationResponse[] { throw new TransformationError('CDKV2 Does not Implement Batch Transform Routine'); } @@ -158,7 +161,7 @@ export default class CDKV2DestinationService implements IntegrationDestinationSe public deliver( _event: ProcessorTransformationOutput, _destinationType: string, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): Promise { throw new TransformationError('CDKV2 Does not Implement Delivery Routine'); } diff --git a/src/services/destination/nativeIntegration.ts b/src/services/destination/nativeIntegration.ts index 8cec0f573f..49fb806094 100644 --- a/src/services/destination/nativeIntegration.ts +++ b/src/services/destination/nativeIntegration.ts @@ -1,5 +1,6 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import groupBy from 'lodash/groupBy'; -import cloneDeep from 'lodash/cloneDeep' +import cloneDeep from 'lodash/cloneDeep'; import IntegrationDestinationService from '../../interfaces/DestinationService'; import { DeliveryResponse, @@ -49,7 +50,7 @@ export default class NativeIntegrationDestinationService implements IntegrationD events: ProcessorTransformationRequest[], destinationType: string, version: string, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): Promise { const destHandler = FetchHandler.getDestHandler(destinationType, version); const respList: ProcessorTransformationResponse[][] = await Promise.all( @@ -87,10 +88,10 @@ export default class NativeIntegrationDestinationService implements IntegrationD events: RouterTransformationRequestData[], destinationType: string, version: string, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): Promise { const destHandler = FetchHandler.getDestHandler(destinationType, version); - const allDestEvents: Object = groupBy( + const allDestEvents: NonNullable = groupBy( events, (ev: RouterTransformationRequestData) => ev.destination?.ID, ); @@ -131,13 +132,13 @@ export default class NativeIntegrationDestinationService implements IntegrationD events: RouterTransformationRequestData[], destinationType: string, version: any, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): RouterTransformationResponse[] { const destHandler = FetchHandler.getDestHandler(destinationType, version); if (!destHandler.batch) { throw new Error(`${destinationType} does not implement batch`); } - const allDestEvents: Object = groupBy( + const allDestEvents: NonNullable = groupBy( events, (ev: RouterTransformationRequestData) => ev.destination?.ID, ); @@ -167,7 +168,7 @@ export default class NativeIntegrationDestinationService implements IntegrationD public async deliver( destinationRequest: ProcessorTransformationOutput, destinationType: string, - _requestMetadata: Object, + _requestMetadata: NonNullable, ): Promise { try { const networkHandler = networkHandlerFactory.getNetworkHandler(destinationType); diff --git a/src/services/destination/postTransformation.ts b/src/services/destination/postTransformation.ts index 9e04f97fac..090e39b059 100644 --- a/src/services/destination/postTransformation.ts +++ b/src/services/destination/postTransformation.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-param-reassign */ import cloneDeep from 'lodash/cloneDeep'; import isObject from 'lodash/isObject'; import isEmpty from 'lodash/isEmpty'; @@ -47,7 +48,7 @@ export default class DestinationPostTransformationService { } public static handleProcessorTransformFailureEvents( - error: Object, + error: NonNullable, metaTo: MetaTransferObject, ): ProcessorTransformationResponse { const errObj = generateErrorObject(error, metaTo.errorDetails); @@ -105,7 +106,7 @@ export default class DestinationPostTransformationService { } public static handleRouterTransformFailureEvents( - error: Object, + error: NonNullable, metaTo: MetaTransferObject, ): RouterTransformationResponse { const errObj = generateErrorObject(error, metaTo.errorDetails); @@ -122,7 +123,7 @@ export default class DestinationPostTransformationService { } public static handleBatchTransformFailureEvents( - error: Object, + error: NonNullable, metaTo: MetaTransferObject, ): RouterTransformationResponse { const errObj = generateErrorObject(error, metaTo.errorDetails); @@ -138,7 +139,7 @@ export default class DestinationPostTransformationService { } public static handleDeliveryFailureEvents( - error: Object, + error: NonNullable, metaTo: MetaTransferObject, ): DeliveryResponse { const errObj = generateErrorObject(error, metaTo.errorDetails, false); @@ -156,7 +157,7 @@ export default class DestinationPostTransformationService { } public static handleUserDeletionFailureEvents( - error: Object, + error: NonNullable, metaTo: MetaTransferObject, ): UserDeletionResponse { const errObj = generateErrorObject(error, metaTo.errorDetails, false); diff --git a/src/services/destination/preTransformation.ts b/src/services/destination/preTransformation.ts index 61ca20f7fe..dd5579b7b9 100644 --- a/src/services/destination/preTransformation.ts +++ b/src/services/destination/preTransformation.ts @@ -1,6 +1,5 @@ import { Context } from 'koa'; import { ProcessorTransformationRequest, RouterTransformationRequestData } from '../../types/index'; -import { DynamicConfigParser } from '../../util/dynamicConfigParser'; export default class PreTransformationDestinationService { public static preProcess( @@ -8,12 +7,13 @@ export default class PreTransformationDestinationService { ctx: Context, ) { const reqParams = ctx.request.query; - events = events.map( + const eventsProcessed = events.map( (event: ProcessorTransformationRequest | RouterTransformationRequestData) => { + // eslint-disable-next-line no-param-reassign event.request = { query: reqParams }; return event; }, ); - return events; + return eventsProcessed; } } diff --git a/src/services/errorReporting.ts b/src/services/errorReporting.ts index ba0bd9b21c..2d3c84ff30 100644 --- a/src/services/errorReporting.ts +++ b/src/services/errorReporting.ts @@ -1,7 +1,7 @@ import { client } from '../util/errorNotifier'; export default class ErrorReportingService { - public static reportError(error: Object, context: string, errorResp: Object) { + public static reportError(error: NonNullable, context: string, errorResp: object) { client.notify(error, context, { ...errorResp, }); diff --git a/src/services/eventTest/eventTester.ts b/src/services/eventTest/eventTester.ts index 3055b947af..d4f30fff78 100644 --- a/src/services/eventTest/eventTester.ts +++ b/src/services/eventTest/eventTester.ts @@ -1,7 +1,9 @@ import { sendToDestination, userTransformHandler } from '../../routerUtils'; +import { FixMe } from '../../util/types'; export default class EventTesterService { private static getDestHandler(version, destination) { + // eslint-disable-next-line global-require, import/no-dynamic-require return require(`../../${version}/destinations/${destination}/transform`); } @@ -9,7 +11,7 @@ export default class EventTesterService { function capitalize(s) { return s === 'id' ? s.toUpperCase() : s.charAt(0).toUpperCase() + s.slice(1); } - const transformedObj = {}; + let transformedObj: FixMe; const { destinationDefinition } = dest; Object.keys(dest).forEach((key) => { transformedObj[capitalize(key)] = dest[key]; @@ -19,7 +21,7 @@ export default class EventTesterService { Object.keys(destinationDefinition).forEach((key) => { destDef[capitalize(key)] = destinationDefinition[key]; }); - transformedObj['DestinationDefinition'] = destDef; + transformedObj.DestinationDefinition = destDef; return transformedObj; } @@ -52,19 +54,19 @@ export default class EventTesterService { libraries, }; - let response = {}; + let response: FixMe; let errorFound = false; if (stage.user_transform) { let librariesVersionIDs = []; - if (event.libraries) { + if (libraries) { librariesVersionIDs = events[0].libraries.map((library) => library.versionId); } const transformationVersionId = ev.destination && - ev.destination['Transformations'] && - ev.destination['Transformations'][0] && - ev.destination['Transformations'][0].versionId; + ev.destination.Transformations && + ev.destination.Transformations[0] && + ev.destination.Transformations[0].versionId; if (transformationVersionId) { try { @@ -78,16 +80,16 @@ export default class EventTesterService { throw new Error(userTransformedEvent.error); } - response['user_transformed_payload'] = userTransformedEvent.transformedEvent; + response.user_transformed_payload = userTransformedEvent.transformedEvent; ev.message = userTransformedEvent.transformedEvent; } catch (err: any) { errorFound = true; - response['user_transformed_payload'] = { + response.user_transformed_payload = { error: err.message || JSON.stringify(err), }; } } else { - response['user_transformed_payload'] = { + response.user_transformed_payload = { error: 'Transformation VersionID not found', }; } @@ -99,18 +101,18 @@ export default class EventTesterService { const desthandler = this.getDestHandler(version, dest); const transformedOutput = await desthandler.process(ev); if (Array.isArray(transformedOutput)) { - response['dest_transformed_payload'] = transformedOutput; + response.dest_transformed_payload = transformedOutput; } else { - response['dest_transformed_payload'] = [transformedOutput]; + response.dest_transformed_payload = [transformedOutput]; } } catch (err: any) { errorFound = true; - response['dest_transformed_payload'] = { + response.dest_transformed_payload = { error: err.message || JSON.stringify(err), }; } } else { - response['dest_transformed_payload'] = { + response.dest_transformed_payload = { error: 'error encountered in user_transformation stage. Aborting.', }; } @@ -119,27 +121,27 @@ export default class EventTesterService { if (stage.dest_transform && stage.send_to_destination) { // send event to destination only after transformation if (!errorFound) { - const destResponses: any[] = []; - const destResponseStatuses: any[] = []; + const destResponses: FixMe[] = []; + const destResponseStatuses: FixMe[] = []; - const transformedPayloads = response['dest_transformed_payload']; + const transformedPayloads = response.dest_transformed_payload; // eslint-disable-next-line no-restricted-syntax for (const payload of transformedPayloads) { // eslint-disable-next-line no-await-in-loop const parsedResponse = await sendToDestination(dest, payload); let contentType = ''; - let response = ''; + let responsePayload = ''; if (parsedResponse.headers) { contentType = parsedResponse.headers['content-type']; if (this.isSupportedContentType(contentType)) { - response = parsedResponse.response; + responsePayload = parsedResponse.response; } } else if (parsedResponse.networkFailure) { - response = parsedResponse.response; + responsePayload = parsedResponse.response; } - destResponses.push(response); + destResponses.push(responsePayload); destResponseStatuses.push(parsedResponse.status); // TODO: Use updated handleResponseTransform function @@ -162,7 +164,7 @@ export default class EventTesterService { destination_response_status: destResponseStatuses, }; } else { - response['destination_response'] = { + response.destination_response = { error: 'error encountered in dest_transformation stage. Aborting.', }; } diff --git a/src/services/misc.ts b/src/services/misc.ts index 2805f58584..fe38b5b2bd 100644 --- a/src/services/misc.ts +++ b/src/services/misc.ts @@ -1,9 +1,10 @@ +/* eslint-disable global-require, import/no-dynamic-require */ import fs from 'fs'; import path from 'path'; import { Context } from 'koa'; import { DestHandlerMap } from '../constants/destinationCanonicalNames'; import { Metadata } from '../types'; -import { getCPUProfile, getHeapProfile, } from '../middleware'; +import { getCPUProfile, getHeapProfile } from '../middleware'; export default class MiscService { public static getDestHandler(dest: string, version: string) { @@ -21,6 +22,7 @@ export default class MiscService { return require(`../${version}/destinations/${dest}/deleteUsers`); } + // eslint-disable-next-line @typescript-eslint/no-unused-vars public static getRequestMetadata(ctx: Context) { // TODO: Parse information such as // cluster, namespace, etc information @@ -69,6 +71,6 @@ export default class MiscService { } public static async getHeapProfile() { - return getHeapProfile() + return getHeapProfile(); } } diff --git a/src/services/profile.ts b/src/services/profile.ts index 5f02b5c2fa..4d7a7104e7 100644 --- a/src/services/profile.ts +++ b/src/services/profile.ts @@ -7,6 +7,8 @@ import v8 from 'v8'; import pprof, { heap } from '@datadog/pprof'; import { promisify } from 'util'; import logger from '../logger'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { CatchErr } from '../util/types'; // The average number of bytes between samples. // 512*1024 = 524288 @@ -22,6 +24,7 @@ heap.start(intervalBytes, stackDepth); export default class ProfileService { private static async promisifiedRead(readable: any) { + // eslint-disable-next-line no-new new Promise((resolve, reject) => { // Instructions for reading data const chunks: any[] = []; @@ -81,11 +84,13 @@ export default class ProfileService { const shouldGenerateLocally = !credBucketDetails.sendTo; logger.info('Before Heapsnapshot converted into a readable stream'); let fileName = ''; - let format = 'pb.gz'; + // eslint-disable-next-line no-param-reassign + format = 'pb.gz'; let profile; if (format && format === 'v8') { const readable = v8.getHeapSnapshot(); snapshotReadableStream = await this.promisifiedRead(readable); + // eslint-disable-next-line no-param-reassign format = 'heapsnapshot'; } else { profile = heap.profile(); @@ -99,7 +104,7 @@ export default class ProfileService { logger.info('Before pipeline'); try { await writeFileProm(fileName, snapshotReadableStream); - } catch (error: any) { + } catch (error: CatchErr) { logger.error('Error occurred:', error); throw new Error(error); } @@ -123,7 +128,7 @@ export default class ProfileService { credBucketDetails.sendTo ? credBucketDetails.sendTo : 'locally' } with filename: ${fileName}`, }; - } catch (error: any) { + } catch (error: CatchErr) { logger.error(error); return { success: false, diff --git a/src/services/source/nativeIntegration.ts b/src/services/source/nativeIntegration.ts index e654940fec..f29d68d054 100644 --- a/src/services/source/nativeIntegration.ts +++ b/src/services/source/nativeIntegration.ts @@ -5,6 +5,7 @@ import { RudderMessage, SourceTransformationResponse, } from '../../types/index'; +import { FixMe } from '../../util/types'; import PostTransformationServiceSource from './postTransformation'; import FetchHandler from '../../helpers/fetchHandlers'; import tags from '../../v0/util/tags'; @@ -25,19 +26,20 @@ export default class NativeIntegrationSourceService implements IntegrationSource } public async sourceTransformRoutine( - sourceEvents: Object[], + sourceEvents: NonNullable[], sourceType: string, version: string, - _requestMetadata: Object, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _requestMetadata: NonNullable, ): Promise { const sourceHandler = FetchHandler.getSourceHandler(sourceType, version); - const respList: SourceTransformationResponse[] = await Promise.all( + const respList: SourceTransformationResponse[] = await Promise.all( sourceEvents.map(async (sourceEvent) => { try { const respEvents: RudderMessage | RudderMessage[] | SourceTransformationResponse = await sourceHandler.process(sourceEvent); return PostTransformationServiceSource.handleSuccessEventsSource(respEvents); - } catch (error: any) { + } catch (error: FixMe) { const metaTO = this.getTags(); stats.increment('source_transform_errors', { sourceType, diff --git a/src/services/source/postTransformation.ts b/src/services/source/postTransformation.ts index 603f1b1c0a..f732cac3a7 100644 --- a/src/services/source/postTransformation.ts +++ b/src/services/source/postTransformation.ts @@ -1,10 +1,11 @@ import { MetaTransferObject, RudderMessage, SourceTransformationResponse } from '../../types/index'; +import { CatchErr } from '../../util/types'; import { generateErrorObject } from '../../v0/util'; import ErrorReportingService from '../errorReporting'; export default class PostTransformationSourceService { public static handleFailureEventsSource( - error: Object, + error: CatchErr, metaTO: MetaTransferObject, ): SourceTransformationResponse { const errObj = generateErrorObject(error, metaTO.errorDetails); diff --git a/src/services/userTransform.ts b/src/services/userTransform.ts index 74d9203188..14c6d9b9aa 100644 --- a/src/services/userTransform.ts +++ b/src/services/userTransform.ts @@ -8,20 +8,24 @@ import { UserTransformationResponse, UserTransformationServiceResponse, } from '../types/index'; -import { RespStatusError, RetryRequestError, extractStackTraceUptoLastSubstringMatch } from '../util/utils'; +import { + RespStatusError, + RetryRequestError, + extractStackTraceUptoLastSubstringMatch, +} from '../util/utils'; import { getMetadata, isNonFuncObject } from '../v0/util'; import { SUPPORTED_FUNC_NAMES } from '../util/ivmFactory'; import logger from '../logger'; import stats from '../util/stats'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { CatchErr, FixMe } from '../util/types'; export default class UserTransformService { public static async transformRoutine( events: ProcessorTransformationRequest[], ): Promise { - - const startTime = new Date(); let retryStatus = 200; - const groupedEvents: Object = groupBy( + const groupedEvents: NonNullable = groupBy( events, (event: ProcessorTransformationRequest) => `${event.metadata.destinationId}_${event.metadata.sourceId}`, @@ -29,14 +33,14 @@ export default class UserTransformService { stats.counter('user_transform_function_group_size', Object.entries(groupedEvents).length, {}); stats.histogram('user_transform_input_events', events.length, {}); - const transformedEvents: any[] = []; - let librariesVersionIDs: any[] = []; + const transformedEvents: FixMe[] = []; + let librariesVersionIDs: FixMe[] = []; if (events[0].libraries) { librariesVersionIDs = events[0].libraries.map( (library: UserTransformationLibrary) => library.VersionID, ); } - const responses = await Promise.all( + const responses = await Promise.all( Object.entries(groupedEvents).map(async ([dest, destEvents]) => { logger.debug(`dest: ${dest}`); const eventsToProcess = destEvents as ProcessorTransformationRequest[]; @@ -83,7 +87,7 @@ export default class UserTransformService { statusCode: 400, error: ev.error, metadata: isEmpty(ev.metadata) ? commonMetadata : ev.metadata, - } as ProcessorTransformationResponse; + } as unknown as ProcessorTransformationResponse; } if (!isNonFuncObject(ev.transformedEvent)) { return { @@ -101,7 +105,7 @@ export default class UserTransformService { } as ProcessorTransformationResponse; }), ); - } catch (error: any) { + } catch (error: CatchErr) { logger.error(error); let status = 400; const errorString = error.toString(); @@ -150,7 +154,7 @@ export default class UserTransformService { } public static async testTransformRoutine(events, trRevCode, libraryVersionIDs) { - const response: any = {}; + const response: FixMe = {}; try { if (!trRevCode || !trRevCode.code || !trRevCode.codeVersion) { throw new Error('Invalid Request. Missing parameters in transformation code block'); @@ -160,6 +164,7 @@ export default class UserTransformService { } logger.debug(`[CT] Test Input Events: ${JSON.stringify(events)}`); + // eslint-disable-next-line no-param-reassign trRevCode.versionId = 'testVersionId'; response.body = await userTransformHandler()( events, @@ -170,9 +175,11 @@ export default class UserTransformService { ); logger.debug(`[CT] Test Output Events: ${JSON.stringify(response.body.transformedEvents)}`); response.status = 200; - } catch (error: any) { + } catch (error: CatchErr) { response.status = 400; - response.body = { error: extractStackTraceUptoLastSubstringMatch(error.stack, SUPPORTED_FUNC_NAMES) }; + response.body = { + error: extractStackTraceUptoLastSubstringMatch(error.stack, SUPPORTED_FUNC_NAMES), + }; } return response; } diff --git a/src/testRouter.js b/src/testRouter.js index 5c9d56e78d..6080816663 100644 --- a/src/testRouter.js +++ b/src/testRouter.js @@ -28,8 +28,8 @@ const isSupportedContentType = (contentType) => { const testRouter = new Router({ prefix: '/test-router' }); -const getDestHandler = (version, destination) => - require(`./${version}/destinations/${destination}/transform`); +const getDestHandler = (ver, destination) => + require(`./${ver}/destinations/${destination}/transform`); const getDestinations = () => fs.readdirSync(path.resolve(__dirname, version, 'destinations')); diff --git a/src/types/index.ts b/src/types/index.ts index 38ce52f017..ff0c1f88b9 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,3 +1,6 @@ +import { CatchErr, FixMe } from '../util/types'; + +/* eslint-disable @typescript-eslint/no-explicit-any */ type ProcessorTransformationOutput = { version: string; type: string; @@ -25,8 +28,8 @@ type Metadata = { sourceCategory: string; trackingPlanId: string; trackingPlanVersion: number; - sourceTpConfig: Object; - mergedTpConfig: Object; + sourceTpConfig: object; + mergedTpConfig: object; destinationId: string; jobRunId: string; jobId: number; @@ -35,7 +38,7 @@ type Metadata = { sourceJobRunId: string; sourceTaskId: string; sourceTaskRunId: string; - recordId: Object; + recordId: object; destinationType: string; messageId: string; oauthAccessToken: string; @@ -52,21 +55,21 @@ type Metadata = { type UserTransformationInput = { VersionID: string; ID: string; - Config: Object; + Config: object; }; type DestinationDefinition = { ID: string; Name: string; DisplayName: string; - Config: Object; + Config: FixMe; }; type Destination = { ID: string; Name: string; DestinationDefinition: DestinationDefinition; - Config: Object; + Config: FixMe; Enabled: boolean; WorkspaceID: string; Transformations: UserTransformationInput[]; @@ -78,16 +81,16 @@ type UserTransformationLibrary = { }; type ProcessorTransformationRequest = { - request?: Object; - message: Object; + request?: object; + message: object; metadata: Metadata; destination: Destination; libraries: UserTransformationLibrary[]; }; type RouterTransformationRequestData = { - request?: Object; - message: Object; + request?: object; + message: object; metadata: Metadata; destination: Destination; }; @@ -102,7 +105,7 @@ type ProcessorTransformationResponse = { metadata: Metadata; statusCode: number; error?: string; - statTags: Object; + statTags: object; }; type RouterTransformationResponse = { @@ -112,7 +115,7 @@ type RouterTransformationResponse = { batched: boolean; statusCode: number; error: string; - statTags: Object; + statTags: object; }; type SourceTransformationOutput = { @@ -121,17 +124,17 @@ type SourceTransformationOutput = { type SourceTransformationResponse = { output: SourceTransformationOutput; - error: Object; + error: CatchErr; statusCode: number; - outputToSource: Object; - statTags: Object; + outputToSource: object; + statTags: object; }; type DeliveryResponse = { status: number; message: string; - destinationResponse: Object; - statTags: Object; + destinationResponse: object; + statTags: object; authErrorCategory?: string; }; @@ -150,15 +153,15 @@ type RudderMessage = { anonymousId: string; type: MessageType; channel: string; - context: Object; + context: object; originalTimestamp: Date; sentAt: Date; timestamp: Date; event?: string; - integrations?: Object; + integrations?: object; messageId: string; - properties?: Object; - traits?: Object; + properties?: object; + traits?: object; }; type ErrorDetailer = { @@ -187,7 +190,7 @@ type MetaTransferObject = { type UserTransformationResponse = { transformedEvent: RudderMessage; metadata: Metadata; - error: Object; + error: CatchErr; }; type UserTransformationServiceResponse = { @@ -196,8 +199,8 @@ type UserTransformationServiceResponse = { }; type UserDeletionRequest = { - userAttributes: any[]; - config: Object; + userAttributes: FixMe[]; + config: object; destType: string; jobId: string; }; @@ -206,15 +209,15 @@ type UserDeletionResponse = { statusCode: number; error?: string; status?: string; - authErrorCategory: any; - statTags: Object; + authErrorCategory: FixMe; + statTags: object; }; type ComparatorInput = { events: ProcessorTransformationRequest[] | RouterTransformationRequestData[]; destination: string; version: string; - requestMetadata: Object; + requestMetadata: object; feature: string; }; diff --git a/src/util/dynamicConfigParser.ts b/src/util/dynamicConfigParser.ts index fc4a02bc84..73ad85a0d2 100644 --- a/src/util/dynamicConfigParser.ts +++ b/src/util/dynamicConfigParser.ts @@ -1,14 +1,15 @@ import cloneDeep from 'lodash/cloneDeep'; import { ProcessorTransformationRequest, RouterTransformationRequestData } from '../types/index'; +import { FixMe } from './types'; /* eslint-disable no-param-reassign */ const get = require('get-value'); const unset = require('unset-value'); -export class DynamicConfigParser { +export default class DynamicConfigParser { private static getDynamicConfigValue( event: ProcessorTransformationRequest | RouterTransformationRequestData, - value: any, + value: FixMe, ) { // this regex checks for pattern "only spaces {{ path || defaultvalue }} only spaces" . // " {{message.traits.key || \"email\" }} " @@ -38,7 +39,7 @@ export class DynamicConfigParser { } private static configureVal( - value: any, + value: FixMe, event: ProcessorTransformationRequest | RouterTransformationRequestData, ) { if (value) { diff --git a/src/util/fetch.js b/src/util/fetch.js index efadc3c884..95856dd7fd 100644 --- a/src/util/fetch.js +++ b/src/util/fetch.js @@ -1,6 +1,7 @@ +/* eslint-disable @typescript-eslint/return-await */ const fetch = require('node-fetch'); const HttpsProxyAgent = require('https-proxy-agent'); -const _ = require('lodash'); +const lodash = require('lodash'); const { RetryRequestError } = require('./utils'); const fetchWithProxy = async (url, options = {}) => { @@ -13,7 +14,7 @@ const fetchWithProxy = async (url, options = {}) => { instanceOptions.agent = new HttpsProxyAgent(process.env.HTTPS_PROXY); } - if (_.isEmpty(instanceOptions)) { + if (lodash.isEmpty(instanceOptions)) { return await fetch(url); } return await fetch(url, instanceOptions); diff --git a/src/util/types.ts b/src/util/types.ts new file mode 100644 index 0000000000..579c35579c --- /dev/null +++ b/src/util/types.ts @@ -0,0 +1,25 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +export type FixMe = any; + +export type CatchErr = any; + +export interface Config { + cdkEnabled?: boolean; + cdkV2Enabled?: boolean; + comparisonTestEnabeld?: boolean; + comparisonService?: string; + camparisonTestThreshold?: number; +} + +export interface IDestDefinition { + id: string; + name: string; + displayName: string; + config: Config; + options: { + isBeta?: boolean; + hidden?: boolean; + } | null; + isPopular: boolean; + uiConfig: FixMe; +} diff --git a/src/util/utils.js b/src/util/utils.js index 160bbae3c9..0ba6008368 100644 --- a/src/util/utils.js +++ b/src/util/utils.js @@ -1,4 +1,4 @@ -/* eslint-disable max-classes-per-file */ +/* eslint-disable max-classes-per-file, @typescript-eslint/return-await */ const http = require('http'); const https = require('https'); const { Resolver } = require('dns').promises; @@ -36,6 +36,7 @@ const staticLookup = (transformerVersionId) => async (hostname, _, cb) => { return; } + // eslint-disable-next-line no-restricted-syntax for (const ip of ips) { if (ip.startsWith(LOCALHOST_OCTET)) { cb(null, `cannot use ${ip} as IP address`, RECORD_TYPE_A); diff --git a/src/v0/destinations/active_campaign/transform.js b/src/v0/destinations/active_campaign/transform.js index f995254730..905a8e897f 100644 --- a/src/v0/destinations/active_campaign/transform.js +++ b/src/v0/destinations/active_campaign/transform.js @@ -283,7 +283,7 @@ const customFieldProcessor = async (message, category, destination) => { const storedFields = Object.keys(fieldMap); const filteredFieldKeys = []; - fieldKeys.map((fieldKey) => { + fieldKeys.forEach((fieldKey) => { // If the field is present in fieldMap push it to filteredFieldKeys else ignore if (storedFields.includes(fieldKey)) { filteredFieldKeys.push(fieldKey); @@ -297,7 +297,7 @@ const customFieldProcessor = async (message, category, destination) => { // Creating a field array list conating field id and field value which will be merged to the contact // Ref: https://developers.activecampaign.com/reference/sync-a-contacts-data const fieldsArrValues = []; - filteredFieldKeys.map((key) => { + filteredFieldKeys.forEach((key) => { let fPayload; if (Array.isArray(fieldInfo[key])) { fPayload = '||'; @@ -327,7 +327,7 @@ const customListProcessor = async (message, category, destination, contactId) => // The list info is pushed into a list object array const listArr = []; if (Array.isArray(listInfo)) { - listInfo.map((list) => { + listInfo.forEach((list) => { listArr.push(list); }); } else { @@ -337,7 +337,8 @@ const customListProcessor = async (message, category, destination, contactId) => // status information // Ref: https://developers.activecampaign.com/reference/update-list-status-for-contact/ const promises = []; - listArr.map(async (li) => { + // 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 requestData = { @@ -356,7 +357,7 @@ const customListProcessor = async (message, category, destination, contactId) => }); promises.push(res); } - }); + } const responses = await Promise.all(promises); responses.forEach((respItem) => { if (respItem.success === false) { diff --git a/src/v0/destinations/adobe_analytics/transform.js b/src/v0/destinations/adobe_analytics/transform.js index c477b4c93c..54806bf578 100644 --- a/src/v0/destinations/adobe_analytics/transform.js +++ b/src/v0/destinations/adobe_analytics/transform.js @@ -36,7 +36,13 @@ const responseBuilderSimple = async (message, destinationConfig, basicPayload) = const { event, context, properties } = message; // set default value of properties.overridePageView to false if not provided properties.overridePageView = properties.overridePageView ?? false; - const { overrideEvars, overrideHiers, overrideLists, overrideCustomProperties } = properties; + const { + overrideEvars, + overrideHiers, + overrideLists, + overrideCustomProperties, + overridePageView, + } = properties; // handle contextData payload = handleContextData(payload, destinationConfig, message); @@ -60,7 +66,7 @@ const responseBuilderSimple = async (message, destinationConfig, basicPayload) = // handle link values // default linktype to 'o', linkName to event name, linkURL to ctx.page.url if not passed in integrations object const adobeIntegrationsObject = getIntegrationsObj(message, 'adobe_analytics'); - if (!properties?.overridePageView) { + if (!overridePageView) { payload.linkType = adobeIntegrationsObject?.linkType || 'o'; payload.linkName = adobeIntegrationsObject?.linkName || event; // setting linkname to page view for page calls @@ -86,7 +92,7 @@ const responseBuilderSimple = async (message, destinationConfig, basicPayload) = // handle pageName, pageUrl const contextPageUrl = context?.page?.url; - if (properties?.overridePageView) { + if (overridePageView) { const propertiesPageUrl = properties?.pageUrl; const pageUrl = contextPageUrl || propertiesPageUrl; if (isDefinedAndNotNullAndNotEmpty(pageUrl)) { @@ -337,7 +343,7 @@ const processTrackEvent = (message, adobeEventName, destinationConfig, extras = const handleTrack = (message, destinationConfig) => { const ORDER_ID_KEY = 'properties.order_id'; - const { event: rawEvent } = message; + const { event: rawEvent, properties } = message; let payload = null; // handle ecommerce events separately // generic events should go to the default @@ -378,12 +384,8 @@ const handleTrack = (message, destinationConfig) => { destinationConfig.rudderEventsToAdobeEvents[event]?.trim(), destinationConfig, ); - } else if (message?.properties?.overrideEventName) { - payload = processTrackEvent( - message, - message?.properties?.overrideEventName, - destinationConfig, - ); + } else if (properties?.overrideEventName) { + payload = processTrackEvent(message, properties.overrideEventName, destinationConfig); } else { throw new ConfigurationError( 'The event is not a supported ECOM event or a mapped custom event. Aborting.', diff --git a/src/v0/destinations/bqstream/transform.js b/src/v0/destinations/bqstream/transform.js index 0674f5e679..55679b08a8 100644 --- a/src/v0/destinations/bqstream/transform.js +++ b/src/v0/destinations/bqstream/transform.js @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -const _ = require('lodash'); +const lodash = require('lodash'); const { EventType } = require('../../../constants'); const { defaultBatchRequestConfig, @@ -56,7 +56,7 @@ const batchEachUserSuccessEvents = (eventsChunk) => { const batchedResponseList = []; // arrayChunks = [[e1,e2, ..batchSize], [e1,e2, ..batchSize], ...] - const arrayChunks = _.chunk(eventsChunk, MAX_ROWS_PER_REQUEST); + const arrayChunks = lodash.chunk(eventsChunk, MAX_ROWS_PER_REQUEST); // list of chunks [ [..], [..] ] arrayChunks.forEach((chunk) => { diff --git a/src/v0/destinations/bqstream/util.js b/src/v0/destinations/bqstream/util.js index 06b7403c87..4fa926e54e 100644 --- a/src/v0/destinations/bqstream/util.js +++ b/src/v0/destinations/bqstream/util.js @@ -39,6 +39,7 @@ const formatCompositeResponse = (errorEvents) => { const resultArray = []; const errorMap = new Map(); + // eslint-disable-next-line no-restricted-syntax for (const item of errorEvents) { if (isDefinedAndNotNull(item.error)) { optimizeErrorResponse(item, errorMap, resultArray); diff --git a/src/v0/destinations/bqstream/util.test.js b/src/v0/destinations/bqstream/util.test.js index 1e99a4f20e..c7635772ac 100644 --- a/src/v0/destinations/bqstream/util.test.js +++ b/src/v0/destinations/bqstream/util.test.js @@ -64,19 +64,19 @@ describe('getRearrangedEvents', () => { ], }, ], - [ - { - batched: false, - destination: {}, - error: "Invalid payload for the destination", - metadata: [ - { - jobId: 5, - userId: "user12345", - }, - ], - }, - ], + [ + { + batched: false, + destination: {}, + error: 'Invalid payload for the destination', + metadata: [ + { + jobId: 5, + userId: 'user12345', + }, + ], + }, + ], ]; const result = getRearrangedEvents(eachUserSuccessEventslist, eachUserErrorEventsList); expect(result).toEqual(expected); @@ -106,7 +106,7 @@ describe('getRearrangedEvents', () => { [ { message: { type: 'track' }, metadata: [{ jobId: 1 }] }, { message: { type: 'track' }, metadata: [{ jobId: 3 }] }, - { message: { type: 'track' }, metadata: [{ jobId: 5 }] } + { message: { type: 'track' }, metadata: [{ jobId: 5 }] }, ], [ { @@ -147,54 +147,54 @@ describe('getRearrangedEvents', () => { const expected = [ [ { - "message": { - "type": "track" + message: { + type: 'track', }, - "metadata": [ + metadata: [ { - "jobId": 1 - } - ] + jobId: 1, + }, + ], }, { - "message": { - "type": "track" + message: { + type: 'track', }, - "metadata": [ + metadata: [ { - "jobId": 2 - } - ] + jobId: 2, + }, + ], }, { - "message": { - "type": "track" + message: { + type: 'track', }, - "metadata": [ + metadata: [ { - "jobId": 5 - } - ] - } + jobId: 5, + }, + ], + }, ], [ { - "batched": false, - "destination": {}, - "error": "Invalid payload for the destination", - "metadata": [ + batched: false, + destination: {}, + error: 'Invalid payload for the destination', + metadata: [ { - "jobId": 3, - "userId": "user12345" + jobId: 3, + userId: 'user12345', }, { - "jobId": 4, - "userId": "user12345" - } - ] - } - ] - ] + jobId: 4, + userId: 'user12345', + }, + ], + }, + ], + ]; const result = getRearrangedEvents(successEventslist, errorEventsList); console.log(JSON.stringify(result)); expect(result).toEqual(expected); @@ -222,48 +222,46 @@ describe('getRearrangedEvents', () => { const expected = [ [ { - "message": { - "type": "track" + message: { + type: 'track', }, - "metadata": [ + metadata: [ { - "jobId": 2 - } - ] + jobId: 2, + }, + ], }, { - "message": { - "type": "track" + message: { + type: 'track', }, - "metadata": [ + metadata: [ { - "jobId": 3 - } - ] - } + jobId: 3, + }, + ], + }, ], [ { - "batched": false, - "destination": {}, - "error": "Invalid payload for the destination", - "metadata": [ + batched: false, + destination: {}, + error: 'Invalid payload for the destination', + metadata: [ { - "jobId": 1, - "userId": "user12345" + jobId: 1, + userId: 'user12345', }, { - "jobId": 4, - "userId": "user12345" - } - ] - } - ] - ] + jobId: 4, + userId: 'user12345', + }, + ], + }, + ], + ]; const result = getRearrangedEvents(successEventslist, errorEventsList); console.log(JSON.stringify(result)); expect(result).toEqual(expected); }); - }); - diff --git a/src/v0/destinations/branch/transform.js b/src/v0/destinations/branch/transform.js index 362f6cc840..0d47fbd791 100644 --- a/src/v0/destinations/branch/transform.js +++ b/src/v0/destinations/branch/transform.js @@ -44,7 +44,7 @@ function getCategoryAndName(rudderEventName) { for (const category of categoriesList) { let requiredName = null; let requiredCategory = null; - // eslint-disable-next-line array-callback-return + // eslint-disable-next-line array-callback-return, sonarjs/no-ignored-return Object.keys(category.name).find((branchKey) => { if ( typeof branchKey === 'string' && @@ -53,7 +53,9 @@ function getCategoryAndName(rudderEventName) { ) { requiredName = category.name[branchKey]; requiredCategory = category; + return true; } + return false; }); if (requiredName != null && requiredCategory != null) { return { evName: requiredName, category: requiredCategory }; @@ -112,6 +114,7 @@ function mapPayload(category, rudderProperty, rudderPropertiesObj) { let valFound = false; if (category.content_items) { + // eslint-disable-next-line sonarjs/no-ignored-return Object.keys(category.content_items).find((branchMappingProperty) => { if (branchMappingProperty === rudderProperty) { const tmpKeyName = category.content_items[branchMappingProperty]; @@ -168,7 +171,7 @@ function getCommonPayload(message, category, evName) { productObj = {}; for (let i = 0; i < rudderPropertiesObj.products.length; i += 1) { const product = rudderPropertiesObj.products[i]; - // eslint-disable-next-line no-loop-func + // eslint-disable-next-line @typescript-eslint/no-loop-func Object.keys(product).forEach((productProp) => { const { contentItemsObj, eventDataObj, customDataObj } = mapPayload( category, diff --git a/src/v0/destinations/braze/networkHandler.js b/src/v0/destinations/braze/networkHandler.js index 48034af487..cf6d36c2b4 100644 --- a/src/v0/destinations/braze/networkHandler.js +++ b/src/v0/destinations/braze/networkHandler.js @@ -10,6 +10,7 @@ const { NetworkError } = require('../../util/errorTypes'); const tags = require('../../util/tags'); const stats = require('../../../util/stats'); +// eslint-disable-next-line @typescript-eslint/no-unused-vars const responseHandler = (destinationResponse, _dest) => { const message = `Request for ${DESTINATION} Processed Successfully`; const { response, status } = destinationResponse; diff --git a/src/v0/destinations/braze/transform.js b/src/v0/destinations/braze/transform.js index 7650f03b8f..5f651041ea 100644 --- a/src/v0/destinations/braze/transform.js +++ b/src/v0/destinations/braze/transform.js @@ -1,5 +1,5 @@ /* eslint-disable no-nested-ternary,no-param-reassign */ -const _ = require('lodash'); +const lodash = require('lodash'); const get = require('get-value'); const { BrazeDedupUtility, @@ -80,7 +80,7 @@ function getIdentifyPayload(message) { let payload = {}; payload = setAliasObjectWithAnonId(payload, message); payload = setExternalId(payload, message); - return { aliases_to_identify: [payload], merge_behavior: "merge" }; + return { aliases_to_identify: [payload], merge_behavior: 'merge' }; } function populateCustomAttributesWithOperation( @@ -379,6 +379,7 @@ function processGroup(message, destination) { } else if (email) { subscriptionGroup.emails = [email]; } + // eslint-disable-next-line @typescript-eslint/naming-convention const subscription_groups = [subscriptionGroup]; const response = defaultRequestConfig(); response.endpoint = getSubscriptionGroupEndPoint(getEndpointFromConfig(destination)); @@ -518,7 +519,7 @@ const processRouterDest = async (inputs, reqMetadata) => { BrazeDedupUtility.updateUserStore(userStore, lookedUpUsers, destination.ID); } // group events by userId or anonymousId and then call process - const groupedInputs = _.groupBy( + const groupedInputs = lodash.groupBy( inputs, (input) => input.message.userId || input.message.anonymousId, ); @@ -537,7 +538,7 @@ const processRouterDest = async (inputs, reqMetadata) => { const output = await Promise.all(allResps); - const allTransfomredEvents = _.flatMap(output); + const allTransfomredEvents = lodash.flatMap(output); return processBatch(allTransfomredEvents); }; diff --git a/src/v0/destinations/braze/util.js b/src/v0/destinations/braze/util.js index d772503b58..0793ca5891 100644 --- a/src/v0/destinations/braze/util.js +++ b/src/v0/destinations/braze/util.js @@ -1,4 +1,4 @@ -/* eslint-disable camelcase */ +/* eslint-disable */ const _ = require('lodash'); const get = require('get-value'); const stats = require('../../../util/stats'); diff --git a/src/v0/destinations/clevertap/networkHandler.js b/src/v0/destinations/clevertap/networkHandler.js index aafe77e792..35c972e502 100644 --- a/src/v0/destinations/clevertap/networkHandler.js +++ b/src/v0/destinations/clevertap/networkHandler.js @@ -43,6 +43,7 @@ const responseHandler = (destinationResponse) => { }; }; +// eslint-disable-next-line @typescript-eslint/naming-convention class networkHandler { constructor() { this.responseHandler = responseHandler; diff --git a/src/v0/destinations/criteo_audience/networkHandler.js b/src/v0/destinations/criteo_audience/networkHandler.js index 5bf29f63c5..83cde5028f 100644 --- a/src/v0/destinations/criteo_audience/networkHandler.js +++ b/src/v0/destinations/criteo_audience/networkHandler.js @@ -81,6 +81,7 @@ const responseHandler = (destinationResponse) => { }; }; +// eslint-disable-next-line @typescript-eslint/naming-convention class networkHandler { constructor() { this.responseHandler = responseHandler; diff --git a/src/v0/destinations/criteo_audience/util.js b/src/v0/destinations/criteo_audience/util.js index ab58560fb1..a7541f7911 100644 --- a/src/v0/destinations/criteo_audience/util.js +++ b/src/v0/destinations/criteo_audience/util.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const { isDefinedAndNotNullAndNotEmpty } = require('../../util'); const { ConfigurationError, InstrumentationError } = require('../../util/errorTypes'); const { MAX_IDENTIFIERS } = require('./config'); @@ -14,7 +14,7 @@ const populateIdentifiers = (audienceList, audienceType) => { } identifiers.push(userTraits[audienceType]); }); - const identifierChunks = _.chunk(identifiers, MAX_IDENTIFIERS); + const identifierChunks = lodash.chunk(identifiers, MAX_IDENTIFIERS); return identifierChunks; }; diff --git a/src/v0/destinations/customerio/util.js b/src/v0/destinations/customerio/util.js index dec16b355e..735b6a73d9 100644 --- a/src/v0/destinations/customerio/util.js +++ b/src/v0/destinations/customerio/util.js @@ -102,7 +102,7 @@ const isdeviceRelatedEventName = (eventName, destination) => const identifyResponseBuilder = (userId, message) => { const rawPayload = {}; // if userId is not there simply drop the payload - const id = userId || getFieldValueFromMessage(message, "email"); + const id = userId || getFieldValueFromMessage(message, 'email'); if (!id) { throw new InstrumentationError('userId or email is not present'); } @@ -177,6 +177,7 @@ const aliasResponseBuilder = (message, userId) => { if (validateEmail(userId)) { cioProperty = 'email'; } + // eslint-disable-next-line @typescript-eslint/naming-convention let prev_cioProperty = 'id'; if (validateEmail(message.previousId)) { prev_cioProperty = 'email'; @@ -229,12 +230,11 @@ const defaultResponseBuilder = (message, evName, userId, evType, destination, me let requestConfig = defaultPostRequestConfig; // any other event type except identify const token = get(message, 'context.device.token'); - const id = userId || getFieldValueFromMessage(message, "email"); + const id = userId || getFieldValueFromMessage(message, 'email'); // use this if only top level keys are to be sent // DEVICE DELETE from CustomerIO const isDeviceDeleteEvent = deviceDeleteRelatedEventName === evName; if (isDeviceDeleteEvent) { - if (!id || !token) { throw new InstrumentationError('userId/email or device_token not present'); } @@ -253,7 +253,7 @@ const defaultResponseBuilder = (message, evName, userId, evType, destination, me last_used: Math.floor(new Date(timestamp).getTime() / 1000), }; const deviceType = get(message, 'context.device.type'); - if (deviceType && typeof deviceType === "string") { + if (deviceType && typeof deviceType === 'string') { // Ref - https://www.customer.io/docs/api/#operation/add_device // supported platform are "ios", "android" devProps.platform = isAppleFamily(deviceType) ? 'ios' : deviceType.toLowerCase(); @@ -306,9 +306,9 @@ const defaultResponseBuilder = (message, evName, userId, evType, destination, me return { rawPayload, endpoint, requestConfig }; }; -const validateConfigFields = destination => { +const validateConfigFields = (destination) => { const { Config } = destination; - configFieldsToCheck.forEach(configProperty => { + configFieldsToCheck.forEach((configProperty) => { if (!Config[configProperty]) { throw new ConfigurationError(`${configProperty} not found in Configs`); } @@ -323,5 +323,5 @@ module.exports = { defaultResponseBuilder, populateSpecedTraits, isdeviceRelatedEventName, - validateConfigFields + validateConfigFields, }; diff --git a/src/v0/destinations/fb/networkHandler.js b/src/v0/destinations/fb/networkHandler.js index b79b2ab493..06235fab40 100644 --- a/src/v0/destinations/fb/networkHandler.js +++ b/src/v0/destinations/fb/networkHandler.js @@ -11,6 +11,7 @@ const destResponseHandler = (destinationResponse) => { }; }; +// eslint-disable-next-line @typescript-eslint/naming-convention class networkHandler { constructor() { this.prepareProxyRequest = prepareProxyRequest; diff --git a/src/v0/destinations/fb_custom_audience/transform.js b/src/v0/destinations/fb_custom_audience/transform.js index 64125ffc3b..f31a3dd42e 100644 --- a/src/v0/destinations/fb_custom_audience/transform.js +++ b/src/v0/destinations/fb_custom_audience/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const get = require('get-value'); const { defaultRequestConfig, @@ -62,7 +62,7 @@ const preparePayload = ( disableFormat, destinationId, ) => { - const prepareFinalPayload = _.cloneDeep(paramsPayload); + const prepareFinalPayload = lodash.cloneDeep(paramsPayload); if (Array.isArray(userSchema)) { prepareFinalPayload.schema = userSchema; } else { diff --git a/src/v0/destinations/fb_custom_audience/util.js b/src/v0/destinations/fb_custom_audience/util.js index 8ec15fe670..9e7198e393 100644 --- a/src/v0/destinations/fb_custom_audience/util.js +++ b/src/v0/destinations/fb_custom_audience/util.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const sha256 = require('sha256'); const get = require('get-value'); const jsonSize = require('json-size'); @@ -31,7 +31,7 @@ const batchingWithPayloadSize = (payload) => { const revisedPayloadArray = []; const noOfBatches = Math.ceil(payloadSize / maxPayloadSize); const revisedRecordsPerPayload = Math.floor(payload.data.length / noOfBatches); - const revisedDataArray = _.chunk(payload.data, revisedRecordsPerPayload); + const revisedDataArray = lodash.chunk(payload.data, revisedRecordsPerPayload); revisedDataArray.forEach((data) => { revisedPayloadArray.push({ ...payload, data }); }); diff --git a/src/v0/destinations/ga/transform.js b/src/v0/destinations/ga/transform.js index 0c2a0f8a49..c10697c4e1 100644 --- a/src/v0/destinations/ga/transform.js +++ b/src/v0/destinations/ga/transform.js @@ -443,7 +443,7 @@ function processRefundEvent(message, destination) { let { enhancedEcommerce } = destination.Config; enhancedEcommerce = enhancedEcommerce || false; - // eslint-disable-next-line camelcase + // eslint-disable-next-line @typescript-eslint/naming-convention const { products, order_id } = message.properties; if (products && products.length > 0) { const productParams = setProductLevelProperties( @@ -598,7 +598,7 @@ function processProductEvent(message, destination) { const customParamKeys = getCustomParamKeys(destination.Config); Object.assign(parameters, getProductLevelCustomParams(message.properties, 1, customParamKeys)); } - // eslint-disable-next-line camelcase + // eslint-disable-next-line @typescript-eslint/naming-convention const { sku, product_id } = message.properties; // eslint-disable-next-line camelcase const productId = product_id; diff --git a/src/v0/destinations/ga360/transform.js b/src/v0/destinations/ga360/transform.js index a9d4f6b210..c60ea47551 100644 --- a/src/v0/destinations/ga360/transform.js +++ b/src/v0/destinations/ga360/transform.js @@ -401,7 +401,7 @@ function processRefundEvent(message, destination) { let { enhancedEcommerce } = destination.Config; enhancedEcommerce = enhancedEcommerce || false; - // eslint-disable-next-line camelcase + // eslint-disable-next-line @typescript-eslint/naming-convention const { products, order_id } = message.properties; if (products && products.length > 0) { const productParams = setProductLevelProperties( @@ -545,7 +545,7 @@ function processProductEvent(message, destination) { const customParamKeys = getCustomParamKeys(destination.Config); Object.assign(parameters, getProductLevelCustomParams(message.properties, 1, customParamKeys)); } - // eslint-disable-next-line camelcase + // eslint-disable-next-line @typescript-eslint/naming-convention const { sku, product_id } = message.properties; // eslint-disable-next-line camelcase const productId = product_id; diff --git a/src/v0/destinations/ga4/utils.js b/src/v0/destinations/ga4/utils.js index b86d14ef1b..4bb35e3fdd 100644 --- a/src/v0/destinations/ga4/utils.js +++ b/src/v0/destinations/ga4/utils.js @@ -410,9 +410,9 @@ const prepareUserProperties = (message) => { const validatedUserProperties = Object.entries(userProperties) .filter(([key, value]) => isValidUserProperty(key, value)) .reduce((acc, [key, value]) => { - const userProperties = acc; - userProperties[key] = { value }; - return userProperties; + const userPropertiesObj = acc; + userPropertiesObj[key] = { value }; + return userPropertiesObj; }, {}); return validatedUserProperties; diff --git a/src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js b/src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js index 9fa0e9a3a4..1f59eb9e40 100644 --- a/src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js +++ b/src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js @@ -18,6 +18,8 @@ const { BASE_ENDPOINT } = require('./config'); const { NetworkError, NetworkInstrumentationError } = require('../../util/errorTypes'); const tags = require('../../util/tags'); +const ERROR_MSG_PATH = 'response[0].error.message'; + /** * This function is used for collecting the conversionActionId using the conversion name * @param {*} method @@ -49,8 +51,8 @@ const getConversionActionId = async (method, headers, params) => { if (!isHttpStatusSuccess(gaecConversionActionIdResponse.status)) { throw new NetworkError( `"${JSON.stringify( - get(gaecConversionActionIdResponse, 'response[0].error.message', '') - ? get(gaecConversionActionIdResponse, 'response[0].error.message', '') + get(gaecConversionActionIdResponse, ERROR_MSG_PATH, '') + ? get(gaecConversionActionIdResponse, ERROR_MSG_PATH, '') : gaecConversionActionIdResponse.response, )} during Google_adwords_enhanced_conversions response transformation"`, gaecConversionActionIdResponse.status, @@ -60,7 +62,7 @@ const getConversionActionId = async (method, headers, params) => { gaecConversionActionIdResponse.response, getAuthErrCategoryFromErrDetailsAndStCode( get(gaecConversionActionIdResponse, 'status'), - get(gaecConversionActionIdResponse, 'response[0].error.message'), + get(gaecConversionActionIdResponse, ERROR_MSG_PATH), ), ); } @@ -144,6 +146,7 @@ const responseHandler = (destinationResponse) => { ); }; +// eslint-disable-next-line func-names, @typescript-eslint/naming-convention class networkHandler { constructor() { this.proxy = ProxyRequest; diff --git a/src/v0/destinations/google_adwords_enhanced_conversions/transform.js b/src/v0/destinations/google_adwords_enhanced_conversions/transform.js index 24993a3006..898c3f95b0 100644 --- a/src/v0/destinations/google_adwords_enhanced_conversions/transform.js +++ b/src/v0/destinations/google_adwords_enhanced_conversions/transform.js @@ -11,10 +11,7 @@ const { getAccessToken, } = require('../../util'); -const { - InstrumentationError, - ConfigurationError, -} = require('../../util/errorTypes'); +const { InstrumentationError, ConfigurationError } = require('../../util/errorTypes'); const { trackMapping, BASE_ENDPOINT } = require('./config'); const { JSON_MIME_TYPE } = require('../../util/constant'); diff --git a/src/v0/destinations/google_adwords_offline_conversions/transform.js b/src/v0/destinations/google_adwords_offline_conversions/transform.js index db87d2488e..93b4592c33 100644 --- a/src/v0/destinations/google_adwords_offline_conversions/transform.js +++ b/src/v0/destinations/google_adwords_offline_conversions/transform.js @@ -139,6 +139,7 @@ const process = async (event) => { const getEventChunks = (event, storeSalesEvents, clickCallEvents) => { const { message, metadata, destination } = event; + // eslint-disable-next-line @typescript-eslint/no-shadow message.forEach((message) => { if (message.body.JSON?.isStoreConversion) { storeSalesEvents.push({ message, metadata, destination }); @@ -166,7 +167,7 @@ const batchEvents = (storeSalesEvents) => { if (index === 0) { return; } - batchEventResponse.batchedRequest?.body?.JSON['addConversionPayload']?.operations?.push( + batchEventResponse.batchedRequest?.body?.JSON.addConversionPayload?.operations?.push( storeSalesEvent.message?.body?.JSON?.addConversionPayload?.operations, ); batchEventResponse.metadatas.push(storeSalesEvent.metadata); diff --git a/src/v0/destinations/google_adwords_offline_conversions/utils.js b/src/v0/destinations/google_adwords_offline_conversions/utils.js index 37f17c9fd0..6bdedcc0d4 100644 --- a/src/v0/destinations/google_adwords_offline_conversions/utils.js +++ b/src/v0/destinations/google_adwords_offline_conversions/utils.js @@ -25,11 +25,7 @@ const { } = require('./config'); const { processAxiosResponse } = require('../../../adapters/utils/networkUtils'); const Cache = require('../../util/cache'); -const { - AbortedError, - ConfigurationError, - InstrumentationError, -} = require('../../util/errorTypes'); +const { AbortedError, ConfigurationError, InstrumentationError } = require('../../util/errorTypes'); const conversionActionIdCache = new Cache(CONVERSION_ACTION_ID_CACHE_TTL); diff --git a/src/v0/destinations/google_cloud_function/transform.js b/src/v0/destinations/google_cloud_function/transform.js index e74d539e3f..b218615b44 100644 --- a/src/v0/destinations/google_cloud_function/transform.js +++ b/src/v0/destinations/google_cloud_function/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const { getSuccessRespEvents, checkInvalidRtTfEvents, @@ -22,7 +22,7 @@ function batchEvents(successRespList, maxBatchSize = 10) { const batchedResponseList = []; // arrayChunks = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] - const arrayChunks = _.chunk(successRespList, maxBatchSize); + const arrayChunks = lodash.chunk(successRespList, maxBatchSize); arrayChunks.forEach((chunk) => { const batchEventResponse = generateBatchedPayload(chunk); batchedResponseList.push( diff --git a/src/v0/destinations/hs/HSTransform-v1.js b/src/v0/destinations/hs/HSTransform-v1.js index 13eeabbc45..387ecbf63f 100644 --- a/src/v0/destinations/hs/HSTransform-v1.js +++ b/src/v0/destinations/hs/HSTransform-v1.js @@ -1,5 +1,5 @@ const get = require('get-value'); -const _ = require('lodash'); +const lodash = require('lodash'); const { MappedToDestinationKey, GENERIC_TRUE_VALUES } = require('../../../constants'); const { defaultGetRequestConfig, @@ -286,9 +286,9 @@ const legacyBatchEvents = (destEvents) => { eventsChunk.push(event); } }); - const arrayChunksIdentifyCreateObjects = _.chunk(createAllObjectsEventChunk, maxBatchSize); + const arrayChunksIdentifyCreateObjects = lodash.chunk(createAllObjectsEventChunk, maxBatchSize); - const arrayChunksIdentifyUpdateObjects = _.chunk(updateAllObjectsEventChunk, maxBatchSize); + const arrayChunksIdentifyUpdateObjects = lodash.chunk(updateAllObjectsEventChunk, maxBatchSize); // batching up 'create' all objects endpoint chunks if (arrayChunksIdentifyCreateObjects.length > 0) { batchedResponseList = batchIdentifyForrETL( @@ -308,7 +308,7 @@ const legacyBatchEvents = (destEvents) => { } // eventChunks = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] - const arrayChunksIdentify = _.chunk(eventsChunk, MAX_BATCH_SIZE); + const arrayChunksIdentify = lodash.chunk(eventsChunk, MAX_BATCH_SIZE); // list of chunks [ [..], [..] ] arrayChunksIdentify.forEach((chunk) => { diff --git a/src/v0/destinations/hs/HSTransform-v2.js b/src/v0/destinations/hs/HSTransform-v2.js index 8cea4611e5..75696b4e96 100644 --- a/src/v0/destinations/hs/HSTransform-v2.js +++ b/src/v0/destinations/hs/HSTransform-v2.js @@ -1,5 +1,5 @@ const get = require('get-value'); -const _ = require('lodash'); +const lodash = require('lodash'); const { MappedToDestinationKey, GENERIC_TRUE_VALUES } = require('../../../constants'); const { defaultPostRequestConfig, @@ -417,23 +417,23 @@ const batchEvents = (destEvents) => { } }); - const arrayChunksIdentifyCreateObjects = _.chunk(createAllObjectsEventChunk, maxBatchSize); + const arrayChunksIdentifyCreateObjects = lodash.chunk(createAllObjectsEventChunk, maxBatchSize); - const arrayChunksIdentifyUpdateObjects = _.chunk(updateAllObjectsEventChunk, maxBatchSize); + const arrayChunksIdentifyUpdateObjects = lodash.chunk(updateAllObjectsEventChunk, maxBatchSize); // eventChunks = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] // CRM create contact endpoint chunks - const arrayChunksIdentifyCreateContact = _.chunk( + const arrayChunksIdentifyCreateContact = lodash.chunk( createContactEventsChunk, MAX_BATCH_SIZE_CRM_CONTACT, ); // CRM update contact endpoint chunks - const arrayChunksIdentifyUpdateContact = _.chunk( + const arrayChunksIdentifyUpdateContact = lodash.chunk( updateContactEventsChunk, MAX_BATCH_SIZE_CRM_CONTACT, ); - const arrayChunksIdentifyCreateAssociations = _.chunk( + const arrayChunksIdentifyCreateAssociations = lodash.chunk( associationObjectsEventChunk, MAX_BATCH_SIZE_CRM_OBJECT, ); diff --git a/src/v0/destinations/intercom/networkHandler.js b/src/v0/destinations/intercom/networkHandler.js index 4133fbe4dc..33f78e8cf6 100644 --- a/src/v0/destinations/intercom/networkHandler.js +++ b/src/v0/destinations/intercom/networkHandler.js @@ -23,6 +23,7 @@ const destResponseHandler = (destinationResponse, dest) => { }; }; +// eslint-disable-next-line @typescript-eslint/naming-convention class networkHandler { constructor() { this.responseHandler = destResponseHandler; diff --git a/src/v0/destinations/intercom/transform.js b/src/v0/destinations/intercom/transform.js index aa088ee5db..552c80527c 100644 --- a/src/v0/destinations/intercom/transform.js +++ b/src/v0/destinations/intercom/transform.js @@ -94,16 +94,17 @@ function validateTrack(payload) { } const checkIfEmailOrUserIdPresent = (message, Config) => { - let user_id = message.userId; - if (Config.sendAnonymousId && !user_id) { - user_id = message.anonymousId; + const { context, anonymousId } = message; + let { userId } = message; + if (Config.sendAnonymousId && !userId) { + userId = anonymousId; } - return !!(user_id || message.context?.traits?.email); + return !!(userId || context.traits?.email); }; function attachUserAndCompany(message, Config) { const email = message.context?.traits?.email; - const { userId, anonymousId } = message; + const { userId, anonymousId, traits, groupId } = message; const requestBody = {}; if (userId) { requestBody.user_id = userId; @@ -115,10 +116,10 @@ function attachUserAndCompany(message, Config) { requestBody.email = email; } const companyObj = { - company_id: message.groupId, + company_id: groupId, }; - if (message.traits?.name) { - companyObj.name = message.traits.name; + if (traits?.name) { + companyObj.name = traits.name; } requestBody.companies = [companyObj]; const response = defaultRequestConfig(); diff --git a/src/v0/destinations/iterable/transform.js b/src/v0/destinations/iterable/transform.js index af666044d3..c54b579a52 100644 --- a/src/v0/destinations/iterable/transform.js +++ b/src/v0/destinations/iterable/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const get = require('get-value'); const { getCatalogEndpoint, @@ -213,10 +213,10 @@ const processRouterDest = async (inputs, reqMetadata) => { * ] */ - const responses = process(event); - const transformedPayloads = Array.isArray(responses) ? responses : [responses]; - return transformedPayloads.map((response) => ({ - message: response, + const responsesFn = process(event); + const transformedPayloadsArr = Array.isArray(responsesFn) ? responsesFn : [responsesFn]; + return transformedPayloadsArr.map((res) => ({ + message: res, metadata: event.metadata, destination: event.destination, })); @@ -230,13 +230,13 @@ const processRouterDest = async (inputs, reqMetadata) => { * Before flat map : transformedPayloads = [{e1}, {e2}, [{e3}, {e4}, {e5}], {e6}] * After flat map : transformedPayloads = [{e1}, {e2}, {e3}, {e4}, {e5}, {e6}] */ - transformedPayloads = _.flatMap(transformedPayloads); + transformedPayloads = lodash.flatMap(transformedPayloads); return filterEventsAndPrepareBatchRequests(transformedPayloads); }), ); // Flatten the response array containing batched events from multiple groups - const allBatchedEvents = _.flatMap(response); + const allBatchedEvents = lodash.flatMap(response); return allBatchedEvents; }; diff --git a/src/v0/destinations/iterable/util.js b/src/v0/destinations/iterable/util.js index 3fe793d561..0b7e402f01 100644 --- a/src/v0/destinations/iterable/util.js +++ b/src/v0/destinations/iterable/util.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const get = require('get-value'); const jsonSize = require('json-size'); const { @@ -22,6 +22,8 @@ const { JSON_MIME_TYPE } = require('../../util/constant'); const { EventType, MappedToDestinationKey } = require('../../../constants'); const { InstrumentationError, ConfigurationError } = require('../../util/errorTypes'); +const MESSAGE_JSON_PATH = 'message.body.JSON'; + /** * Returns preferUserId param * @param {*} config @@ -168,7 +170,8 @@ const pageOrScreenEventPayloadBuilder = (message, destination, category) => { let rawPayload = {}; const eventType = message.type.toLowerCase(); - const { trackAllPages, trackCategorisedPages, trackNamedPages } = destination.Config; + const { trackAllPages, trackCategorisedPages, trackNamedPages, mapToSingleEvent } = + destination.Config; if (trackAllPages) { rawPayload = constructPayload(message, mappingConfig[category.name]); } else if (trackCategorisedPages && (message.properties?.category || message.category)) { @@ -185,7 +188,7 @@ const pageOrScreenEventPayloadBuilder = (message, destination, category) => { rawPayload.campaignId = rawPayload.campaignId ? parseInt(rawPayload.campaignId, 10) : undefined; rawPayload.templateId = rawPayload.templateId ? parseInt(rawPayload.templateId, 10) : undefined; rawPayload.eventName = - destination.Config.mapToSingleEvent === true + mapToSingleEvent === true ? `Loaded a ${eventType.charAt(0).toUpperCase()}${eventType.slice(1)}` : `${rawPayload.eventName} ${eventType}`; @@ -368,7 +371,7 @@ const prepareAndSplitUpdateUserBatchesBasedOnPayloadSize = ( let nonBatchedRequests = []; chunk.forEach((event) => { - size += jsonSize(get(event, 'message.body.JSON')); + size += jsonSize(get(event, `${MESSAGE_JSON_PATH}`)); if (size > IDENTIFY_MAX_BODY_SIZE_IN_BYTES) { batches.push({ users: usersChunk, @@ -380,7 +383,7 @@ const prepareAndSplitUpdateUserBatchesBasedOnPayloadSize = ( usersChunk = []; metadataChunk = []; nonBatchedRequests = []; - size = jsonSize(get(event, 'message.body.JSON')); + size = jsonSize(get(event, `${MESSAGE_JSON_PATH}`)); } if (registerDeviceOrBrowserTokenEvents[event.metadata.jobId]) { @@ -389,7 +392,7 @@ const prepareAndSplitUpdateUserBatchesBasedOnPayloadSize = ( } metadataChunk.push(event.metadata); - usersChunk.push(get(event, 'message.body.JSON')); + usersChunk.push(get(event, `${MESSAGE_JSON_PATH}`)); }); if (usersChunk.length > 0) { @@ -467,7 +470,7 @@ const processUpdateUserBatch = (chunk, registerDeviceOrBrowserTokenEvents) => { const batchUpdateUserEvents = (updateUserEvents, registerDeviceOrBrowserTokenEvents) => { // Batching update user events // arrayChunks = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] - const updateUserEventsChunks = _.chunk(updateUserEvents, IDENTIFY_MAX_BATCH_SIZE); + const updateUserEventsChunks = lodash.chunk(updateUserEvents, IDENTIFY_MAX_BATCH_SIZE); return updateUserEventsChunks.reduce((batchedResponseList, chunk) => { const batchedResponse = processUpdateUserBatch(chunk, registerDeviceOrBrowserTokenEvents); return batchedResponseList.concat(batchedResponse); @@ -532,7 +535,7 @@ const processCatalogBatch = (chunk) => { const batchCatalogEvents = (catalogEvents) => { // Batching catalog events // arrayChunks = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] - const catalogEventsChunks = _.chunk(catalogEvents, IDENTIFY_MAX_BATCH_SIZE); + const catalogEventsChunks = lodash.chunk(catalogEvents, IDENTIFY_MAX_BATCH_SIZE); return catalogEventsChunks.reduce((batchedResponseList, chunk) => { const batchedResponse = processCatalogBatch(chunk); return batchedResponseList.concat(batchedResponse); @@ -553,7 +556,7 @@ const processTrackBatch = (chunk) => { chunk.forEach((event) => { metadata.push(event.metadata); - events.push(get(event, 'message.body.JSON')); + events.push(get(event, `${MESSAGE_JSON_PATH}`)); }); const batchEventResponse = defaultBatchRequestConfig(); @@ -579,7 +582,7 @@ const processTrackBatch = (chunk) => { const batchTrackEvents = (trackEvents) => { // Batching track events // arrayChunks = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] - const trackEventsChunks = _.chunk(trackEvents, TRACK_MAX_BATCH_SIZE); + const trackEventsChunks = lodash.chunk(trackEvents, TRACK_MAX_BATCH_SIZE); return trackEventsChunks.reduce((batchedResponseList, chunk) => { const batchedResponse = processTrackBatch(chunk); return batchedResponseList.concat(batchedResponse); @@ -649,9 +652,9 @@ const mapRegisterDeviceOrBrowserTokenEventsWithJobId = (events) => { * @returns */ const categorizeEvent = (event) => { - const { message, metadata, destination } = event; + const { message, metadata, destination, error } = event; - if (event?.error) { + if (error) { return { type: 'error', data: event }; } diff --git a/src/v0/destinations/klaviyo/transform.js b/src/v0/destinations/klaviyo/transform.js index bb19c5f8fd..86d5880e4c 100644 --- a/src/v0/destinations/klaviyo/transform.js +++ b/src/v0/destinations/klaviyo/transform.js @@ -53,7 +53,7 @@ const { JSON_MIME_TYPE } = require('../../util/constant'); */ const identifyRequestHandler = async (message, category, destination) => { // If listId property is present try to subscribe/member user in list - const { privateApiKey, enforceEmailAsPrimary, flattenProperties } = destination.Config; + const { privateApiKey, enforceEmailAsPrimary, listId, flattenProperties } = destination.Config; const mappedToDestination = get(message, MappedToDestinationKey); if (mappedToDestination) { addExternalIdToTraits(message); @@ -111,10 +111,7 @@ const identifyRequestHandler = async (message, category, destination) => { const responseArray = [profileUpdateResponseBuilder(payload, profileId, category, privateApiKey)]; // 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) - ) { + if (traitsInfo?.properties?.subscribe && (traitsInfo.properties?.listId || listId)) { responseArray.push(subscribeUserToList(message, traitsInfo, destination)); return responseArray; } diff --git a/src/v0/destinations/klaviyo/util.js b/src/v0/destinations/klaviyo/util.js index 3c4882b834..21a492739b 100644 --- a/src/v0/destinations/klaviyo/util.js +++ b/src/v0/destinations/klaviyo/util.js @@ -1,5 +1,5 @@ const { defaultRequestConfig } = require('rudder-transformer-cdk/build/utils'); -const _ = require('lodash'); +const lodash = require('lodash'); const { WhiteListedTraits } = require('../../../constants'); const { @@ -21,6 +21,8 @@ const tags = require('../../util/tags'); const { handleHttpRequest } = require('../../../adapters/network'); const { client: errNotificationClient } = require('../../../util/errorNotifier'); +const REVISION_CONSTANT = '2023-02-22'; + /** * This function calls the create user endpoint ref: https://developers.klaviyo.com/en/reference/create_profile * If the user doesn't exist, it creates a profile for the user and return 201 status code and the response which contains all the profile data @@ -88,7 +90,7 @@ const profileUpdateResponseBuilder = (payload, profileId, category, privateApiKe Authorization: `Klaviyo-API-Key ${privateApiKey}`, 'Content-Type': JSON_MIME_TYPE, Accept: JSON_MIME_TYPE, - revision: '2023-02-22', + revision: REVISION_CONSTANT, }; identifyResponse.body.JSON = removeUndefinedAndNullValues(payload); return identifyResponse; @@ -148,7 +150,7 @@ const subscribeUserToList = (message, traitsInfo, destination) => { Authorization: `Klaviyo-API-Key ${privateApiKey}`, 'Content-Type': JSON_MIME_TYPE, Accept: JSON_MIME_TYPE, - revision: '2023-02-22', + revision: REVISION_CONSTANT, }; response.body.JSON = removeUndefinedAndNullValues(payload); @@ -220,7 +222,7 @@ const generateBatchedPaylaodForArray = (events) => { Authorization: `Klaviyo-API-Key ${destination.Config.privateApiKey}`, 'Content-Type': JSON_MIME_TYPE, Accept: JSON_MIME_TYPE, - revision: '2023-02-22', + revision: REVISION_CONSTANT, }; batchEventResponse = { @@ -237,7 +239,7 @@ const generateBatchedPaylaodForArray = (events) => { * @returns */ const groupSubsribeResponsesUsingListId = (subscribeResponseList) => { - const subscribeEventGroups = _.groupBy( + const subscribeEventGroups = lodash.groupBy( subscribeResponseList, (event) => event.message.body.JSON.data.attributes.list_id, ); @@ -248,7 +250,7 @@ const getBatchedResponseList = (subscribeEventGroups, identifyResponseList) => { let batchedResponseList = []; Object.keys(subscribeEventGroups).forEach((listId) => { // eventChunks = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] - const eventChunks = _.chunk(subscribeEventGroups[listId], MAX_BATCH_SIZE); + const eventChunks = lodash.chunk(subscribeEventGroups[listId], MAX_BATCH_SIZE); const batchedResponse = eventChunks.map((chunk) => { const batchEventResponse = generateBatchedPaylaodForArray(chunk); return getSuccessRespEvents( diff --git a/src/v0/destinations/kustomer/util.js b/src/v0/destinations/kustomer/util.js index dd89f8ed5d..31157b2738 100644 --- a/src/v0/destinations/kustomer/util.js +++ b/src/v0/destinations/kustomer/util.js @@ -1,5 +1,5 @@ /* eslint-disable eqeqeq */ -const _ = require('lodash'); +const lodash = require('lodash'); const set = require('set-value'); const get = require('get-value'); const myAxios = require('../../../util/myAxios'); @@ -26,7 +26,7 @@ const ISO_8601 = /^\d{4}(-\d\d(-\d\d(t\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)| const transformNumberField = (fieldName) => { const typeDelim = ''; const transformedFieldName = fieldName.trim().replace(/\s+/g, '-'); - if (_.endsWith(transformedFieldName, 'Num')) { + if (lodash.endsWith(transformedFieldName, 'Num')) { return transformedFieldName; } return `${transformedFieldName}${typeDelim}Num`; @@ -35,7 +35,7 @@ const transformNumberField = (fieldName) => { const transformDateField = (fieldName) => { const typeDelim = ''; const transformedFieldName = fieldName.trim().replace(/\s+/g, '-'); - if (_.endsWith(transformedFieldName, 'At')) { + if (lodash.endsWith(transformedFieldName, 'At')) { return transformedFieldName; } return `${transformedFieldName}${typeDelim}At`; @@ -62,7 +62,7 @@ const transformField = (fieldName) => { }; const handleAdvancedtransformations = (event) => { - let cloneEvent = _.cloneDeep(event); + let cloneEvent = lodash.cloneDeep(event); const transformedMeta = {}; let eventName = get(cloneEvent, 'name'); const { meta } = cloneEvent; diff --git a/src/v0/destinations/mailchimp/transform.js b/src/v0/destinations/mailchimp/transform.js index 3ceb669da1..70b37200f4 100644 --- a/src/v0/destinations/mailchimp/transform.js +++ b/src/v0/destinations/mailchimp/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const { defaultPutRequestConfig, handleRtTfSingleEventError, @@ -130,10 +130,10 @@ const batchEvents = (successRespList) => { // audienceId1: [...events] // audienceId2: [...events] // } - const audienceEventGroups = _.groupBy(successRespList, (event) => event.message.audienceId); + const audienceEventGroups = lodash.groupBy(successRespList, (event) => event.message.audienceId); Object.keys(audienceEventGroups).forEach((audienceId) => { // eventChunks = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] - const eventChunks = _.chunk(audienceEventGroups[audienceId], MAX_BATCH_SIZE); + const eventChunks = lodash.chunk(audienceEventGroups[audienceId], MAX_BATCH_SIZE); eventChunks.forEach((chunk) => { const batchEventResponse = generateBatchedPaylaodForArray(audienceId, chunk); batchedResponseList.push( diff --git a/src/v0/destinations/mailjet/transform.js b/src/v0/destinations/mailjet/transform.js index fa87b3ed2a..3e3cfe5c81 100644 --- a/src/v0/destinations/mailjet/transform.js +++ b/src/v0/destinations/mailjet/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const { getErrorRespEvents, getSuccessRespEvents, @@ -98,12 +98,12 @@ const batchEvents = (successRespList) => { "listId2&&Action2": [{message : {}, metadata : {}, destination: {}}], "listId2&&Action1": [{message : {}, metadata : {}, destination: {}}] */ - const eventGroups = _.groupBy(successRespList, (event) => { + const eventGroups = lodash.groupBy(successRespList, (event) => { const { listId, action } = event.message; return `${listId}&&${action}`; }); Object.keys(eventGroups).forEach((combination) => { - const eventChunks = _.chunk(eventGroups[combination], MAX_BATCH_SIZE); + const eventChunks = lodash.chunk(eventGroups[combination], MAX_BATCH_SIZE); // eventChunks = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] eventChunks.forEach((chunk) => { const batchEventResponse = generateBatchedPaylaodForArray(chunk, combination); diff --git a/src/v0/destinations/mailmodo/transform.js b/src/v0/destinations/mailmodo/transform.js index 4f1a3d7e8c..39783c864f 100644 --- a/src/v0/destinations/mailmodo/transform.js +++ b/src/v0/destinations/mailmodo/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const get = require('get-value'); const { isEmpty } = require('lodash'); const { EventType } = require('../../../constants'); @@ -112,7 +112,7 @@ const process = (event) => processEvent(event.message, event.destination); function batchEvents(eventsChunk) { const batchedResponseList = []; - const arrayChunks = _.chunk(eventsChunk, IDENTIFY_MAX_BATCH_SIZE); + const arrayChunks = lodash.chunk(eventsChunk, IDENTIFY_MAX_BATCH_SIZE); // list of chunks [ [..], [..] ] arrayChunks.forEach((chunk) => { diff --git a/src/v0/destinations/marketo/networkHandler.js b/src/v0/destinations/marketo/networkHandler.js index c25a7a246c..7abcc65c02 100644 --- a/src/v0/destinations/marketo/networkHandler.js +++ b/src/v0/destinations/marketo/networkHandler.js @@ -3,7 +3,6 @@ const { marketoResponseHandler } = require('./util'); const { proxyRequest, prepareProxyRequest } = require('../../../adapters/network'); const { processAxiosResponse } = require('../../../adapters/utils/networkUtils'); -// eslint-disable-next-line no-unused-vars const responseHandler = (destinationResponse, destType) => { const message = 'Request Processed Successfully'; const { status, rudderJobMetadata } = destinationResponse; diff --git a/src/v0/destinations/marketo_bulk_upload/util.js b/src/v0/destinations/marketo_bulk_upload/util.js index 0b4eb1e48a..a60f57e50b 100644 --- a/src/v0/destinations/marketo_bulk_upload/util.js +++ b/src/v0/destinations/marketo_bulk_upload/util.js @@ -410,8 +410,9 @@ const getFieldSchemaMap = async (accessToken, munchkinId) => { const checkEventStatusViaSchemaMatching = (event, fieldMap) => { const mismatchedFields = {}; const events = event.input; - events.forEach((event) => { - const { message, metadata } = event; + events.forEach((ev) => { + const { message, metadata } = ev; + // eslint-disable-next-line @typescript-eslint/naming-convention const { job_id } = metadata; Object.entries(message).forEach(([paramName, paramValue]) => { diff --git a/src/v0/destinations/marketo_static_list/networkHandler.js b/src/v0/destinations/marketo_static_list/networkHandler.js index 5a783086b8..30b053b9d3 100644 --- a/src/v0/destinations/marketo_static_list/networkHandler.js +++ b/src/v0/destinations/marketo_static_list/networkHandler.js @@ -4,7 +4,6 @@ const v0Utils = require('../../util'); const { processAxiosResponse } = require('../../../adapters/utils/networkUtils'); const { DESTINATION } = require('./config'); -// eslint-disable-next-line no-unused-vars const responseHandler = (destinationResponse, destType) => { const message = 'Request Processed Successfully'; const { status, rudderJobMetadata } = destinationResponse; @@ -25,6 +24,7 @@ const responseHandler = (destinationResponse, destType) => { }; }; +// eslint-disable-next-line @typescript-eslint/naming-convention class networkHandler { constructor() { this.responseHandler = responseHandler; diff --git a/src/v0/destinations/marketo_static_list/transform.js b/src/v0/destinations/marketo_static_list/transform.js index 7175b5241f..156e26270b 100644 --- a/src/v0/destinations/marketo_static_list/transform.js +++ b/src/v0/destinations/marketo_static_list/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const cloneDeep = require('lodash/cloneDeep'); const { defaultPostRequestConfig, @@ -50,7 +50,7 @@ const batchResponseBuilder = (message, Config, token, leadIds, operation) => { throw new InstrumentationError('No static listId is provided'); } const response = []; - const leadIdsChunks = _.chunk(leadIds, MAX_LEAD_IDS_SIZE); + const leadIdsChunks = lodash.chunk(leadIds, MAX_LEAD_IDS_SIZE); leadIdsChunks.forEach((ids) => { response.push(responseBuilder(endpoint, ids, operation, token)); }); diff --git a/src/v0/destinations/mp/deleteUsers.js b/src/v0/destinations/mp/deleteUsers.js index 52be45f230..5b86cae6ae 100644 --- a/src/v0/destinations/mp/deleteUsers.js +++ b/src/v0/destinations/mp/deleteUsers.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const { handleHttpRequest } = require('../../../adapters/network'); const { isHttpStatusSuccess } = require('../../util'); const { @@ -37,7 +37,7 @@ const deleteProfile = async (userAttributes, config) => { // batchEvents = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] // ref : https://developer.mixpanel.com/reference/delete-profile - const batchEvents = _.chunk(data, DEL_MAX_BATCH_SIZE); + const batchEvents = lodash.chunk(data, DEL_MAX_BATCH_SIZE); await Promise.all( batchEvents.map(async (batchEvent) => { const { processedResponse: handledDelResponse } = await handleHttpRequest( @@ -70,7 +70,7 @@ const deleteProfile = async (userAttributes, config) => { }; const createDeletionTask = async (userAttributes, config) => { - const { token, gdprApiToken } = config; + const { token, gdprApiToken, dataResidency } = config; if (!gdprApiToken) { throw new ConfigurationError( @@ -84,7 +84,7 @@ const createDeletionTask = async (userAttributes, config) => { 'Content-Type': JSON_MIME_TYPE, Authorization: `Bearer ${gdprApiToken}`, }; - const complianceType = config?.dataResidency === 'eu' ? 'GDPR' : 'CCPA'; + const complianceType = dataResidency === 'eu' ? 'GDPR' : 'CCPA'; // batchEvents = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] // ref : https://developer.mixpanel.com/docs/privacy-security#create-a-deletion-task diff --git a/src/v0/destinations/mp/transform.js b/src/v0/destinations/mp/transform.js index 7839b9f123..bdae00e1c2 100644 --- a/src/v0/destinations/mp/transform.js +++ b/src/v0/destinations/mp/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const get = require('get-value'); const { EventType } = require('../../../constants'); const { @@ -440,8 +440,8 @@ const processRouterDest = async (inputs, reqMetadata) => { let processedEvents = await process(event); processedEvents = CommonUtils.toArray(processedEvents); - return processedEvents.map((response) => ({ - message: response, + return processedEvents.map((res) => ({ + message: res, metadata: event.metadata, destination: event.destination, })); @@ -451,7 +451,7 @@ const processRouterDest = async (inputs, reqMetadata) => { }), ); - transformedPayloads = _.flatMap(transformedPayloads); + transformedPayloads = lodash.flatMap(transformedPayloads); const { engageEvents, groupsEvents, trackEvents, importEvents, batchErrorRespList } = groupEventsByEndpoint(transformedPayloads); @@ -471,7 +471,7 @@ const processRouterDest = async (inputs, reqMetadata) => { ); // Flatten the response array containing batched events from multiple groups - const allBatchedEvents = _.flatMap(response); + const allBatchedEvents = lodash.flatMap(response); return combineBatchRequestsWithSameJobIds(allBatchedEvents); }; diff --git a/src/v0/destinations/mp/util.js b/src/v0/destinations/mp/util.js index c5fc7e04be..35c530855e 100644 --- a/src/v0/destinations/mp/util.js +++ b/src/v0/destinations/mp/util.js @@ -143,6 +143,7 @@ const isImportAuthCredentialsAvailable = (destination) => const findExistingBatch = (batch, metadataMap) => { let existingBatch = null; + // eslint-disable-next-line no-restricted-syntax for (const metadataItem of batch.metadata) { if (metadataMap.has(metadataItem.jobId)) { existingBatch = metadataMap.get(metadataItem.jobId); @@ -158,8 +159,9 @@ const findExistingBatch = (batch, metadataMap) => { * @param {*} mergedBatches An array of merged batch objects. */ const removeDuplicateMetadata = (mergedBatches) => { - for (const batch of mergedBatches) { + mergedBatches.forEach((batch) => { const metadataSet = new Set(); + // eslint-disable-next-line no-param-reassign batch.metadata = batch.metadata.filter((metadataItem) => { if (!metadataSet.has(metadataItem.jobId)) { metadataSet.add(metadataItem.jobId); @@ -167,7 +169,7 @@ const removeDuplicateMetadata = (mergedBatches) => { } return false; }); - } + }); }; /** diff --git a/src/v0/destinations/ometria/transform.js b/src/v0/destinations/ometria/transform.js index d3a4d71753..6d3c2ab174 100644 --- a/src/v0/destinations/ometria/transform.js +++ b/src/v0/destinations/ometria/transform.js @@ -1,4 +1,4 @@ -/* eslint-disable one-var */ +/* eslint-disable one-var, @typescript-eslint/naming-convention */ /* eslint-disable camelcase */ const { EventType } = require('../../../constants'); const { ConfigurationError, InstrumentationError } = require('../../util/errorTypes'); diff --git a/src/v0/destinations/pardot/transform.js b/src/v0/destinations/pardot/transform.js index b9f78a6c34..bfc7386ef9 100644 --- a/src/v0/destinations/pardot/transform.js +++ b/src/v0/destinations/pardot/transform.js @@ -48,10 +48,7 @@ const { getAccessToken, } = require('../../util'); const { CONFIG_CATEGORIES } = require('./config'); -const { - ConfigurationError, - InstrumentationError, -} = require('../../util/errorTypes'); +const { ConfigurationError, InstrumentationError } = require('../../util/errorTypes'); const buildResponse = (payload, url, destination, token) => { const responseBody = removeUndefinedValues(payload); diff --git a/src/v0/destinations/personalize/scripts/create-trackingid.js b/src/v0/destinations/personalize/scripts/create-trackingid.js index 0f4553baac..efd8eaa2f9 100644 --- a/src/v0/destinations/personalize/scripts/create-trackingid.js +++ b/src/v0/destinations/personalize/scripts/create-trackingid.js @@ -11,7 +11,7 @@ const { fromEnv } = require('@aws-sdk/credential-providers'); const readline = require('readline'); -require('dotenv').config() +require('dotenv').config(); async function promtForInput(rl, questionText) { return new Promise((resolve) => { @@ -33,7 +33,8 @@ async function collectInputs(rl) { await checkEnvAndpromtForInput(rl, 'AWS Secret Access Key: ', 'AWS_SECRET_ACCESS_KEY'); await checkEnvAndpromtForInput(rl, 'AWS REGION: ', 'AWS_REGION'); await checkEnvAndpromtForInput(rl, 'Name of Dataset Group: ', 'DATASET_GROUP_NAME'); - await checkEnvAndpromtForInput(rl, + await checkEnvAndpromtForInput( + rl, 'Number of fields in Schema in addition to USER_ID, TIMESTAMP, ITEM_ID: ', 'NUMBER_OF_FIELDS', ); @@ -55,14 +56,12 @@ async function collectFileds(rl) { for (let i = 4; i <= noOfFields + 3; i += 1) { const fieldName = await promtForInput(rl, `Name of field no. ${i}: `); - const typeName = await promtForInput(rl, `Type of field ${fieldName}: `) + const typeName = await promtForInput(rl, `Type of field ${fieldName}: `); schema.fields.push({ name: fieldName, type: typeName }); - } return schema; } - (async function () { let rl = readline.createInterface(process.stdin, process.stdout); await collectInputs(rl); diff --git a/src/v0/destinations/personalize/transform.js b/src/v0/destinations/personalize/transform.js index c8eca2af2f..bb547f7b28 100644 --- a/src/v0/destinations/personalize/transform.js +++ b/src/v0/destinations/personalize/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const { KEY_CHECK_LIST, MANDATORY_PROPERTIES } = require('./config'); const { EventType } = require('../../../constants'); const { @@ -42,28 +42,28 @@ const putEventsHandler = (message, destination) => { throw new InstrumentationError(`Mapped property ${keyMap[key]} not found`); } if (isDefined(disableStringify) && disableStringify) { - outputEvent.properties[_.camelCase(key)] = value; + outputEvent.properties[lodash.camelCase(key)] = value; } else { // users using old config will have stringified property by default - outputEvent.properties[_.camelCase(key)] = String(value); + outputEvent.properties[lodash.camelCase(key)] = String(value); } } else if (!MANDATORY_PROPERTIES.includes(key.toUpperCase())) { if ((!isDefinedAndNotNull(value) || isBlank(value)) && key.toUpperCase() !== 'ITEM_ID') { throw new InstrumentationError(`Null values cannot be sent for ${keyMap[key]} `); } if (!(key.toUpperCase() === 'IMPRESSION' || key.toUpperCase() === 'EVENT_VALUE')) - outputEvent[_.camelCase(key)] = String(value); + outputEvent[lodash.camelCase(key)] = String(value); else if (key.toUpperCase() === 'IMPRESSION') { - outputEvent[_.camelCase(key)] = Array.isArray(value) ? value.map(String) : [String(value)]; - outputEvent[_.camelCase(key)] = _.without( - outputEvent[_.camelCase(key)], + outputEvent[lodash.camelCase(key)] = Array.isArray(value) ? value.map(String) : [String(value)]; + outputEvent[lodash.camelCase(key)] = lodash.without( + outputEvent[lodash.camelCase(key)], undefined, null, '', ); } else if (!Number.isNaN(parseFloat(value))) { // for eventValue - outputEvent[_.camelCase(key)] = parseFloat(value); + outputEvent[lodash.camelCase(key)] = parseFloat(value); } else throw new InstrumentationError('EVENT_VALUE should be a float value'); } }); @@ -115,7 +115,7 @@ const putItemsHandler = (message, destination) => { // eslint-disable-next-line no-lonely-if if (!isDefinedAndNotNull(value) || isBlank(value)) { // itemId cannot be null - value = String(_.get(message, keyMap[key])); + value = String(lodash.get(message, keyMap[key])); } } if (!isDefined(value)) { @@ -123,7 +123,7 @@ const putItemsHandler = (message, destination) => { } if (key.toUpperCase() !== 'ITEM_ID') { // itemId is not allowed inside properties - outputItem.properties[_.camelCase(key)] = value; + outputItem.properties[lodash.camelCase(key)] = value; } else { outputItem.itemId = String(value); } @@ -185,7 +185,7 @@ const identifyRequestHandler = (message, destination, eventOperation) => { } if (key.toUpperCase() !== 'USER_ID') { // userId is not allowed inside properties - outputUser.properties[_.camelCase(key)] = value; + outputUser.properties[lodash.camelCase(key)] = value; } }); if (!outputUser.userId) { diff --git a/src/v0/destinations/redis/transform.js b/src/v0/destinations/redis/transform.js index 124569c8e8..e9442d8487 100644 --- a/src/v0/destinations/redis/transform.js +++ b/src/v0/destinations/redis/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const flatten = require('flat'); const { isEmpty, isObject } = require('../../util'); @@ -17,7 +17,7 @@ const processValues = (obj) => { } const val = obj[key]; // eslint-disable-next-line no-param-reassign - obj[key] = _.isArray(val) ? JSON.stringify(val) : _.toString(val); + obj[key] = lodash.isArray(val) ? JSON.stringify(val) : lodash.toString(val); }); }; @@ -68,7 +68,7 @@ const process = (event) => { } const hmap = { - key: `${keyPrefix}user:${_.toString(message.userId)}`, + key: `${keyPrefix}user:${lodash.toString(message.userId)}`, fields: {}, }; diff --git a/src/v0/destinations/sendgrid/transform.js b/src/v0/destinations/sendgrid/transform.js index 0f944e5f28..4e68b34c7d 100644 --- a/src/v0/destinations/sendgrid/transform.js +++ b/src/v0/destinations/sendgrid/transform.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const { EventType } = require('../../../constants'); const { ErrorMessage, @@ -211,10 +211,10 @@ const batchEvents = (successRespList) => { "contactListIds3": [{message : {}, metadata : {}, destination: {}}], "contactListIds4": [{message : {}, metadata : {}, destination: {}}] */ - const eventGroups = _.groupBy(identifyCalls, (event) => event.message.body.JSON.contactListIds); + const eventGroups = lodash.groupBy(identifyCalls, (event) => event.message.body.JSON.contactListIds); Object.keys(eventGroups).forEach((combination) => { - const eventChunks = _.chunk(eventGroups[combination], MAX_BATCH_SIZE); + const eventChunks = lodash.chunk(eventGroups[combination], MAX_BATCH_SIZE); // eventChunks = [[e1,e2,e3,..batchSize],[e1,e2,e3,..batchSize]..] eventChunks.forEach((chunk) => { const batchEventResponse = generateBatchedPaylaodForArray(chunk, combination); diff --git a/src/v0/destinations/sendinblue/transform.js b/src/v0/destinations/sendinblue/transform.js index 8e8645f32f..151304db22 100644 --- a/src/v0/destinations/sendinblue/transform.js +++ b/src/v0/destinations/sendinblue/transform.js @@ -1,4 +1,5 @@ /* eslint-disable camelcase */ +/* eslint-disable @typescript-eslint/naming-convention */ const { EventType } = require('../../../constants'); const { defaultRequestConfig, diff --git a/src/v0/destinations/singular/util.js b/src/v0/destinations/singular/util.js index c2a88a9c46..542b049a2e 100644 --- a/src/v0/destinations/singular/util.js +++ b/src/v0/destinations/singular/util.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); const { CONFIG_CATEGORIES, MAPPING_CONFIG, @@ -75,7 +75,7 @@ const exclusionList = { * @param {*} eventName */ const isSessionEvent = (Config, eventName) => { - const mappedSessionEvents = _.map(Config.sessionEventList, 'sessionEventName'); + const mappedSessionEvents = lodash.map(Config.sessionEventList, 'sessionEventName'); return mappedSessionEvents.includes(eventName) || SESSIONEVENTS.includes(eventName.toLowerCase()); }; diff --git a/src/v0/destinations/slack/transform.js b/src/v0/destinations/slack/transform.js index c913f3103e..8db934d71f 100644 --- a/src/v0/destinations/slack/transform.js +++ b/src/v0/destinations/slack/transform.js @@ -1,5 +1,4 @@ -/* eslint-disable no-nested-ternary */ -/* eslint-disable no-prototype-builtins */ +/* eslint-disable no-nested-ternary, no-restricted-syntax, no-prototype-builtins */ const Handlebars = require('handlebars'); const { EventType } = require('../../../constants'); const { diff --git a/src/v0/destinations/snapchat_custom_audience/networkHandler.js b/src/v0/destinations/snapchat_custom_audience/networkHandler.js index 49ea452550..196f9a87fb 100644 --- a/src/v0/destinations/snapchat_custom_audience/networkHandler.js +++ b/src/v0/destinations/snapchat_custom_audience/networkHandler.js @@ -1,9 +1,7 @@ const { removeUndefinedValues, getAuthErrCategoryFromErrDetailsAndStCode } = require('../../util'); const { prepareProxyRequest, getPayloadData, httpSend } = require('../../../adapters/network'); const { isHttpStatusSuccess } = require('../../util/index'); -const { - REFRESH_TOKEN, -} = require('../../../adapters/networkhandler/authConstants'); +const { REFRESH_TOKEN } = require('../../../adapters/networkhandler/authConstants'); const tags = require('../../util/tags'); const { getDynamicErrorType, diff --git a/src/v0/destinations/tiktok_ads/networkHandler.js b/src/v0/destinations/tiktok_ads/networkHandler.js index ade33e5133..1ec31e982a 100644 --- a/src/v0/destinations/tiktok_ads/networkHandler.js +++ b/src/v0/destinations/tiktok_ads/networkHandler.js @@ -40,6 +40,7 @@ const responseHandler = (destinationResponse) => { ); }; +// eslint-disable-next-line @typescript-eslint/naming-convention class networkHandler { constructor() { this.responseHandler = responseHandler; diff --git a/src/v0/destinations/tiktok_ads/transform.js b/src/v0/destinations/tiktok_ads/transform.js index 6bf9cd7270..4e99d83575 100644 --- a/src/v0/destinations/tiktok_ads/transform.js +++ b/src/v0/destinations/tiktok_ads/transform.js @@ -1,4 +1,5 @@ /* eslint-disable camelcase */ +/* eslint-disable @typescript-eslint/naming-convention */ const _ = require('lodash'); const { SHA256 } = require('crypto-js'); const get = require('get-value'); diff --git a/src/v0/destinations/tiktok_ads/util.js b/src/v0/destinations/tiktok_ads/util.js index 98acb794a5..4050a9fe34 100644 --- a/src/v0/destinations/tiktok_ads/util.js +++ b/src/v0/destinations/tiktok_ads/util.js @@ -8,6 +8,7 @@ const { removeUndefinedAndNullValues } = require('../../util'); const getContents = (message) => { const contents = []; const { properties } = message; + // eslint-disable-next-line @typescript-eslint/naming-convention const { products, content_type, contentType } = properties; if (products && Array.isArray(products) && products.length > 0) { products.forEach((product) => { diff --git a/src/v0/destinations/tiktok_ads_offline_events/transform.js b/src/v0/destinations/tiktok_ads_offline_events/transform.js index 0ade5bbfbb..3539c856a3 100644 --- a/src/v0/destinations/tiktok_ads_offline_events/transform.js +++ b/src/v0/destinations/tiktok_ads_offline_events/transform.js @@ -1,6 +1,6 @@ const { SHA256 } = require('crypto-js'); const set = require('set-value'); -const _ = require('lodash'); +const lodash = require('lodash'); const { EventType } = require('../../../constants'); const { constructPayload, @@ -191,7 +191,7 @@ const batchEvents = (eventChunksArray) => { // event_set_id1: [...events] // event_set_id2: [...events] // } - const groupedEventChunks = _.groupBy(eventChunksArray, ({ message }) => { + const groupedEventChunks = lodash.groupBy(eventChunksArray, ({ message }) => { if (Array.isArray(message)) return message[0].event_set_id; return message.event_set_id; }); diff --git a/src/v0/sources/auth0/transform.js b/src/v0/sources/auth0/transform.js index 8a0013036b..d2721780d8 100644 --- a/src/v0/sources/auth0/transform.js +++ b/src/v0/sources/auth0/transform.js @@ -41,6 +41,7 @@ function processEvents(eventList) { eventList.forEach((event) => { let response = {}; // eslint-disable-next-line camelcase + // eslint-disable-next-line @typescript-eslint/naming-convention const { data, log_id } = event; // Dropping the event if type is not present if (data && data.type) { diff --git a/src/v0/sources/shopify/transform.js b/src/v0/sources/shopify/transform.js index 5c26bfd844..7bbb928fd8 100644 --- a/src/v0/sources/shopify/transform.js +++ b/src/v0/sources/shopify/transform.js @@ -1,4 +1,5 @@ -const _ = require('lodash'); +/* eslint-disable @typescript-eslint/naming-convention */ +const lodash = require('lodash'); const get = require('get-value'); const stats = require('../../../util/stats'); const { @@ -125,8 +126,8 @@ const trackPayloadBuilder = (event, shopifyTopic) => { const processEvent = async (inputEvent, metricMetadata) => { let message; + const event = lodash.cloneDeep(inputEvent); let redisData; - const event = _.cloneDeep(inputEvent); const shopifyTopic = getShopifyTopic(event); delete event.query_parameters; switch (shopifyTopic) { diff --git a/src/v0/sources/shopify/util.js b/src/v0/sources/shopify/util.js index 76cc255f38..0d81ddc185 100644 --- a/src/v0/sources/shopify/util.js +++ b/src/v0/sources/shopify/util.js @@ -1,8 +1,15 @@ /* eslint-disable camelcase */ +/* eslint-disable @typescript-eslint/naming-convention */ const { v5 } = require('uuid'); const sha256 = require('sha256'); const stats = require('../../../util/stats'); -const { constructPayload, extractCustomFields, flattenJson, generateUUID, isDefinedAndNotNull, } = require('../../util'); +const { + constructPayload, + extractCustomFields, + flattenJson, + generateUUID, + isDefinedAndNotNull, +} = require('../../util'); const { RedisDB } = require('../../../util/redis/redisConnector'); const logger = require('../../../logger'); const { @@ -13,11 +20,10 @@ const { SHOPIFY_TRACK_MAP, SHOPIFY_ADMIN_ONLY_EVENTS, useRedisDatabase, - maxTimeToIdentifyRSGeneratedCall + maxTimeToIdentifyRSGeneratedCall, } = require('./config'); const { TransformationError } = require('../../util/errorTypes'); - const getDataFromRedis = async (key, metricMetadata) => { try { stats.increment('shopify_redis_calls', { @@ -32,8 +38,7 @@ const getDataFromRedis = async (key, metricMetadata) => { }); } return redisData; - } - catch (e) { + } catch (e) { logger.debug(`{{SHOPIFY::}} Get call Failed due redis error ${e}`); stats.increment('shopify_redis_failures', { type: 'get', @@ -112,11 +117,11 @@ const extractEmailFromPayload = (event) => { }; const getCartToken = (message) => { - const { event } = message; + const { event, properties } = message; if (event === SHOPIFY_TRACK_MAP.carts_update) { - return message.properties?.id || message.properties?.token; + return properties?.id || properties?.token; } - return message.properties?.cart_token || null; + return properties?.cart_token || null; }; /** @@ -141,9 +146,9 @@ const getRudderIdFromNoteAtrributes = (noteAttributes, field) => { * -> if true we return `null`; * -> else we don't have any identifer (very edge case) we return `random anonymousId` * No Random SessionId is generated as its not a required field - * @param {*} message - * @param {*} metricMetadata - * @returns + * @param {*} message + * @param {*} metricMetadata + * @returns */ const getAnonymousIdAndSessionId = async (message, metricMetadata, redisData = null) => { let anonymousId; @@ -151,8 +156,8 @@ const getAnonymousIdAndSessionId = async (message, metricMetadata, redisData = n const noteAttributes = message.properties?.note_attributes; // Giving Priority to note_attributes to fetch rudderAnonymousId over Redis due to better efficiency if (isDefinedAndNotNull(noteAttributes)) { - anonymousId = getRudderIdFromNoteAtrributes(noteAttributes, "rudderAnonymousId"); - sessionId = getRudderIdFromNoteAtrributes(noteAttributes, "rudderSessionId"); + anonymousId = getRudderIdFromNoteAtrributes(noteAttributes, 'rudderAnonymousId'); + sessionId = getRudderIdFromNoteAtrributes(noteAttributes, 'rudderSessionId'); } // falling back to cartToken mapping or its hash in case no rudderAnonymousId or rudderSessionId is found if (isDefinedAndNotNull(anonymousId) && isDefinedAndNotNull(sessionId)) { @@ -163,7 +168,10 @@ const getAnonymousIdAndSessionId = async (message, metricMetadata, redisData = n if (SHOPIFY_ADMIN_ONLY_EVENTS.includes(message.event)) { return { anonymousId, sessionId }; } - return { anonymousId: isDefinedAndNotNull(anonymousId) ? anonymousId : generateUUID(), sessionId }; + return { + anonymousId: isDefinedAndNotNull(anonymousId) ? anonymousId : generateUUID(), + sessionId, + }; } if (useRedisDatabase) { if (!isDefinedAndNotNull(redisData)) { @@ -196,8 +204,7 @@ const updateCartItemsInRedis = async (cartToken, newCartItemsHash, metricMetadat ...metricMetadata, }); await RedisDB.setVal(`${cartToken}`, value); - } - catch (e) { + } catch (e) { logger.debug(`{{SHOPIFY::}} itemsHash set call Failed due redis error ${e}`); stats.increment('shopify_redis_failures', { type: 'set', @@ -228,10 +235,10 @@ const checkAndUpdateCartItems = async (inputEvent, redisData, metricMetadata) => } await updateCartItemsInRedis(cartToken, newCartItemsHash, metricMetadata); } else { - const { created_at, updated_at } = inputEvent; + const { created_at, updated_at, line_items } = inputEvent; const timeDifference = Date.parse(updated_at) - Date.parse(created_at); const isTimeWithinThreshold = timeDifference < maxTimeToIdentifyRSGeneratedCall; - const isLineItemsEmpty = inputEvent?.line_items?.length === 0; + const isLineItemsEmpty = line_items?.length === 0; if (isTimeWithinThreshold && isLineItemsEmpty) { return false; diff --git a/src/v0/util/deleteUserUtils.js b/src/v0/util/deleteUserUtils.js index 81607aeb3d..6cf16d7f9e 100644 --- a/src/v0/util/deleteUserUtils.js +++ b/src/v0/util/deleteUserUtils.js @@ -1,4 +1,4 @@ -const _ = require('lodash'); +const lodash = require('lodash'); /** * Takes the userAttributes array fetches userIds at root level of each element * and make batches of Ids accoring to MAX_BATCH_SIZE @@ -14,7 +14,7 @@ const getUserIdBatches = (userAttributes, MAX_BATCH_SIZE) => { userIds.push(userAttribute.userId); } }); - const userIdBatches = _.chunk(userIds, MAX_BATCH_SIZE); + const userIdBatches = lodash.chunk(userIds, MAX_BATCH_SIZE); return userIdBatches; }; diff --git a/src/v0/util/index.js b/src/v0/util/index.js index 00f98cafaf..42a4100510 100644 --- a/src/v0/util/index.js +++ b/src/v0/util/index.js @@ -9,7 +9,7 @@ const Handlebars = require('handlebars'); const fs = require('fs'); const path = require('path'); -const _ = require('lodash'); +const lodash = require('lodash'); const set = require('set-value'); const get = require('get-value'); const uaParser = require('ua-parser-js'); @@ -36,17 +36,18 @@ const { // INLINERS // ======================================================================== -const isDefined = (x) => !_.isUndefined(x); -const isNotEmpty = (x) => !_.isEmpty(x); +const isDefined = (x) => !lodash.isUndefined(x); +const isNotEmpty = (x) => !lodash.isEmpty(x); const isNotNull = (x) => x != null; const isDefinedAndNotNull = (x) => isDefined(x) && isNotNull(x); const isDefinedAndNotNullAndNotEmpty = (x) => isDefined(x) && isNotNull(x) && isNotEmpty(x); -const removeUndefinedValues = (obj) => _.pickBy(obj, isDefined); -const removeNullValues = (obj) => _.pickBy(obj, isNotNull); -const removeUndefinedAndNullValues = (obj) => _.pickBy(obj, isDefinedAndNotNull); -const removeUndefinedAndNullAndEmptyValues = (obj) => _.pickBy(obj, isDefinedAndNotNullAndNotEmpty); -const isBlank = (value) => _.isEmpty(_.toString(value)); -const flattenMap = (collection) => _.flatMap(collection, (x) => x); +const removeUndefinedValues = (obj) => lodash.pickBy(obj, isDefined); +const removeNullValues = (obj) => lodash.pickBy(obj, isNotNull); +const removeUndefinedAndNullValues = (obj) => lodash.pickBy(obj, isDefinedAndNotNull); +const removeUndefinedAndNullAndEmptyValues = (obj) => + lodash.pickBy(obj, isDefinedAndNotNullAndNotEmpty); +const isBlank = (value) => lodash.isEmpty(lodash.toString(value)); +const flattenMap = (collection) => lodash.flatMap(collection, (x) => x); // ======================================================================== // GENERIC UTLITY // ======================================================================== @@ -108,7 +109,7 @@ const isObject = (value) => { }; function isEmpty(input) { - return _.isEmpty(_.toString(input).trim()); + return lodash.isEmpty(lodash.toString(input).trim()); } /** @@ -126,8 +127,8 @@ function isEmptyObject(obj) { /** * Function to check if value is Defined, Not null and Not Empty. - * Create this function, Because existing isDefinedAndNotNullAndNotEmpty(123) is returning false due to lodash _.isEmpty function. - * _.isEmpty is used to detect empty collections/objects and it will return true for Integer, Boolean values. + * Create this function, Because existing isDefinedAndNotNullAndNotEmpty(123) is returning false due to lodash lodash.isEmpty function. + * lodash.isEmpty is used to detect empty collections/objects and it will return true for Integer, Boolean values. * ref: https://github.com/lodash/lodash/issues/496 * @param {*} value 123 * @returns yes @@ -141,7 +142,7 @@ const isDefinedNotNullNotEmpty = (value) => (typeof value === 'string' && value.trim().length === 0) ); -const removeUndefinedNullEmptyExclBoolInt = (obj) => _.pickBy(obj, isDefinedNotNullNotEmpty); +const removeUndefinedNullEmptyExclBoolInt = (obj) => lodash.pickBy(obj, isDefinedNotNullNotEmpty); /** * Recursively removes undefined, null, empty objects, and empty arrays from the given object at all levels. @@ -149,6 +150,7 @@ const removeUndefinedNullEmptyExclBoolInt = (obj) => _.pickBy(obj, isDefinedNotN * @returns */ const removeUndefinedNullValuesAndEmptyObjectArray = (obj) => { + // eslint-disable-next-line @typescript-eslint/no-shadow function recursive(obj) { if (Array.isArray(obj)) { const cleanedArray = obj @@ -239,11 +241,11 @@ const getHashFromArrayWithValueAsObject = (arrays, fromKey = 'from', isLowerCase const getValueFromPropertiesOrTraits = ({ message, key }) => { const keySet = ['properties', 'traits', 'context.traits']; - const val = _.find( - _.map(keySet, (k) => get(message, `${k}.${key}`)), - (v) => !_.isNil(v), + const val = lodash.find( + lodash.map(keySet, (k) => get(message, `${k}.${key}`)), + (v) => !lodash.isNil(v), ); - return !_.isNil(val) ? val : null; + return !lodash.isNil(val) ? val : null; }; /** @@ -263,6 +265,7 @@ const hasCircularReference = (obj, seen = []) => { } seen.push(obj); + // eslint-disable-next-line no-restricted-syntax for (const value of Object.values(obj)) { if (hasCircularReference(value, seen)) { return true; @@ -556,7 +559,7 @@ const handleSourceKeysOperation = ({ message, operationObject }) => { // quick sanity check for the undefined values in the list. // if there is any undefined values, return null // without going further for operations - const isAllDefined = _.every(argValues, (v) => !_.isNil(v)); + const isAllDefined = lodash.every(argValues, (v) => !lodash.isNil(v)); if (!isAllDefined) { return null; } @@ -568,9 +571,9 @@ const handleSourceKeysOperation = ({ message, operationObject }) => { result = 1; // eslint-disable-next-line no-restricted-syntax for (const v of argValues) { - if (_.isNumber(v)) { + if (lodash.isNumber(v)) { result *= v; - } else if (_.isString(v) && /^[+-]?(\d+(\.\d*)?|\.\d+)([Ee][+-]?\d+)?$/.test(v)) { + } else if (lodash.isString(v) && /^[+-]?(\d+(\.\d*)?|\.\d+)([Ee][+-]?\d+)?$/.test(v)) { result *= parseFloat(v); } else { // if there is a non number argument simply return null @@ -583,7 +586,7 @@ const handleSourceKeysOperation = ({ message, operationObject }) => { result = 0; // eslint-disable-next-line no-restricted-syntax for (const v of argValues) { - if (_.isNumber(v)) { + if (lodash.isNumber(v)) { result += v; } else { // if there is a non number argument simply return null @@ -1051,7 +1054,7 @@ const constructPayload = (message, mappingJson, destinationName = null) => { if (value || value === 0 || value === false) { if (destKey) { // set the value only if correct - _.set(payload, destKey, value); + lodash.set(payload, destKey, value); } else { // to set to root and flatten later payload[''] = value; @@ -1428,12 +1431,12 @@ const errorStatusCodeKeys = ['response.status', 'code', 'status']; const getErrorStatusCode = (error, defaultStatusCode = HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR) => { try { let defaultStCode = defaultStatusCode; - if (!_.isNumber(defaultStatusCode)) { + if (!lodash.isNumber(defaultStatusCode)) { defaultStCode = HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR; } const errStCode = errorStatusCodeKeys .map((statusKey) => get(error, statusKey)) - .find((stCode) => _.isNumber(stCode)); + .find((stCode) => lodash.isNumber(stCode)); return errStCode || defaultStCode; } catch (err) { logger.error('Failed in getErrorStatusCode', err); @@ -1931,7 +1934,7 @@ const batchMultiplexedEvents = (transformedEventsList, maxBatchSize) => { } if (batchedEvents.length === 0 || eventsNotBatched) { if (transformedMessage.length > maxBatchSize) { - transformedMessage = _.chunk(transformedMessage, maxBatchSize); + transformedMessage = lodash.chunk(transformedMessage, maxBatchSize); } batchedEvents.push({ events: transformedMessage, diff --git a/test/__mocks__/data/marketo_static_list/proxy_response.json b/test/__mocks__/data/marketo_static_list/proxy_response.json index 2a58d99da2..290a4f5fbf 100644 --- a/test/__mocks__/data/marketo_static_list/proxy_response.json +++ b/test/__mocks__/data/marketo_static_list/proxy_response.json @@ -96,4 +96,4 @@ }, "status": 200 } -} \ No newline at end of file +} diff --git a/test/__tests__/data/customerio_input.json b/test/__tests__/data/customerio_input.json index ea89411524..e2d987fc5a 100644 --- a/test/__tests__/data/customerio_input.json +++ b/test/__tests__/data/customerio_input.json @@ -2584,21 +2584,11 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU" - ], - "web": [ - "useNativeSDK" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU"], + "web": ["useNativeSDK"] }, "excludeKeys": [], - "includeKeys": [ - "apiKey", - "siteID", - "datacenterEU" - ], + "includeKeys": ["apiKey", "siteID", "datacenterEU"], "saveDestinationResponse": true, "secretKeys": [], "supportedSourceTypes": [ @@ -2674,21 +2664,11 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU" - ], - "web": [ - "useNativeSDK" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU"], + "web": ["useNativeSDK"] }, "excludeKeys": [], - "includeKeys": [ - "apiKey", - "siteID", - "datacenterEU" - ], + "includeKeys": ["apiKey", "siteID", "datacenterEU"], "saveDestinationResponse": true, "secretKeys": [], "supportedSourceTypes": [ @@ -2804,17 +2784,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -2826,12 +2797,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -2945,17 +2911,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -2967,12 +2924,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -3085,17 +3037,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -3107,12 +3050,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -3225,17 +3163,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -3247,12 +3176,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -3362,17 +3286,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -3384,12 +3299,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -3503,17 +3413,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -3525,12 +3426,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -3644,17 +3540,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -3666,12 +3553,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -3785,17 +3667,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -3807,12 +3680,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -3925,17 +3793,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -3947,12 +3806,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -4062,17 +3916,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -4084,12 +3929,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -4203,17 +4043,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -4225,12 +4056,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -4308,17 +4134,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -4330,12 +4147,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -4413,17 +4225,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -4435,12 +4238,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -4521,17 +4319,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -4543,12 +4332,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -4629,17 +4413,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -4651,12 +4426,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -4738,17 +4508,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -4760,12 +4521,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -4847,17 +4603,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -4869,12 +4616,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -4956,17 +4698,8 @@ "DisplayName": "Customer IO", "Config": { "destConfig": { - "defaultConfig": [ - "apiKey", - "siteID", - "datacenterEU", - "deviceTokenEventName" - ], - "web": [ - "useNativeSDK", - "blackListedEvents", - "whiteListedEvents" - ] + "defaultConfig": ["apiKey", "siteID", "datacenterEU", "deviceTokenEventName"], + "web": ["useNativeSDK", "blackListedEvents", "whiteListedEvents"] }, "excludeKeys": [], "includeKeys": [ @@ -4978,12 +4711,7 @@ ], "saveDestinationResponse": true, "secretKeys": [], - "supportedMessageTypes": [ - "identify", - "page", - "screen", - "track" - ], + "supportedMessageTypes": ["identify", "page", "screen", "track"], "supportedSourceTypes": [ "android", "ios", @@ -5167,4 +4895,4 @@ } } } -] \ No newline at end of file +] diff --git a/test/__tests__/data/google_adwords_enhanced_conversions_proxy_input.json b/test/__tests__/data/google_adwords_enhanced_conversions_proxy_input.json index 612efeb99a..430cfbd05f 100644 --- a/test/__tests__/data/google_adwords_enhanced_conversions_proxy_input.json +++ b/test/__tests__/data/google_adwords_enhanced_conversions_proxy_input.json @@ -158,4 +158,4 @@ }, "files": {} } -] \ No newline at end of file +] diff --git a/test/__tests__/data/google_adwords_offline_conversions.json b/test/__tests__/data/google_adwords_offline_conversions.json index 9bdb5cda45..3c7b54ac4c 100644 --- a/test/__tests__/data/google_adwords_offline_conversions.json +++ b/test/__tests__/data/google_adwords_offline_conversions.json @@ -4600,4 +4600,4 @@ } ] } -] \ No newline at end of file +] diff --git a/test/__tests__/data/google_adwords_remarketing_lists_proxy_input.json b/test/__tests__/data/google_adwords_remarketing_lists_proxy_input.json index 3cd282ec2a..ff74720bc3 100644 --- a/test/__tests__/data/google_adwords_remarketing_lists_proxy_input.json +++ b/test/__tests__/data/google_adwords_remarketing_lists_proxy_input.json @@ -135,4 +135,4 @@ }, "files": {} } -] \ No newline at end of file +] diff --git a/test/__tests__/data/marketo_static_list_proxy_output.json b/test/__tests__/data/marketo_static_list_proxy_output.json index 8ac482b5be..ec52d0c37c 100644 --- a/test/__tests__/data/marketo_static_list_proxy_output.json +++ b/test/__tests__/data/marketo_static_list_proxy_output.json @@ -126,4 +126,4 @@ } } } -] \ No newline at end of file +] diff --git a/test/__tests__/data/slack_input.json b/test/__tests__/data/slack_input.json index f9a0b49841..e29624490c 100644 --- a/test/__tests__/data/slack_input.json +++ b/test/__tests__/data/slack_input.json @@ -1412,4 +1412,4 @@ "sourceId": "1YhwKyDcKstudlGxkeN5p2wgsrp" } } -] \ No newline at end of file +] diff --git a/test/__tests__/data/slack_output.json b/test/__tests__/data/slack_output.json index 63d7934a00..c772aa3b19 100644 --- a/test/__tests__/data/slack_output.json +++ b/test/__tests__/data/slack_output.json @@ -161,4 +161,4 @@ { "error": "Event is denied. Please check configuration." } -] \ No newline at end of file +] diff --git a/test/integrations/destinations/bqstream/router/data.ts b/test/integrations/destinations/bqstream/router/data.ts index 4fac9047cc..e44ce4af15 100644 --- a/test/integrations/destinations/bqstream/router/data.ts +++ b/test/integrations/destinations/bqstream/router/data.ts @@ -418,27 +418,27 @@ export const data = [ Name: 'bqstream test', }, - error: "Message Type not supported: identify", + error: 'Message Type not supported: identify', metadata: [ { jobId: 3, - userId: "user12345" + userId: 'user12345', }, { jobId: 9, - userId: "user125" - } + userId: 'user125', + }, ], statTags: { - destType: "BQSTREAM", - errorCategory: "dataValidation", - errorType: "instrumentation", - feature: "router", - implementation: "native", - module: "destination" + destType: 'BQSTREAM', + errorCategory: 'dataValidation', + errorType: 'instrumentation', + feature: 'router', + implementation: 'native', + module: 'destination', }, - statusCode: 400 - } + statusCode: 400, + }, ], }, },