-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Parent Issue
Epic 3.5: Observability & Operations (#190)
Summary
Refactor logger-client.ts to remove its dependency on authStore, breaking the circular dependency and improving bundle size.
Problem
The initial logger implementation (#250) had logger-client.ts importing authStore to get userId. This caused:
- Circular dependency: authStore -> logger -> authStore
- Vite warnings during build
- Bundle optimization issues (dynamic imports not effective)
Solution
- Remove authStore dependency from logger-client.ts
- Add userId field to LogOptions interface
- Callers pass userId via { userId: getUserId() }
- Each store defines a simple getUserId() helper
Changes
| File | Change |
|---|---|
| frontend/src/lib/logger-client.ts | Remove authStore import, add userId to LogOptions |
| frontend/src/stores/authStore.ts | Pass userId in logger calls |
| frontend/src/stores/libraryStore.ts | Add getUserId() helper, pass userId in logger calls |
| frontend/src/stores/playlistStore.ts | Add getUserId() helper, pass userId in logger calls |
| frontend/src/stores/playerStore/persistence.ts | Add getUserId() helper, pass userId in logger calls |
Bundle Impact
| Metric | Before (v2.0.2-rc.5) | After | Delta |
|---|---|---|---|
| Main bundle | 293.03 KB | 301.10 KB | +8.07 KB |
| Main gzip | 91.31 KB | 93.63 KB | +2.32 KB |
The ~8 KB increase is the total cost of the logging system (logger-client.ts + userId tracking in stores). This is acceptable for production observability.
Acceptance Criteria
- No Vite circular dependency warnings
- All tests pass (411 frontend tests)
- Build succeeds without warnings
- Logger has no business dependencies (pure utility)
Reactions are currently unavailable