Skip to content

feat: add endpointPath to fb custom audience response config - #4630

Merged
koladilip merged 1 commit into
developfrom
feat/fb-custom-audience-endpoint-path
Sep 15, 2025
Merged

koladilip merged 1 commit into
developfrom
feat/fb-custom-audience-endpoint-path

Conversation

@koladilip

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

This PR adds an endpointPath field 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:

  • Extract ENDPOINT_PATH constant in config.js for better maintainability
  • Add endpointPath field to response configuration in util.js
  • Update processor and router test data to include endpointPath field
  • Ensures consistent API response structure across all Facebook Custom Audience operations

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

No breaking changes. This is an additive change that adds the endpointPath field 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

  • 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?

@koladilip
koladilip requested review from a team and sivashanmukh as code owners September 11, 2025 16:10
@koladilip
koladilip requested review from a team, maheshkutty and vinayteki95 September 11, 2025 16:10
@coderabbitai

coderabbitai Bot commented Sep 11, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • None; no user-facing behavior changes.
  • Refactor
    • Centralized endpoint configuration for Facebook Custom Audiences to improve consistency and maintainability.
    • Added endpoint path metadata in responses; no functional impact.
  • Tests
    • Updated tests to align with the new configuration-driven endpoint construction.
  • Chores
    • CI now stops on test failures to ensure higher build quality.

Walkthrough

Centralizes 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

Cohort / File(s) Summary
Config constant & URL builder
src/v0/destinations/fb_custom_audience/config.js
Added exported ENDPOINT_PATH = '/users' and updated getEndPoint(audienceId) to build URLs using ENDPOINT_PATH.
Response construction
src/v0/destinations/fb_custom_audience/util.js
responseBuilderSimple now sets response.endpointPath = config.ENDPOINT_PATH immediately after response.endpoint is set. No other logic changes.
Tests updated
src/v0/destinations/fb_custom_audience/util.test.js
Tests import getEndPoint and ENDPOINT_PATH, replace hard-coded endpoint with getEndPoint(...), and add endpointPath: ENDPOINT_PATH to expected response.
CI workflow
.github/workflows/dt-test-and-report-code-coverage.yml
Removed continue-on-error: true from the Run Tests step so test failures now fail the step and stop the coverage job.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • sivashanmukh
  • vinayteki95
  • maheshkutty

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly identifies the primary change—adding an endpointPath to the Facebook Custom Audience response configuration—and uses the conventional "feat:" prefix; it is concise, specific, and directly reflects the main change in the diff.
Description Check ✅ Passed The PR description follows the repository template and documents the change, objectives, and developer checklist, but it leaves the Linear task as a placeholder (INT-XXX) and does not mention the CI workflow change (.github/workflows/dt-test-and-report-code-coverage.yml) present in the diff that removes continue-on-error and may affect CI behavior; adding these specifics would improve reviewer context.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/fb-custom-audience-endpoint-path

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Sep 11, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.78%. Comparing base (63bd4e3) to head (1d506ee).
⚠️ Report is 23 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6b30364 and 820b34a.

⛔ Files ignored due to path filters (2)
  • test/integrations/destinations/fb_custom_audience/processor/data.ts is excluded by !**/test/**
  • test/integrations/destinations/fb_custom_audience/router/data.ts is 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.js
  • src/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
@koladilip
koladilip force-pushed the feat/fb-custom-audience-endpoint-path branch from 820b34a to 1d506ee Compare September 15, 2025 04:32
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

payload and expectedResponse reference 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

payload is undefined in this scope, so the test passes due to a JS scoping error, not responseBuilderSimple’s validation. Call the function with undefined (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

📥 Commits

Reviewing files that changed from the base of the PR and between 820b34a and 1d506ee.

⛔ Files ignored due to path filters (2)
  • test/integrations/destinations/fb_custom_audience/processor/data.ts is excluded by !**/test/**
  • test/integrations/destinations/fb_custom_audience/router/data.ts is 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)

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants