Repository navigation
feat(topsort): prefix event ids with the source platform - #5771
bernirosas wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
🟡 Changes recommended
The OS substring check misclassifies KaiOS mobile events as iOS, incorrectly prefixing message IDs and reporting the wrong source platform to Topsort.
1 open issue
What changed in this PR
This PR adds source-platform prefixes to Topsort event IDs, helping marketplaces identify where events originated when debugging delivery issues.
Changes:
- Derives
web-,ios-, orandroid-prefixes from SDK-populated fields, leaving IDs unchanged when no platform is recognized. - Applies prefixes to clicks, impressions, purchases, and per-product IDs.
- Adds tests for platform detection, fallback behavior, and product fan-out.
| File | Description |
|---|---|
src/v0/destinations/topsort/utils.ts |
Derives platform prefixes and applies them across Topsort event types. |
src/v0/destinations/topsort/routerTransform.test.ts |
Adds coverage for prefixed IDs, fallbacks, fan-out, and purchases. |
Review effort: Balanced
91121ea to
66ce6f1
Compare
Prefix the Topsort event id with web, ios or android, read from channel and context.os.name, so marketplaces can trace failing events back to their source. OS names are matched exactly with the shared isAppleFamily/isAndroidFamily helpers. Events whose platform can't be told keep the plain messageId. Co-Authored-By: Claude Opus 5.5 <[email protected]>
66ce6f1 to
4db6d27
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5771 +/- ##
========================================
Coverage 92.44% 92.44%
========================================
Files 741 741
Lines 41119 41131 +12
Branches 9675 9680 +5
========================================
+ Hits 38013 38025 +12
Misses 2845 2845
Partials 261 261 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
## What are the changes introduced in this PR? PRs opened from forks fail six CI checks before any of the contributor's code is tested (e.g. #5771). The workflows assume the PR branch lives in this repo and that secrets are available. Neither is true for a fork PR. | Check | Cause | Fix | |---|---|---| | Check for formatting & lint errors, Verify generated secret paths (`verify.yml`) | `actions/checkout` used `ref: github.head_ref` against this repo; the fork's branch doesn't exist here, so `git fetch` exits 1 | Check out `pull_request.head.sha` from `pull_request.head.repo.full_name` | | Code Coverage (`dt-test-and-report-code-coverage.yml`) | SonarCloud runs with an empty `SONAR_TOKEN` → "Not authorized" | Skip Sonar on fork PRs; it still runs on `push` and same-repo PRs | | Build (User) Transformer Docker Image – PR (`build-pr-artifacts.yml`) | `Configure AWS Credentials` fails, as fork PRs get no OIDC token or registry secrets | Skip the tag, build and ingestion-test jobs on fork PRs | For same-repo PRs, nothing changes. `verify.yml` still lints the PR head commit; it now refers to it by SHA instead of by branch name. Security: the trigger stays `pull_request` (read-only token, no secrets), not `pull_request_target`, and `persist-credentials: false` is kept. Not covered here: the org-level `zizmor` scan check also fails on fork PRs, at its "Mint scanner token" step. It's defined outside this repo, so it needs a separate fix there. ## How was this change tested? - `actionlint` (v1.7.7) on the three workflows: no findings on changed lines (one existing `set-output` deprecation at `dt-test-and-report-code-coverage.yml:32`, untouched) - This PR's own CI exercises the same-repo path; a fork PR (like #5771) rebased onto this exercises the fork path ## Checklist - [x] CI workflow change only; no runtime code changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
> **Contributed by @bernirosas in #5771** (fork PR). This PR carries their commit `4db6d27`, cherry-picked onto `develop` with authorship unchanged, so the full CI (Docker build + ingestion-service test, SonarCloud) can run; those checks can't run from a fork. **Merge with a merge commit (not squash)** to keep the contributor's commit on `develop`. > > Diff reviewed before pushing: only Topsort transform code and tests; no `.github/` changes, no env, network or shell access in tests. ## What are the changes introduced in this PR? The Topsort destination now prefixes each event `id` with the platform that sent it, using fields RudderStack's SDKs already set. Marketplaces don't need to change anything. | RudderStack fields | Topsort event `id` | | --- | --- | | `channel: "web"` | `web-<messageId>` | | `channel: "mobile"` + `context.os.name` iOS, iPadOS, watchOS or tvOS | `ios-<messageId>` | | `channel: "mobile"` + `context.os.name: "Android"` | `android-<messageId>` | | anything else (no channel, server-side, mobile with no or another OS name) | `<messageId>` (unchanged) | This applies to impressions, clicks and purchases, including events fanned out per product (`ios-<messageId>-0`, `ios-<messageId>-1`, ...). OS names are matched exactly with the shared `isAppleFamily` / `isAndroidFamily` helpers, so e.g. KaiOS is not tagged as iOS. ## What is the related Linear task? N/A ## Please explain the objectives of your changes below Marketplaces that send events from web and mobile apps through the same destination can't tell, from the Topsort side, which platform a rejected or malformed event came from. Every event reaches the Topsort Events API from RudderStack's servers, and the `id` is the RudderStack `messageId`. With the prefix, the Topsort dashboard and request logs show the source of each event directly. `channel` is set by every RudderStack SDK, and `context.os.name` by the mobile SDKs. Checked against real payloads: the JavaScript SDK sends `channel: "web"`, and the iOS SDK sends `channel: "mobile"` with `context.os.name: "iOS"`. ### Any changes to existing capabilities/behaviour, mention the reason & what are the changes ? For events whose platform can be identified, the event `id` changes from `<messageId>` to `<platform>-<messageId>`. The Topsort Events API accepts any unique string as `id`, so no request is affected. Topsort dedupes on `id`, and the prefix is deterministic for a given message, so retries still produce the same `id`. The exception is an event first sent before this deploys and retried after it: it goes out with the new `id` and isn't deduped against the first attempt. Anyone matching Topsort event ids against their own RudderStack `messageId`s will now see the prefix. ### Any new dependencies introduced with this change? N/A ### Any new generic utility introduced or modified. Please explain the changes. N/A. `getPlatform` and `getEventId` are local to `src/v0/destinations/topsort/utils.ts`; OS matching reuses the existing `isAppleFamily` / `isAndroidFamily` from `src/v0/util`. ### Any technical or performance related pointers to consider with the change? N/A. A couple of string comparisons per event. <hr> ### Developer checklist - [x] My code follows the style guidelines of this project - [x] **No breaking changes are being introduced.** - [ ] All related docs linked with the PR? - [ ] All changes manually tested? - [ ] Any documentation changes needed with this change? - [x] Is the PR limited to 10 file changes? - [x] Is the PR limited to one linear task? - [x] Are relevant unit and component test-cases added in **new readability format**? Tests: unit cases in `routerTransform.test.ts` for web, iOS, iPadOS, Android, KaiOS (not prefixed), mobile without an OS name and server-side events, plus fanned-out and purchase ids. A component fixture (`topsort-router-platform-prefix`) sends a web click, an iOS impression and an Android purchase in one batch. All Topsort unit and component tests pass. ### 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. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: bernirosas <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
|
Changes got merged as part of PR #5774 where all the checks have passed |
## What are the changes introduced in this PR? Adds a `fork-pr-contribution` skill (`.claude/skills/fork-pr-contribution/SKILL.md`) so everyone handles open-source contributions the same way: ``` fork PR ──(squash)──▶ contrib/<pr> ──(PR, full CI, merge commit)──▶ develop ``` 1. **Sanity checks on the contributor PR:** lint, format, secret paths and unit tests run on fork PRs since #5772. Lists which checks are expected to be skipped (Docker build, ingestion test, Sonar) or to fail (org-level zizmor `scan`). 2. **Review the diff before it reaches our repo:** in our repo it runs with our secrets. The skill says to stop and escalate on `.github/`, Dockerfile, npm script, lockfile or test-setup changes, and includes a grep for env, shell and network access. 3. **Squash-merge into `contrib/<pr>`:** the squash commit is authored by the PR author, so the contributor keeps the credit. 4. **Raise `contrib/<pr>` → `develop`:** reuses the contributor's title and description, with a credit header. 5. **Full CI, then merge with a merge commit:** squashing here would make the maintainer the author. ## Please explain the objectives of your changes below Fork PRs can't run the checks that need secrets, and those checks show as *skipped*, which branch protection treats as passing. Without a shared process, a fork PR can be merged into `develop` without the full CI ever running. Agreed in standup; first used on #5771 → #5774. ## Any changes to existing capabilities/behaviour? None. Docs and agent skill only, no runtime or CI changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)

What are the changes introduced in this PR?
The Topsort destination now prefixes each event
idwith the platform that sent it, using fields RudderStack's SDKs already set. Marketplaces don't need to change anything.idchannel: "web"web-<messageId>channel: "mobile"+context.os.nameiOS, iPadOS, watchOS or tvOSios-<messageId>channel: "mobile"+context.os.name: "Android"android-<messageId><messageId>(unchanged)This applies to impressions, clicks and purchases, including events fanned out per product (
ios-<messageId>-0,ios-<messageId>-1, ...). OS names are matched exactly with the sharedisAppleFamily/isAndroidFamilyhelpers, so e.g. KaiOS is not tagged as iOS.What is the related Linear task?
N/A
Please explain the objectives of your changes below
Marketplaces that send events from web and mobile apps through the same destination can't tell, from the Topsort side, which platform a rejected or malformed event came from. Every event reaches the Topsort Events API from RudderStack's servers, and the
idis the RudderStackmessageId. With the prefix, the Topsort dashboard and request logs show the source of each event directly.channelis set by every RudderStack SDK, andcontext.os.nameby the mobile SDKs. Checked against real payloads: the JavaScript SDK sendschannel: "web", and the iOS SDK sendschannel: "mobile"withcontext.os.name: "iOS".Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
For events whose platform can be identified, the event
idchanges from<messageId>to<platform>-<messageId>. The Topsort Events API accepts any unique string asid, so no request is affected. Topsort dedupes onid, and the prefix is deterministic for a given message, so retries still produce the sameid. The exception is an event first sent before this deploys and retried after it: it goes out with the newidand isn't deduped against the first attempt. Anyone matching Topsort event ids against their own RudderStackmessageIds will now see the prefix.Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A.
getPlatformandgetEventIdare local tosrc/v0/destinations/topsort/utils.ts; OS matching reuses the existingisAppleFamily/isAndroidFamilyfromsrc/v0/util.Any technical or performance related pointers to consider with the change?
N/A. A couple of string comparisons per event.
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?
Tests: unit cases in
routerTransform.test.tsfor web, iOS, iPadOS, Android, KaiOS (not prefixed), mobile without an OS name and server-side events, plus fanned-out and purchase ids. A component fixture (topsort-router-platform-prefix) sends a web click, an iOS impression and an Android purchase in one batch. All Topsort unit and component tests pass.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.
🤖 Generated with Claude Code