From a0dd97f0d257f59cfb16277adb590f9d7431a0a7 Mon Sep 17 00:00:00 2001 From: AASHISH MALIK <=> Date: Mon, 18 Nov 2024 12:30:53 +0530 Subject: [PATCH] fix: revert gaec changes --- .../transform.js | 35 +--- .../processor/data.ts | 190 ------------------ .../router/data.ts | 189 ----------------- 3 files changed, 5 insertions(+), 409 deletions(-) diff --git a/src/v0/destinations/google_adwords_enhanced_conversions/transform.js b/src/v0/destinations/google_adwords_enhanced_conversions/transform.js index 497d4f294f..0badf49241 100644 --- a/src/v0/destinations/google_adwords_enhanced_conversions/transform.js +++ b/src/v0/destinations/google_adwords_enhanced_conversions/transform.js @@ -2,11 +2,7 @@ const get = require('get-value'); const { cloneDeep, isNumber } = require('lodash'); -const { - InstrumentationError, - ConfigurationError, - isDefinedAndNotNull, -} = require('@rudderstack/integrations-lib'); +const { InstrumentationError, ConfigurationError } = require('@rudderstack/integrations-lib'); const isString = require('lodash/isString'); const { constructPayload, @@ -15,7 +11,6 @@ const { removeHyphens, simpleProcessRouterDest, getAccessToken, - isDefined, } = require('../../util'); const { trackMapping, BASE_ENDPOINT } = require('./config'); @@ -43,15 +38,6 @@ const responseBuilder = async (metadata, message, { Config }, payload) => { const { event } = message; const { subAccount } = Config; let { customerId, loginCustomerId } = Config; - const { configData } = Config; - - if (isDefinedAndNotNull(configData)) { - const configDetails = JSON.parse(configData); - customerId = configDetails.customerId; - if (isDefined(configDetails.loginCustomerId)) { - loginCustomerId = configDetails.loginCustomerId; - } - } if (isNumber(customerId)) { customerId = customerId.toString(); @@ -84,29 +70,18 @@ const responseBuilder = async (metadata, message, { Config }, payload) => { response.headers['login-customer-id'] = filteredLoginCustomerId; } - if (loginCustomerId) { - const filteredLoginCustomerId = removeHyphens(loginCustomerId); - response.headers['login-customer-id'] = filteredLoginCustomerId; - } - return response; }; const processTrackEvent = async (metadata, message, destination) => { - let flag = 0; + let flag = false; const { Config } = destination; const { event } = message; const { listOfConversions } = Config; - if (listOfConversions && listOfConversions.length > 0) { - if (typeof listOfConversions[0] === 'string') { - if (listOfConversions.includes(event)) { - flag = 1; - } - } else if (listOfConversions.some((i) => i.conversions === event)) { - flag = 1; - } + if (listOfConversions.some((i) => i.conversions === event)) { + flag = true; } - if (event === undefined || event === '' || flag === 0) { + if (event === undefined || event === '' || !flag) { throw new ConfigurationError( `Conversion named "${event}" was not specified in the RudderStack destination configuration`, ); diff --git a/test/integrations/destinations/google_adwords_enhanced_conversions/processor/data.ts b/test/integrations/destinations/google_adwords_enhanced_conversions/processor/data.ts index fcdb6f15ca..1d20e887e9 100644 --- a/test/integrations/destinations/google_adwords_enhanced_conversions/processor/data.ts +++ b/test/integrations/destinations/google_adwords_enhanced_conversions/processor/data.ts @@ -1720,194 +1720,4 @@ export const data = [ }, }, }, - { - name: 'google_adwords_enhanced_conversions', - description: 'Success test with configDetails', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl91011', - }, - }, - destination: { - Config: { - rudderAccountId: '25u5whFH7gVTnCiAjn4ykoCLGoC', - listOfConversions: ['Page View', 'Product Added'], - authStatus: 'active', - configData: '{"customerId": "1234567890", "loginCustomerId": ""}', - }, - }, - message: { - channel: 'web', - context: { - app: { - build: '1.0.0', - name: 'RudderLabs JavaScript SDK', - namespace: 'com.rudderlabs.javascript', - version: '1.0.0', - }, - traits: { - phone: '912382193', - firstName: 'John', - lastName: 'Gomes', - city: 'London', - state: 'UK', - countryCode: 'us', - streetAddress: '71 Cherry Court SOUTHAMPTON SO53 5PD UK', - }, - library: { - name: 'RudderLabs JavaScript SDK', - version: '1.0.0', - }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', - locale: 'en-US', - ip: '0.0.0.0', - os: { - name: '', - version: '', - }, - screen: { - density: 2, - }, - }, - event: 'Page View', - type: 'track', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - gclid: 'gclid1234', - conversionDateTime: '2022-01-01 12:32:45-08:00', - adjustedValue: '10', - currency: 'INR', - adjustmentDateTime: '2022-01-01 12:32:45-08:00', - partialFailure: true, - campaignId: '1', - templateId: '0', - order_id: 10000, - total: 1000, - products: [ - { - product_id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - price: '19', - position: '1', - category: 'cars', - url: 'https://www.example.com/product/path', - image_url: 'https://www.example.com/product/path.jpg', - quantity: '2', - }, - { - product_id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - price: '192', - quantity: 22, - position: '12', - category: 'Cars2', - url: 'https://www.example.com/product/path2', - image_url: 'https://www.example.com/product/path.jpg2', - }, - ], - }, - integrations: { - All: true, - }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - }, - ], - }, - }, - output: { - response: { - status: 200, - body: [ - { - output: { - version: '1', - type: 'REST', - method: 'POST', - endpoint: `https://googleads.googleapis.com/${API_VERSION}/customers/1234567890:uploadConversionAdjustments`, - headers: { - Authorization: 'Bearer abcd1234', - 'Content-Type': 'application/json', - 'developer-token': 'ijkl91011', - }, - params: { - event: 'Page View', - customerId: '1234567890', - }, - body: { - JSON: { - conversionAdjustments: [ - { - gclidDateTimePair: { - gclid: 'gclid1234', - conversionDateTime: '2022-01-01 12:32:45-08:00', - }, - restatementValue: { - adjustedValue: 10, - currencyCode: 'INR', - }, - orderId: '10000', - adjustmentDateTime: '2022-01-01 12:32:45-08:00', - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', - userIdentifiers: [ - { - hashedPhoneNumber: - '04387707e6cbed8c4538c81cc570ed9252d579469f36c273839b26d784e4bdbe', - }, - { - addressInfo: { - hashedFirstName: - 'a8cfcd74832004951b4408cdb0a5dbcd8c7e52d43f7fe244bf720582e05241da', - hashedLastName: - '1c574b17eefa532b6d61c963550a82d2d3dfca4a7fb69e183374cfafd5328ee4', - state: 'UK', - city: 'London', - countryCode: 'us', - hashedStreetAddress: - '9a4d2e50828448f137f119a3ebdbbbab8d6731234a67595fdbfeb2a2315dd550', - }, - }, - ], - adjustmentType: 'ENHANCEMENT', - }, - ], - partialFailure: true, - }, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - files: {}, - userId: '', - }, - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl91011', - }, - }, - statusCode: 200, - }, - ], - }, - }, - }, ]; diff --git a/test/integrations/destinations/google_adwords_enhanced_conversions/router/data.ts b/test/integrations/destinations/google_adwords_enhanced_conversions/router/data.ts index fe0acf7964..5ac05b5a53 100644 --- a/test/integrations/destinations/google_adwords_enhanced_conversions/router/data.ts +++ b/test/integrations/destinations/google_adwords_enhanced_conversions/router/data.ts @@ -1,5 +1,3 @@ -import { API_VERSION } from '../../../../../src/v0/destinations/google_adwords_enhanced_conversions/config'; - const events = [ { metadata: { @@ -413,100 +411,6 @@ const events = [ sentAt: '2019-10-14T11:15:53.296Z', }, }, - { - metadata: { - secret: { - access_token: 'abcd1234', - refresh_token: 'efgh5678', - developer_token: 'ijkl91011', - }, - jobId: 6, - userId: 'u1', - }, - destination: { - Config: { - rudderAccountId: '25u5whFH7gVTnCiAjn4ykoCLGoC', - configData: '{"customerId":"1234567890", "loginCustomerId":"65656565"}', - customerId: '1234567890', - subAccount: true, - listOfConversions: [{ conversions: 'Page View' }, { conversions: 'Product Added' }], - authStatus: 'active', - }, - }, - message: { - channel: 'web', - context: { - app: { - build: '1.0.0', - name: 'RudderLabs JavaScript SDK', - namespace: 'com.rudderlabs.javascript', - version: '1.0.0', - }, - traits: { - phone: '912382193', - firstName: 'John', - lastName: 'Gomes', - city: 'London', - state: 'UK', - streetAddress: '71 Cherry Court SOUTHAMPTON SO53 5PD UK', - }, - library: { name: 'RudderLabs JavaScript SDK', version: '1.0.0' }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', - locale: 'en-US', - ip: '0.0.0.0', - os: { name: '', version: '' }, - screen: { density: 2 }, - customerID: {}, - subaccountID: 11, - }, - event: 'Page View', - type: 'track', - messageId: '5e10d13a-bf9a-44bf-b884-43a9e591ea71', - originalTimestamp: '2019-10-14T11:15:18.299Z', - anonymousId: '00000000000000000000000000', - userId: '12345', - properties: { - gclid: 'gclid1234', - conversionDateTime: '2022-01-01 12:32:45-08:00', - adjustedValue: '10', - currency: 'INR', - adjustmentDateTime: '2022-01-01 12:32:45-08:00', - partialFailure: true, - campaignId: '1', - templateId: '0', - order_id: 10000, - total: 1000, - products: [ - { - product_id: '507f1f77bcf86cd799439011', - sku: '45790-32', - name: 'Monopoly: 3rd Edition', - price: '19', - position: '1', - category: 'cars', - url: 'https://www.example.com/product/path', - image_url: 'https://www.example.com/product/path.jpg', - quantity: '2', - }, - { - product_id: '507f1f77bcf86cd7994390112', - sku: '45790-322', - name: 'Monopoly: 3rd Edition2', - price: '192', - quantity: 22, - position: '12', - category: 'Cars2', - url: 'https://www.example.com/product/path2', - image_url: 'https://www.example.com/product/path.jpg2', - }, - ], - }, - integrations: { All: true }, - name: 'ApplicationLoaded', - sentAt: '2019-10-14T11:15:53.296Z', - }, - }, { metadata: { secret: { @@ -1012,99 +916,6 @@ export const data = [ module: 'destination', }, }, - { - batched: false, - batchedRequest: { - body: { - FORM: {}, - JSON: { - conversionAdjustments: [ - { - adjustmentDateTime: '2022-01-01 12:32:45-08:00', - adjustmentType: 'ENHANCEMENT', - gclidDateTimePair: { - conversionDateTime: '2022-01-01 12:32:45-08:00', - gclid: 'gclid1234', - }, - orderId: '10000', - restatementValue: { - adjustedValue: 10, - currencyCode: 'INR', - }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', - userIdentifiers: [ - { - hashedPhoneNumber: - '04387707e6cbed8c4538c81cc570ed9252d579469f36c273839b26d784e4bdbe', - }, - { - addressInfo: { - city: 'London', - hashedFirstName: - 'a8cfcd74832004951b4408cdb0a5dbcd8c7e52d43f7fe244bf720582e05241da', - hashedLastName: - '1c574b17eefa532b6d61c963550a82d2d3dfca4a7fb69e183374cfafd5328ee4', - hashedStreetAddress: - '9a4d2e50828448f137f119a3ebdbbbab8d6731234a67595fdbfeb2a2315dd550', - state: 'UK', - }, - }, - ], - }, - ], - partialFailure: true, - }, - JSON_ARRAY: {}, - XML: {}, - }, - endpoint: - 'https://googleads.googleapis.com/v17/customers/1234567890:uploadConversionAdjustments', - files: {}, - headers: { - Authorization: 'Bearer abcd1234', - 'Content-Type': 'application/json', - 'developer-token': 'ijkl91011', - 'login-customer-id': '65656565', - }, - method: 'POST', - params: { - customerId: '1234567890', - event: 'Page View', - }, - type: 'REST', - version: '1', - }, - destination: { - Config: { - authStatus: 'active', - configData: '{"customerId":"1234567890", "loginCustomerId":"65656565"}', - customerId: '1234567890', - listOfConversions: [ - { - conversions: 'Page View', - }, - { - conversions: 'Product Added', - }, - ], - rudderAccountId: '25u5whFH7gVTnCiAjn4ykoCLGoC', - subAccount: true, - }, - }, - metadata: [ - { - jobId: 6, - secret: { - access_token: 'abcd1234', - developer_token: 'ijkl91011', - refresh_token: 'efgh5678', - }, - userId: 'u1', - }, - ], - statusCode: 200, - }, { batched: false, destination: {