Skip to content

Commit

Permalink
Merge branch 'develop' into feat.cdkV2-componentTests
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik authored Nov 10, 2023
2 parents 9a8eb59 + 8eb1e1d commit 9ac5340
Show file tree
Hide file tree
Showing 260 changed files with 729 additions and 853 deletions.
49 changes: 38 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@
"@koa/router": "^12.0.0",
"@ndhoule/extend": "^2.0.0",
"@pyroscope/nodejs": "^0.2.6",
"@rudderstack/integrations-lib": "^0.1.8",
"@rudderstack/workflow-engine": "^0.5.7",
"ajv": "^8.12.0",
"ajv-draft-04": "^1.0.0",
"ajv-formats": "^2.1.1",
"axios": "^1.4.0",
"axios": "^1.6.0",
"btoa": "^1.2.1",
"component-each": "^0.2.6",
"crypto-js": "^4.1.1",
"crypto-js": "^4.2.0",
"dotenv": "^16.0.3",
"flat": "^5.0.2",
"form-data": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/networkhandler/genericNetworkHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { NetworkError } = require('@rudderstack/integrations-lib');
const { isHttpStatusSuccess } = require('../../v0/util/index');
const { proxyRequest, prepareProxyRequest } = require('../network');
const { getDynamicErrorType, processAxiosResponse } = require('../utils/networkUtils');
const { NetworkError } = require('../../v0/util/errorTypes');
const tags = require('../../v0/util/tags');

/**
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/utils/networkUtils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable eqeqeq */
const lodash = require('lodash');
const { isEmpty } = require('lodash');
const { AbortedError } = require('@rudderstack/integrations-lib');
const {
isHttpStatusRetryable,
isDefinedAndNotNullAndNotEmpty,
Expand All @@ -9,7 +10,6 @@ const {
isHttpStatusSuccess,
getErrorStatusCode,
} = require('../../v0/util');
const { AbortedError } = require('../../v0/util/errorTypes');
const tags = require('../../v0/util/tags');
const { HTTP_STATUS_CODES } = require('../../v0/util/constant');

Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v1/autopilot/transform.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { Utils } = require('rudder-transformer-cdk');
const { InstrumentationError } = require('../../../v0/util/errorTypes');
const { InstrumentationError } = require('@rudderstack/integrations-lib');

function identifyPostMapper(event, mappedPayload) {
const { message } = event;
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v1/dcm_floodlight/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {
removeUndefinedAndNullValues,
isDefinedAndNotNull,
} = require('rudder-transformer-cdk/build/utils');
const { ConfigurationError, InstrumentationError } = require('@rudderstack/integrations-lib');
const {
getIntegrationsObj,
isEmpty,
Expand All @@ -14,7 +15,6 @@ const {
} = require('../../../v0/util');
const { GENERIC_TRUE_VALUES, GENERIC_FALSE_VALUES } = require('../../../constants');
const { BASE_URL, BLACKLISTED_CHARACTERS } = require('./config');
const { ConfigurationError, InstrumentationError } = require('../../../v0/util/errorTypes');

// append properties to endpoint
// eg: ${BASE_URL}key1=value1;key2=value2;....
Expand Down
8 changes: 4 additions & 4 deletions src/cdk/v1/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const path = require('path');
const basePath = path.resolve(__dirname);
ConfigFactory.init({ basePath, loggingMode: 'production' });

const tags = require('../../v0/util/tags');
const { generateErrorObject } = require('../../v0/util');
const {
InstrumentationError,
TransformationError,
ConfigurationError,
InstrumentationError,
} = require('../../v0/util/errorTypes');
} = require('@rudderstack/integrations-lib');
const tags = require('../../v0/util/tags');
const { generateErrorObject } = require('../../v0/util');

const defTags = {
[tags.TAG_NAMES.IMPLEMENTATION]: tags.IMPLEMENTATIONS.CDK_V1,
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/bindings/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
InstrumentationError,
ConfigurationError,
NetworkError,
} = require('../../../v0/util/errorTypes');
} = require('@rudderstack/integrations-lib');
const { isHttpStatusSuccess } = require('../../../v0/util');
const { getDynamicErrorType } = require('../../../adapters/utils/networkUtils');
const tags = require('../../../v0/util/tags');
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/dcm_floodlight/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const lodash = require('lodash');
const { InstrumentationError } = require('@rudderstack/integrations-lib');
const { getValueFromPropertiesOrTraits, getHashFromArray } = require('../../../../v0/util');
const { GENERIC_TRUE_VALUES, GENERIC_FALSE_VALUES } = require('../../../../constants');
const { InstrumentationError } = require('../../../../v0/util/errorTypes');

// valid flag should be provided [1|true] or [0|false]
const mapFlagValue = (key, value) => {
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'path';
import fs from 'fs/promises';
import { WorkflowExecutionError, WorkflowCreationError } from '@rudderstack/workflow-engine';
import { PlatformError } from '@rudderstack/integrations-lib';
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';

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/serviceSelector.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PlatformError } from '@rudderstack/integrations-lib';
import { ProcessorTransformationRequest, RouterTransformationRequestData } from '../types/index';
import { INTEGRATION_SERVICE } from '../routes/utils/constants';
import CDKV1DestinationService from '../services/destination/cdkV1Integration';
Expand All @@ -6,7 +7,6 @@ import DestinationService from '../interfaces/DestinationService';
import NativeIntegrationDestinationService from '../services/destination/nativeIntegration';
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';

Expand Down
11 changes: 0 additions & 11 deletions src/legacy/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,14 +571,9 @@ if (startDestTransformer) {
destEvents.length > 0 && destEvents[0].metadata
? getMetadata(destEvents[0].metadata)
: {};
const userFuncStartTime = new Date();
if (transformationVersionId) {
let destTransformedEvents;
try {
stats.counter('user_transform_function_input_events', destEvents.length, {
processSessions,
...metaTags,
});
destTransformedEvents = await userTransformHandler()(
destEvents,
transformationVersionId,
Expand Down Expand Up @@ -630,12 +625,6 @@ if (startDestTransformer) {
processSessions,
...metaTags,
});
} finally {
stats.timing('user_transform_function_latency', userFuncStartTime, {
transformationVersionId,
processSessions,
...metaTags,
});
}
} else {
const errorMessage = 'Transformation VersionID not found';
Expand Down
2 changes: 1 addition & 1 deletion src/services/destination/cdkV1Integration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { ConfigFactory, Executor, RudderBaseConfig } from 'rudder-transformer-cdk';
import path from 'path';
import { TransformationError } from '@rudderstack/integrations-lib';
import IntegrationDestinationService from '../../interfaces/DestinationService';
import {
DeliveryResponse,
Expand All @@ -14,7 +15,6 @@ import {
UserDeletionRequest,
UserDeletionResponse,
} from '../../types/index';
import { TransformationError } from '../../v0/util/errorTypes';
import DestinationPostTransformationService from './postTransformation';
import tags from '../../v0/util/tags';
import { getErrorInfo } from '../../cdk/v1/handler';
Expand Down
2 changes: 1 addition & 1 deletion src/services/destination/cdkV2Integration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable class-methods-use-this */
import groupBy from 'lodash/groupBy';
import { TransformationError } from '@rudderstack/integrations-lib';
import { processCdkV2Workflow } from '../../cdk/v2/handler';
import IntegrationDestinationService from '../../interfaces/DestinationService';
import {
Expand All @@ -15,7 +16,6 @@ import {
UserDeletionRequest,
UserDeletionResponse,
} from '../../types/index';
import { TransformationError } from '../../v0/util/errorTypes';
import tags from '../../v0/util/tags';
import DestinationPostTransformationService from './postTransformation';
import stats from '../../util/stats';
Expand Down
3 changes: 0 additions & 3 deletions src/services/userTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ export default class UserTransformService {
}
const userFuncStartTime = new Date();
try {
stats.counter('user_transform_function_input_events', eventsToProcess.length, {
...metaTags,
});
const destTransformedEvents: UserTransformationResponse[] = await userTransformHandler()(
eventsToProcess,
transformationVersionId,
Expand Down
17 changes: 3 additions & 14 deletions src/util/customTransformer-faas.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ function generateFunctionName(userTransformation, libraryVersionIds, testMode) {
const ids = [userTransformation.workspaceId, userTransformation.versionId].concat(
(libraryVersionIds || []).sort(),
);
const hash = crypto.createHash('md5').update(`${ids}`).digest('hex');

const hash = crypto.createHash('md5').update(`${ids}`).digest('hex');
return `fn-${userTransformation.workspaceId}-${hash}`.substring(0, 63).toLowerCase();
}

Expand Down Expand Up @@ -127,15 +127,8 @@ async function runOpenFaasUserTransform(
if (events.length === 0) {
throw new Error('Invalid payload. No events');
}
const metaTags = events[0].metadata ? getMetadata(events[0].metadata) : {};
const tags = {
transformerVersionId: userTransformation.versionId,
identifier: 'openfaas',
testMode,
...metaTags,
};
const trMetadata = events[0].metadata ? getTransformationMetadata(events[0].metadata) : {};

const trMetadata = events[0].metadata ? getTransformationMetadata(events[0].metadata) : {};
// check and deploy faas function if not exists
const functionName = generateFunctionName(userTransformation, libraryVersionIds, testMode);
if (testMode) {
Expand All @@ -148,9 +141,7 @@ async function runOpenFaasUserTransform(
);
}

const invokeTime = new Date();
stats.counter('events_to_process', events.length, tags);
const result = await executeFaasFunction(
return await executeFaasFunction(
functionName,
events,
userTransformation.versionId,
Expand All @@ -165,8 +156,6 @@ async function runOpenFaasUserTransform(
testMode,
trMetadata,
);
stats.timing('run_time', invokeTime, tags);
return result;
}

module.exports = {
Expand Down
Loading

0 comments on commit 9ac5340

Please sign in to comment.