Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:rudderlabs/rudder-transformer in…
Browse files Browse the repository at this point in the history
…to fix.add-ga-auth-status-inactive
  • Loading branch information
Sai Sankeerth committed Sep 29, 2023
2 parents 63cfe9a + 4d6c4b8 commit 4ea02c3
Show file tree
Hide file tree
Showing 123 changed files with 723 additions and 903 deletions.
40 changes: 21 additions & 19 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
4 changes: 2 additions & 2 deletions src/adapters/network.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/utils/networkUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable eqeqeq */
const _ = require('lodash');
const lodash = require('lodash');
const { isEmpty } = require('lodash');
const {
isHttpStatusRetryable,
Expand Down Expand Up @@ -100,7 +100,7 @@ const parseDestResponse = (destResponse, destination = '') => {
if (
!isDefinedAndNotNull(responseBody) ||
!isDefinedAndNotNull(status) ||
!_.isNumber(status) ||
!lodash.isNumber(status) ||
status === 0
) {
throw new AbortedError(
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/v1/dcm_floodlight/transform.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-param-reassign */
const get = require('get-value');
const _ = require('lodash');
const lodash = require('lodash');
const {
removeUndefinedAndNullValues,
isDefinedAndNotNull,
Expand Down Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions src/cdk/v1/new_relic/transform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-param-reassign */
const { isBoolean } = require('lodash');
const { Utils } = require('rudder-transformer-cdk');

Expand Down
4 changes: 2 additions & 2 deletions src/cdk/v2/destinations/dcm_floodlight/utils.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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))
Expand Down
9 changes: 5 additions & 4 deletions src/cdk/v2/destinations/eloqua/utils.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/v2/destinations/launchdarkly_audience/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const _ = require('lodash');
const lodash = require('lodash');
const { ACTION_TYPES, IDENTIFIER_KEY, MAX_IDENTIFIERS } = require('./config');

/**
Expand Down Expand Up @@ -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) => {
Expand Down
15 changes: 8 additions & 7 deletions src/cdk/v2/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ExecutionBindings,
StepOutput,
} from '@rudderstack/workflow-engine';
import { FixMe } from '../../util/types';

import tags from '../../v0/util/tags';

Expand All @@ -25,7 +26,7 @@ export function getEmptyExecutionBindings() {
return {
outputs: {},
context,
setContext: (key: string, value: any) => {
setContext: (key: string, value: FixMe) => {
context[key] = value;
},
};
Expand All @@ -34,7 +35,7 @@ export function getEmptyExecutionBindings() {
export async function getWorkflowEngine(
destName: string,
feature: string,
bindings: Record<string, any> = {},
bindings: Record<string, FixMe> = {},
) {
const destRootDir = getRootPathForDestination(destName);
const workflowPath = await getWorkflowPath(destRootDir, feature);
Expand All @@ -52,7 +53,7 @@ const workflowEnginePromiseMap = new Map();
export function getCachedWorkflowEngine(
destName: string,
feature: string,
bindings: Record<string, any> = {},
bindings: Record<string, unknown> = {},
): WorkflowEngine {
// Create a new instance of the engine for the destination if needed
// TODO: Use cache to avoid long living engine objects
Expand All @@ -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
Expand All @@ -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<string, any> = {},
bindings: Record<string, FixMe> = {},
) {
try {
const workflowEngine = await getCachedWorkflowEngine(destType, feature, bindings);
Expand All @@ -90,7 +91,7 @@ export async function processCdkV2Workflow(
export function executeStep(
workflowEngine: WorkflowEngine,
stepName: string,
input: any,
input: FixMe,
bindings?: ExecutionBindings,
): Promise<StepOutput> {
return workflowEngine
Expand Down
11 changes: 4 additions & 7 deletions src/cdk/v2/utils.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -83,15 +80,15 @@ 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;

if (err instanceof WorkflowExecutionError) {
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;
Expand Down
Loading

0 comments on commit 4ea02c3

Please sign in to comment.