diff --git a/src/adapters/networkHandlerFactory.js b/src/adapters/networkHandlerFactory.js index 7cfa4b048e..f4940553f5 100644 --- a/src/adapters/networkHandlerFactory.js +++ b/src/adapters/networkHandlerFactory.js @@ -8,6 +8,8 @@ const { getIntegrations } = require('../routes/utils'); const handlers = { generic: GenericNetworkHandler, + v0: {}, + v1: {}, }; // Dynamically import the network handlers for all @@ -16,7 +18,17 @@ SUPPORTED_VERSIONS.forEach((version) => { const destinations = getIntegrations(path.resolve(__dirname, `../${version}/destinations`)); destinations.forEach((dest) => { try { - handlers[dest] = require(`../${version}/destinations/${dest}/networkHandler`).networkHandler; + // handles = { + // v0: { + // dest: handler + // }, + // v1: { + // dest: handler + // }, + // generic: GenericNetworkHandler, + // } + handlers[version][dest] = + require(`../${version}/destinations/${dest}/networkHandler`).networkHandler; } catch { // Do nothing as exception indicates // network handler is not defined for that destination @@ -24,8 +36,8 @@ SUPPORTED_VERSIONS.forEach((version) => { }); }); -const getNetworkHandler = (type) => { - const NetworkHandler = handlers[type] || handlers.generic; +const getNetworkHandler = (type, version) => { + const NetworkHandler = handlers[version][type] || handlers.generic; return new NetworkHandler(); }; diff --git a/src/controllers/delivery.ts b/src/controllers/delivery.ts index af94764d46..3ccc241b87 100644 --- a/src/controllers/delivery.ts +++ b/src/controllers/delivery.ts @@ -16,9 +16,15 @@ export class DeliveryController { const requestMetadata = MiscService.getRequestMetadata(ctx); const event = ctx.request.body as ProcessorTransformationOutput; const { destination }: { destination: string } = ctx.params; + const { version }: { version: string } = ctx.params; const integrationService = ServiceSelector.getNativeDestinationService(); try { - deliveryResponse = await integrationService.deliver(event, destination, requestMetadata); + deliveryResponse = await integrationService.deliver( + event, + destination, + requestMetadata, + version, + ); } catch (error: any) { const metaTO = integrationService.getTags( destination, diff --git a/src/interfaces/DestinationService.ts b/src/interfaces/DestinationService.ts index b27f98da2a..16f6b9349c 100644 --- a/src/interfaces/DestinationService.ts +++ b/src/interfaces/DestinationService.ts @@ -47,6 +47,7 @@ export interface DestinationService { event: ProcessorTransformationOutput, destinationType: string, requestMetadata: NonNullable, + version: string, ): Promise; processUserDeletion( diff --git a/src/services/comparator.ts b/src/services/comparator.ts index 7f63da9402..58c96beabb 100644 --- a/src/services/comparator.ts +++ b/src/services/comparator.ts @@ -368,11 +368,13 @@ export class ComparatorService implements DestinationService { event: ProcessorTransformationOutput, destinationType: string, requestMetadata: NonNullable, + version: string, ): Promise { const primaryResplist = await this.primaryService.deliver( event, destinationType, requestMetadata, + version, ); logger.error('[LIVE_COMPARE_TEST] not implemented for delivery routine'); diff --git a/src/services/destination/nativeIntegration.ts b/src/services/destination/nativeIntegration.ts index 6763f54c7e..510fa80362 100644 --- a/src/services/destination/nativeIntegration.ts +++ b/src/services/destination/nativeIntegration.ts @@ -172,9 +172,10 @@ export class NativeIntegrationDestinationService implements DestinationService { destinationRequest: ProcessorTransformationOutput, destinationType: string, _requestMetadata: NonNullable, + version: string, ): Promise { try { - const networkHandler = networkHandlerFactory.getNetworkHandler(destinationType); + const networkHandler = networkHandlerFactory.getNetworkHandler(destinationType, version); const rawProxyResponse = await networkHandler.proxy(destinationRequest, destinationType); const processedProxyResponse = networkHandler.processAxiosResponse(rawProxyResponse); return networkHandler.responseHandler( diff --git a/src/v1/destinations/campaign_manager/networkHandler.js b/src/v1/destinations/campaign_manager/networkHandler.js index 2ce59f83f4..6b2d8ccce1 100644 --- a/src/v1/destinations/campaign_manager/networkHandler.js +++ b/src/v1/destinations/campaign_manager/networkHandler.js @@ -11,42 +11,6 @@ const { // const { TransformerProxyError } = require('../../util/errorTypes'); const tags = require('../../../v0/util/tags'); -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function checkIfFailuresAreRetryable(response, proxyOutputObj) { - const { status } = response; - try { - if (Array.isArray(status)) { - // iterate over each status, and if found retryable in conversations ..retry else discard - /* status : [{ - "conversion": { - object (Conversion) - }, - "errors": [ - { - object (ConversionError) - } - ], - "kind": string - }] */ - for (const st of status) { - for (const err of st.errors) { - // if code is any of these, event is not retryable - if ( - err.code === 'PERMISSION_DENIED' || - err.code === 'INVALID_ARGUMENT' || - err.code === 'NOT_FOUND' - ) { - return false; - } - } - } - } - return true; - } catch (e) { - return false; - } -} - function isEventRetryable(element, proxyOutputObj) { let flag = false; let errorMsg = '';