-
-
Notifications
You must be signed in to change notification settings - Fork 39
fix: replace console statements with centralized logger utility #1057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Create environment-aware logger utility (dev/prod) - Migrate all 150 console.* statements to logger - Add Sentry-ready structure for future integration - Configure logger with category-based filtering - Document logger usage in frontend CLAUDE.md - Zero ESLint console warnings remaining Logger features: - Debug/info only in development - Warn/error always logged - Context support for errors - Performance timing utilities - TypeScript fully typed
Warning Rate limit exceeded@tphakala has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 23 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (5)
WalkthroughA centralized, environment-aware logging utility was introduced for the frontend, replacing direct console logging throughout the codebase. All logging—debug, info, warn, and error—is now routed through this utility, with category-based loggers for different modules. Documentation and tests were added for the logger, and ESLint rules were adjusted in test files to allow console usage where appropriate. Changes
Sequence Diagram(s)sequenceDiagram
participant Component
participant Logger
participant Console
Component->>Logger: logger.error("Error occurred", err, context)
Logger->>Console: [category] Error occurred, err, context (only if meets log level & env)
sequenceDiagram
participant Developer
participant Logger Doc
Developer->>Logger Doc: Reads Logging Section
Logger Doc->>Developer: Shows usage, best practices, examples
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
- Fix CLAUDE.md examples to avoid duplicate const declarations - Remove TODO comment about Sentry since logger is already Sentry-ready - Clarify logger usage patterns with proper variable names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
🔭 Outside diff range comments (1)
frontend/src/lib/desktop/features/settings/pages/IntegrationSettingsPage.svelte (1)
230-874
: Alignlogger.error
calls with theLogContext
signatureThe optional third parameter of
logger.error
must be aLogContext
object, not a raw string. Update the three occurrences accordingly:• frontend/src/lib/desktop/features/settings/pages/IntegrationSettingsPage.svelte:383
Before
ts logger.error('Failed to parse BirdWeather test result:', parseError, jsonStr);
After
ts logger.error( 'Failed to parse BirdWeather test result:', parseError, { raw: jsonStr } );
• Same file:574 (MQTT)
Before
ts logger.error('Failed to parse MQTT test result:', parseError, jsonStr);
After
ts logger.error( 'Failed to parse MQTT test result:', parseError, { raw: jsonStr } );
• Same file:699 (Weather)
Before
ts logger.error('Failed to parse stage result:', parseError, line);
After
ts logger.error( 'Failed to parse stage result:', parseError, { raw: line } );
These changes will satisfy the
error(message: string, error?: Error, context?: LogContext)
signature.
frontend/src/lib/desktop/features/analytics/pages/Species.svelte
Outdated
Show resolved
Hide resolved
@@ -230,7 +233,7 @@ Responsive Breakpoints: | |||
const date = new Date(timeStr); | |||
return date.getHours(); | |||
} catch (error) { | |||
console.error('Error parsing time:', timeStr, error); | |||
logger.error('Error parsing time:', timeStr, error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix TypeScript error with logger parameters.
The pipeline failure indicates a type mismatch. The error
parameter is of type unknown
but the logger expects specific types.
Apply this fix to handle the unknown error type:
- logger.error('Error parsing time:', timeStr, error);
+ logger.error('Error parsing time:', error instanceof Error ? error : new Error(String(error)), { timeStr });
This ensures type safety while preserving all error context.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
logger.error('Error parsing time:', timeStr, error); | |
logger.error('Error parsing time:', error instanceof Error ? error : new Error(String(error)), { timeStr }); |
🧰 Tools
🪛 GitHub Actions: Frontend Quality
[error] 236-236: Argument of type 'unknown' is not assignable to parameter of type 'LogContext | undefined'.
🤖 Prompt for AI Agents
In
frontend/src/lib/desktop/features/dashboard/components/DailySummaryCard.svelte
at line 236, the logger.error call passes an error parameter typed as unknown,
causing a TypeScript type mismatch. To fix this, explicitly convert or cast the
error to a compatible type such as Error or string before passing it to
logger.error, ensuring type safety while preserving the error context in the log
output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (4)
frontend/CLAUDE.md (4)
218-221
: Add explicit “instantiate once per module” guidanceA prior review already requested clarifying that the logger (from
getLogger
orloggers.*
) should be created once at module load and re-used, not inside every function. Please include this single-instantiation note next to the example.
241-248
: Clarify dev-only nature oftime/-End
&group/-End
helpersState that these helpers are stripped / no-op in production so newcomers know they incur zero runtime cost outside dev builds.
254-260
: Add security bullet: never log passwords / PIIThe “Key Features” list is missing the promised security reminder. Add something like:
“Security-aware: never log passwords, tokens, or other PII.”
279-281
: Provide explicit mapping of log levels per build targetInclude a one-liner or table:
debug/info → development only
,warn/error → always included
. This prevents accidental noise in production bundles.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
frontend/CLAUDE.md
(1 hunks)frontend/src/lib/desktop/components/forms/RTSPUrlInput.svelte
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
frontend/src/**/*.svelte
📄 CodeRabbit Inference Engine (frontend/CLAUDE.md)
frontend/src/**/*.svelte
: Follow Svelte 5 patterns (runes, snippets)
Use TypeScript for all components
Address accessibility by ARIA roles, semantic markup, keyboard event handlers
Document all components - Include comprehensive HTML comments at the top of each component describing purpose, usage, features, and props
ALWAYS use centralized icons from$lib/utils/icons.ts
- NEVER create inline SVGs
For TypeScript type assertions in Svelte bindings, use<!-- prettier-ignore -->
comments to avoid Prettier formatting issues
All components must follow WCAG 2.1 Level AA accessibility standards
All form inputs must have proper labels and accessible error states
All buttons must have accessible names (text, aria-label, or aria-labelledby)
Links must have descriptive text (not vague like 'Click here')
Use proper table structure and header association for data tables
Modals must trap focus and use proper ARIA attributes
Dropdown menus must use proper menu semantics (aria-haspopup, role="menu", role="menuitem")
Pagination controls must have descriptive button labels (e.g., aria-label)
Use live regions (role="status" or role="alert") for status updates and dynamic content
All centralized icons includearia-hidden="true"
automatically; never add custom SVG icons directly in components
Check component type compatibility
Announce loading states to screen readers using live regions
Display accessible error messages using role="alert" for error boundaries
Announce dynamic content changes to screen readers using aria-live regions
Files:
frontend/src/lib/desktop/components/forms/RTSPUrlInput.svelte
frontend/src/**/*.{svelte,css}
📄 CodeRabbit Inference Engine (frontend/CLAUDE.md)
Run
npm run lint:css
for Tailwind/CSS issues and fix major violations before commit
Files:
frontend/src/lib/desktop/components/forms/RTSPUrlInput.svelte
frontend/src/**/*.{ts,svelte}
📄 CodeRabbit Inference Engine (frontend/CLAUDE.md)
frontend/src/**/*.{ts,svelte}
: Ensure noany
types without proper eslint-disable comments
Revieweslint-plugin-security
warnings, especially for regex and filesystem usage
Verify all imports resolve correctly
Files:
frontend/src/lib/desktop/components/forms/RTSPUrlInput.svelte
**/*.md
📄 CodeRabbit Inference Engine (CLAUDE.md)
Format markdown with prettier
Files:
frontend/CLAUDE.md
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Review `eslint-plugin-security` warnings, especially for regex and filesystem usage
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Use type assertions (e.g., '(settings.googleAuth as any).userId') to bypass TypeScript interface caching issues during migration.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{svelte,css} : Run `npm run lint:css` for Tailwind/CSS issues and fix major violations before commit
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Ensure no `any` types without proper eslint-disable comments
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Verify all imports resolve correctly
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Refer to internal/logging/README.md for full documentation on architecture, service patterns, best practices, and privacy/security.
Learnt from: tphakala
PR: tphakala/birdnet-go#683
File: internal/httpcontroller/middleware.go:59-71
Timestamp: 2025-04-30T19:22:35.548Z
Learning: The s.Debug() calls in the codebase are intentionally maintained alongside structured logging (s.webLogger) to provide human-readable logs, and should not be flagged as redundant or suggested for removal or consolidation.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Applies to internal/logging/**/*.go : Use async event bus for high-frequency errors and batch logging for bulk operations to improve performance.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Applies to internal/logging/**/*.go : When logging errors, use enhanced errors with context: errors.New(originalErr).Component("<component>").Category(errors.CategoryNetwork).Build(), and log the full enhanced error object.
Learnt from: tphakala
PR: tphakala/birdnet-go#683
File: internal/httpcontroller/middleware.go:124-131
Timestamp: 2025-04-30T19:22:43.606Z
Learning: The codebase intentionally maintains both s.Debug() human-readable logs alongside structured logging with s.webLogger. This dual logging approach should not be flagged as an issue in PR reviews.
frontend/src/lib/desktop/components/forms/RTSPUrlInput.svelte (11)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : All form inputs must have proper labels and accessible error states
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Display accessible error messages using role="alert" for error boundaries
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : For SubnetInput components, use the 'subnets' + 'onUpdate' pattern.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Align change detection paths with the actual store structure to ensure correct change detection logic.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Apply type assertions strategically for complex derived scenarios to resolve TypeScript errors.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : For TextInput and SelectField components, use 'bind:value' + 'onchange'.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Use type assertions (e.g., '(settings.googleAuth as any).userId') to bypass TypeScript interface caching issues during migration.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.svelte : Define proper TypeScript interfaces for components
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:16.387Z
Learning: Applies to frontend/src/lib/desktop/components/components/**/*.svelte : Use proper accessibility attributes
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Import interface types explicitly from '$lib/stores/settings' to ensure proper TypeScript resolution.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/src/lib/stores/**/*.ts : Always verify store exports before importing; check 'src/lib/stores/settings.ts' for actual exported stores and use only existing exports.
frontend/CLAUDE.md (16)
Learnt from: tphakala
PR: #770
File: CLAUDE.md:3-3
Timestamp: 2025-06-25T16:31:15.577Z
Learning: CLAUDE.md file is intended for AI tool consumption, not human readability, so markdown formatting standards for headings, code blocks, and lists don't need to be enforced for this file.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Refer to internal/logging/README.md for full documentation on architecture, service patterns, best practices, and privacy/security.
Learnt from: tphakala
PR: #770
File: CLAUDE.md:236-236
Timestamp: 2025-06-25T16:31:25.487Z
Learning: CLAUDE.md file should be ignored for linting and formatting issues as it is intended for AI tools, not human consumption, per user tphakala's preference.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/README.md : When creating a new component, add an entry to README.md with full documentation
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:16.387Z
Learning: Applies to frontend/src/lib/desktop/components/**/README.md : Document new components - Any new components must be added to README.md inventory
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Document all components - Include comprehensive HTML comments at the top of each component describing purpose, usage, features, and props
Learnt from: tphakala
PR: #793
File: internal/observability/metrics/myaudio_test.go:69-82
Timestamp: 2025-06-27T09:02:44.970Z
Learning: Added comprehensive testing guidelines to CLAUDE.md including t.Parallel() recommendations for the birdnet-go project to ensure consistent modern Go testing practices.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Applies to internal/logging/**/*.go : Never log sensitive data such as passwords, tokens, connection strings, or full paths. Always scrub sensitive data before logging.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Review eslint-plugin-security
warnings, especially for regex and filesystem usage
Learnt from: tphakala
PR: #683
File: internal/httpcontroller/middleware.go:124-131
Timestamp: 2025-04-30T19:22:43.606Z
Learning: The codebase intentionally maintains both s.Debug() human-readable logs alongside structured logging with s.webLogger. This dual logging approach should not be flagged as an issue in PR reviews.
Learnt from: tphakala
PR: #683
File: internal/httpcontroller/middleware.go:59-71
Timestamp: 2025-04-30T19:22:35.548Z
Learning: The s.Debug() calls in the codebase are intentionally maintained alongside structured logging (s.webLogger) to provide human-readable logs, and should not be flagged as redundant or suggested for removal or consolidation.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/lib/utils/**/*.ts : Use reconnecting-eventsource
package for SSE with automatic reconnection; do not implement manual reconnection logic
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/lib/utils/api.ts : API requests require CSRF tokens, retrieved using the getCsrfToken
function pattern in utils/api.ts, and included in request headers as 'X-CSRF-Token'
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : ALWAYS use centralized icons from $lib/utils/icons.ts
- NEVER create inline SVGs
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Use type assertions (e.g., '(settings.googleAuth as any).userId') to bypass TypeScript interface caching issues during migration.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Applies to internal/logging/**/*.go : Use async event bus for high-frequency errors and batch logging for bulk operations to improve performance.
🪛 LanguageTool
frontend/CLAUDE.md
[grammar] ~202-~202: There might be a mistake here.
Context: ...lized logger utility instead of console statements: typescript import { getLogger, loggers } from '$lib/utils/logger'; // Option 1: Create a custom logger for your module const logger = getLogger('myModule'); // Option 2: Use predefined category loggers const apiLogger = loggers.api; // For API-related logging const authLogger = loggers.auth; // For authentication const sseLogger = loggers.sse; // For SSE connections const audioLogger = loggers.audio; // For audio components const uiLogger = loggers.ui; // For UI components const settingsLogger = loggers.settings; // For settings // Most common pattern - choose one logger per file: const logger = loggers.ui; // For UI components
### Logger Methods ```ty...
(QB_NEW_EN_OTHER)
[grammar] ~222-~222: Use correct spacing
Context: ...i; // For UI components ### Logger Methods
typescript // Debug information (dev only) logger.debug('Component initialized', props); // Informational messages (dev only) logger.info('Connection established'); // Warnings (always logged) logger.warn('Deprecated method used'); // Errors with context (always logged) logger.error('Failed to save', error, { component: 'SettingsPage', action: 'save', userId: user.id, }); // Performance timing (dev only) logger.time('dataLoad'); // ... expensive operation logger.timeEnd('dataLoad'); // Logs: [category] dataLoad: 123.45ms // Grouping (dev only) logger.group('Processing items'); items.forEach(item => logger.debug('Item:', item)); logger.groupEnd(); ``` ### Key Features - Environment-aware: D...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~252-~252: Use correct spacing
Context: ...item)); logger.groupEnd(); ``` ### Key Features - Environment-aware: Debug/info logs onl...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~259-~259: Use correct spacing
Context: ...ole warnings**: Properly configured for ESLint ### Best Practices 1. Use appropriate log l...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~261-~261: Use correct spacing
Context: ...roperly configured for ESLint ### Best Practices 1. Use appropriate log levels: - debug
...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~267-~267: Use correct spacing
Context: ...lbacks - error
: Failures requiring attention 2. Always provide context for errors: `...
(QB_NEW_EN_OTHER_ERROR_IDS_5)
[grammar] ~269-~269: There might be a mistake here.
Context: ...ttention 2. Always provide context for errors: typescript logger.error('API request failed', error, { component: 'DetectionsPage', action: 'loadDetections', endpoint: '/api/v2/detections', });
3. Use categories that match your ...
(QB_NEW_EN_OTHER)
[grammar] ~279-~279: There might be a mistake here.
Context: ...Use categories that match your module's purpose 4. Keep production logs minimal (warn/error...
(QB_NEW_EN_OTHER)
[grammar] ~280-~280: There might be a mistake here.
Context: ...eep production logs minimal (warn/error only) ## Server-Sent Events (SSE) Use `reconnect...
(QB_NEW_EN_OTHER)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: unit-tests
- Remove redundant import.meta.env.DEV checks (logger handles environment automatically) - Move template logging to proper functions using snippets - Add comprehensive component context to all error logs - Update documentation with Svelte-specific logging best practices Fixed issues: - NotificationBell: Improved error context for loadNotifications and markAsRead - DailySummaryCard: Moved template logging to snippet pattern - FilterSettingsPage: Simplified environment-aware logging - Added Svelte logging patterns to frontend CLAUDE.md
- Standardized logger usage across components by replacing `getLogger('app')` with specific loggers like `loggers.analytics` and `loggers.auth`. - Improved error logging context in `DailySummaryCard` for better traceability. - Updated `CLAUDE.md` to include critical guidelines on PII protection and logging best practices. - Added security-aware logging patterns to prevent exposure of sensitive data. These changes aim to streamline logging practices and enhance security measures in the codebase.
- Added a function to redact credentials from RTSP URLs for safer logging. - Enhanced error logging in the addUrl function to include redacted URLs, improving security and traceability. These changes aim to protect sensitive information during logging while maintaining functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
♻️ Duplicate comments (3)
frontend/src/lib/utils/logger.ts (1)
124-142
: Memory leak concern in timing functionality.The timing implementation stores entries in a Map but only removes them in
timeEnd()
. Iftime()
is called without a correspondingtimeEnd()
, entries will accumulate indefinitely, despite the cleanup mechanism.Consider enhancing the cleanup mechanism or adding automatic expiration for stale timers to fully prevent memory leaks from abandoned timing operations.
frontend/src/lib/desktop/features/dashboard/components/DailySummaryCard.svelte (1)
236-236
: Fix TypeScript error with logger parameters.The pipeline failure indicates a type mismatch. The
error
parameter is of typeunknown
but the logger expects specific types.Apply this fix to handle the unknown error type:
- logger.error('Error parsing time', error, { timeStr }); + logger.error('Error parsing time:', error instanceof Error ? error : new Error(String(error)), { timeStr });This ensures type safety while preserving all error context.
frontend/CLAUDE.md (1)
296-312
: Previous review points fully addressed – great jobThe new log-level matrix and the note that
time/-End
andgroup/-End
are no-ops in production resolve the earlier clarity issues. Nothing further to add here.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (8)
frontend/CLAUDE.md
(1 hunks)frontend/src/lib/desktop/components/ui/NotificationBell.svelte
(5 hunks)frontend/src/lib/desktop/features/analytics/pages/Species.svelte
(3 hunks)frontend/src/lib/desktop/features/dashboard/components/DailySummaryCard.svelte
(5 hunks)frontend/src/lib/desktop/features/settings/pages/FilterSettingsPage.svelte
(2 hunks)frontend/src/lib/stores/auth.ts
(2 hunks)frontend/src/lib/utils/api.ts
(3 hunks)frontend/src/lib/utils/logger.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
frontend/src/**/*.svelte
📄 CodeRabbit Inference Engine (frontend/CLAUDE.md)
frontend/src/**/*.svelte
: Follow Svelte 5 patterns (runes, snippets)
Use TypeScript for all components
Address accessibility by ARIA roles, semantic markup, keyboard event handlers
Document all components - Include comprehensive HTML comments at the top of each component describing purpose, usage, features, and props
ALWAYS use centralized icons from$lib/utils/icons.ts
- NEVER create inline SVGs
For TypeScript type assertions in Svelte bindings, use<!-- prettier-ignore -->
comments to avoid Prettier formatting issues
All components must follow WCAG 2.1 Level AA accessibility standards
All form inputs must have proper labels and accessible error states
All buttons must have accessible names (text, aria-label, or aria-labelledby)
Links must have descriptive text (not vague like 'Click here')
Use proper table structure and header association for data tables
Modals must trap focus and use proper ARIA attributes
Dropdown menus must use proper menu semantics (aria-haspopup, role="menu", role="menuitem")
Pagination controls must have descriptive button labels (e.g., aria-label)
Use live regions (role="status" or role="alert") for status updates and dynamic content
All centralized icons includearia-hidden="true"
automatically; never add custom SVG icons directly in components
Check component type compatibility
Announce loading states to screen readers using live regions
Display accessible error messages using role="alert" for error boundaries
Announce dynamic content changes to screen readers using aria-live regions
Files:
frontend/src/lib/desktop/features/analytics/pages/Species.svelte
frontend/src/lib/desktop/features/settings/pages/FilterSettingsPage.svelte
frontend/src/lib/desktop/features/dashboard/components/DailySummaryCard.svelte
frontend/src/lib/desktop/components/ui/NotificationBell.svelte
frontend/src/**/*.{svelte,css}
📄 CodeRabbit Inference Engine (frontend/CLAUDE.md)
Run
npm run lint:css
for Tailwind/CSS issues and fix major violations before commit
Files:
frontend/src/lib/desktop/features/analytics/pages/Species.svelte
frontend/src/lib/desktop/features/settings/pages/FilterSettingsPage.svelte
frontend/src/lib/desktop/features/dashboard/components/DailySummaryCard.svelte
frontend/src/lib/desktop/components/ui/NotificationBell.svelte
frontend/src/**/*.{ts,svelte}
📄 CodeRabbit Inference Engine (frontend/CLAUDE.md)
frontend/src/**/*.{ts,svelte}
: Ensure noany
types without proper eslint-disable comments
Revieweslint-plugin-security
warnings, especially for regex and filesystem usage
Verify all imports resolve correctly
Files:
frontend/src/lib/desktop/features/analytics/pages/Species.svelte
frontend/src/lib/desktop/features/settings/pages/FilterSettingsPage.svelte
frontend/src/lib/stores/auth.ts
frontend/src/lib/desktop/features/dashboard/components/DailySummaryCard.svelte
frontend/src/lib/utils/api.ts
frontend/src/lib/utils/logger.ts
frontend/src/lib/desktop/components/ui/NotificationBell.svelte
frontend/src/lib/desktop/features/settings/**/*.svelte
📄 CodeRabbit Inference Engine (frontend/src/lib/desktop/features/settings/CLAUDE.md)
frontend/src/lib/desktop/features/settings/**/*.svelte
: Map logical UI sections to actual store structure when creating derived settings objects.
Align change detection paths with the actual store structure to ensure correct change detection logic.
For NumberField components, use the 'value' + 'onUpdate' pattern instead of mixing 'bind:value' with 'onUpdate'.
Use correct section names that match the store structure when calling 'settingsActions.updateSection()'.
For TextInput and SelectField components, use 'bind:value' + 'onchange'.
For Checkbox components, use 'bind:checked' + 'onchange'.
For PasswordField components, use 'value' + 'onUpdate'.
For SubnetInput components, use the 'subnets' + 'onUpdate' pattern.
Files:
frontend/src/lib/desktop/features/settings/pages/FilterSettingsPage.svelte
frontend/src/lib/desktop/features/settings/**/*.{ts,svelte}
📄 CodeRabbit Inference Engine (frontend/src/lib/desktop/features/settings/CLAUDE.md)
frontend/src/lib/desktop/features/settings/**/*.{ts,svelte}
: Import interface types explicitly from '$lib/stores/settings' to ensure proper TypeScript resolution.
Use type assertions (e.g., '(settings.googleAuth as any).userId') to bypass TypeScript interface caching issues during migration.
Cast derived fallback objects to the correct interface type (e.g., '({...} as SecuritySettings)').
Handle optional properties with fallbacks (e.g., 'obj?.prop || defaultValue') when accessing possibly undefined properties.
Apply type assertions strategically for complex derived scenarios to resolve TypeScript errors.
Files:
frontend/src/lib/desktop/features/settings/pages/FilterSettingsPage.svelte
frontend/src/lib/utils/api.ts
📄 CodeRabbit Inference Engine (frontend/CLAUDE.md)
API requests require CSRF tokens, retrieved using the
getCsrfToken
function pattern in utils/api.ts, and included in request headers as 'X-CSRF-Token'
Files:
frontend/src/lib/utils/api.ts
frontend/src/lib/utils/**/*.ts
📄 CodeRabbit Inference Engine (frontend/CLAUDE.md)
Use
reconnecting-eventsource
package for SSE with automatic reconnection; do not implement manual reconnection logic
Files:
frontend/src/lib/utils/api.ts
frontend/src/lib/utils/logger.ts
**/*.md
📄 CodeRabbit Inference Engine (CLAUDE.md)
Format markdown with prettier
Files:
frontend/CLAUDE.md
frontend/src/lib/desktop/components/ui/**/*.svelte
📄 CodeRabbit Inference Engine (frontend/src/lib/desktop/components/ui/CLAUDE.md)
frontend/src/lib/desktop/components/ui/**/*.svelte
: Import UI components from '$lib/desktop/components/ui/ComponentName.svelte'
When creating a new component, add a TypeScript interface
When creating a new component, follow Svelte 5 patterns ($state, $derived, snippets)
When creating a new component, include accessibility features
When creating a new component, use DaisyUI styling
UseclassName
prop for customization in components
Support HTML attribute spreading with{...rest}
in components
Includechildren
snippet for flexible content in components
Define proper TypeScript interfaces for components
Files:
frontend/src/lib/desktop/components/ui/NotificationBell.svelte
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Review `eslint-plugin-security` warnings, especially for regex and filesystem usage
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Use type assertions (e.g., '(settings.googleAuth as any).userId') to bypass TypeScript interface caching issues during migration.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{svelte,css} : Run `npm run lint:css` for Tailwind/CSS issues and fix major violations before commit
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Ensure no `any` types without proper eslint-disable comments
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Verify all imports resolve correctly
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Refer to internal/logging/README.md for full documentation on architecture, service patterns, best practices, and privacy/security.
Learnt from: tphakala
PR: tphakala/birdnet-go#683
File: internal/httpcontroller/middleware.go:59-71
Timestamp: 2025-04-30T19:22:35.548Z
Learning: The s.Debug() calls in the codebase are intentionally maintained alongside structured logging (s.webLogger) to provide human-readable logs, and should not be flagged as redundant or suggested for removal or consolidation.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Applies to internal/logging/**/*.go : Use async event bus for high-frequency errors and batch logging for bulk operations to improve performance.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Applies to internal/logging/**/*.go : When logging errors, use enhanced errors with context: errors.New(originalErr).Component("<component>").Category(errors.CategoryNetwork).Build(), and log the full enhanced error object.
Learnt from: tphakala
PR: tphakala/birdnet-go#683
File: internal/httpcontroller/middleware.go:124-131
Timestamp: 2025-04-30T19:22:43.606Z
Learning: The codebase intentionally maintains both s.Debug() human-readable logs alongside structured logging with s.webLogger. This dual logging approach should not be flagged as an issue in PR reviews.
frontend/src/lib/desktop/features/analytics/pages/Species.svelte (19)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Use correct section names that match the store structure when calling 'settingsActions.updateSection()'.
Learnt from: tphakala
PR: #683
File: internal/httpcontroller/middleware.go:59-71
Timestamp: 2025-04-30T19:22:35.548Z
Learning: The s.Debug() calls in the codebase are intentionally maintained alongside structured logging (s.webLogger) to provide human-readable logs, and should not be flagged as redundant or suggested for removal or consolidation.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Align change detection paths with the actual store structure to ensure correct change detection logic.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Apply type assertions strategically for complex derived scenarios to resolve TypeScript errors.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Use type assertions (e.g., '(settings.googleAuth as any).userId') to bypass TypeScript interface caching issues during migration.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Display accessible error messages using role="alert" for error boundaries
Learnt from: tphakala
PR: #862
File: internal/datastore/logger.go:24-24
Timestamp: 2025-07-03T16:49:43.690Z
Learning: In the birdnet-go codebase, log paths should be configured through the configuration system in internal/conf/config.go rather than hardcoded as defaults in individual components. Having both hardcoded defaults and configuration parameters for the same value is an anti-pattern that can lead to inconsistency.
Learnt from: tphakala
PR: #683
File: internal/httpcontroller/middleware.go:124-131
Timestamp: 2025-04-30T19:22:43.606Z
Learning: The codebase intentionally maintains both s.Debug() human-readable logs alongside structured logging with s.webLogger. This dual logging approach should not be flagged as an issue in PR reviews.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:16.387Z
Learning: Applies to frontend/src/lib/desktop/components/components/**/*.svelte : Follow Svelte 5 patterns (runes, snippets)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.svelte : When creating a new component, follow Svelte 5 patterns ($state, $derived, snippets)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/src/lib/stores/**/*.ts : Always verify store exports before importing; check 'src/lib/stores/settings.ts' for actual exported stores and use only existing exports.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Import interface types explicitly from '$lib/stores/settings' to ensure proper TypeScript resolution.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Follow Svelte 5 patterns (runes, snippets)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.svelte : Define proper TypeScript interfaces for components
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Check component type compatibility
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.svelte : When creating a new component, add a TypeScript interface
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/lib/features/settings/**/*.svelte : Use SettingsSection
component with change detection for settings pages
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:16.387Z
Learning: Applies to frontend/src/lib/desktop/components/components/**/*.svelte : Use TypeScript for all components
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.svelte : Import UI components from '$lib/desktop/components/ui/ComponentName.svelte'
frontend/src/lib/desktop/features/settings/pages/FilterSettingsPage.svelte (15)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Use correct section names that match the store structure when calling 'settingsActions.updateSection()'.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Align change detection paths with the actual store structure to ensure correct change detection logic.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/lib/features/settings/**/*.svelte : Use SettingsSection
component with change detection for settings pages
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Use type assertions (e.g., '(settings.googleAuth as any).userId') to bypass TypeScript interface caching issues during migration.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Apply type assertions strategically for complex derived scenarios to resolve TypeScript errors.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Import interface types explicitly from '$lib/stores/settings' to ensure proper TypeScript resolution.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Cast derived fallback objects to the correct interface type (e.g., '({...} as SecuritySettings)').
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Map logical UI sections to actual store structure when creating derived settings objects.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : For NumberField components, use the 'value' + 'onUpdate' pattern instead of mixing 'bind:value' with 'onUpdate'.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Review eslint-plugin-security
warnings, especially for regex and filesystem usage
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : ALWAYS use centralized icons from $lib/utils/icons.ts
- NEVER create inline SVGs
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/src/lib/stores/settings.ts : When extending interfaces (e.g., adding new properties), update the interface definition, default settings structure, and handle missing properties gracefully.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/src/lib/stores/**/*.ts : Always verify store exports before importing; check 'src/lib/stores/settings.ts' for actual exported stores and use only existing exports.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Handle optional properties with fallbacks (e.g., 'obj?.prop || defaultValue') when accessing possibly undefined properties.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Test new icons in multiple contexts after adding to icons.ts
frontend/src/lib/stores/auth.ts (9)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/src/lib/stores/**/*.ts : Always verify store exports before importing; check 'src/lib/stores/settings.ts' for actual exported stores and use only existing exports.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Use type assertions (e.g., '(settings.googleAuth as any).userId') to bypass TypeScript interface caching issues during migration.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Import interface types explicitly from '$lib/stores/settings' to ensure proper TypeScript resolution.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Use correct section names that match the store structure when calling 'settingsActions.updateSection()'.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Align change detection paths with the actual store structure to ensure correct change detection logic.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Review eslint-plugin-security
warnings, especially for regex and filesystem usage
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Apply type assertions strategically for complex derived scenarios to resolve TypeScript errors.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Verify all imports resolve correctly
Learnt from: CR
PR: tphakala/birdnet-go#0
File: .cursor/rules/frontend.mdc:0-0
Timestamp: 2025-07-18T14:40:08.446Z
Learning: Applies to *.js : Use safe storage access patterns with error handling for localStorage
frontend/src/lib/desktop/features/dashboard/components/DailySummaryCard.svelte (16)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Align change detection paths with the actual store structure to ensure correct change detection logic.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Use correct section names that match the store structure when calling 'settingsActions.updateSection()'.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Use type assertions (e.g., '(settings.googleAuth as any).userId') to bypass TypeScript interface caching issues during migration.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Apply type assertions strategically for complex derived scenarios to resolve TypeScript errors.
Learnt from: tphakala
PR: #683
File: internal/httpcontroller/middleware.go:59-71
Timestamp: 2025-04-30T19:22:35.548Z
Learning: The s.Debug() calls in the codebase are intentionally maintained alongside structured logging (s.webLogger) to provide human-readable logs, and should not be flagged as redundant or suggested for removal or consolidation.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:16.387Z
Learning: Applies to frontend/src/lib/desktop/components/components/**/*.svelte : Follow Svelte 5 patterns (runes, snippets)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Use live regions (role="status" or role="alert") for status updates and dynamic content
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Display accessible error messages using role="alert" for error boundaries
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.svelte : When creating a new component, follow Svelte 5 patterns ($state, $derived, snippets)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Review eslint-plugin-security
warnings, especially for regex and filesystem usage
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Cast derived fallback objects to the correct interface type (e.g., '({...} as SecuritySettings)').
Learnt from: tphakala
PR: #1054
File: frontend/src/lib/desktop/components/ui/Card.test.ts:7-10
Timestamp: 2025-07-31T06:48:16.641Z
Learning: Always raise and flag TypeScript type safety issues when encountered, including improper use of 'any' types, missing type annotations, and violations of strict typing guidelines.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.svelte : Import UI components from '$lib/desktop/components/ui/ComponentName.svelte'
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Announce loading states to screen readers using live regions
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.svelte : Include children
snippet for flexible content in components
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Map logical UI sections to actual store structure when creating derived settings objects.
frontend/src/lib/utils/api.ts (7)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/lib/utils/api.ts : API requests require CSRF tokens, retrieved using the getCsrfToken
function pattern in utils/api.ts, and included in request headers as 'X-CSRF-Token'
Learnt from: tphakala
PR: #683
File: internal/httpcontroller/middleware.go:59-71
Timestamp: 2025-04-30T19:22:35.548Z
Learning: The s.Debug() calls in the codebase are intentionally maintained alongside structured logging (s.webLogger) to provide human-readable logs, and should not be flagged as redundant or suggested for removal or consolidation.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: .cursor/rules/frontend.mdc:0-0
Timestamp: 2025-07-18T14:40:08.446Z
Learning: Applies to *.js : Use safe fetch patterns with timeouts and error handling
Learnt from: tphakala
PR: #683
File: internal/httpcontroller/middleware.go:124-131
Timestamp: 2025-04-30T19:22:43.606Z
Learning: The codebase intentionally maintains both s.Debug() human-readable logs alongside structured logging with s.webLogger. This dual logging approach should not be flagged as an issue in PR reviews.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Handle optional properties with fallbacks (e.g., 'obj?.prop || defaultValue') when accessing possibly undefined properties.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.{ts,svelte} : Use type assertions (e.g., '(settings.googleAuth as any).userId') to bypass TypeScript interface caching issues during migration.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Review eslint-plugin-security
warnings, especially for regex and filesystem usage
frontend/src/lib/utils/logger.ts (9)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Applies to internal/logging/**/*.go : Use async event bus for high-frequency errors and batch logging for bulk operations to improve performance.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Applies to internal/logging/**/*.go : When logging errors, use enhanced errors with context: errors.New(originalErr).Component("").Category(errors.CategoryNetwork).Build(), and log the full enhanced error object.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-21T12:31:02.363Z
Learning: Applies to **/*.go : Provide fallback mechanisms (e.g., default loggers)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: .cursor/rules/go.mdc:0-0
Timestamp: 2025-07-18T14:45:53.478Z
Learning: Applies to **/*.go : Implement proper logging with log/slog (Go 1.21+).
Learnt from: tphakala
PR: #862
File: internal/datastore/logger.go:24-24
Timestamp: 2025-07-03T16:49:43.690Z
Learning: In the birdnet-go codebase, log paths should be configured through the configuration system in internal/conf/config.go rather than hardcoded as defaults in individual components. Having both hardcoded defaults and configuration parameters for the same value is an anti-pattern that can lead to inconsistency.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-21T12:31:02.363Z
Learning: Applies to **/*.go : For logging use internal/logging
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Applies to internal/logging/**/*.go : Use the Service Logger Pattern: Each service must initialize its logger using logging.ForService("") in an init() function, with a defensive fallback to slog.Default().With("service", "") if nil.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: .cursor/rules/go.mdc:0-0
Timestamp: 2025-07-18T14:45:53.478Z
Learning: Applies to **/*.go : Adopt log/slog for structured logging (Go 1.21+).
Learnt from: CR
PR: tphakala/birdnet-go#0
File: .cursor/rules/go.mdc:0-0
Timestamp: 2025-07-18T14:45:53.478Z
Learning: Applies to **/*.go : Use structured logging formats.
frontend/CLAUDE.md (25)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Refer to internal/logging/README.md for full documentation on architecture, service patterns, best practices, and privacy/security.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Document all components - Include comprehensive HTML comments at the top of each component describing purpose, usage, features, and props
Learnt from: tphakala
PR: #770
File: CLAUDE.md:3-3
Timestamp: 2025-06-25T16:31:15.577Z
Learning: CLAUDE.md file is intended for AI tool consumption, not human readability, so markdown formatting standards for headings, code blocks, and lists don't need to be enforced for this file.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:16.387Z
Learning: Applies to frontend/src/lib/desktop/components/**/README.md : Document new components - Any new components must be added to README.md inventory
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/README.md : When creating a new component, add an entry to README.md with full documentation
Learnt from: tphakala
PR: #770
File: CLAUDE.md:236-236
Timestamp: 2025-06-25T16:31:25.487Z
Learning: CLAUDE.md file should be ignored for linting and formatting issues as it is intended for AI tools, not human consumption, per user tphakala's preference.
Learnt from: tphakala
PR: #793
File: internal/observability/metrics/myaudio_test.go:69-82
Timestamp: 2025-06-27T09:02:44.970Z
Learning: Added comprehensive testing guidelines to CLAUDE.md including t.Parallel() recommendations for the birdnet-go project to ensure consistent modern Go testing practices.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Use correct section names that match the store structure when calling 'settingsActions.updateSection()'.
Learnt from: tphakala
PR: #1057
File: frontend/CLAUDE.md:254-260
Timestamp: 2025-07-31T11:44:27.096Z
Learning: Always proactively identify and raise potential security or privacy issues during code reviews, including concerns about logging sensitive data, authentication vulnerabilities, data exposure, and other security risks.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: internal/logging/CLAUDE.md:0-0
Timestamp: 2025-07-18T14:39:19.968Z
Learning: Applies to internal/logging/**/*.go : Never log sensitive data such as passwords, tokens, connection strings, or full paths. Always scrub sensitive data before logging.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Review eslint-plugin-security
warnings, especially for regex and filesystem usage
Learnt from: tphakala
PR: #683
File: internal/httpcontroller/middleware.go:124-131
Timestamp: 2025-04-30T19:22:43.606Z
Learning: The codebase intentionally maintains both s.Debug() human-readable logs alongside structured logging with s.webLogger. This dual logging approach should not be flagged as an issue in PR reviews.
Learnt from: tphakala
PR: #683
File: internal/httpcontroller/middleware.go:59-71
Timestamp: 2025-04-30T19:22:35.548Z
Learning: The s.Debug() calls in the codebase are intentionally maintained alongside structured logging (s.webLogger) to provide human-readable logs, and should not be flagged as redundant or suggested for removal or consolidation.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: .cursor/rules/go.mdc:0-0
Timestamp: 2025-07-18T14:45:53.478Z
Learning: Applies to **/*.go : Handle sensitive data appropriately.
Learnt from: tphakala
PR: #793
File: internal/observability/metrics/myaudio_test.go:97-106
Timestamp: 2025-06-27T09:01:30.848Z
Learning: User tphakala requested to update CLAUDE.md file with instructions to use range instead of for loop, indicating preference for modern Go 1.24+ range syntax in AI-generated code suggestions.
Learnt from: tphakala
PR: #841
File: internal/telemetry/telemetry_worker_recommendation.go:123-168
Timestamp: 2025-07-01T17:49:06.606Z
Learning: The file internal/telemetry/telemetry_worker_recommendation.go should be ignored during code reviews as it contains unfinished example code for upcoming telemetry implementation, not production-ready code.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: NEVER COMMIT CODE WITH: TypeScript compilation errors, ESLint errors, critical security issues, major CSS/style violations, missing imports or undefined variables, component type mismatches, or accessibility violations
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/lib/utils/**/*.ts : Use reconnecting-eventsource
package for SSE with automatic reconnection; do not implement manual reconnection logic
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : ALWAYS use centralized icons from $lib/utils/icons.ts
- NEVER create inline SVGs
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Use live regions (role="status" or role="alert") for status updates and dynamic content
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Follow Svelte 5 patterns (runes, snippets)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:16.387Z
Learning: Applies to frontend/src/lib/desktop/components/components/**/*.svelte : Follow Svelte 5 patterns (runes, snippets)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/lib/features/settings/**/*.svelte : Use SettingsSection
component with change detection for settings pages
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.svelte : When creating a new component, follow Svelte 5 patterns ($state, $derived, snippets)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/lib/utils/api.ts : API requests require CSRF tokens, retrieved using the getCsrfToken
function pattern in utils/api.ts, and included in request headers as 'X-CSRF-Token'
frontend/src/lib/desktop/components/ui/NotificationBell.svelte (12)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Display accessible error messages using role="alert" for error boundaries
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Align change detection paths with the actual store structure to ensure correct change detection logic.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Use live regions (role="status" or role="alert") for status updates and dynamic content
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Announce dynamic content changes to screen readers using aria-live regions
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:16.387Z
Learning: Applies to frontend/src/lib/desktop/components/components/**/*.svelte : Follow Svelte 5 patterns (runes, snippets)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/features/settings/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:32:20.392Z
Learning: Applies to frontend/src/lib/desktop/features/settings/**/*.svelte : Use correct section names that match the store structure when calling 'settingsActions.updateSection()'.
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.{ts,svelte} : Review eslint-plugin-security
warnings, especially for regex and filesystem usage
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.svelte : When creating a new component, follow Svelte 5 patterns ($state, $derived, snippets)
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/**/*.svelte : Announce loading states to screen readers using live regions
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:16.387Z
Learning: Applies to frontend/src/lib/desktop/components/components/**/*.svelte : Use TypeScript for all components
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/src/lib/desktop/components/ui/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:28.981Z
Learning: Applies to frontend/src/lib/desktop/components/ui/**/*.{js,ts} : Import utilities from '$lib/desktop/components/ui/image-utils.js'
Learnt from: CR
PR: tphakala/birdnet-go#0
File: frontend/CLAUDE.md:0-0
Timestamp: 2025-07-24T19:31:06.382Z
Learning: Applies to frontend/src/lib/utils/**/*.ts : Use reconnecting-eventsource
package for SSE with automatic reconnection; do not implement manual reconnection logic
🧬 Code Graph Analysis (2)
frontend/src/lib/stores/auth.ts (1)
frontend/src/lib/utils/logger.ts (3)
logger
(149-149)loggers
(154-163)error
(86-110)
frontend/src/lib/utils/api.ts (1)
frontend/src/lib/utils/logger.ts (2)
logger
(149-149)loggers
(154-163)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: unit-tests
🔇 Additional comments (26)
frontend/src/lib/utils/logger.ts (4)
1-21
: Excellent documentation and appropriate ESLint configuration.The comprehensive JSDoc header clearly explains the logger's features, usage patterns, and environment-aware behavior. The ESLint disable for console usage is justified since this is the centralized logging utility that legitimately needs console access.
22-41
: Well-designed TypeScript interfaces.The type definitions are comprehensive and follow best practices. The
LogContext
interface provides flexibility for structured logging metadata while maintaining type safety.
43-58
: Good memory management for timing functionality.The implementation includes proactive memory leak prevention with
MAX_TIMERS
limit and automatic cleanup of oldest entries. This addresses potential issues with abandoned timers effectively.
146-164
: Well-organized logger categories.The predefined loggers provide comprehensive coverage of application domains (api, auth, sse, etc.) and the
as const
assertion ensures type safety. The category selection aligns well with the codebase structure.frontend/src/lib/desktop/features/analytics/pages/Species.svelte (3)
7-9
: Appropriate logger category selection.Using
loggers.analytics
is the correct choice for this analytics page, providing proper contextual logging. This aligns well with the codebase's category-based logging approach.
143-143
: Improved error logging with structured context.The replacement of
console.error
withlogger.error
provides better structured logging and maintains consistency with the centralized logging approach.
292-292
: Consistent error logging pattern.Good use of structured logging for the thumbnail loading error, maintaining the same pattern as other error logging in the file.
frontend/src/lib/stores/auth.ts (2)
34-36
: Correct logger category for authentication context.Using
loggers.auth
is appropriate for this authentication store and aligns with the logging utility's category-based approach.
120-120
: Improved error logging in logout function.The structured logging provides better context for logout errors and maintains consistency with the centralized logging approach.
frontend/src/lib/desktop/features/settings/pages/FilterSettingsPage.svelte (2)
22-24
: Appropriate logger selection for settings context.Using
loggers.settings
is the correct choice for this settings page, providing proper contextual categorization.
75-79
: Enhanced warning logging with structured context.The structured logging with component and action context provides valuable debugging information while maintaining consistent logging patterns. The replacement of
console.warn
improves log management.frontend/src/lib/utils/api.ts (4)
5-7
: Appropriate logger category for API utilities.Using
loggers.api
is the correct choice for API-related logging, providing proper contextual categorization.
151-164
: Safe JSON parsing for request body logging.The implementation properly handles potential JSON parsing errors with try-catch and provides fallback logging for non-JSON bodies. This addresses security concerns while maintaining useful debug information.
167-167
: Consistent debug logging for responses.Good use of structured logging for response debugging, maintaining consistency with the request logging pattern.
182-182
: Appropriate handling of error logging.Keeping the error logging commented out for production while maintaining the structure for potential future use is a good approach.
frontend/src/lib/desktop/features/dashboard/components/DailySummaryCard.svelte (3)
59-61
: LGTM!The logger import and initialization correctly follows the centralized logging pattern established in this PR.
200-200
: LGTM!The conversion from
console.warn
tologger.warn
is correctly implemented for the sun times fetch error.
215-215
: LGTM!The error logging conversion maintains proper context and follows the established logging patterns.
frontend/src/lib/desktop/components/ui/NotificationBell.svelte (8)
7-9
: LGTM!The logger import and initialization correctly follows the centralized logging pattern.
155-158
: LGTM!The error logging correctly uses structured logging with proper context including component and action identifiers.
179-179
: LGTM!The debug logging for SSE connection status is appropriately leveled and correctly implemented.
187-187
: LGTM!The error logging for SSE message parsing failures is correctly implemented with proper error context.
200-200
: LGTM!The error logging for ReconnectingEventSource creation failures is correctly implemented.
278-282
: LGTM!Excellent example of structured error logging with comprehensive context including component, action, and the specific notification ID for debugging.
330-330
: LGTM!The warning for audio preload failures is correctly implemented with the centralized logger.
192-192
: No type compatibility issue for Event parameterThe
logger.error
signature iserror(message: string, error?: Error | unknown, context?: LogContext)
. Passing the SSEEvent
as the second argument falls underunknown
and is fully supported by the implementation’s runtime checks. You can safely keep the existing call:- logger.error('Notification SSE error:', error); + logger.error('Notification SSE error:', error);No changes required here.
Likely an incorrect or invalid review comment.
@@ -314,14 +320,14 @@ | |||
}); | |||
|
|||
audio.addEventListener('error', e => { | |||
console.warn('Failed to load notification sound:', e); | |||
logger.warn('Failed to load notification sound:', e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Consider type safety for Event parameter.
The event parameter from the audio error handler may need type conversion for better compatibility with the logger.
Consider:
- logger.warn('Failed to load notification sound:', e);
+ logger.warn('Failed to load notification sound:', e instanceof Error ? e : new Error('Audio loading failed'));
🤖 Prompt for AI Agents
In frontend/src/lib/desktop/components/ui/NotificationBell.svelte at line 323,
the event parameter 'e' passed to logger.warn may not have a consistent type. To
improve type safety, explicitly cast or extract the error message or relevant
information from the event before logging it, ensuring the logger receives a
string or a well-defined error object.
frontend/src/lib/desktop/features/dashboard/components/DailySummaryCard.svelte
Outdated
Show resolved
Hide resolved
- Updated logger usage in NotificationBell and DailySummaryCard components to include detailed context for warnings, improving traceability of issues. - Renamed logger instance in CLAUDE.md for clarity. - Enhanced logger interface to support throttling, preventing excessive log messages and improving performance. These changes aim to streamline logging practices and provide better insights during debugging.
|
Summary
This PR eliminates all 150 ESLint console warnings in the frontend by implementing a centralized, environment-aware logger utility.
Changes
Created a lightweight logger utility (
src/lib/utils/logger.ts
) with:Migrated all console.* statements across 27 files
Added comprehensive logger documentation to frontend CLAUDE.md
Created automated migration script for bulk changes
Results
no-console
ESLint warningsTesting
Future Considerations
When ready to integrate Sentry.io, only
logger.ts
needs modification to add the transport layer. The current implementation is designed to make this transition seamless.Related Issue
Fixes linter warnings reported in frontend build output.
Summary by CodeRabbit
New Features
Refactor
Documentation
Tests
Style