-
Notifications
You must be signed in to change notification settings - Fork 5
Send Rudder eventId/event_id/messageId as TikTok event_id #2568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Send Rudder eventId/event_id/messageId as TikTok event_id #2568
Conversation
📝 WalkthroughWalkthroughThis pull request adds page-level event tracking to the TikTok Ads integration. A new Changes
Sequence DiagramsequenceDiagram
participant App as Application
participant Browser as browser.js
participant Util as util.js
participant Constants as constants.js
participant SDK as window.ttq
App->>Browser: page(rudderElement)
Browser->>Util: getPageResponse(message)
Util->>Constants: pageMapping
Constants-->>Util: pageMapping config
Util->>Util: Extract event_id from<br/>properties.eventId,<br/>properties.event_id,<br/>or messageId
Util->>Util: Add partner_name<br/>Remove undefined values
Util-->>Browser: updatedProperties
Browser->>SDK: window.ttq.page(updatedProperties)
SDK-->>App: Event tracked
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes The changes follow consistent patterns established by existing track functionality, with Pre-merge checks✅ Passed checks (2 passed)
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 |
There was a problem hiding this comment.
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 (1)
packages/analytics-js-integrations/src/integrations/TiktokAds/constants.js (1)
74-79: Consider extracting the common event_id mapping to reduce duplication.The
event_idmapping inpageMapping(lines 74-78) is identical to the first entry intrackMapping(lines 19-23). While the separation of page and track mappings is reasonable for clarity, you could extract the common event_id mapping entry to reduce duplication.For example:
+const eventIdMapping = { + destKey: 'event_id', + sourceKeys: ['properties.eventId', 'properties.event_id', 'messageId'], +}; + const trackMapping = [ - { - destKey: 'event_id', - sourceKeys: ['properties.eventId', 'properties.event_id', 'messageId'], - }, + eventIdMapping, { destKey: 'test_event_code', sourceKeys: 'testEventCode', }, // ... rest of mappings ]; -const pageMapping = [ - { - destKey: 'event_id', - sourceKeys: ['properties.eventId', 'properties.event_id', 'messageId'], - }, -]; +const pageMapping = [eventIdMapping];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js(4 hunks)packages/analytics-js-integrations/src/integrations/TiktokAds/browser.js(2 hunks)packages/analytics-js-integrations/src/integrations/TiktokAds/constants.js(2 hunks)packages/analytics-js-integrations/src/integrations/TiktokAds/util.js(2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/002-javascript-typescript.mdc)
Code must work in browsers AND service workers (no Node.js APIs)
Files:
packages/analytics-js-integrations/src/integrations/TiktokAds/util.jspackages/analytics-js-integrations/src/integrations/TiktokAds/browser.jspackages/analytics-js-integrations/src/integrations/TiktokAds/constants.jspackages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
packages/*/src/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place all package source code under packages/[package-name]/src/
Files:
packages/analytics-js-integrations/src/integrations/TiktokAds/util.jspackages/analytics-js-integrations/src/integrations/TiktokAds/browser.jspackages/analytics-js-integrations/src/integrations/TiktokAds/constants.js
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Adhere to the repository’s ESLint configuration for JavaScript/TypeScript code
Files:
packages/analytics-js-integrations/src/integrations/TiktokAds/util.jspackages/analytics-js-integrations/src/integrations/TiktokAds/browser.jspackages/analytics-js-integrations/src/integrations/TiktokAds/constants.jspackages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
packages/analytics-js-integrations/src/integrations/*/browser.js
📄 CodeRabbit inference engine (CLAUDE.md)
packages/analytics-js-integrations/src/integrations/*/browser.js: Device mode integrations must be implemented at packages/analytics-js-integrations/src/integrations/[name]/browser.js
Each integration implementation must provide init(), isLoaded(), isReady(), and event handler methods
Files:
packages/analytics-js-integrations/src/integrations/TiktokAds/browser.js
packages/*/__tests__/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place unit tests under packages/[package-name]/tests/
Files:
packages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
packages/*/__tests__/**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use Jest for tests and MSW for HTTP mocking
Files:
packages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
🧠 Learnings (17)
📚 Learning: 2024-10-08T15:52:59.819Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1754
File: packages/analytics-js-common/src/utilities/page.ts:1-34
Timestamp: 2024-10-08T15:52:59.819Z
Learning: The compatibility issue with `globalThis` in `packages/analytics-js-common/src/utilities/page.ts` is handled elsewhere in the codebase as per user `saikumarrs`.
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/util.jspackages/analytics-js-integrations/src/integrations/TiktokAds/browser.jspackages/analytics-js-integrations/src/integrations/TiktokAds/constants.js
📚 Learning: 2024-10-09T06:41:05.073Z
Learnt from: MoumitaM
Repo: rudderlabs/rudder-sdk-js PR: 1876
File: packages/analytics-js/src/app/RudderAnalytics.ts:0-0
Timestamp: 2024-10-09T06:41:05.073Z
Learning: The `trackPageLifecycleEvents` method in `packages/analytics-js/src/app/RudderAnalytics.ts` does not require refactoring as the current implementation is preferred.
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/util.jspackages/analytics-js-integrations/src/integrations/TiktokAds/browser.jspackages/analytics-js-integrations/src/integrations/TiktokAds/constants.js
📚 Learning: 2025-08-27T06:40:15.058Z
Learnt from: CR
Repo: rudderlabs/rudder-sdk-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-27T06:40:15.058Z
Learning: Applies to packages/analytics-js-integrations/src/integrations/*/browser.js : Each integration implementation must provide init(), isLoaded(), isReady(), and event handler methods
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/browser.jspackages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
📚 Learning: 2025-08-27T06:40:15.058Z
Learnt from: CR
Repo: rudderlabs/rudder-sdk-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-27T06:40:15.058Z
Learning: Applies to packages/analytics-js-integrations/src/integrations/*/browser.js : Device mode integrations must be implemented at packages/analytics-js-integrations/src/integrations/[name]/browser.js
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/browser.jspackages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
📚 Learning: 2024-11-09T06:40:30.520Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1823
File: packages/analytics-js-common/src/types/LoadOptions.ts:0-0
Timestamp: 2024-11-09T06:40:30.520Z
Learning: In the `packages/analytics-js-common/src/types/LoadOptions.ts` file, the `dataplanes` property within the `SourceConfigResponse` type has been removed as it is no longer necessary.
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/browser.jspackages/analytics-js-integrations/src/integrations/TiktokAds/constants.js
📚 Learning: 2024-10-28T08:03:12.163Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1902
File: packages/analytics-js-plugins/src/utilities/eventsDelivery.ts:0-0
Timestamp: 2024-10-28T08:03:12.163Z
Learning: In `packages/analytics-js-plugins/src/utilities/eventsDelivery.ts`, the issue regarding inconsistent error handling approaches in `getDMTDeliveryPayload` is no longer valid.
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/browser.js
📚 Learning: 2025-08-27T06:40:15.058Z
Learnt from: CR
Repo: rudderlabs/rudder-sdk-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-27T06:40:15.058Z
Learning: Applies to packages/analytics-js/src/**/*.{js,ts,tsx} : Use preact/signals-core for reactive state in the core SDK (analytics-js)
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/browser.js
📚 Learning: 2024-08-26T09:34:28.341Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1823
File: examples/integrations/Ninetailed/sample-apps/app-using-v1.1-cdn/src/App.js:18-18
Timestamp: 2024-08-26T09:34:28.341Z
Learning: When reviewing the `examples/integrations/Ninetailed/sample-apps/app-using-v1.1-cdn/src/App.js` file, ignore the assignment pattern `let e = (window.rudderanalytics = window.rudderanalytics || []);` as it is a standard snippet.
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/browser.js
📚 Learning: 2024-07-27T07:02:57.329Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1708
File: packages/analytics-js/__tests__/nativeSdkLoader.js:31-33
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The loading snippet in `packages/analytics-js/__tests__/nativeSdkLoader.js` is a standard part of the SDK, and no changes are desired on it.
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/browser.jspackages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
📚 Learning: 2024-11-08T06:57:00.859Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1907
File: CODEOWNERS:3-12
Timestamp: 2024-11-08T06:57:00.859Z
Learning: The paths `/packages/analytics-js-integrations/scripts/`, `/packages/analytics-js-common/src/types/Integration.ts`, `/packages/analytics-v1.1/src/utils/IntegrationsData.js`, `/packages/sanity-suite/public/v1.1/integrations/`, and `/packages/sanity-suite/public/v3/integrations/` do not need ownership assignment changes in the `CODEOWNERS` file.
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/constants.js
📚 Learning: 2025-08-27T06:40:15.058Z
Learnt from: CR
Repo: rudderlabs/rudder-sdk-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-27T06:40:15.058Z
Learning: Applies to packages/!(analytics-js-common)/**/src/**/*.{ts,tsx} : Prefer shared TypeScript types from analytics-js-common across packages
Applied to files:
packages/analytics-js-integrations/src/integrations/TiktokAds/constants.jspackages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
📚 Learning: 2024-11-08T12:31:40.009Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1823
File: packages/analytics-js-integrations/src/integrations/Sprig/browser.js:10-22
Timestamp: 2024-11-08T12:31:40.009Z
Learning: Tests for the constructor in `packages/analytics-js-integrations/src/integrations/Sprig/browser.js` are not required.
Applied to files:
packages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
📚 Learning: 2024-10-08T15:52:59.819Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1708
File: packages/analytics-js-plugins/__tests__/deviceModeTransformation/index.test.ts:10-11
Timestamp: 2024-10-08T15:52:59.819Z
Learning: The misuse of `IHttpClient` in type assertions within the file `packages/analytics-js-plugins/__tests__/deviceModeTransformation/index.test.ts` has been corrected by the user.
Applied to files:
packages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
📚 Learning: 2024-11-08T13:17:51.356Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1823
File: packages/analytics-js-common/src/utilities/retryQueue/utilities.ts:0-0
Timestamp: 2024-11-08T13:17:51.356Z
Learning: The issue regarding missing test coverage for the `findOtherQueues` function in `packages/analytics-js-common/src/utilities/retryQueue/utilities.ts` is no longer applicable.
Applied to files:
packages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
📚 Learning: 2024-11-08T12:33:43.273Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1823
File: packages/analytics-js-integrations/src/integrations/Sprig/browser.js:36-38
Timestamp: 2024-11-08T12:33:43.273Z
Learning: Tests for the `isReady` function in `packages/analytics-js-integrations/src/integrations/Sprig/browser.js` are not required.
Applied to files:
packages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
📚 Learning: 2024-10-07T05:43:26.038Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1823
File: packages/analytics-js-integrations/__tests__/integrations/Amplitude/browser.test.js:193-194
Timestamp: 2024-10-07T05:43:26.038Z
Learning: In the Amplitude integration tests (`browser.test.js`), the tests no longer rely on `appVersion`, so including `appVersion` in the mocked navigator object is unnecessary.
Applied to files:
packages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
📚 Learning: 2024-10-08T06:50:02.860Z
Learnt from: saikumarrs
Repo: rudderlabs/rudder-sdk-js PR: 1823
File: packages/analytics-js/__tests__/components/utilities/consent.test.ts:1-1
Timestamp: 2024-10-08T06:50:02.860Z
Learning: In `packages/analytics-js/__tests__/components/utilities/consent.test.ts`, the relative import path `../../../src/state` correctly refers to the `index.ts` file in the `/state` directory.
Applied to files:
packages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js
🧬 Code graph analysis (2)
packages/analytics-js-integrations/src/integrations/TiktokAds/util.js (2)
packages/analytics-js-integrations/src/utils/utils.js (1)
constructPayload(563-577)packages/analytics-js-integrations/src/integrations/TiktokAds/constants.js (2)
pageMapping(74-79)PARTNER_NAME(17-17)
packages/analytics-js-integrations/src/integrations/TiktokAds/browser.js (1)
packages/analytics-js-integrations/src/integrations/TiktokAds/util.js (2)
getPageResponse(68-74)message(7-7)
🔇 Additional comments (5)
packages/analytics-js-integrations/src/integrations/TiktokAds/util.js (2)
1-1: LGTM!The import of
pageMappingis correct and necessary for the newgetPageResponsefunction.
68-76: LGTM!The
getPageResponsefunction follows the same pattern asgetTrackResponse, ensuring consistency across the codebase. The implementation correctly constructs page properties usingpageMapping, adds the partner name, and filters out undefined/null values.packages/analytics-js-integrations/src/integrations/TiktokAds/browser.js (2)
11-11: LGTM!The import of
getPageResponseis correct and necessary for the updatedpagemethod.
102-106: LGTM!The
pagemethod now correctly constructs properties usinggetPageResponseand passes them towindow.ttq.page, enabling TikTokevent_idon Pageview events. This addresses the PR objective of enabling inspection and correlation with RudderStackpagecalls.packages/analytics-js-integrations/__tests__/integrations/TikTokAds/browser.test.js (1)
32-96: LGTM! Excellent test coverage.The new page tests comprehensively verify
event_idextraction from all three sources (properties.event_id,properties.eventId, andmessageId) with correct precedence rules. Each test confirms thatpartner_nameis included and thatwindow.ttq.pageis called with the properly constructed payload.
|
@maheshkutty @chandumlg SonarQube step failed due to As this is something I cannot fix, can you please have a look at the GitHub workflow? |
Hello @mgryszko As GitHub secrets are not accessible on forks, the workflow failure is expected. We can ignore the failures for now. |
|
@saikumarrs is there a chance to merge it and release it after your Black Friday code freeze (Dec 2nd)? |
PR Description
TikTok
Pageviewevents are missingevent_id, which makes them harder to inspect and correlate to RudderStackpagecalls.If the PR is approved, please update the documentation for TikTok Ads Device Mode Integration, Page section.
Linear task (optional)
Cross Browser Tests
Please confirm you have tested for the following browsers:
Sanity Suite
Security
Summary by CodeRabbit
Release Notes
New Features
Tests