Repository navigation
chore: use google ads SDK in GAEC destination - #4177
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4177 +/- ##
===========================================
- Coverage 91.05% 91.03% -0.02%
===========================================
Files 627 626 -1
Lines 33049 32915 -134
Branches 7818 7792 -26
===========================================
- Hits 30092 29964 -128
- Misses 2710 2734 +24
+ Partials 247 217 -30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
Summary by CodeRabbitSummary by CodeRabbit
WalkthroughThis update removes hardcoded API version and endpoint constants from multiple modules and tests. The network handler functions have been refactored to leverage the Google Ads SDK directly for obtaining conversion action IDs, with enhanced error handling. In addition, test integrations now omit the previously constructed endpoints in favor of empty strings while incorporating new authentication parameters such as Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant PR as ProxyRequest Handler
participant GA as GoogleAds SDK
C->>PR: Send request with event and params
PR->>GA: Call getConversionActionId(event)
GA-->>PR: Return conversion action ID or error
PR->>GA: Call addConversionAdjustment with conversion ID and params
GA-->>PR: Return success/failure response
PR-->>C: Return structured response
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
Allure Test reports for this run are available at:
|
46af874 to
c140015
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js (1)
5-6: Remove commented-out code.There are commented-out imports (
NetworkInstrumentationErrorandSqlString) that should be removed if they're no longer needed to maintain code cleanliness.- const { NetworkError, - // NetworkInstrumentationError, GoogleAdsSDK, InstrumentationError, isDefinedAndNotNullAndNotEmpty, } = require('@rudderstack/integrations-lib'); - // const SqlString = require('sqlstring');Also applies to: 10-10
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 46af874d7002ea4cce20e61594a91bf769f37bbc and c140015.
📒 Files selected for processing (1)
src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (8)
src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js (8)
3-9: Good update to import Google Ads SDK and required error handling utilities.The imports now correctly include the necessary components from the
@rudderstack/integrations-libpackage, aligning with the PR objective to use the Google Ads SDK in the GAEC destination.
31-42: Good refactoring to use Google Ads SDK for conversion action ID retrieval.The function signature has been appropriately updated to accept a
googleAdsparameter instead of the previously needed method, headers, and metadata. The implementation now properly leverages the SDK'sgetConversionActionIdmethod and includes good error handling for the case when no conversion action is found.
43-53: Proper error handling for client errors.This client-error handling block correctly uses the NetworkError class with appropriate error message formatting and propagates status code and error type information.
55-67: Good application error handling.The application-error handling is well implemented, correctly formatting the error message and including all necessary error details for proper debugging and client communication.
77-89: Good implementation of Google Ads SDK initialization.The ProxyRequest function has been simplified and now properly initializes the GoogleAds SDK with all required authentication parameters.
91-95: Clean implementation of conversion adjustment submission.The code properly sets the conversion action ID in the request body and directly leverages the SDK's addConversionAdjustMent method.
98-102: Well-structured response processing function.The
gaecProcessAxiosResponsefunction correctly transforms the SDK response structure to match what the existingresponseHandlerexpects, maintaining compatibility with the rest of the system.
148-148: Good implementation of the custom response processor.The class is correctly updated to use the new
gaecProcessAxiosResponsefunction, addressing the comment from the previous review about overriding theprocessAxiosResponsefunction.
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
…to chore.use_google_sdk_gaec
e86e1e6 to
199f39a
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/v0/destinations/google_adwords_enhanced_conversions/transform.js (1)
52-64: Consider avoiding token duplication.The developer token is fetched twice - once for headers and once for params. Consider extracting this to a variable to avoid duplication.
const accessToken = getAccessToken(metadata, 'access_token'); + const developerToken = getValueFromMessage(metadata, 'secret.developer_token'); deliveryRequest.headers = { Authorization: `Bearer ${accessToken}`, 'Content-Type': JSON_MIME_TYPE, - 'developer-token': getValueFromMessage(metadata, 'secret.developer_token'), + 'developer-token': developerToken, }; const filteredLoginCustomerId = removeHyphens(loginCustomerId); deliveryRequest.params = { event, customerId: filteredCustomerId, accessToken, loginCustomerId: filteredLoginCustomerId, - developerToken: getValueFromMessage(metadata, 'secret.developer_token'), + developerToken, };src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js (2)
3-10: Updated imports for Google Ads SDK integration.The imports have been updated to include the Google Ads SDK and necessary error handling utilities. Consider removing the commented-out imports for cleaner code.
const { NetworkError, - // NetworkInstrumentationError, GoogleAdsSDK, InstrumentationError, isDefinedAndNotNullAndNotEmpty, } = require('@rudderstack/integrations-lib'); -// const SqlString = require('sqlstring'); const { prepareProxyRequest } = require('../../../adapters/network');
31-74: Comprehensive refactoring ofgetConversionActionId.The function has been refactored to use the Google Ads SDK directly instead of constructing SQL queries, with enhanced error handling for various response types. The error message for non-existent conversion actions is particularly helpful.
However, the error message formatting is inconsistent - some contain extra quotes that could cause confusion when reading logs.
if (resp.type === 'client-error') { throw new NetworkError( - `"${resp.message} during Google_adwords_enhanced_conversions response transformation[client-error]"`, + `${resp.message} during Google_adwords_enhanced_conversions response transformation[client-error]`, resp.statusCode, { [tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(resp.statusCode), }, resp, getAuthErrCategory({ response: resp, status: resp.statusCode }), ); } if (resp.type === 'application-error') { throw new NetworkError( - `"${JSON.stringify(resp.responseBody)} during Google_adwords_enhanced_conversions response transformation"`, + `${JSON.stringify(resp.responseBody)} during Google_adwords_enhanced_conversions response transformation`, resp.statusCode, { [tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(resp.statusCode), }, resp.responseBody, getAuthErrCategory({ response: resp.responseBody, status: resp.statusCode }), ); } throw new NetworkError( - `"${JSON.stringify(resp)} during Google_adwords_enhanced_conversions response transformation"`, + `${JSON.stringify(resp)} during Google_adwords_enhanced_conversions response transformation`, 500, { [tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(500), }, resp, );
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js(4 hunks)src/v0/destinations/google_adwords_enhanced_conversions/transform.js(4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).
**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).
src/v0/destinations/google_adwords_enhanced_conversions/transform.jssrc/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js
🧬 Code Definitions (1)
src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js (2)
src/v0/destinations/google_adwords_enhanced_conversions/transform.js (5)
require(4-4)require(5-5)require(7-14)require(16-16)require(17-17)src/v0/destinations/google_adwords_enhanced_conversions/config.js (2)
require(1-1)CONVERSION_ACTION_ID_CACHE_TTL(7-9)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: ingestion-service-test
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (11)
src/v0/destinations/google_adwords_enhanced_conversions/transform.js (6)
16-16: Import change aligns with SDK migration.The removal of
BASE_ENDPOINTfrom the imports indicates the shift towards using the Google Ads SDK directly instead of hardcoded endpoints, which is a positive architectural change.
37-37: Good variable renaming fromresponsetodeliveryRequest.This rename more accurately represents the purpose of the variable, improving code readability and addressing the previous review feedback.
50-50: Simplified payload assignment.Direct assignment to
deliveryRequest.body.JSONsimplifies the code by removing endpoint construction logic.
57-57: UsingfilteredLoginCustomerIdfor both params and headers.This is not a duplicate as correctly noted in previous comments - one usage is for the params object and the other is for headers.
75-75: Consistent use offilteredLoginCustomerId.The code correctly uses the previously calculated
filteredLoginCustomerIdin the headers when subAccount is true.
78-78: Return updated variable name.Updated return statement to use
deliveryRequestinstead ofresponse, maintaining consistency with the variable renaming.src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js (5)
18-18: Added utility for dynamic error type handling.The import of
getDynamicErrorTypeenhances error handling capabilities, providing more specific error categorization.
84-103: Renamed and improved proxy request implementation.The function has been renamed to
gaecProxyRequestfor clarity and refactored to use the Google Ads SDK directly. The creation of the GoogleAds instance with the necessary authentication parameters is well structured.Consider using template literals consistently:
- set(body.JSON, 'conversionAdjustments[0].conversionAction', `${conversionActionId}`); + set(body.JSON, 'conversionAdjustments[0].conversionAction', conversionActionId);
105-109: New function for Axios response processing.The
gaecProcessAxiosResponsefunction provides standardized processing of SDK responses, improving consistency across the codebase. The conditional spread of headers only when defined is a good practice.
110-148: Well-structured response handler with detailed error handling.The
gaecResponseHandlerfunction includes comprehensive error handling for different response types, including the special case of partial failures with a 200 status code. The reference to the Google RPC code proto is helpful.
153-156: Updated networkHandler class with new function references.The class now uses the renamed and improved functions, maintaining consistency with the overall refactoring approach.
|
Allure Test reports for this run are available at:
|
|



This pull request focuses on refactoring the Google AdWords Enhanced Conversions destination to use the Google Ads SDK and improve error handling. The most important changes include removing the
BASE_ENDPOINTandAPI_VERSIONconstants, updating the network handler to use the Google Ads SDK, and modifying the test cases accordingly.Refactoring to use Google Ads SDK and improve error handling:
src/v0/destinations/google_adwords_enhanced_conversions/config.js: RemovedBASE_ENDPOINTandAPI_VERSIONconstants. [1] [2]src/v0/destinations/google_adwords_enhanced_conversions/networkHandler.js: Updated to use Google Ads SDK for fetching conversion action IDs and handling conversion adjustments. Improved error handling by utilizing SDK's response structure. [1] [2] [3] [4]Test case updates:
test/integrations/destinations/google_adwords_enhanced_conversions/dataDelivery/business.ts: RemovedBASE_ENDPOINTandAPI_VERSIONconstants from test cases. Added new parameters (developerToken,accessToken,loginCustomerId) to test scenarios. [1] [2] [3] [4] [5] [6]test/integrations/destinations/google_adwords_enhanced_conversions/dataDelivery/oauth.ts: Updated OAuth test scenarios to removeBASE_ENDPOINTandAPI_VERSIONconstants. Added new parameters (developerToken,accessToken,loginCustomerId). Improved error message formatting. [1] [2] [3] [4] [5] [6] [7] [8]What are the changes introduced in this PR?
We are using googleAds SDK in google ads enhanced conversion destination.
What is the related Linear task?
Resolves INT-3400
Please explain the objectives of your changes below
Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A
Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A
Any technical or performance related pointers to consider with the change?
N/A
@coderabbitai review
Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested?
Any documentation changes needed with this change?
Is the PR limited to 10 file changes?
Is the PR limited to one linear task?
Are relevant unit and component test-cases added in new readability format?
Reviewer checklist
Is the type of change in the PR title appropriate as per the changes?
Verified that there are no credentials or confidential data exposed with the changes.