Skip to content

feat: add missing params and refactor - #4527

Merged
ItsSudip merged 4 commits into
fix/tiktok_ads_v2from
feat/addMissingParamsAndRefactor2
Jul 29, 2025
Merged

ItsSudip merged 4 commits into
fix/tiktok_ads_v2from
feat/addMissingParamsAndRefactor2

Conversation

@ItsSudip

@ItsSudip ItsSudip commented Jul 24, 2025 •

Copy link
Copy Markdown
Member

TikTok Ads Destination Enhancement PR Description

What are the changes introduced in this PR?

This PR enhances the TikTok Ads destination transformer with missing parameters, improved content processing, and comprehensive code refactoring. The changes include:

  1. Added Missing Parameters: Enhanced mapping configuration with device IDs (idfa, idfv, gaid), search functionality (search_string), attribution tracking (att_status), and lead management fields (lead_id, lead_event_source)

  2. Improved Content Processing: Added automatic generation of contents_ids and num_items from content arrays with proper filtering to prevent empty arrays

  3. Platform-Specific Device ID Handling: Implemented OS-based logic to remove inappropriate device IDs (removes gaid for Apple devices, idfa/idfv for Android devices)

  4. Enhanced Event Source Detection: Added support for both eventSource and event_source (V2) properties. Also added mapping for the rudderstack-defined channel to eventSource.

  5. Code Refactoring: Improved function naming (getEventChunks → separateTestEvents) and variable naming for better readability and maintainability

  6. Enhanced User Field Hashing: Extended hashing functionality to include device advertising IDs (idfa, gaid)

What is the related Linear task?

https://linear.app/rudderstack/issue/INT-3933/investigate-hardcoded-event-source-in-tiktok-ads-v2-integration

Please explain the objectives of your changes below

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

No breaking changes introduced. The enhancements maintain backward compatibility while adding new capabilities:

  • Content Processing Enhancement: Previously, content arrays were processed without generating contents_ids and num_items. Now these fields are automatically generated from content arrays, improving data completeness for TikTok's tracking requirements.

  • Device ID Compliance: Added platform-specific device ID filtering to ensure only appropriate device identifiers are sent to TikTok (Apple devices don't send gaid, Android devices don't send idfa/idfv).

  • Enhanced Event Source Support: Extended support for both legacy and new event source properties to accommodate different client implementations. Also considered a mapping to convert rudderstack supported channel to a specific eventSources.

Any new dependencies introduced with this change?

No new dependencies were introduced. All changes utilize existing utility functions and libraries.

Any new generic utility introduced or modified. Please explain the changes.

No new utilities were introduced. The changes leverage existing utilities:

  • isAppleFamily() for OS detection
  • get() for safe property access
  • hashToSha256() for device ID hashing
  • removeUndefinedAndNullValues() for payload cleanup

Any technical or performance related pointers to consider with this change?

  • Performance Improvement: Optimized content processing with early returns and filtered arrays to prevent unnecessary operations
  • Memory Efficiency: Prevents creation of empty arrays and reduces redundant object operations
  • Data Integrity: Enhanced validation and filtering ensure only valid data is sent to TikTok
  • Platform Compliance: Proper device ID handling ensures compliance with platform-specific requirements

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.
  • Code follows the established patterns and conventions
  • Function names accurately reflect their purpose
  • No unnecessary complexity introduced
  • Platform-specific logic is correctly implemented
  • Test coverage is adequate for new functionality
  • Mapping configuration is complete and accurate

@coderabbitai review

@ItsSudip
ItsSudip requested review from a team and sivashanmukh as code owners July 24, 2025 04:44
@ItsSudip
ItsSudip requested review from a team, maheshkutty and vinayteki95 July 24, 2025 04:44
@coderabbitai

coderabbitai Bot commented Jul 24, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Summary by CodeRabbit

  • New Features

    • Enhanced TikTok Ads event payloads to include product content IDs and item counts when available.
    • Improved user identifier handling by removing platform-inapplicable IDs based on detected operating system.
    • Introduced dynamic event source detection, allowing event source to be set per event rather than using a static value.
  • Bug Fixes

    • Ensured correct handling and separation of test events from normal events during batching.
  • Tests

    • Added comprehensive test cases for content aggregation, user identifier filtering, and event source selection.
    • Expanded utility function tests for hashing and event source detection.
  • Refactor

    • Updated batching logic to group and process events by their event source for improved accuracy and maintainability.

Walkthrough

This update enhances the TikTok Ads destination transformation logic by enriching event payloads, introducing platform-specific user identifier filtering, and implementing dynamic event source handling. The batching logic is refactored to separate test events and group events by their source. Utility functions are extended, and comprehensive tests are added for the new behaviors.

Changes

File(s) Change Summary
src/v0/destinations/tiktok_ads/transformV2.js Refactored batching logic, enriched payloads with content IDs/count, OS-based user ID filtering, dynamic event source, and updated function signatures.
src/v0/destinations/tiktok_ads/transformV2.test.js Added test cases for content enrichment, OS-based user ID handling, and event source logic; removed unused import.
src/v0/destinations/tiktok_ads/util.js Extended hashUserField for idfa/gaid, added getEventSource utility, updated exports.
src/v0/destinations/tiktok_ads/util.test.js Added tests for idfa/gaid hashing, array handling, and comprehensive getEventSource scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant SourceEvent
    participant transformV2
    participant util
    participant BatchBuilder
    participant TikTokAPI

    SourceEvent->>transformV2: Incoming event(s)
    transformV2->>util: getContents, hashUserField, getEventSource
    util-->>transformV2: Enriched payload, filtered user IDs, event source
    transformV2->>transformV2: Separate test events, group by event source
    transformV2->>BatchBuilder: Batch normal events per source
    BatchBuilder->>TikTokAPI: Send batched events
    transformV2->>TikTokAPI: Send test events separately
    TikTokAPI-->>transformV2: Responses
    transformV2-->>SourceEvent: Aggregated and sorted responses
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

The changes involve significant refactoring, new utility logic, and comprehensive test additions. Reviewers should pay close attention to the batching logic, platform-specific user filtering, and event source handling to ensure correctness and backward compatibility.

Possibly related PRs

  • fix: rt event ordering for hs #4397: Modifies processRouterDest in transformV2.js to sort combined batch and test event responses by job ID, directly overlapping with this PR's batching logic.

Suggested reviewers

  • sivashanmukh
  • maheshkutty
  • koladilip
  • yashasvibajpai

Suggestions for improvement:

  • Consider isolating platform-specific user filtering into a dedicated utility for easier testing and maintenance.
  • Ensure that error handling for unsupported or malformed event sources is explicit and well-documented.
  • If event source logic expands, a mapping configuration may improve scalability and reduce hardcoding.
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/addMissingParamsAndRefactor2

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ItsSudip
ItsSudip changed the base branch from develop to fix/tiktok_ads_v2 July 24, 2025 04:45

@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

🔭 Outside diff range comments (1)
src/v0/destinations/tiktok_ads/transformV2.js (1)

715-756: Potential issue with eventSource variable scope

The eventSource variable is declared outside the loop but reassigned inside it (line 724). Since this is used later when creating the batch event, consider declaring it inside the appropriate scope or extracting it differently:

 const batchEvents = (processedEvents) => {
   const events = [];
   let data = [];
   let metadata = [];
-  let eventSource = 'web';
   const { destination } = processedEvents[0];
   const { pixelCode } = destination.Config;
+  // Extract event source from first event as all events in this batch should have the same source
+  const eventSource = processedEvents[0]?.message[0]?.body.JSON.event_source || 'web';
   processedEvents.forEach((event) => {
     const eventData = event.message[0]?.body.JSON.data;
-    eventSource = event.message[0]?.body.JSON.event_source;

This ensures consistency since all events in a batch should have the same event source after grouping.

🧹 Nitpick comments (4)
src/v0/destinations/tiktok_ads/util.test.js (1)

175-185: Consider adding test for idfa lowercase behavior

The test verifies that idfa and gaid are hashed, but doesn't validate that idfa is lowercased after hashing (as mentioned in the implementation). Consider adding an assertion to verify this specific behavior:

 it('should hash idfa and gaid fields if present', () => {
   const user = {
     idfa: 'AEBE52E7-03EE-455A-B3C4-E57283966239',
     gaid: '38400000-8cf0-11bd-b23e-10b96e40000d',
   };
   const hashedUser = hashUserField(user);
   expect(hashedUser.idfa).toBeDefined();
   expect(hashedUser.idfa).not.toBe(user.idfa);
+  expect(hashedUser.idfa).toBe(hashedUser.idfa.toLowerCase());
   expect(hashedUser.gaid).toBeDefined();
   expect(hashedUser.gaid).not.toBe(user.gaid);
 });
src/v0/destinations/tiktok_ads/transformV2.test.js (2)

168-188: Consider adding initial gaid value to strengthen the test

While the test correctly verifies that gaid is undefined for Apple OS, it would be more robust to initially set a gaid value in the message to ensure it's actively removed:

 it('should remove gaid for Apple family OS', async () => {
   const message = {
     event: 'purchase',
     properties: {
       products: [{ product_id: '123', name: 'Product1', price: 10, quantity: 2 }],
     },
+    user: {
+      gaid: 'test-gaid-value',
+      idfa: 'test-idfa-value'
+    },
     context: { os: { name: 'ios' }, device: { advertisingId: 'some-idfa' } },
     timestamp: '2023-10-01T00:00:00Z',
   };

190-211: Consider adding initial device ID values

Similar to the Apple OS test, consider adding initial idfa and idfv values to verify they are actively removed:

 it('should remove idfa and idfv for Android OS', async () => {
   const message = {
     event: 'purchase',
     properties: {
       products: [{ product_id: '123', name: 'Product1', price: 10, quantity: 2 }],
     },
+    user: {
+      idfa: 'test-idfa-value',
+      idfv: 'test-idfv-value',
+      gaid: 'test-gaid-value'
+    },
     context: { os: { name: 'android' }, device: { advertisingId: 'some-gaid' } },
     timestamp: '2023-10-01T00:00:00Z',
   };
src/v0/destinations/tiktok_ads/transformV2.js (1)

86-97: Platform-specific ID filtering implemented correctly

The logic appropriately removes device IDs based on the operating system. Consider extracting the OS name to a variable to avoid multiple lookups:

-  const os = get(message, 'context.os.name');
-
-  if (isDefinedAndNotNull(os) && payload.user) {
-    if (isAppleFamily(os)) {
+  const osName = get(message, 'context.os.name');
+
+  if (isDefinedAndNotNull(osName) && payload.user) {
+    if (isAppleFamily(osName)) {
       delete payload.user.gaid;
-    } else if (os.toLowerCase() === 'android') {
+    } else if (osName?.toLowerCase() === 'android') {
       delete payload.user.idfa;
       delete payload.user.idfv;
     }
   }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73262d8 and 25bac55.

⛔ Files ignored due to path filters (3)
  • src/v0/destinations/tiktok_ads/data/TikTokTrackV2.json is excluded by !**/*.json
  • test/integrations/destinations/tiktok_ads/processor/data.ts is excluded by !**/test/**
  • test/integrations/destinations/tiktok_ads/router/data.ts is excluded by !**/test/**
📒 Files selected for processing (4)
  • src/v0/destinations/tiktok_ads/transformV2.js (13 hunks)
  • src/v0/destinations/tiktok_ads/transformV2.test.js (1 hunks)
  • src/v0/destinations/tiktok_ads/util.js (2 hunks)
  • src/v0/destinations/tiktok_ads/util.test.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/tiktok_ads/util.test.js
  • src/v0/destinations/tiktok_ads/transformV2.test.js
  • src/v0/destinations/tiktok_ads/util.js
  • src/v0/destinations/tiktok_ads/transformV2.js
🧠 Learnings (5)
📓 Common learnings
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4380
File: src/v0/destinations/google_adwords_remarketing_lists/config.js:3-5
Timestamp: 2025-06-04T07:24:58.591Z
Learning: User maheshkutty prefers to handle Google Ads API version upgrades for different destinations in separate pull requests rather than bundling multiple destinations together in a single PR.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The `combineBatchRequestsWithSameJobIds` function in `src/v0/util/index.js` is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.
src/v0/destinations/tiktok_ads/util.test.js (3)

Learnt from: ItsSudip
PR: #4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.

Learnt from: anantjain45823
PR: #2842
File: src/v1/sources/shopify/identifierEventsLayer.test.js:5-40
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The processIdentifierEvent function in identifierEventsLayer.test.js is designed to succeed for any input, hence no negative test cases are required.

src/v0/destinations/tiktok_ads/transformV2.test.js (4)

Learnt from: ItsSudip
PR: #4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.

Learnt from: anantjain45823
PR: #2842
File: src/v1/sources/shopify/identifierEventsLayer.test.js:5-40
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The processIdentifierEvent function in identifierEventsLayer.test.js is designed to succeed for any input, hence no negative test cases are required.

Learnt from: krishna2020
PR: #4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function in Shopify source transformation throws an error if request is not defined, making additional null checks in getEventFromV2Request function unnecessary.

src/v0/destinations/tiktok_ads/util.js (2)

Learnt from: ItsSudip
PR: #4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.

src/v0/destinations/tiktok_ads/transformV2.js (6)

Learnt from: ItsSudip
PR: #4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.

Learnt from: maheshkutty
PR: #4380
File: src/v0/destinations/google_adwords_remarketing_lists/config.js:3-5
Timestamp: 2025-06-04T07:24:58.591Z
Learning: User maheshkutty prefers to handle Google Ads API version upgrades for different destinations in separate pull requests rather than bundling multiple destinations together in a single PR.

Learnt from: krishna2020
PR: #4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function in Shopify source transformation throws an error if request is not defined, making additional null checks in getEventFromV2Request function unnecessary.

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.

Learnt from: anantjain45823
PR: #2842
File: src/v1/sources/shopify/identifierEventsLayer.test.js:5-40
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The processIdentifierEvent function in identifierEventsLayer.test.js is designed to succeed for any input, hence no negative test cases are required.

⏰ 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 (13)
src/v0/destinations/tiktok_ads/util.test.js (2)

1-1: Import statement correctly updated

The addition of getEventSource to the imports is necessary for the new test suite.


199-240: Comprehensive test coverage for getEventSource

The test suite thoroughly covers all scenarios including fallback logic, default values, and support for both camelCase and snake_case properties. Well done!

src/v0/destinations/tiktok_ads/util.js (4)

40-40: Destructuring correctly extended

The addition of idfa and gaid to the destructured variables is appropriate for the subsequent hashing logic.


61-68: Hashing implementation for device IDs looks good

The implementation correctly hashes idfa with lowercase conversion and gaid without modification, which aligns with platform-specific requirements.


72-98: Well-implemented event source resolution

The getEventSource function correctly implements the fallback logic with proper validation against supported sources. The precedence (camelCase > snake_case > channel > default) is appropriate, and the function handles edge cases safely.


99-99: Module exports correctly updated

The addition of getEventSource to exports is necessary for its usage in the transformation logic.

src/v0/destinations/tiktok_ads/transformV2.test.js (2)

144-166: Good test coverage for content aggregation

The test correctly verifies that contents_ids and num_items are properly extracted from the products array.


213-231: Good test for snake_case event source support

The test correctly verifies that event_source in snake_case format is properly recognized and used in the response.

src/v0/destinations/tiktok_ads/transformV2.js (5)

4-28: Import statements properly extended

The additional imports correctly support the new functionality for batching, OS detection, and event source handling.


65-76: Well-implemented content aggregation logic

The code correctly extracts content_id values, filters out falsy values, and only adds contents_ids when valid IDs exist. The num_items count is appropriately added.


167-167: Dynamic event source correctly implemented

The replacement of the hardcoded 'web' value with getEventSource(message) enables proper event source resolution from message properties.


423-435: Function rename improves clarity

The rename from getEventChunks to separateTestEvents better describes the function's purpose, and the updated parameter names are more descriptive.


788-803: Event source grouping well implemented

The implementation correctly groups events by event_source before batching, ensuring all events in a batch have the same source. This aligns with the planned enhancement mentioned in the previous PR feedback.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Jul 24, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.77778% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.45%. Comparing base (fbe12e7) to head (a12c942).
⚠️ Report is 1 commits behind head on fix/tiktok_ads_v2.

Files with missing lines Patch % Lines
src/v0/destinations/tiktok_ads/transformV2.js 96.55% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           fix/tiktok_ads_v2    #4527   +/-   ##
==================================================
  Coverage              91.44%   91.45%           
==================================================
  Files                    639      639           
  Lines                  33788    33809   +21     
  Branches                7988     7995    +7     
==================================================
+ Hits                   30899    30920   +21     
  Misses                  2627     2627           
  Partials                 262      262           

☔ 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.

Comment thread src/v0/destinations/tiktok_ads/util.js Resolved
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

Copy link
Copy Markdown

@ItsSudip
ItsSudip merged this pull request into fix/tiktok_ads_v2 Jul 29, 2025
@ItsSudip
ItsSudip deleted the feat/addMissingParamsAndRefactor2 branch July 29, 2025 05:05
koladilip pushed a commit that referenced this pull request Aug 16, 2025
* feat: add missing parameters and refactor code

* chore: fix as per cursor review

* chore: add test cases to increase coverage

* feat: add support of mapping to consider default eventSource

---------

Co-authored-by: Sudip Paul <[email protected]>
ItsSudip added a commit that referenced this pull request Aug 18, 2025
* fix: add mapping of event_source instead of static

* feat: enhance mapping with missing fields of app event_source and the batching logic with grouping  (#4501)

* feat: enable group by event_source before batching

* feat: add missing parameter for app event_source

* chore: refactor test cases

* chore: revert unwanted changes to test cases

---------

Co-authored-by: Sudip Paul <[email protected]>

* feat: add missing params and refactor (#4527)

* feat: add missing parameters and refactor code

* chore: fix as per cursor review

* chore: add test cases to increase coverage

* feat: add support of mapping to consider default eventSource

---------

Co-authored-by: Sudip Paul <[email protected]>

* chore: refactor code

* chore: address comments

* chore: address coderabbit comments

---------

Co-authored-by: Sudip Paul <[email protected]>
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