From f44a951fc2a23135e3d0950d7a29421ca939de1a Mon Sep 17 00:00:00 2001 From: AASHISH MALIK Date: Thu, 14 Sep 2023 14:42:37 +0530 Subject: [PATCH 1/2] feat: google ads v14 upgrade (#2578) --- .../config.js | 2 +- .../config.js | 2 +- .../utils.test.js | 8 ++-- .../config.js | 2 +- .../response.json | 18 ++++----- .../proxy_response.json | 18 ++++----- ...e_adwords_enhanced_conversions_output.json | 8 ++-- ...ords_enhanced_conversions_proxy_input.json | 6 +-- ...ds_enhanced_conversions_router_output.json | 2 +- .../google_adwords_offline_conversions.json | 38 +++++++++---------- ...words_offline_conversions_proxy_input.json | 12 +++--- ...ords_offline_conversions_proxy_output.json | 2 +- ...rds_offline_conversions_router_output.json | 8 ++-- ...ogle_adwords_remarketing_lists_output.json | 38 +++++++++---------- ...adwords_remarketing_lists_proxy_input.json | 6 +-- ...words_remarketing_lists_router_output.json | 10 ++--- ...google_adwords_offline_conversions.test.js | 12 +++--- 17 files changed, 96 insertions(+), 96 deletions(-) diff --git a/src/v0/destinations/google_adwords_enhanced_conversions/config.js b/src/v0/destinations/google_adwords_enhanced_conversions/config.js index a86d0606a6..66d12c34d7 100644 --- a/src/v0/destinations/google_adwords_enhanced_conversions/config.js +++ b/src/v0/destinations/google_adwords_enhanced_conversions/config.js @@ -1,6 +1,6 @@ const { getMappingConfig } = require('../../util'); -const BASE_ENDPOINT = 'https://googleads.googleapis.com/v13/customers'; +const BASE_ENDPOINT = 'https://googleads.googleapis.com/v14/customers'; const CONFIG_CATEGORIES = { TRACK_CONFIG: { type: 'track', name: 'trackConfig' }, diff --git a/src/v0/destinations/google_adwords_offline_conversions/config.js b/src/v0/destinations/google_adwords_offline_conversions/config.js index 1d77af02e6..a02732894f 100644 --- a/src/v0/destinations/google_adwords_offline_conversions/config.js +++ b/src/v0/destinations/google_adwords_offline_conversions/config.js @@ -1,6 +1,6 @@ const { getMappingConfig } = require('../../util'); -const API_VERSION = 'v13'; +const API_VERSION = 'v14'; const BASE_ENDPOINT = `https://googleads.googleapis.com/${API_VERSION}/customers/:customerId`; diff --git a/src/v0/destinations/google_adwords_offline_conversions/utils.test.js b/src/v0/destinations/google_adwords_offline_conversions/utils.test.js index 775e123cfe..8deaa3ab0a 100644 --- a/src/v0/destinations/google_adwords_offline_conversions/utils.test.js +++ b/src/v0/destinations/google_adwords_offline_conversions/utils.test.js @@ -161,7 +161,7 @@ describe('getExisitingUserIdentifier util tests', () => { describe('getClickConversionPayloadAndEndpoint util tests', () => { it('getClickConversionPayloadAndEndpoint flow check when default field identifier is present', () => { let expectedOutput = { - endpoint: 'https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions', + endpoint: 'https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions', payload: { conversions: [ { @@ -187,7 +187,7 @@ describe('getClickConversionPayloadAndEndpoint util tests', () => { delete fittingPayload.traits.email; delete fittingPayload.properties.email; let expectedOutput = { - endpoint: 'https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions', + endpoint: 'https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions', payload: { conversions: [ { @@ -215,7 +215,7 @@ describe('getClickConversionPayloadAndEndpoint util tests', () => { delete fittingPayload.traits.phone; delete fittingPayload.properties.email; let expectedOutput = { - endpoint: 'https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions', + endpoint: 'https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions', payload: { conversions: [ { @@ -251,7 +251,7 @@ describe('getClickConversionPayloadAndEndpoint util tests', () => { }, ]; let expectedOutput = { - endpoint: 'https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions', + endpoint: 'https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions', payload: { conversions: [ { diff --git a/src/v0/destinations/google_adwords_remarketing_lists/config.js b/src/v0/destinations/google_adwords_remarketing_lists/config.js index 902ac1cbff..94059c69f1 100644 --- a/src/v0/destinations/google_adwords_remarketing_lists/config.js +++ b/src/v0/destinations/google_adwords_remarketing_lists/config.js @@ -1,6 +1,6 @@ const { getMappingConfig } = require('../../util'); -const BASE_ENDPOINT = 'https://googleads.googleapis.com/v13/customers'; +const BASE_ENDPOINT = 'https://googleads.googleapis.com/v14/customers'; const CONFIG_CATEGORIES = { AUDIENCE_LIST: { type: 'audienceList', name: 'offlineDataJobs' }, ADDRESSINFO: { type: 'addressInfo', name: 'addressInfo' }, diff --git a/test/__mocks__/data/google_adwords_offline_conversion/response.json b/test/__mocks__/data/google_adwords_offline_conversion/response.json index d9e763c3ac..285ef56509 100644 --- a/test/__mocks__/data/google_adwords_offline_conversion/response.json +++ b/test/__mocks__/data/google_adwords_offline_conversion/response.json @@ -1,17 +1,17 @@ { - "https://googleads.googleapis.com/v13/customers/11122233331/offlineUserDataJobs:create": { + "https://googleads.googleapis.com/v14/customers/11122233331/offlineUserDataJobs:create": { "data": { "resourceName": "customers/111-222-3333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID_FOR_ADD_FAILURE" }, "status": 200 }, - "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs:create": { + "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs:create": { "data": { "resourceName": "customers/111-222-3333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID" }, "status": 200 }, - "https://googleads.googleapis.com/v13/customers/customerid/offlineUserDataJobs:create": { + "https://googleads.googleapis.com/v14/customers/customerid/offlineUserDataJobs:create": { "status": 401, "data": { "error": { @@ -21,11 +21,11 @@ } } }, - "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID:addOperations": { + "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID:addOperations": { "status": 200, "data": {} }, - "https://googleads.googleapis.com/v13/customers/11122233331/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID_FOR_ADD_FAILURE:addOperations": { + "https://googleads.googleapis.com/v14/customers/11122233331/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID_FOR_ADD_FAILURE:addOperations": { "status": 400, "data": { "error": { @@ -34,7 +34,7 @@ "status": "INVALID_ARGUMENT", "details": [ { - "@type": "type.googleapis.com/google.ads.googleads.v13.errors.GoogleAdsFailure", + "@type": "type.googleapis.com/google.ads.googleads.v14.errors.GoogleAdsFailure", "errors": [ { "errorCode": { @@ -67,13 +67,13 @@ } } }, - "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID:run": { + "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID:run": { "status": 200, "data": { "name": "customers/111-222-3333/operations/abcd=" } }, - "https://googleads.googleapis.com/v13/customers/customerid/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID_ADD_FAILURE:addOperations": { + "https://googleads.googleapis.com/v14/customers/customerid/offlineUserDataJobs/OFFLINE_USER_DATA_JOB_ID_ADD_FAILURE:addOperations": { "status": 400, "data": { "error": { @@ -82,7 +82,7 @@ "status": "INVALID_ARGUMENT", "details": [ { - "@type": "type.googleapis.com/google.ads.googleads.v13.errors.GoogleAdsFailure", + "@type": "type.googleapis.com/google.ads.googleads.v14.errors.GoogleAdsFailure", "errors": [ { "errorCode": { diff --git a/test/__mocks__/data/google_adwords_remarketing_lists/proxy_response.json b/test/__mocks__/data/google_adwords_remarketing_lists/proxy_response.json index 93689bb0cb..246ba7f9fb 100644 --- a/test/__mocks__/data/google_adwords_remarketing_lists/proxy_response.json +++ b/test/__mocks__/data/google_adwords_remarketing_lists/proxy_response.json @@ -1,23 +1,23 @@ { - "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs:create": { + "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs:create": { "status": 200, "data": { "resourceName": "customers/9249589672/offlineUserDataJobs/18025019461" } }, - "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs/18025019461:addOperations": { + "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs/18025019461:addOperations": { "status": 200 }, - "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs/18025019461:run": { + "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs/18025019461:run": { "status": 200 }, - "https://googleads.googleapis.com/v13/customers/7693729834/offlineUserDataJobs:create": { + "https://googleads.googleapis.com/v14/customers/7693729834/offlineUserDataJobs:create": { "status": 200, "data": { "resourceName": "customers/9249589672/offlineUserDataJobs/18025019462" } }, - "https://googleads.googleapis.com/v13/customers/7693729834/offlineUserDataJobs/18025019462:addOperations": { + "https://googleads.googleapis.com/v14/customers/7693729834/offlineUserDataJobs/18025019462:addOperations": { "response": { "data": { "error": { @@ -60,7 +60,7 @@ "status": 400 } }, - "https://googleads.googleapis.com/v13/customers/1234567890/googleAds:searchStream": { + "https://googleads.googleapis.com/v14/customers/1234567890/googleAds:searchStream": { "response": { "data": [ { @@ -74,11 +74,11 @@ "status": 401 } }, - "https://googleads.googleapis.com/v13/customers/1234567899/googleAds:searchStream": { + "https://googleads.googleapis.com/v14/customers/1234567899/googleAds:searchStream": { "response": "", "code": "ECONNREFUSED" }, - "https://googleads.googleapis.com/v13/customers/1234567891/googleAds:searchStream": { + "https://googleads.googleapis.com/v14/customers/1234567891/googleAds:searchStream": { "data": [ { "results": [ @@ -95,7 +95,7 @@ ], "status": 200 }, - "https://googleads.googleapis.com/v13/customers/1234567891:uploadConversionAdjustments": { + "https://googleads.googleapis.com/v14/customers/1234567891:uploadConversionAdjustments": { "data": [ { "adjustmentType": "ENHANCEMENT", diff --git a/test/__tests__/data/google_adwords_enhanced_conversions_output.json b/test/__tests__/data/google_adwords_enhanced_conversions_output.json index f90bcd5901..d260502926 100644 --- a/test/__tests__/data/google_adwords_enhanced_conversions_output.json +++ b/test/__tests__/data/google_adwords_enhanced_conversions_output.json @@ -3,7 +3,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567890:uploadConversionAdjustments", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567890:uploadConversionAdjustments", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -91,7 +91,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567890:uploadConversionAdjustments", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567890:uploadConversionAdjustments", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -204,7 +204,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567890:uploadConversionAdjustments", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567890:uploadConversionAdjustments", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -260,7 +260,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567890:uploadConversionAdjustments", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567890:uploadConversionAdjustments", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", diff --git a/test/__tests__/data/google_adwords_enhanced_conversions_proxy_input.json b/test/__tests__/data/google_adwords_enhanced_conversions_proxy_input.json index d9d0575355..612efeb99a 100644 --- a/test/__tests__/data/google_adwords_enhanced_conversions_proxy_input.json +++ b/test/__tests__/data/google_adwords_enhanced_conversions_proxy_input.json @@ -3,7 +3,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567890:uploadConversionAdjustments", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567890:uploadConversionAdjustments", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -56,7 +56,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567899:uploadConversionAdjustments", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567899:uploadConversionAdjustments", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -109,7 +109,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567891:uploadConversionAdjustments", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567891:uploadConversionAdjustments", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", 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 6ddec019e3..bab6c05cc9 100644 --- a/test/__tests__/data/google_adwords_enhanced_conversions_router_output.json +++ b/test/__tests__/data/google_adwords_enhanced_conversions_router_output.json @@ -4,7 +4,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567890:uploadConversionAdjustments", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567890:uploadConversionAdjustments", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", diff --git a/test/__tests__/data/google_adwords_offline_conversions.json b/test/__tests__/data/google_adwords_offline_conversions.json index 53c0f9bf3e..9bdb5cda45 100644 --- a/test/__tests__/data/google_adwords_offline_conversions.json +++ b/test/__tests__/data/google_adwords_offline_conversions.json @@ -159,7 +159,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -418,7 +418,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -677,7 +677,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -936,7 +936,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadCallConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadCallConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -1796,7 +1796,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -1896,7 +1896,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadCallConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadCallConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -2090,7 +2090,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -2257,7 +2257,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadCallConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadCallConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -2461,7 +2461,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadCallConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadCallConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -2651,7 +2651,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -3077,7 +3077,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -3383,7 +3383,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -3544,7 +3544,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -3827,7 +3827,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -3993,7 +3993,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -4163,7 +4163,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -4294,7 +4294,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -4421,7 +4421,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -4546,7 +4546,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", diff --git a/test/__tests__/data/google_adwords_offline_conversions_proxy_input.json b/test/__tests__/data/google_adwords_offline_conversions_proxy_input.json index a812fdbcc4..5a9f4e4126 100644 --- a/test/__tests__/data/google_adwords_offline_conversions_proxy_input.json +++ b/test/__tests__/data/google_adwords_offline_conversions_proxy_input.json @@ -5,7 +5,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/11122233331/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/11122233331/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -75,7 +75,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1112223333/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/1112223333/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -145,7 +145,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/customerid/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/customerid/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -215,7 +215,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567890:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567890:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -320,7 +320,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567891:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567891:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -425,7 +425,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/1234567891:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/1234567891:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", diff --git a/test/__tests__/data/google_adwords_offline_conversions_proxy_output.json b/test/__tests__/data/google_adwords_offline_conversions_proxy_output.json index 2bdcaeea49..e6d298956f 100644 --- a/test/__tests__/data/google_adwords_offline_conversions_proxy_output.json +++ b/test/__tests__/data/google_adwords_offline_conversions_proxy_output.json @@ -8,7 +8,7 @@ "code": 400, "details": [ { - "@type": "type.googleapis.com/google.ads.googleads.v13.errors.GoogleAdsFailure", + "@type": "type.googleapis.com/google.ads.googleads.v14.errors.GoogleAdsFailure", "errors": [ { "errorCode": { diff --git a/test/__tests__/data/google_adwords_offline_conversions_router_output.json b/test/__tests__/data/google_adwords_offline_conversions_router_output.json index 87c4b671f7..16b07233e3 100644 --- a/test/__tests__/data/google_adwords_offline_conversions_router_output.json +++ b/test/__tests__/data/google_adwords_offline_conversions_router_output.json @@ -4,7 +4,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -130,7 +130,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadClickConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadClickConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -259,7 +259,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/9625812972:uploadCallConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/9625812972:uploadCallConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -367,7 +367,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833:uploadCallConversions", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833:uploadCallConversions", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", diff --git a/test/__tests__/data/google_adwords_remarketing_lists_output.json b/test/__tests__/data/google_adwords_remarketing_lists_output.json index 8c938bc3d3..2a6d04bea1 100644 --- a/test/__tests__/data/google_adwords_remarketing_lists_output.json +++ b/test/__tests__/data/google_adwords_remarketing_lists_output.json @@ -4,7 +4,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -52,7 +52,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -90,7 +90,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -197,7 +197,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -1219,7 +1219,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -1278,7 +1278,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -1339,7 +1339,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -2359,7 +2359,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -3381,7 +3381,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -3458,7 +3458,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -4478,7 +4478,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -5500,7 +5500,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -5559,7 +5559,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -5620,7 +5620,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -5678,7 +5678,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -5735,7 +5735,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -5791,7 +5791,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -5835,7 +5835,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -5877,7 +5877,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", diff --git a/test/__tests__/data/google_adwords_remarketing_lists_proxy_input.json b/test/__tests__/data/google_adwords_remarketing_lists_proxy_input.json index d9745e9f65..3cd282ec2a 100644 --- a/test/__tests__/data/google_adwords_remarketing_lists_proxy_input.json +++ b/test/__tests__/data/google_adwords_remarketing_lists_proxy_input.json @@ -3,7 +3,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -53,7 +53,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729834/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729834/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", @@ -89,7 +89,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer dummy-access", "Content-Type": "application/json", diff --git a/test/__tests__/data/google_adwords_remarketing_lists_router_output.json b/test/__tests__/data/google_adwords_remarketing_lists_router_output.json index 0b5d5265f9..ff6755237f 100644 --- a/test/__tests__/data/google_adwords_remarketing_lists_router_output.json +++ b/test/__tests__/data/google_adwords_remarketing_lists_router_output.json @@ -5,7 +5,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -76,7 +76,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -136,7 +136,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -207,7 +207,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", @@ -250,7 +250,7 @@ "version": "1", "type": "REST", "method": "POST", - "endpoint": "https://googleads.googleapis.com/v13/customers/7693729833/offlineUserDataJobs", + "endpoint": "https://googleads.googleapis.com/v14/customers/7693729833/offlineUserDataJobs", "headers": { "Authorization": "Bearer abcd1234", "Content-Type": "application/json", diff --git a/test/__tests__/google_adwords_offline_conversions.test.js b/test/__tests__/google_adwords_offline_conversions.test.js index d1edec7b58..b08b6de968 100644 --- a/test/__tests__/google_adwords_offline_conversions.test.js +++ b/test/__tests__/google_adwords_offline_conversions.test.js @@ -45,7 +45,7 @@ axios.mockImplementation(async config => { // httpSend() -> inside ProxyRequest for google_adwords_offline if ( config.url.includes( - "https://googleads.googleapis.com/v13/customers/1234567891:uploadClickConversions" + "https://googleads.googleapis.com/v14/customers/1234567891:uploadClickConversions" ) ) { return { @@ -74,7 +74,7 @@ axios.post = jest.fn(async (url, data, reqConfig) => { // This mocking is for calls that make use of httpPOST() if ( url.includes( - "https://googleads.googleapis.com/v13/customers/1234567891/googleAds:searchStream" + "https://googleads.googleapis.com/v14/customers/1234567891/googleAds:searchStream" ) ) { // this is for true case @@ -126,7 +126,7 @@ axios.post = jest.fn(async (url, data, reqConfig) => { } } else if ( url.includes( - "https://googleads.googleapis.com/v13/customers/1234567890/googleAds:searchStream" + "https://googleads.googleapis.com/v14/customers/1234567890/googleAds:searchStream" ) ) { // this case is for refresh token expire @@ -145,12 +145,12 @@ axios.post = jest.fn(async (url, data, reqConfig) => { }; } else if ( url.includes( - "https://googleads.googleapis.com/v13/customers/1112223333/googleAds:searchStream" + "https://googleads.googleapis.com/v14/customers/1112223333/googleAds:searchStream" ) || url.includes( - "https://googleads.googleapis.com/v13/customers/111-222-3333/googleAds:searchStream" + "https://googleads.googleapis.com/v14/customers/111-222-3333/googleAds:searchStream" ) || url.includes( - "https://googleads.googleapis.com/v13/customers/customer-id/googleAds:searchStream" + "https://googleads.googleapis.com/v14/customers/customer-id/googleAds:searchStream" ) ) { // this is for store case From 7d268f046f92d86f48ced06c586b0d098a913113 Mon Sep 17 00:00:00 2001 From: Utsab Chowdhury Date: Thu, 14 Sep 2023 15:20:33 +0530 Subject: [PATCH 2/2] fix: pyroscope endpoints (#2613) --- src/controllers/misc.ts | 18 +++++++++++++++ src/index.ts | 7 +++--- src/middleware.js | 51 ++++++++++------------------------------- src/routes/misc.ts | 2 ++ src/services/misc.ts | 11 ++++++++- 5 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/controllers/misc.ts b/src/controllers/misc.ts index eff0eee244..92ec33f80f 100644 --- a/src/controllers/misc.ts +++ b/src/controllers/misc.ts @@ -25,4 +25,22 @@ export default class MiscController { ctx.status = 200; return ctx; } + + public static async getCPUProfile(ctx: Context) { + const { seconds } = ctx.query; + let secondsData = 10; + // if seconds is not null and is not array then parseInt + if (seconds && !Array.isArray(seconds)) { + secondsData = parseInt(seconds, 10); + } + ctx.body = await MiscService.getCPUProfile(secondsData); + ctx.status = 200; + return ctx; + } + + public static async getHeapProfile(ctx: Context) { + ctx.body = await MiscService.getHeapProfile(); + ctx.status = 200; + return ctx; + } } diff --git a/src/index.ts b/src/index.ts index a928c8c3c5..d1cc95cc36 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,7 @@ import cluster from './util/cluster'; import { router } from './legacy/router'; import { testRouter } from './testRouter'; import { metricsRouter } from './routes/metricsRouter'; -import { addStatMiddleware, addRequestSizeMiddleware, addPyroscopeMiddleware } from './middleware'; +import { addStatMiddleware, addRequestSizeMiddleware, initPyroscope } from './middleware'; import { logProcessInfo } from './util/utils'; import { applicationRoutes, addSwaggerRoutes } from './routes'; import { RedisDB } from './util/redis/redisConnector'; @@ -15,9 +15,11 @@ import { RedisDB } from './util/redis/redisConnector'; dotenv.config(); const clusterEnabled = process.env.CLUSTER_ENABLED !== 'false'; const useUpdatedRoutes = process.env.ENABLE_NEW_ROUTES !== 'false'; -const port = parseInt(process.env.PORT || '9090', 10); +const port = parseInt(process.env.PORT ?? '9090', 10); const metricsPort = parseInt(process.env.METRICS_PORT || '9091', 10); +initPyroscope(); + const app = new Koa(); addStatMiddleware(app); @@ -30,7 +32,6 @@ app.use( jsonLimit: '200mb', }), ); -addPyroscopeMiddleware(app); addRequestSizeMiddleware(app); addSwaggerRoutes(app); diff --git a/src/middleware.js b/src/middleware.js index b8f6a2ac1b..53aabc90e3 100644 --- a/src/middleware.js +++ b/src/middleware.js @@ -1,48 +1,19 @@ const Pyroscope = require('@pyroscope/nodejs'); const stats = require('./util/stats'); -const logger = require('./logger'); -Pyroscope.init({ - appName: 'rudder-transformer', -}); - -async function handlerCpu(ctx) { - try { - const p = await Pyroscope.collectCpu(Number(ctx.query.seconds)); - ctx.body = p; - ctx.status = 200; - } catch (e) { - logger.error(e); - ctx.status = 500; - } -} - -async function handlerHeap(ctx) { - try { - const p = await Pyroscope.collectHeap(); - ctx.body = p; - ctx.status = 200; - } catch (e) { - logger.error(e); - ctx.status = 500; - } +function initPyroscope() { + Pyroscope.init({ + appName: 'rudder-transformer', + }); + Pyroscope.startHeapCollecting(); } -function pyroscopeMiddleware() { - Pyroscope.startHeapCollecting(); - return (ctx, next) => { - if (ctx.method === 'GET' && ctx.path === '/debug/pprof/profile') { - return handlerCpu(ctx).then(() => next()); - } - if (ctx.method === 'GET' && ctx.path === '/debug/pprof/heap') { - return handlerHeap(ctx).then(() => next()); - } - return next(); - }; +function getCPUProfile(seconds) { + return Pyroscope.collectCpu(seconds); } -function addPyroscopeMiddleware(app) { - app.use(pyroscopeMiddleware()); +function getHeapProfile() { + return Pyroscope.collectHeap(); } function durationMiddleware() { @@ -90,5 +61,7 @@ function addRequestSizeMiddleware(app) { module.exports = { addStatMiddleware, addRequestSizeMiddleware, - addPyroscopeMiddleware, + getHeapProfile, + getCPUProfile, + initPyroscope, }; diff --git a/src/routes/misc.ts b/src/routes/misc.ts index 12ee09b8a9..3e30b9dd39 100644 --- a/src/routes/misc.ts +++ b/src/routes/misc.ts @@ -10,5 +10,7 @@ router.get('/transformerBuildVersion', MiscController.buildVersion); // depricia router.get('/buildVersion', MiscController.buildVersion); router.get('/version', MiscController.version); router.get('/features', MiscController.features); +router.get('/debug/pprof/profile', MiscController.getCPUProfile); +router.get('/debug/pprof/heap', MiscController.getHeapProfile); export const miscRoutes = router.routes(); diff --git a/src/services/misc.ts b/src/services/misc.ts index 6508ced809..2805f58584 100644 --- a/src/services/misc.ts +++ b/src/services/misc.ts @@ -3,6 +3,7 @@ import path from 'path'; import { Context } from 'koa'; import { DestHandlerMap } from '../constants/destinationCanonicalNames'; import { Metadata } from '../types'; +import { getCPUProfile, getHeapProfile, } from '../middleware'; export default class MiscService { public static getDestHandler(dest: string, version: string) { @@ -32,7 +33,7 @@ export default class MiscService { public static getMetaTags(metadata: Metadata) { if (!metadata) { - return {} + return {}; } return { sourceType: metadata.sourceType, @@ -62,4 +63,12 @@ export default class MiscService { const obj = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../features.json'), 'utf8')); return JSON.stringify(obj); } + + public static async getCPUProfile(seconds: number) { + return getCPUProfile(seconds); + } + + public static async getHeapProfile() { + return getHeapProfile() + } }