Skip to content

chore(release): pull main into develop post release v1.107.2 - #4585

Merged
ItsSudip merged 3 commits into
developfrom
main
Aug 22, 2025
Merged

ItsSudip merged 3 commits into
developfrom
main

Conversation

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

👑 An automated PR

@coderabbitai

coderabbitai Bot commented Aug 21, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor

    • Simplified TikTok Ads event source resolution: removed channel-based fallbacks and legacy aliases. Only explicit eventSource/event_source values are honored; when missing or invalid, events now default to “web.”
  • Tests

    • Updated tests to reflect the new behavior, including defaulting to “web,” preserving precedence when both eventSource and event_source are present, and removing expectations tied to channel-based or legacy mappings.

Walkthrough

Removes 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

Cohort / File(s) Summary
TikTok Ads util refactor
src/v0/destinations/tiktok_ads/util.js
Simplified getEventSource: removed channel parameter, deleted legacy sourceMapping, no aliasing; resolve from eventSource or event_source only; default to "web".
TikTok Ads util tests update
src/v0/destinations/tiktok_ads/util.test.js
Updated tests to expect "web" when eventSource absent/invalid regardless of channel; removed expectations tied to channel or legacy aliases; kept precedence and snake_case checks.

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
Loading

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

  • sivashanmukh
  • vinayteki95
  • koladilip

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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch main

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@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 (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 value

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

📥 Commits

Reviewing files that changed from the base of the PR and between ef4f64f and 67c3fda.

⛔ Files ignored due to path filters (4)
  • CHANGELOG.md is excluded by !**/*.md
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
  • test/integrations/destinations/tiktok_ads/router/data.ts is 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.js
  • src/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.js
  • src/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 documentation

The recent change removes any use of message.channel in getEventSource, defaulting to 'web' whenever neither properties.eventSource nor properties.event_source is valid. This impacts how events without an explicit source are classified and grouped. Please review the following:

  • src/v0/destinations/tiktok_ads/util.js:95 now returns
    resolveSource(eventSource) || resolveSource(eventSourceV2) || 'web',
    completely ignoring message.channel (previously used for fallback).
  • All tests in src/v0/destinations/tiktok_ads/util.test.js have been updated to expect 'web' even when channel is set (e.g., channel 'crm' or 'offline' now result in 'web').
  • In src/v0/destinations/tiktok_ads/transformV2.js, events are grouped by the event_source field (from getEventSource) before batching. Any events relying solely on message.channel (e.g., offline events) will now be misclassified under the 'web' group.
  • There are no other call sites of getEventSource or 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 a resolveSource(message.channel) fallback or mandate setting properties.event_source.
  • Update the JSDoc in util.js (lines 73–76) to remove the outdated “or channel” reference and accurately reflect the current behavior.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor Author

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Aug 21, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.81%. Comparing base (99c3e78) to head (67c3fda).
⚠️ Report is 9 commits behind head on develop.

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

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

4 participants