Skip to content

feat(topsort): prefix event ids with the source platform - #5771

Closed
bernirosas wants to merge 1 commit into
rudderlabs:developfrom
bernirosas:feat/Topsort/add-prefix-to-events-id
Closed

bernirosas wants to merge 1 commit into
rudderlabs:developfrom
bernirosas:feat/Topsort/add-prefix-to-events-id

Conversation

@bernirosas

@bernirosas bernirosas commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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


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

@bernirosas
bernirosas requested review from a team as code owners November 5, 2026 14:32
Copilot AI balanced review requested due to automatic review settings November 5, 2026 14:32
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. 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.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bc4f90f6-6938-4543-90bc-82213bfe43ce

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

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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-, or android- 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

Comment thread src/v0/destinations/topsort/utils.ts Resolved
Copilot AI balanced review requested due to automatic review settings November 5, 2026 14:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The OS substring check misclassifies KaiOS as iOS, incorrectly prefixing mobile event IDs instead of retaining the original IDs for unrecognized operating systems.

1 open issue

Review effort: Balanced

@bernirosas
bernirosas force-pushed the feat/Topsort/add-prefix-to-events-id branch from 91121ea to 66ce6f1 Compare November 5, 2026 14:59
Copilot AI balanced review requested due to automatic review settings November 5, 2026 14:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the source-platform event ID prefixing changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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]>
@bernirosas
bernirosas force-pushed the feat/Topsort/add-prefix-to-events-id branch from 66ce6f1 to 4db6d27 Compare November 5, 2026 15:02
@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.44%. Comparing base (5b82078) to head (4db6d27).

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

krishna2020 added a commit that referenced this pull request Nov 6, 2026
## 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]>
krishna2020 added a commit that referenced this pull request Nov 10, 2026
> **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]>
@krishna2020

Copy link
Copy Markdown
Collaborator

Changes got merged as part of PR #5774 where all the checks have passed

krishna2020 added a commit that referenced this pull request Nov 11, 2026
## 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants