From e98ea84265ee37bfc6d3e99104af7bb4a3d78007 Mon Sep 17 00:00:00 2001 From: Gauravudia <60897972+Gauravudia@users.noreply.github.com> Date: Thu, 14 Sep 2023 09:56:38 +0530 Subject: [PATCH 1/3] feat(mixpanel): add incremental properties support (#2550) * feat(mixpanel): add incremental properties support * docs: add comment * test: update testcase --- src/v0/destinations/mp/transform.js | 39 +++++++++++++++++++++++++++++ src/v0/destinations/mp/util.test.js | 5 +--- test/__tests__/data/mp_input.json | 25 +++++++++++++++--- test/__tests__/data/mp_output.json | 20 ++++++++++++++- 4 files changed, 81 insertions(+), 8 deletions(-) diff --git a/src/v0/destinations/mp/transform.js b/src/v0/destinations/mp/transform.js index 0cb06aad93..425b7a8249 100644 --- a/src/v0/destinations/mp/transform.js +++ b/src/v0/destinations/mp/transform.js @@ -130,6 +130,37 @@ const processRevenueEvents = (message, destination, revenueValue) => { return responseBuilderSimple(payload, message, 'revenue', destination.Config); }; +/** + * This function is used to process the incremental properties + * ref :- https://developer.mixpanel.com/reference/profile-numerical-add + * @param {*} message + * @param {*} destination + * @param {*} propIncrements + * @returns + */ +const processIncrementalProperties = (message, destination, propIncrements) => { + const payload = { + $add: {}, + $token: destination.Config.token, + $distinct_id: message.userId || message.anonymousId, + }; + + if (destination?.Config.identityMergeApi === 'simplified') { + payload.$distinct_id = message.userId || `$device:${message.anonymousId}`; + } + + Object.keys(message.properties).forEach((prop) => { + const value = message.properties[prop]; + if (value && propIncrements.includes(prop)) { + payload.$add[prop] = value; + } + }); + + return Object.keys(payload.$add).length > 0 + ? responseBuilderSimple(payload, message, 'incremental_properties', destination.Config) + : null; +}; + const getEventValueForTrackEvent = (message, destination) => { const mappedProperties = constructPayload(message, mPEventPropertiesConfigJson); // This is to conform with SDKs sending timestamp component with messageId @@ -178,6 +209,14 @@ const processTrack = (message, destination) => { if (revenue) { returnValue.push(processRevenueEvents(message, destination, revenue)); } + + if (Array.isArray(destination.Config.propIncrements)) { + const propIncrements = destination.Config.propIncrements.map((item) => item.property); + const response = processIncrementalProperties(message, destination, propIncrements); + if (response) { + returnValue.push(response); + } + } returnValue.push(getEventValueForTrackEvent(message, destination)); return returnValue; }; diff --git a/src/v0/destinations/mp/util.test.js b/src/v0/destinations/mp/util.test.js index 2434564699..c5cd5b61e8 100644 --- a/src/v0/destinations/mp/util.test.js +++ b/src/v0/destinations/mp/util.test.js @@ -1,7 +1,4 @@ -const { - combineBatchRequestsWithSameJobIds, - combineBatchRequestsWithSameJobIds2, -} = require('./util'); +const { combineBatchRequestsWithSameJobIds } = require('./util'); const destinationMock = { Config: { diff --git a/test/__tests__/data/mp_input.json b/test/__tests__/data/mp_input.json index 394fc49b61..6d456858c9 100644 --- a/test/__tests__/data/mp_input.json +++ b/test/__tests__/data/mp_input.json @@ -432,7 +432,18 @@ "apiKey": "dummyApiKey", "token": "dummyApiKey", "prefixProperties": true, - "useNativeSDK": false + "useNativeSDK": false, + "propIncrements": [ + { + "property": "counter" + }, + { + "property": "item_purchased" + }, + { + "property": "number_of_logins" + } + ] }, "DestinationDefinition": { "DisplayName": "Kiss Metrics", @@ -493,7 +504,10 @@ "originalTimestamp": "2020-01-24T06:29:02.364Z", "properties": { "currency": "USD", - "revenue": 45.89 + "revenue": 45.89, + "counter": 1, + "item_purchased": "2", + "number_of_logins": "" }, "receivedAt": "2020-01-24T11:59:02.403+05:30", "request_ip": "[::1]:53710", @@ -582,7 +596,12 @@ "apiKey": "dummyApiKey", "token": "dummyApiKey", "prefixProperties": true, - "useNativeSDK": false + "useNativeSDK": false, + "propIncrements": [ + { + "property": "" + } + ] }, "DestinationDefinition": { "DisplayName": "Kiss Metrics", diff --git a/test/__tests__/data/mp_output.json b/test/__tests__/data/mp_output.json index fe54474dd8..61100a1b84 100644 --- a/test/__tests__/data/mp_output.json +++ b/test/__tests__/data/mp_output.json @@ -128,6 +128,24 @@ "files": {}, "userId": "e6ab2c5e-2cda-44a9-a962-e2f67df78bca" }, + { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://api.mixpanel.com/engage/", + "headers": {}, + "params": {}, + "body": { + "JSON": {}, + "JSON_ARRAY": { + "batch": "[{\"$add\":{\"counter\":1,\"item_purchased\":\"2\"},\"$token\":\"dummyApiKey\",\"$distinct_id\":\"e6ab2c5e-2cda-44a9-a962-e2f67df78bca\"}]" + }, + "XML": {}, + "FORM": {} + }, + "files": {}, + "userId": "e6ab2c5e-2cda-44a9-a962-e2f67df78bca" + }, { "version": "1", "type": "REST", @@ -138,7 +156,7 @@ "body": { "JSON": {}, "JSON_ARRAY": { - "batch": "[{\"event\":\"test revenue MIXPANEL\",\"properties\":{\"currency\":\"USD\",\"revenue\":45.89,\"city\":\"Disney\",\"country\":\"USA\",\"email\":\"mickey@disney.com\",\"firstName\":\"Mickey\",\"ip\":\"0.0.0.0\",\"$current_url\":\"https://docs.rudderstack.com/destinations/mixpanel\",\"$screen_dpi\":2,\"mp_lib\":\"RudderLabs JavaScript SDK\",\"$app_build_number\":\"1.0.0\",\"$app_version_string\":\"1.0.5\",\"$insert_id\":\"a6a0ad5a-bd26-4f19-8f75-38484e580fc7\",\"token\":\"dummyApiKey\",\"distinct_id\":\"e6ab2c5e-2cda-44a9-a962-e2f67df78bca\",\"time\":1579847342,\"$browser\":\"Chrome\",\"$browser_version\":\"79.0.3945.117\"}}]" + "batch": "[{\"event\":\"test revenue MIXPANEL\",\"properties\":{\"currency\":\"USD\",\"revenue\":45.89,\"counter\":1,\"item_purchased\":\"2\",\"number_of_logins\":\"\",\"city\":\"Disney\",\"country\":\"USA\",\"email\":\"mickey@disney.com\",\"firstName\":\"Mickey\",\"ip\":\"0.0.0.0\",\"$current_url\":\"https://docs.rudderstack.com/destinations/mixpanel\",\"$screen_dpi\":2,\"mp_lib\":\"RudderLabs JavaScript SDK\",\"$app_build_number\":\"1.0.0\",\"$app_version_string\":\"1.0.5\",\"$insert_id\":\"a6a0ad5a-bd26-4f19-8f75-38484e580fc7\",\"token\":\"dummyApiKey\",\"distinct_id\":\"e6ab2c5e-2cda-44a9-a962-e2f67df78bca\",\"time\":1579847342,\"$browser\":\"Chrome\",\"$browser_version\":\"79.0.3945.117\"}}]" }, "XML": {}, "FORM": {} From f44a951fc2a23135e3d0950d7a29421ca939de1a Mon Sep 17 00:00:00 2001 From: AASHISH MALIK Date: Thu, 14 Sep 2023 14:42:37 +0530 Subject: [PATCH 2/3] 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 3/3] 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() + } }