Skip to content

rename tabId to sessionReplaySegmentId#1206

Merged
BilalG1 merged 2 commits intodevfrom
rename-replay-tab-id
Feb 17, 2026
Merged

rename tabId to sessionReplaySegmentId#1206
BilalG1 merged 2 commits intodevfrom
rename-replay-tab-id

Conversation

@BilalG1
Copy link
Copy Markdown
Collaborator

@BilalG1 BilalG1 commented Feb 17, 2026

Summary by CodeRabbit

Release Notes

  • Terminology Update
    • Renamed "Session Recording" to "Session Replay" across the platform for improved clarity
    • Updated API field names: session_recording_idsession_replay_id and tab_idsession_replay_segment_id
    • Internal API endpoints updated to reflect new naming conventions

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stack-backend Ready Ready Preview, Comment Feb 17, 2026 7:07pm
stack-dashboard Ready Ready Preview, Comment Feb 17, 2026 7:07pm
stack-demo Ready Ready Preview, Comment Feb 17, 2026 7:07pm
stack-docs Ready Ready Preview, Comment Feb 17, 2026 7:07pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 17, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Comprehensive terminology migration from "session recording" to "session replay" across the entire stack, including database schema, API routes, type definitions, and client/server implementations. Renames database models, columns, API endpoints, interface methods, and field identifiers to reflect the new domain terminology.

Changes

Cohort / File(s) Summary
Database Schema & Migrations
apps/backend/prisma/migrations/20260216000000_.../migration.sql, apps/backend/prisma/schema.prisma
Renames tables (SessionRecording→SessionReplay, SessionRecordingChunk→SessionReplayChunk), columns (tabId→sessionReplaySegmentId, sessionRecordingId→sessionReplayId), and associated constraints/indexes in database schema and migration.
Backend API Routes
apps/backend/src/app/api/latest/session-replays/batch/route.tsx, apps/backend/src/app/api/latest/internal/session-replays/route.tsx, apps/backend/src/app/api/latest/internal/session-replays/[session_replay_id]/chunks/route.tsx, apps/backend/src/app/api/latest/internal/session-replays/[session_replay_id]/chunks/[chunk_id]/events/route.tsx, apps/backend/src/app/api/latest/internal/session-replays/[session_replay_id]/events/route.tsx
Updates route parameters (session_recording_id→session_replay_id), Prisma model references (sessionRecording→sessionReplay), field mappings (tab_id→session_replay_segment_id), and error messages across all session replay endpoints.
Backend Services
apps/backend/prisma/seed.ts, apps/backend/src/lib/events.tsx, apps/backend/src/lib/tokens.tsx, apps/backend/scripts/clickhouse-migrations.ts
Renames seed functions (seedDummySessionRecordings→seedDummySessionReplays), updates event logging options with replay-related fields, extends ClickHouse migrations with replay columns and backfill logic.
Type Definitions & Shared Interfaces
packages/stack-shared/src/interface/admin-interface.ts, packages/stack-shared/src/interface/client-interface.ts, packages/stack-shared/src/interface/crud/session-replays.ts
Renames type exports (AdminListSessionRecordings...→AdminListSessionReplays...), updates method signatures across admin/client interfaces, changes field names (tab_id→session_replay_segment_id) in response types.
Admin & Client Implementations
packages/template/src/lib/stack-app/apps/implementations/admin-app-impl.ts, packages/template/src/lib/stack-app/apps/implementations/client-app-impl.ts, packages/template/src/lib/stack-app/apps/implementations/session-replay.ts, packages/template/src/lib/stack-app/apps/interfaces/admin-app.ts, packages/template/src/lib/stack-app/apps/interfaces/client-app.ts
Updates method signatures (listSessionRecordings→listSessionReplays, sendSessionRecordingBatch→sendSessionReplayBatch), renames internal fields (_tabId→_sessionReplaySegmentId), aligns imports and re-exports with session-replay terminology.
Dashboard & UI
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/analytics/replays/page-client.tsx, apps/dashboard/src/lib/session-replay-streams.ts, apps/dashboard/src/lib/session-replay-streams.test.ts
Renames ChunkRow fields (tabId→sessionReplaySegmentId), updates type casts to AdminAppWithSessionReplays, refactors stream grouping logic and test data to use new field names.
Template Configuration & Exports
packages/template/src/index.ts, packages/template/src/lib/stack-app/session-replays/index.ts
Updates re-export sources from session-recording to session-replay modules; renames public type exports (AdminSessionRecording→AdminSessionReplay, ListSessionRecordings...→ListSessionReplays...); updates field names in exported type structures.
End-to-End Tests
apps/e2e/tests/backend/endpoints/api/v1/session-replays.test.ts
Updates test endpoint paths (/session-recordings/batch→/session-replays/batch), request/response field names (tab_id→session_replay_segment_id, session_recording_id→session_replay_id), helper function signatures (tabId parameter→sessionReplaySegmentId).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

  • rename tabId to sessionReplaySegmentId #1206: Directly related—both PRs apply the same tabId → sessionReplaySegmentId rename across database schema, migrations, and API/type mappings.
  • session replays #1187: Directly related—this PR builds on and extends the session-recording models, routes, and admin/client interfaces introduced in that PR.
  • clickhouse setup #1032: Related—this PR extends the ClickHouse analytics migration script by adding replay-related columns and backfill logic that builds upon the ClickHouse setup.

Suggested reviewers

  • N2D4

Poem

🐰 Hops through code with careful intent,
Recordings become Replays—a migration well-spent!
TabIds transform to segmentIds so fine,
Schema and routes now perfectly align.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the template reminder comment with no actual details about the changes, purpose, or scope of the rename. Add a description explaining the purpose of the rename, affected components, and any migration considerations for API consumers.
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: renaming tabId to sessionReplaySegmentId across the codebase, which is the primary objective evident from the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rename-replay-tab-id

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 17, 2026

Greptile Summary

Renamed tabId to sessionReplaySegmentId across the entire session recording stack to better reflect its purpose of grouping recording chunks into per-tab replay segments.

  • Renamed Postgres column via migration and updated Prisma schema
  • Added new ClickHouse analytics columns (session_replay_segment_id, session_replay_id, refresh_token_id) to the events table
  • Updated API endpoints to accept and return session_replay_segment_id instead of tab_id
  • Modified client-side recorder to use new naming in payload construction
  • Updated all TypeScript interfaces, tests, and dashboard code consistently
  • Enhanced event logging infrastructure to support session replay tracking metadata

Confidence Score: 5/5

  • Safe to merge - clean refactoring with comprehensive test coverage
  • This is a straightforward rename refactoring that touches 16 files systematically. All database migrations are properly structured, API contracts are updated consistently, and comprehensive E2E tests validate the changes. The ClickHouse schema additions use safe ADD COLUMN IF NOT EXISTS syntax.
  • No files require special attention

Important Files Changed

Filename Overview
apps/backend/prisma/schema.prisma Updated Prisma schema to rename column and improve comment clarity
apps/backend/scripts/clickhouse-migrations.ts Added new ClickHouse columns for session replay tracking and refresh token ID backfill
apps/backend/src/lib/events.tsx Added optional session replay tracking parameters to event logging
apps/backend/src/app/api/latest/session-recordings/batch/route.tsx Renamed API parameter and internal variable from tab_id to session_replay_segment_id
packages/template/src/lib/stack-app/apps/implementations/session-recording.ts Renamed client-side session recorder property and payload field
apps/e2e/tests/backend/endpoints/api/v1/session-recordings.test.ts Comprehensively updated E2E tests to use new parameter name

Flowchart

flowchart TD
    A[Client: SessionRecorder] -->|POST /session-recordings/batch| B[API Route]
    B -->|Validate session_replay_segment_id| C{Valid UUID?}
    C -->|Yes| D[Store in Postgres]
    C -->|No| E[Return Error]
    D -->|SessionRecordingChunk.sessionReplaySegmentId| F[(PostgreSQL)]
    B -->|Log Event with metadata| G[logEvent]
    G -->|sessionReplaySegmentId param| H[(ClickHouse)]
    H -->|New columns| I[session_replay_segment_id<br/>session_replay_id<br/>refresh_token_id]
    F -->|Query chunks| J[Internal API]
    J -->|Map to response| K[Dashboard]
    K -->|Group by sessionReplaySegmentId| L[Tab Streams]
Loading

Last reviewed commit: 68ab2d3

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

16 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/backend/src/lib/events.tsx (1)

326-344: New ClickHouse column population logic is correct.

The fallback chain for resolvedRefreshTokenId (explicit option → data field for $token-refresh → null) is sound, and session_replay_id / session_replay_segment_id are cleanly plumbed through.

Minor note: lines 328–329 use as any to access clickhouseEventData.refresh_token_id. This is pragmatic given the Record<string, unknown> typing, but a narrowing check (e.g., 'refresh_token_id' in clickhouseEventData && typeof clickhouseEventData.refresh_token_id === 'string') would avoid the cast. Low priority given the controlled scope. As per coding guidelines, "Do NOT use as/any/type casts or anything else to bypass the type system unless explicitly approved."

Optional: avoid `as any` cast
-      const resolvedRefreshTokenId = options.refreshTokenId
-        ?? (matchingEventType.id === "$token-refresh" && typeof (clickhouseEventData as any).refresh_token_id === "string"
-          ? (clickhouseEventData as any).refresh_token_id as string
-          : null);
+      const resolvedRefreshTokenId = options.refreshTokenId
+        ?? (matchingEventType.id === "$token-refresh"
+            && "refresh_token_id" in clickhouseEventData
+            && typeof clickhouseEventData.refresh_token_id === "string"
+          ? clickhouseEventData.refresh_token_id
+          : null);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/backend/src/lib/events.tsx` around lines 326 - 344, The code uses an `as
any` cast to read `clickhouseEventData.refresh_token_id` when computing
`resolvedRefreshTokenId`; replace that cast with a proper type-narrowing check
on `clickhouseEventData` (e.g., verify `'refresh_token_id' in
clickhouseEventData` and `typeof clickhouseEventData.refresh_token_id ===
"string"`) so the fallback for `matchingEventType.id === "$token-refresh"` reads
the field safely without bypassing the type system; update the
`resolvedRefreshTokenId` expression accordingly (referencing the symbol
resolvedRefreshTokenId, clickhouseEventData, and matchingEventType.id).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/backend/src/lib/events.tsx`:
- Around line 326-344: The code uses an `as any` cast to read
`clickhouseEventData.refresh_token_id` when computing `resolvedRefreshTokenId`;
replace that cast with a proper type-narrowing check on `clickhouseEventData`
(e.g., verify `'refresh_token_id' in clickhouseEventData` and `typeof
clickhouseEventData.refresh_token_id === "string"`) so the fallback for
`matchingEventType.id === "$token-refresh"` reads the field safely without
bypassing the type system; update the `resolvedRefreshTokenId` expression
accordingly (referencing the symbol resolvedRefreshTokenId, clickhouseEventData,
and matchingEventType.id).

@BilalG1 BilalG1 requested a review from N2D4 February 17, 2026 18:56
@BilalG1 BilalG1 merged commit fa27c80 into dev Feb 17, 2026
17 of 24 checks passed
@BilalG1 BilalG1 deleted the rename-replay-tab-id branch February 17, 2026 19:00
@coderabbitai coderabbitai bot mentioned this pull request Feb 17, 2026
N2D4 pushed a commit that referenced this pull request Feb 17, 2026
<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added new session replay analytics columns to ClickHouse for enhanced
tracking and reporting

* **Refactor**
* Renamed session recording segment identifier across APIs and data
models from `tab_id` to `session_replay_segment_id`
* Updated internal data structures and type definitions to align with
new naming convention

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

2 participants