diff --git a/src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js b/src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js index e79c568238..52bc748790 100644 --- a/src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js +++ b/src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js @@ -107,7 +107,21 @@ const responseHandler = (destinationResponse) => { const message = 'Request Processed Successfully'; const { status } = destinationResponse; if (isHttpStatusSuccess(status)) { - // Mostly any error will not have a status of 2xx + // for google ads enhance conversions the partialFailureError returns with status 200 + const { partialFailureError } = destinationResponse.response; + // non-zero code signifies partialFailure + // Ref - https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto + if (partialFailureError && partialFailureError.code !== 0) { + throw new NetworkError( + `[Google Ads Offline Conversions]:: partialFailureError - ${partialFailureError?.message}`, + 400, + { + [tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(400), + }, + partialFailureError, + ); + } + return { status, message, diff --git a/src/v0/destinations/google_adwords_enhanced_conversions/transform.js b/src/v0/destinations/google_adwords_enhanced_conversions/transform.js index 24993a3006..de62dbc13a 100644 --- a/src/v0/destinations/google_adwords_enhanced_conversions/transform.js +++ b/src/v0/destinations/google_adwords_enhanced_conversions/transform.js @@ -1,5 +1,5 @@ /* eslint-disable no-param-reassign */ - +const moment = require('moment'); const get = require('get-value'); const { cloneDeep } = require('lodash'); const { @@ -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'); @@ -86,6 +83,18 @@ const processTrackEvent = async (metadata, message, destination) => { `Any of email, phone, firstName, lastName, city, street, countryCode, postalCode or streetAddress is required in traits.`, ); } + + if (payload.conversionAdjustments[0].gclidDateTimePair.conversionDateTime) { + const conversionDateTime = moment( + payload.conversionAdjustments[0].gclidDateTimePair.conversionDateTime, + ) + .utcOffset( + moment(payload.conversionAdjustments[0].gclidDateTimePair.conversionDateTime).utcOffset(), + ) + .format('YYYY-MM-DD HH:mm:ssZ'); + payload.conversionAdjustments[0].gclidDateTimePair.conversionDateTime = conversionDateTime; + } + payload.conversionAdjustments[0].adjustmentType = 'ENHANCEMENT'; // Removing the null values from userIdentifier const arr = payload.conversionAdjustments[0].userIdentifiers; diff --git a/test/__tests__/data/google_adwords_enhanced_conversions_output.json b/test/__tests__/data/google_adwords_enhanced_conversions_output.json index 292a849673..479e9ca798 100644 --- a/test/__tests__/data/google_adwords_enhanced_conversions_output.json +++ b/test/__tests__/data/google_adwords_enhanced_conversions_output.json @@ -21,7 +21,7 @@ { "gclidDateTimePair": { "gclid": "gclid1234", - "conversionDateTime": "2022-01-01 12:32:45-08:00" + "conversionDateTime": "2022-01-02 02:02:45+05:30" }, "restatementValue": { "adjustedValue": 10, @@ -108,7 +108,7 @@ { "gclidDateTimePair": { "gclid": "gclid1234", - "conversionDateTime": "2022-01-01 12:32:45-08:00" + "conversionDateTime": "2022-01-02 02:02:45+05:30" }, "restatementValue": { "adjustedValue": 10, @@ -221,7 +221,7 @@ { "gclidDateTimePair": { "gclid": "gclid1234", - "conversionDateTime": "2022-01-01 12:32:45-08:00" + "conversionDateTime": "2022-01-02 02:02:45+05:30" }, "restatementValue": { "adjustedValue": 10, @@ -277,7 +277,7 @@ { "gclidDateTimePair": { "gclid": "gclid1234", - "conversionDateTime": "2022-01-01 12:32:45-08:00" + "conversionDateTime": "2022-01-02 02:02:45+05:30" }, "restatementValue": { "adjustedValue": 10, diff --git a/test/__tests__/data/google_adwords_enhanced_conversions_router_output.json b/test/__tests__/data/google_adwords_enhanced_conversions_router_output.json index c283549e50..b8235d9043 100644 --- a/test/__tests__/data/google_adwords_enhanced_conversions_router_output.json +++ b/test/__tests__/data/google_adwords_enhanced_conversions_router_output.json @@ -19,7 +19,7 @@ { "gclidDateTimePair": { "gclid": "gclid1234", - "conversionDateTime": "2022-01-01 12:32:45-08:00" + "conversionDateTime": "2022-01-02 02:02:45+05:30" }, "restatementValue": { "adjustedValue": 10,