Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughComprehensive 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
Greptile SummaryRenamed
Confidence Score: 5/5
Important Files Changed
Flowchartflowchart 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]
Last reviewed commit: 68ab2d3 |
There was a problem hiding this comment.
🧹 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, andsession_replay_id/session_replay_segment_idare cleanly plumbed through.Minor note: lines 328–329 use
as anyto accessclickhouseEventData.refresh_token_id. This is pragmatic given theRecord<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 useas/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).
<!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md -->
<!-- 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 -->
Summary by CodeRabbit
Release Notes
session_recording_id→session_replay_idandtab_id→session_replay_segment_id