Repository navigation
feat: add endpointPath to Facebook Pixel transformation - #4626
Conversation
Summary by CodeRabbit
WalkthroughReplaces per-destination endpoint string builders with getEndpointDetails(pixelId, accessToken) that returns { endpoint, path }. formingFinalResponse now accepts endpointDetails and sets response.endpoint and response.endpointPath. Call sites updated in Pixel and Conversions transforms; payload logic unchanged. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Transform as Transform (Pixel/Conversions)
participant Config as Config.getEndpointDetails
participant Utils as facebookUtils.formingFinalResponse
participant FB as Facebook Graph API
Transform->>Config: getEndpointDetails(pixelId, accessToken)
Config-->>Transform: { endpoint: "https://graph.facebook.com/V/PIXEL_ID/events?access_token=..", path: "/events" }
Transform->>Utils: formingFinalResponse(userData, commonData, customData, endpointDetails, testDestination, testEventCode, appData)
Utils->>Utils: build payload\nresponse.endpoint = endpointDetails.endpoint\nresponse.endpointPath = endpointDetails.path
Utils-->>Transform: response (with endpoint & endpointPath)
alt downstream send (outside diff)
Transform->>FB: POST response.endpoint with payload
FB-->>Transform: 200 / error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Pre-merge checks and finishing touches✅ Passed checks (3 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 |
|
Allure Test reports for this run are available at:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4626 +/- ##
========================================
Coverage 91.78% 91.78%
========================================
Files 642 642
Lines 33941 33953 +12
Branches 8042 8034 -8
========================================
+ Hits 31153 31165 +12
- Misses 2536 2558 +22
+ Partials 252 230 -22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/v0/util/facebookUtils/index.js (2)
262-266: Optional: add a lightweight backward-compat shim to prevent silent mis-order bugs.Defensively handle old arity (where 5th arg was boolean testDestination). This avoids accidental regressions if any caller slipped through.
const formingFinalResponse = ( userData, commonData, customData, endpoint, endpointPath, testDestination, testEventCode, appData, ) => { + // Back-compat: older callers passed (endpoint, testDestination, testEventCode, appData) + if (typeof endpointPath === 'boolean') { + appData = testEventCode; + testEventCode = testDestination; + testDestination = endpointPath; + endpointPath = undefined; + }
270-271: Nit: set endpointPath only when defined.Avoid introducing undefined fields into the response object.
- response.endpointPath = endpointPath; + if (endpointPath) { + response.endpointPath = endpointPath; + }src/v0/destinations/facebook_pixel/transform.js (1)
69-70: Prevent drift between endpoint and endpointPath.Hardcoding '/events' is fine, but it can fall out of sync if the endpoint changes. At minimum, document intent; optionally derive from endpoint.
Minimal doc tweak (preferred, no behavior change):
- const endpointPath = '/events'; + // Intentionally only the resource path segment for logging/diagnostics; keep in sync with `endpoint` above. + const endpointPath = '/events';Alternative: derive last segment from the URL (includes less risk of drift, but changes value if the path ever differs):
const endpointPath = `/${new URL(endpoint).pathname.split('/').pop()}`; // -> '/events'
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (8)
test/integrations/destinations/facebook_pixel/processor/configLevelFeaturesTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/ecommTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/identifyTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/pageScreenTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/trackTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/validationTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/router/data.tsis excluded by!**/test/**test/integrations/testUtils.tsis excluded by!**/test/**
📒 Files selected for processing (2)
src/v0/destinations/facebook_pixel/transform.js(2 hunks)src/v0/util/facebookUtils/index.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/util/facebookUtils/index.jssrc/v0/destinations/facebook_pixel/transform.js
🧬 Code graph analysis (1)
src/v0/util/facebookUtils/index.js (2)
src/v0/destinations/facebook_pixel/transform.js (2)
endpointPath(69-69)endpoint(68-68)src/v0/util/index.js (1)
defaultRequestConfig(462-476)
⏰ 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 ARM64
- 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: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
src/v0/util/facebookUtils/index.js (1)
257-266: Signature change — verify all call sites use new param order (endpointPath is now 5th arg)Automated search returned no matches (ripgrep skipped files). Confirm every formingFinalResponse(...) call uses:
(userData, commonData, customData, endpoint, endpointPath, testDestination, testEventCode, appData) so testDestination/testEventCode/appData are not shifted. Suggested check: runrg -nC2 -uu '\bformingFinalResponse\s*\('in the repo.src/v0/destinations/facebook_pixel/transform.js (1)
157-165: Confirm tests/assertions validate endpointPath is present in responsesendpointPath is passed into formingFinalResponse — add or update fixtures and assertions to ensure responses include endpointPath to prevent regressions.
File: src/v0/destinations/facebook_pixel/transform.js (lines 157–165)
Suggestion: add an assertion such as expect(response.endpointPath).toBe('/expected/path') and search tests with: rg -n -C2 --glob 'test/**' endpointPath || rg -n -C2 endpointPath test
f84e545 to
ff847a2
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
src/v0/util/facebookUtils/index.js (1)
268-270: Defensive assignment for endpoint and endpointPathAvoid crash if endpointDetails is undefined and only set endpointPath when present.
- response.endpoint = endpointDetails.endpoint; - response.endpointPath = endpointDetails.path; + const { endpoint, path } = endpointDetails || {}; + if (!endpoint) { + throw new TransformationError('Endpoint details missing'); + } + response.endpoint = endpoint; + if (path) { + response.endpointPath = path; + }src/v0/destinations/facebook_pixel/config.js (2)
7-10: URL-encode the accessToken in the endpointSmall hardening to prevent surprises if token contains special chars.
- endpoint: `https://graph.facebook.com/${VERSION}/${pixelId}${ENDPOINT_PATH}?access_token=${accessToken}`, + endpoint: `https://graph.facebook.com/${VERSION}/${pixelId}${ENDPOINT_PATH}?access_token=${encodeURIComponent(accessToken)}`,
119-121: Avoid VERSION duplication across destinationsIf another module (e.g., fb/config.js) also defines VERSION, consider centralizing to prevent drift.
src/v0/destinations/facebook_pixel/transform.js (2)
68-68: Rename variable for clarityIt holds an object, not a string. Rename to endpointDetails to match usage and new API.
- const endpoint = getEndpointDetails(pixelId, accessToken); + const endpointDetails = getEndpointDetails(pixelId, accessToken);
156-163: Pass the renamed endpointDetails; consider log hygieneUpdate the call to match the rename. Also verify your router/logging prefers endpointPath for logs/metrics to avoid leaking access_token from endpoint.
return formingFinalResponse( userData, commonData, customData, - endpoint, + endpointDetails, testDestination, testEventCode, );
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (9)
test/integrations/destinations/facebook_pixel/common.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/configLevelFeaturesTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/ecommTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/identifyTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/pageScreenTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/trackTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/processor/validationTestData.tsis excluded by!**/test/**test/integrations/destinations/facebook_pixel/router/data.tsis excluded by!**/test/**test/integrations/testUtils.tsis excluded by!**/test/**
📒 Files selected for processing (3)
src/v0/destinations/facebook_pixel/config.js(2 hunks)src/v0/destinations/facebook_pixel/transform.js(2 hunks)src/v0/util/facebookUtils/index.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/util/facebookUtils/index.jssrc/v0/destinations/facebook_pixel/config.jssrc/v0/destinations/facebook_pixel/transform.js
🧬 Code graph analysis (3)
src/v0/util/facebookUtils/index.js (4)
src/v0/destinations/facebook_conversions/utils.js (1)
appData(200-204)src/v0/destinations/facebook_conversions/transform.js (3)
appData(102-102)userData(56-61)commonData(67-71)src/v0/destinations/facebook_pixel/transform.js (2)
userData(70-75)commonData(77-81)src/v0/util/index.js (1)
defaultRequestConfig(462-476)
src/v0/destinations/facebook_pixel/config.js (1)
src/v0/destinations/fb/config.js (1)
VERSION(4-4)
src/v0/destinations/facebook_pixel/transform.js (1)
src/v0/destinations/facebook_pixel/config.js (1)
getEndpointDetails(7-10)
⏰ 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). (8)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
src/v0/util/facebookUtils/index.js (1)
257-265: Add guard + JSDoc for endpointDetails to avoid property-access throwsAdd a light runtime guard and a short JSDoc for the new endpointDetails param so callers that still pass a legacy string URL don't cause property-access errors. Suggested guard:
const ed = typeof endpointDetails === 'string' ? { url: endpointDetails } : (endpointDetails || {});Check/update these locations as needed:
- Definition: src/v0/util/facebookUtils/index.js (around line 257)
- Call sites: src/v0/destinations/facebook_pixel/transform.js:156, src/v0/destinations/facebook_conversions/transform.js:107
src/v0/destinations/facebook_pixel/transform.js (1)
10-11: Good move: centralizing endpoint constructionUsing getEndpointDetails removes URL-building duplication and clarifies intent.
ff847a2 to
58aa735
Compare
- Add endpointPath parameter to responseBuilderSimple function - Update formingFinalResponse to include endpointPath in response - Update test data to include endpointPath field
58aa735 to
5bfdd0c
Compare
- Add endpointPath parameter to responseBuilderSimple function - Update formingFinalResponse to include endpointPath in response - Update test data to include endpointPath field
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/v0/destinations/facebook_conversions/config.js (1)
3-10: Harden endpoint construction and avoid version drift.
- Encode
pixelIdandaccessTokento guard against special chars in URLs.- Consider sourcing
VERSIONfromsrc/v0/destinations/fb/config.js(if exported) to keep a single source of truth.- Nit: In Conversions we pass
datasetId; param namepixelIdhere may confuse future readers.Apply encoding with this diff:
-const getEndpointDetails = (pixelId, accessToken) => ({ - endpoint: `https://graph.facebook.com/${VERSION}/${pixelId}${ENDPOINT_PATH}?access_token=${accessToken}`, +const getEndpointDetails = (pixelId, accessToken) => ({ + endpoint: `https://graph.facebook.com/${VERSION}/${encodeURIComponent(pixelId)}${ENDPOINT_PATH}?access_token=${encodeURIComponent(accessToken)}`, path: ENDPOINT_PATH, });If
VERSIONis exported upstream, prefer importing it and dropping the local constant to avoid mismatches.src/v0/destinations/facebook_conversions/transform.js (1)
107-115: PassingendpointDetailsintoformingFinalResponsematches the new API.Good adaptation. Minor readability tweak (optional): precompute
const endpointDetails = getEndpointDetails(datasetId, accessToken);then pass it, which also helps when debugging.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
test/integrations/destinations/facebook_conversions/common.tsis excluded by!**/test/**test/integrations/destinations/facebook_conversions/processor/data.tsis excluded by!**/test/**test/integrations/destinations/facebook_conversions/router/data.tsis excluded by!**/test/**
📒 Files selected for processing (2)
src/v0/destinations/facebook_conversions/config.js(2 hunks)src/v0/destinations/facebook_conversions/transform.js(2 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/facebook_conversions/config.jssrc/v0/destinations/facebook_conversions/transform.js
🧬 Code graph analysis (2)
src/v0/destinations/facebook_conversions/config.js (1)
src/v0/destinations/fb/config.js (1)
VERSION(4-4)
src/v0/destinations/facebook_conversions/transform.js (1)
src/v0/destinations/facebook_conversions/config.js (1)
getEndpointDetails(7-10)
⏰ 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)
🔇 Additional comments (1)
src/v0/destinations/facebook_conversions/config.js (1)
124-124: Export switch looks good.Switching from
ENDPOINTtogetEndpointDetailsaligns with the new response shape andendpointPathaddition.Please confirm no other modules still import
ENDPOINTfrom this file.
|



What are the changes introduced in this PR?
This PR adds an
endpointPathparameter to the Facebook Pixel transformation to provide better endpoint path tracking and debugging capabilities.What is the related Linear task?
Resolves https://linear.app/rudderstack/issue/INT-4102/add-endpoint-path-details-in-rudder-transformer-for-top-15
Please explain the objectives of your changes below
The changes introduce a new
endpointPathfield that gets passed through the Facebook Pixel transformation pipeline, allowing for better tracking and debugging of API endpoints.Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
endpointPathparameter toresponseBuilderSimplefunction in Facebook Pixel transformformingFinalResponsefunction to includeendpointPathin the response objectendpointPathfieldAny 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?
This is a non-breaking change that adds a new optional field to the response object. No performance impact expected.
@coderabbitai review
Developer checklist
Reviewer checklist