Repository navigation
feat: snapchat v3 - #4052
feat: snapchat v3#4052
Conversation
|
Allure Test reports for this run are available at: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4052 +/- ##
===========================================
+ Coverage 91.21% 91.26% +0.05%
===========================================
Files 632 634 +2
Lines 33053 33243 +190
Branches 7827 7867 +40
===========================================
+ Hits 30150 30340 +190
Misses 2658 2658
Partials 245 245 ☔ 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: |
1 similar comment
|
Allure Test reports for this run are available at: |
|
Allure Test reports for this run are available at: |
|
|
This PR is considered to be stale. It has been open for 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR. |
|
This PR is considered to be stale. It has been open for 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR. |
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThe changes introduce support for Snapchat Conversion API version 3 alongside the existing version 2 integration. The configuration is refactored to handle multiple API versions, and new configuration objects and mappings are added for v3. The transformation logic is updated to delegate processing to version-specific modules based on the configured API version. Utility functions for event mapping, conversion type determination, event configuration validation, and timestamp handling are refactored and enhanced. New modules implement the v3 transformation and batching logic, including detailed user data handling and payload construction. The codebase is reorganized for better modularity and maintainability. Changes
Sequence Diagram(s)sequenceDiagram
participant Source as Source Event
participant Transform as transform.js
participant Util as util.js
participant TransformV3 as transformV3.js
participant UtilsV3 as utilsV3.js
participant Config as config.js
Source->>Transform: process(event)
Transform->>Config: Check API_VERSION
alt API v2
Transform->>Util: eventMappingHandler, getEventConversionType, etc.
Util-->>Transform: Mapped event, conversion type, timestamp, etc.
Transform->>Config: Use ENDPOINT.Endpoint_v2
Transform-->>Source: v2 HTTP request
else API v3
Transform->>TransformV3: processV3(event)
TransformV3->>Config: Use ENDPOINT.Endpoint_v3, mappingConfigV3
TransformV3->>UtilsV3: getExtInfo (for device/app info)
TransformV3-->>Transform: v3 HTTP request
Transform-->>Source: v3 HTTP request
end
Suggested reviewers
Suggestions for improvement:
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (9)
✨ Finishing Touches
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. 🪧 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:
|
|
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:
|
There was a problem hiding this comment.
Actionable comments posted: 4
🔭 Outside diff range comments (1)
src/v0/destinations/snapchat_conversion/util.js (1)
23-27:⚠️ Potential issue
msUnixTimestampreturns wrong value (×1000 instead of ÷1000)
Date#getTime()already yields milliseconds, but the helper multiplies that value by 1000 and then trims digits, effectively converting back to seconds via string slicing – a fragile and confusing approach that can generate wrong timestamps for some dates.-function msUnixTimestamp(timestamp) { - const time = new Date(timestamp); - return time.getTime() * 1000 + time.getMilliseconds(); -} +function msUnixTimestamp(timestamp) { + const time = new Date(timestamp); + // Convert ms → s and round down + return Math.floor(time.getTime() / 1000); +}This removes the string hack, is O(1) faster, and obeys the Snapchat API spec of seconds since epoch.
🧹 Nitpick comments (6)
src/v0/destinations/snapchat_conversion/config.js (2)
3-6: Consider harmonising endpoint constant names
Endpoint_v2/Endpoint_v3mixPascalCaseandsnake_case. Sticking to a single naming convention (e.g. all‐caps snakeENDPOINT_V2) keeps the public surface predictable and lets static‑analysis tools spot typos more easily.
41-66: Large duplication betweenConfigCategoryandConfigCategoryV3
ConfigCategoryV3repeats every entry ofConfigCategorywith only theV3suffix changed. A programmatic derivation avoids drift and cuts maintenance in half:-const ConfigCategoryV3 = { - DEFAULT: { name: 'SnapchatTrackDefaultConfigV3' }, - … -}; +const appendV3 = (obj) => + Object.fromEntries( + Object.entries(obj).map(([k, v]) => [k, { name: `${v.name}V3` }]), + ); +const ConfigCategoryV3 = appendV3(ConfigCategory);src/v0/destinations/snapchat_conversion/transformV3.js (1)
154-160: Missingcontent_ids/valuefor other product events
product_viewedandproduct_addedalso benefit fromcontent_idsandvalue, yet they are omitted fromisProductEvent. Expanding the set avoids incomplete attribution metrics.src/v0/destinations/snapchat_conversion/transform.js (2)
40-49: Clarify endpoint selection to avoid accidental v3 routing through v2 URL
buildResponseis hard‑coded toENDPOINT.Endpoint_v2. That’s fine while the caller is only the v2 branch, but it becomes brittle if future refactors reuse this utility for v3 (or any other version). A small, low‑risk tweak would make the helper future‑proof:-function buildResponse(apiKey, payload) { +function buildResponse(apiKey, payload, endpoint = ENDPOINT.Endpoint_v2) { const response = defaultRequestConfig(); - response.endpoint = ENDPOINT.Endpoint_v2; + response.endpoint = endpoint; ... }Then pass
endpointexplicitly from the v2 path.
This prevents silent mis‑routing should a v3 code path ever (re)use the helper.
263-269: Consider fast‑exit to reduce cyclomatic complexityThe early
if (destination.Config?.apiVersion === API_VERSION.v3)branch is correct, but the v2 logic continues to run a few inexpensive lines (e.g.if (!message.type) …) before the branch. Moving the version check to the top ofprocesslets v3 traffic bail out immediately and removes two indentation levels from the bulk of the function:const process = (event) => { + if (event.destination?.Config?.apiVersion === API_VERSION.v3) { + return processV3(event); + } const { message, destination } = event; - if (destination.Config?.apiVersion === API_VERSION.v3) { - return processV3(event); - }No functional change, just improved readability and a touch less cognitive load.
src/v0/destinations/snapchat_conversion/util.js (1)
145-160:eventMappingHandlerdoes a linear scan for each call – consider pre‑compilingIf a workspace has large mapping tables, repeatedly iterating the array for every event can add noticeable latency. You can pre‑index the
rudderEventsToSnapEventsconfig once:const buildEventMap = (mappings) => mappings.reduce((acc, { from, to }) => { acc[from.trim().replace(/\s+/g, '_').toLowerCase()] = to; return acc; }, {});Cache the map per destination (e.g., inside
destination.Context) and lookups become O(1). This is a nice‑to‑have optimisation, but worth considering for high‑throughput pipelines.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (17)
src/v0/destinations/snapchat_conversion/data/CheckoutStartedConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/OrderCompletedConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/PaymentInfoEnteredConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/ProductAddedConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/ProductAddedToWishlistConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/ProductListViewedConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/ProductViewedConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/ProductsSearchedConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/PromotionClickedConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/PromotionViewedConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/SignupConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/SnapchatTrackDefaultConfigV3.jsonis excluded by!**/*.jsonsrc/v0/destinations/snapchat_conversion/data/TrackEventCommonConfigV3.jsonis excluded by!**/*.jsontest/integrations/destinations/snapchat_conversion/processor/data.tsis excluded by!**/test/**test/integrations/destinations/snapchat_conversion/processor/dataV3.tsis excluded by!**/test/**test/integrations/destinations/snapchat_conversion/router/data.tsis excluded by!**/test/**test/integrations/destinations/snapchat_conversion/router/dataV3.tsis excluded by!**/test/**
📒 Files selected for processing (5)
src/v0/destinations/snapchat_conversion/config.js(3 hunks)src/v0/destinations/snapchat_conversion/transform.js(5 hunks)src/v0/destinations/snapchat_conversion/transformV3.js(1 hunks)src/v0/destinations/snapchat_conversion/util.js(3 hunks)src/v0/destinations/snapchat_conversion/utilsV3.js(1 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/snapchat_conversion/transformV3.jssrc/v0/destinations/snapchat_conversion/utilsV3.jssrc/v0/destinations/snapchat_conversion/transform.jssrc/v0/destinations/snapchat_conversion/config.jssrc/v0/destinations/snapchat_conversion/util.js
🧬 Code Graph Analysis (3)
src/v0/destinations/snapchat_conversion/utilsV3.js (5)
src/v0/destinations/snapchat_conversion/util.js (8)
require(3-3)require(7-12)require(13-13)require(14-14)moment(4-4)destination(111-111)destination(142-142)get(1-1)src/v0/destinations/snapchat_conversion/transform.js (6)
require(2-2)require(3-3)require(5-15)require(16-24)require(25-36)get(1-1)src/v0/destinations/snapchat_conversion/transformV3.js (11)
require(2-2)require(3-3)require(5-13)require(14-20)require(21-31)require(32-32)require(33-33)webOrOfflineEventsChunk(269-269)mobileEventsChunk(270-270)get(1-1)extInfo(115-115)src/v0/util/index.js (1)
batch(2072-2072)src/v0/destinations/snapchat_conversion/config.js (1)
MAX_BATCH_SIZE(7-7)
src/v0/destinations/snapchat_conversion/config.js (1)
src/v0/util/index.js (1)
getMappingConfig(538-548)
src/v0/destinations/snapchat_conversion/util.js (4)
src/v0/destinations/snapchat_conversion/transform.js (8)
require(2-2)require(3-3)require(5-15)event(157-157)event(264-264)get(1-1)mappedEvents(278-278)eventConversionType(158-158)src/v0/destinations/snapchat_conversion/transformV3.js (11)
require(2-2)require(3-3)require(5-13)require(14-20)require(21-31)require(32-32)require(33-33)event(195-195)event(250-250)get(1-1)mappedEvents(236-236)src/v0/destinations/snapchat_conversion/config.js (1)
ENDPOINT(3-6)src/v0/util/index.js (1)
getFieldValueFromMessage(685-691)
⏰ Context from checks skipped due to timeout of 90000ms (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 (2)
src/v0/destinations/snapchat_conversion/config.js (1)
113-115: *Verify presence of the new .json mapping files
getMappingConfigeagerly reads a JSON file for every entry inConfigCategoryV3. If even one file (e.g.ProductAddedConfigV3.json) is missing, the whole SDK will crash at module‑load time. Please make sure those files exist or guard the call withtry/catch.src/v0/destinations/snapchat_conversion/transformV3.js (1)
228-230: Guard against undefinedpixelId/snapAppId
IDis chosen purely fromactionSource, but either identifier could still beundefined(e.g. mis‑configured destination). Adding an explicit check yields earlier, clearer errors:if (!ID) { throw new InstrumentationError('pixelId / snapAppId is required for API v3 calls'); }
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Pull Request Overview
This PR introduces Snapchat v3 conversion support by incorporating new data files, utility methods, and transformations for the updated API. Key changes include:
- Splitting test data into v2 and v3 sets and merging them.
- Adding new utility and transformation functions to support v3 endpoints.
- Updating configuration to include v3 endpoints and mapping configuration.
Reviewed Changes
Copilot reviewed 9 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/integrations/destinations/snapchat_conversion/router/data.ts | Introduces dataV3 import, renames existing export to dataV2 and merges data arrays. |
| test/integrations/destinations/snapchat_conversion/processor/data.ts | Similar update for processor test data with dataV3 integration. |
| src/v0/destinations/snapchat_conversion/utilsV3.js | New v3 utility methods added to support batched responses and metadata merging. |
| src/v0/destinations/snapchat_conversion/util.js | Updates include new error handling, v2 endpoint selection via configuration, and added helper functions. |
| src/v0/destinations/snapchat_conversion/transformV3.js | A new transformation file for processing Snapchat v3 events. |
| src/v0/destinations/snapchat_conversion/transform.js | Modified to check and delegate processing based on the API version. |
| src/v0/destinations/snapchat_conversion/config.js | Updated endpoint configuration and added v3 mapping configuration and API version details. |
Files not reviewed (13)
- src/v0/destinations/snapchat_conversion/data/CheckoutStartedConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/OrderCompletedConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/PaymentInfoEnteredConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/ProductAddedConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/ProductAddedToWishlistConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/ProductListViewedConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/ProductViewedConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/ProductsSearchedConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/PromotionClickedConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/PromotionViewedConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/SignupConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/SnapchatTrackDefaultConfigV3.json: Language not supported
- src/v0/destinations/snapchat_conversion/data/TrackEventCommonConfigV3.json: Language not supported
Comments suppressed due to low confidence (2)
test/integrations/destinations/snapchat_conversion/router/data.ts:5
- [nitpick] Consider renaming 'dataV2' to a more descriptive name (e.g., 'snapchatConversionDataV2') to clearly differentiate between v2 and v3 test data sets.
export const dataV2 = [
test/integrations/destinations/snapchat_conversion/processor/data.ts:3
- [nitpick] Consider renaming 'dataV2' to a more descriptive name (e.g., 'snapchatConversionDataV2') for improved clarity in the test data context.
const dataV2 = [
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
* chore(docs): update README on how to configure secrets in tests (#4242) * chore: remove conplexity issue and redundant comments (#4250) * chore: remove conplexity issue and redundant comments * chore: address comment * chore(deps): bump rudderlabs/build-scan-push-action from 1.5.2 to 1.5.3 (#4236) chore(deps): bump build scan push action to 1.5.3 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(pyroscope): use forked pyroscope middleware with latest updates * chore(pyroscope): use forked pyroscope middleware with latest updates * chore(pyroscope): use rudderstack scoped pyroscope nodejs * chore(pyroscope): scope and version change * chore: run ingestion svc test after artefacts build (#4196) * chore: run ingestion svc test after artefacts build * fix: test * fix: test * fix: test * chore: test * chore: test * chore: use go version file * chore: use transformer image * chore: misc * chore: review comment * chore: misc * chore: pass secrets * chore: fix workflow * chore: add docker login * chore: pull image * chore: misc * chore: misc * chore: misc * chore: cleanup * chore: remmove env * chore: remove branch * chore: bump actions/setup-node from 4.0.4 to 4.4.0 (#4262) chore(deps): bump actions/setup-node from 4.0.4 to 4.4.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4.0.4 to 4.4.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@v4.0.4...v4.4.0) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 4.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump codecov/codecov-action from 5.4.0 to 5.4.2 (#4264) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.0 to 5.4.2. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](codecov/codecov-action@v5.4.0...v5.4.2) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-version: 5.4.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: convert necessary fields to string for pinterest (#4272) * feat: onboarding new destination loops (#3976) (#4235) * feat: identify and track for loops (#3976) * feat: identify and track for loops * feat: test for mailing lists * Update src/cdk/v2/destinations/loops/procWorkflow.yaml Co-authored-by: Yashasvi Bajpai <[email protected]> * fix: added response step; updated tests * fix: better way to get email and userId * feat: some changes * feat: use type --------- Co-authored-by: Yashasvi Bajpai <[email protected]> * fix: minor issues * chore: added test * feat: identify and track for loops (#3976) * feat: identify and track for loops * feat: test for mailing lists * Update src/cdk/v2/destinations/loops/procWorkflow.yaml Co-authored-by: Yashasvi Bajpai <[email protected]> * fix: added response step; updated tests * fix: better way to get email and userId * feat: some changes * feat: use type --------- Co-authored-by: Yashasvi Bajpai <[email protected]> * fix: minor issues * chore: added test * chore: update test to new structure * chore: minor change * chore: minor change --------- Co-authored-by: Dan <[email protected]> Co-authored-by: Yashasvi Bajpai <[email protected]> * feat: onboarding snapchat v3 (#4052) * feat: snapchat v3 * chore: added mappings for v3 * chore: small fix * chore: updated files * feat: onboarding snapchat capi v3 * feat: refactoring and some changes * chore: minor changes * chore: added tests and minor refactoring * fix: minor change * chore: minor changes --------- Co-authored-by: Manish Kumar <[email protected]> Co-authored-by: Manish Kumar <[email protected]> * fix(dynamicConfigParser): fix cloning issue in getdynamicconfig method (#4278) fix(dynamic config): fix cloning issue in getdynamicconfig method Resolves INT-3571 - Fix bug where original event was being modified instead of cloned event - Add comprehensive tests to verify the fix works correctly - Implement table-driven tests for better maintainability * feat(mixpanel): add support for partial batch failure handling (#4260) * feat(mixpanel): add support for partial batch failure handling * chore: misc * fix: handler * fix: handler * fix: review comments * fix: review comments * chore: review comments * chore: review comments * chore: review comments * chore: review comments * chore: review comments * chore: remove unused code * chore: table test case * chore: table test case * fix: test * chore: improve test * chore: upgrade salesforce api version from v50.0 to v63.0 (#4116) Co-authored-by: Manish Kumar <[email protected]> Co-authored-by: Manish Kumar <[email protected]> * chore: return error when gzip compression fails (#4283) chore: return error when gzip compression fails for mp * chore: revert "chore: upgrade salesforce api version from v50.0 to v63.0" (#4285) Revert "chore: upgrade salesforce api version from v50.0 to v63.0 (#4116)" This reverts commit c600f53. * chore: improving code coverage of snapchat conversion (#4284) * chore: improving code coverage of snapchat conversion * chore: minor change * fix: timestamp duration in v2 api * chore(release): 1.98.0 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Dilip Kola <[email protected]> Co-authored-by: Yashasvi Bajpai <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Vinay Teki <[email protected]> Co-authored-by: Mahesh Kutty <[email protected]> Co-authored-by: Manish Kumar <[email protected]> Co-authored-by: Dan <[email protected]> Co-authored-by: Aanshi Lahoti <[email protected]> Co-authored-by: Manish Kumar <[email protected]> Co-authored-by: GitHub Actions <[email protected]>







What are the changes introduced in this PR?
Added version 3 for snapchat
ref: https://developers.snap.com/api/marketing-api/Conversions-API/UsingTheAPI
What is the related Linear task?
Resolves INT-2703
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.