Repository navigation
Conversation
Summary by CodeRabbit
WalkthroughRemoves channel-based fallback and legacy source mappings from TikTok Ads getEventSource. The function now only inspects properties.eventSource and properties.event_source, defaulting to "web" if invalid/missing. Tests updated to reflect the new defaulting behavior and removal of channel-based outcomes. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant getEventSource
Note over getEventSource: Resolution order updated
Caller->>getEventSource: { properties }
alt properties.eventSource is valid
getEventSource-->>Caller: eventSource
else alt properties.event_source is valid
getEventSource-->>Caller: event_source
else
Note over getEventSource: No channel fallback or legacy mapping
getEventSource-->>Caller: "web"
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggestions: Double-check all call sites for removed channel arg; consider adding explicit validation for supportedSources and unit tests for edge-case payloads. Possibly related PRs
Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
src/v0/destinations/tiktok_ads/util.js (2)
72-76: Update docs/comments to reflect removal of channel-based logic.
- JSDoc still mentions "channel" and the inline comment says "with mapping," which are no longer true and can mislead future readers.
Apply this diff to align the docs and comment with current behavior:
-/** - * Get event source from message properties or channel. We have considered the following doc - * https://business-api.tiktok.com/portal/docs?id=1771100779668482 - * @param {*} message - * @returns (string): The resolved, valid event source — one of 'web', 'app', 'offline', or 'crm'. Defaults to 'web' if none are valid. - */ +/** + * Resolve TikTok event source from message properties. + * Reference: https://business-api.tiktok.com/portal/docs?id=1771100779668482 + * @param {*} message + * @returns {string} One of 'web', 'app', 'offline', or 'crm'. Defaults to 'web' if none are valid. + */ @@ - // Helper function to resolve source with mapping + // Helper to validate a provided source valueAlso applies to: 83-83
78-95: Harden source resolution: type-guard, trim, and case-normalize.Current logic only accepts exact, lowercased matches. Normalizing and guarding against non-string inputs makes the helper more robust without reintroducing legacy aliasing.
Apply this diff:
-const getEventSource = ({ properties }) => { - const supportedSources = ['web', 'app', 'offline', 'crm']; +const getEventSource = ({ properties }) => { + const supportedSources = new Set(['web', 'app', 'offline', 'crm']); @@ - const resolveSource = (source) => { - if (!source) return null; - - // First check if it's a direct supported source - if (supportedSources.includes(source)) { - return source; - } - - return null; - }; + const resolveSource = (source) => { + if (typeof source !== 'string') return null; + const normalized = source.trim().toLowerCase(); + return supportedSources.has(normalized) ? normalized : null; + };src/v0/destinations/tiktok_ads/util.test.js (3)
208-211: Rename test to match new behavior (channel ignored).The title says "returns channel..." but expectation is 'web'. Please rename for clarity.
- it('returns channel if eventSource is missing and channel is valid', () => { + it('returns "web" if eventSource is missing (channel ignored)', () => {
212-215: Rename test to match new behavior (channel ignored on invalid eventSource).Title contradicts the assertion.
- it('returns channel if eventSource is invalid and channel is valid', () => { + it('returns "web" if eventSource is invalid (channel ignored)', () => {
240-243: Rename test to reflect removal of 'mobile' → 'app' alias and precedence of event_source.The description says "return app," but we now expect 'web' via event_source since 'mobile' is invalid.
- it('if mobile is present, it should return app', () => { + it('returns event_source when eventSource is an invalid alias (e.g., mobile) and event_source is valid', () => {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (4)
CHANGELOG.mdis excluded by!**/*.mdpackage-lock.jsonis excluded by!**/package-lock.json,!**/*.jsonpackage.jsonis excluded by!**/*.jsontest/integrations/destinations/tiktok_ads/router/data.tsis excluded by!**/test/**
📒 Files selected for processing (2)
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.jssrc/v0/destinations/tiktok_ads/util.js
🧠 Learnings (2)
📓 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.
📚 Learning: 2025-07-15T06:27:07.528Z
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.
Applied to files:
src/v0/destinations/tiktok_ads/util.test.jssrc/v0/destinations/tiktok_ads/util.js
🧬 Code graph analysis (1)
src/v0/destinations/tiktok_ads/util.test.js (1)
src/v0/destinations/tiktok_ads/util.js (2)
getEventSource(78-96)message(11-11)
⏰ 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). (1)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
src/v0/destinations/tiktok_ads/util.js (1)
95-95: Verify channel fallback removal and update documentationThe recent change removes any use of
message.channelingetEventSource, defaulting to'web'whenever neitherproperties.eventSourcenorproperties.event_sourceis valid. This impacts how events without an explicit source are classified and grouped. Please review the following:
src/v0/destinations/tiktok_ads/util.js:95now returns
resolveSource(eventSource) || resolveSource(eventSourceV2) || 'web',
completely ignoringmessage.channel(previously used for fallback).- All tests in
src/v0/destinations/tiktok_ads/util.test.jshave been updated to expect'web'even whenchannelis set (e.g., channel'crm'or'offline'now result in'web').- In
src/v0/destinations/tiktok_ads/transformV2.js, events are grouped by theevent_sourcefield (fromgetEventSource) before batching. Any events relying solely onmessage.channel(e.g., offline events) will now be misclassified under the'web'group.- There are no other call sites of
getEventSourceor alternate fallbacks for channel in this destination.Action items:
- Confirm that classifying channel-only events as
'web'is acceptable for your downstream workflows.- If you need to preserve channel-based sources (e.g.,
'offline'), reintroduce aresolveSource(message.channel)fallback or mandate settingproperties.event_source.- Update the JSDoc in
util.js(lines 73–76) to remove the outdated “or channel” reference and accurately reflect the current behavior.
|
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 #4585 +/- ##
===========================================
- Coverage 91.81% 91.81% -0.01%
===========================================
Files 642 642
Lines 33930 33926 -4
Branches 8041 8030 -11
===========================================
- Hits 31152 31148 -4
- Misses 2526 2548 +22
+ Partials 252 230 -22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|



👑 An automated PR