Repository navigation
feat: add endpointPath to fb custom audience response config - #4630
Conversation
Summary by CodeRabbit
WalkthroughCentralizes the Facebook Custom Audience users endpoint by adding and exporting ENDPOINT_PATH in config.js, updating getEndPoint to use it, setting response.endpointPath = config.ENDPOINT_PATH in util.js, updating tests to use the new config values, and removing continue-on-error from a GitHub Actions test step. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant Util as fb_custom_audience/util.js
participant Config as fb_custom_audience/config.js
Caller->>Util: responseBuilderSimple(event, config)
Util->>Config: getEndPoint(audienceId)
Config-->>Util: endpoint (BASE_URL/{audienceId}/users)
Note right of Util: New: also reads ENDPOINT_PATH
Util->>Util: response.endpoint = endpoint
Util->>Util: response.endpointPath = ENDPOINT_PATH
Util-->>Caller: response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4630 +/- ##
========================================
Coverage 91.78% 91.78%
========================================
Files 642 642
Lines 33941 33951 +10
Branches 8035 8035
========================================
+ Hits 31152 31163 +11
+ Misses 2559 2558 -1
Partials 230 230 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/v0/destinations/fb_custom_audience/config.js (2)
3-4: Good extraction of endpoint path; centralization helps.Adding ENDPOINT_PATH reduces duplication and makes future changes safer. Consider documenting expected leading-slash semantics in a short comment.
6-6: Harden URL construction to avoid double-slash edge cases.Using the URL API makes joins resilient if BASE_URL or ENDPOINT_PATH change their trailing/leading slashes.
- return `${BASE_URL}/${audienceId}${ENDPOINT_PATH}`; + const url = new URL(`${audienceId}${ENDPOINT_PATH}`, `${BASE_URL}/`); + return url.toString();src/v0/destinations/fb_custom_audience/util.js (1)
261-262: Consolidate config requires — destructure ENDPOINT_PATH and remove duplicate require.Replace the assignment in src/v0/destinations/fb_custom_audience/util.js (lines ~261–262):
- response.endpointPath = config.ENDPOINT_PATH; + response.endpointPath = ENDPOINT_PATH;Update imports in that file to a single destructure:
const { typeFields, subTypeFields, getEndPoint, ENDPOINT_PATH } = require('./config'); // remove: const config = require('./config');rg output: '/users' is only in src/v0/destinations/fb_custom_audience/config.js and src/v0/destinations/fb_custom_audience/util.test.js (OK).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
test/integrations/destinations/fb_custom_audience/processor/data.tsis excluded by!**/test/**test/integrations/destinations/fb_custom_audience/router/data.tsis excluded by!**/test/**
📒 Files selected for processing (2)
src/v0/destinations/fb_custom_audience/config.js(2 hunks)src/v0/destinations/fb_custom_audience/util.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/v0/destinations/fb_custom_audience/util.jssrc/v0/destinations/fb_custom_audience/config.js
🧬 Code graph analysis (1)
src/v0/destinations/fb_custom_audience/util.js (1)
src/v0/destinations/fb_custom_audience/recordTransform.js (2)
config(86-86)config(133-142)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- 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: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
src/v0/destinations/fb_custom_audience/config.js (1)
105-105: Export looks good; public API additive.No breaking change. Ensure any downstream TypeScript typings (if present elsewhere) are updated to include ENDPOINT_PATH.
- Extract ENDPOINT_PATH constant in config.js - Add endpointPath field to response configuration - Update processor and router test data to include endpointPath - Improves API response structure consistency
820b34a to
1d506ee
Compare
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/v0/destinations/fb_custom_audience/util.test.js (2)
62-79: Shared fixture mutation across tests; clone per test to prevent bleed-through
payloadandexpectedResponsereference the shared bases and are mutated (operationCategory,method). This can leak state between tests and cause order-dependent behavior.- const payload = basePayload; + const payload = JSON.parse(JSON.stringify(basePayload)); payload.operationCategory = 'add'; - const expectedResponse = baseResponse; + const expectedResponse = JSON.parse(JSON.stringify(baseResponse)); expectedResponse.method = 'POST';Apply the same deep-clone pattern in the "delete payload" test.
Optional hardening (outside this hunk):
Object.freeze(basePayload); Object.freeze(baseResponse);
81-88: Test is asserting a ReferenceError, not the function’s error path
payloadis undefined in this scope, so the test passes due to a JS scoping error, notresponseBuilderSimple’s validation. Call the function withundefined(or{}) explicitly and assert the thrown error.- it('Should throw error if payload is empty', () => { - try { - const response = responseBuilderSimple(payload, ''); - expect(response).toEqual(); - } catch (error) { - expect(error.message).toEqual(`payload is not defined`); - } - }); + it('Should throw error if payload is empty', () => { + expect(() => responseBuilderSimple(undefined, '')) + .toThrow('payload is not defined'); + });
🧹 Nitpick comments (1)
src/v0/destinations/fb_custom_audience/util.test.js (1)
53-53: Fix typo in test description“macthes” → “matches”.
- it('Should set subType and type if value present in destination config macthes with preset list', () => { + it('Should set subType and type if value present in destination config matches the preset list', () => {
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
test/integrations/destinations/fb_custom_audience/processor/data.tsis excluded by!**/test/**test/integrations/destinations/fb_custom_audience/router/data.tsis excluded by!**/test/**
📒 Files selected for processing (4)
.github/workflows/dt-test-and-report-code-coverage.yml(0 hunks)src/v0/destinations/fb_custom_audience/config.js(2 hunks)src/v0/destinations/fb_custom_audience/util.js(1 hunks)src/v0/destinations/fb_custom_audience/util.test.js(2 hunks)
💤 Files with no reviewable changes (1)
- .github/workflows/dt-test-and-report-code-coverage.yml
🚧 Files skipped from review as they are similar to previous changes (2)
- src/v0/destinations/fb_custom_audience/util.js
- src/v0/destinations/fb_custom_audience/config.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/v0/destinations/fb_custom_audience/util.test.js
🧬 Code graph analysis (1)
src/v0/destinations/fb_custom_audience/util.test.js (1)
src/v0/destinations/fb_custom_audience/config.js (1)
ENDPOINT_PATH(3-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- 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: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
|



What are the changes introduced in this PR?
This PR adds an
endpointPathfield to the Facebook Custom Audience destination response configuration to improve API response structure consistency.What is the related Linear task?
Resolves INT-XXX
Please explain the objectives of your changes below
Changes made:
ENDPOINT_PATHconstant inconfig.jsfor better maintainabilityendpointPathfield to response configuration inutil.jsendpointPathfieldAny changes to existing capabilities/behaviour, mention the reason & what are the changes ?
No breaking changes. This is an additive change that adds the
endpointPathfield to response configurations, improving the structure and consistency of API responses.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