Successfully created and wrote to new file: /home/Messier82/.gemini/tmp/service-book/6a1c8d1e-8a60-4460-a64e-c185658d819d/plans/pr-86-round-6.md. Here is the updated code: # Implementation Plan - PR #86 Round 6 Improvements This plan addresses the remaining feedback from the Round 5 and "Full PR Sweep" reviews of PR #86, focusing on non-blocking items, code quality improvements, and documentation. ## Objective Refine the bug-reporting and telemetry implementation to meet all reviewer suggestions, including stricter email validation, cleaner dependency injection for Sentry configuration, simplified test setups, and updated documentation. ## Key Changes ### 1. Refine Email Validation - **Goal**: Address the leniency of `Patterns.EMAIL_ADDRESS` (e.g., it accepts `a@b`). - **File**: `app/src/main/java/com/servicebook/ui/reportbug/ReportBugViewModel.kt` - **Change**: Update `ReportBugState.isEmailInvalid` to ensure the domain part contains at least one dot. - **Verification**: Update `ReportBugViewModelTest.kt` to assert that `a@b` is considered invalid. ### 2. Refactor Sentry Config & Injection - **Goal**: Move Sentry configuration ownership to the wrapper and reduce VM exposure to build metadata. - **Files**: - `app/src/main/java/com/servicebook/util/SentryWrapper.kt`: - Update `SentryWrapperImpl` to take `SentryInitParams` in its constructor. - Remove `params` from `lazyInitAndSendFeedback` signature. - `app/src/main/java/com/servicebook/ServiceBookApplication.kt`: - Introduce `sentryInitParams` and `sentryWrapper` as `internal open val` (lazy). - Use these centralized params in `configureSentryOptions` and when providing `sentryWrapper` to ViewModels. - `app/src/main/java/com/servicebook/ui/util/ViewModelDependencies.kt`: - Add `val sentryWrapper: SentryWrapper`. - `app/src/main/java/com/servicebook/ui/reportbug/ReportBugViewModel.kt`: - Pull `sentryWrapper` from `dependencies`. - Simplify `performSubmission` to use the updated `lazyInitAndSendFeedback` without manual param construction. ### 3. Simplify Test Dependencies - **Goal**: Reduce boilerplate in VM tests that require `ViewModelDependencies`. - **File**: `app/src/main/java/com/servicebook/ui/util/ViewModelDependencies.kt` - **Change**: Add a `testInstance` factory method in a companion object to provide a mocked instance with sensible defaults. - **Verification**: Refactor `ReportBugScreenTest.kt` (and others if applicable) to use this factory. ### 4. Explicit MockK Verifications - **Goal**: Make Sentry wrapper tests more robust and readable. - **File**: `app/src/test/java/com/servicebook/util/SentryWrapperTest.kt` - **Change**: Update `verify` blocks to check against explicit literal strings (e.g., `"debug"`) instead of reusing the input parameters. ### 5. Documentation & Screenshots - **File**: `docs/sentry-setup.md`: Add a section explaining the "User-Initiated Feedback" path and its breadcrumb for transparency. - **File**: `app/src/test/java/com/servicebook/ui/reportbug/ReportBugScreenshotTest.kt`: Change `captureScreen` to `captureFull` for invalid email states to ensure the error text is always captured regardless of screen height. ## Verification & Testing ### Automated Tests - Run all unit tests: `./gradlew test` - Run specific tests: - `ReportBugViewModelTest` (Email validation & VM refactor) - `SentryWrapperTest` (Explicit verifications & refactor) - `ServiceBookApplicationTest` (Centralized config) - `ReportBugScreenshotTest` (Full capture check) ### Manual Verification - Verify the "Report Bug" screen in a debug build: - Input `a@b` and confirm the "Submit" button remains disabled and an error is shown. - Input `a@b.c` and confirm it is accepted. - Verify that Sentry still works by using the "Force test crash" button in Settings (already implemented, just a regression check). ## Migration & Rollback - These are non-breaking changes to internal APIs. Rollback involves reverting the commits.