Skip to content

feat: implement in-app review system with debug controls#7

Merged
Sloy merged 16 commits intomasterfrom
reviews
Sep 19, 2025
Merged

feat: implement in-app review system with debug controls#7
Sloy merged 16 commits intomasterfrom
reviews

Conversation

@Sloy
Copy link
Copy Markdown
Owner

@Sloy Sloy commented Sep 18, 2025

Summary

Implements a comprehensive in-app review system that prompts users for reviews at optimal moments, with full debug controls for testing different criteria and monitoring conditions.

Key Features

  • Smart Review Prompts: Multiple criteria for triggering reviews at positive moments
  • Debug Module: Complete testing interface with criteria selection and real-time monitoring
  • Criteria Override System: Debug-only ability to switch between different review criteria
  • Current Conditions Display: Real-time view of user state (favorites, app opens, login status)

Review Criteria

  1. Adding Favorite: Triggers when users add new favorites (but not their first one)
  2. Returning User with Favorites: For users with 3+ app starts and existing favorites
  3. Returning User: For users with 3+ app starts
  4. Always True: Debug-only criteria that always triggers

Debug Module Features

Review Control

  • Enable/Disable Toggle: Turn in-app reviews on/off completely
  • Criteria Selection: Material Design dropdown to select any available criteria
  • Live/Debug Mode Indicators: Shows whether using live or debug criteria selection
  • Revert Button: One-click return to production criteria selection

Real-time Monitoring

  • Active Criteria Display: Shows currently active criteria with mode indicator
  • Current Conditions: Live view of user state including:
    • Number of favorite stops
    • App opens in past 30 days
    • User login status

Persistence

  • Session Persistence: Debug criteria selection survives app restarts
  • Clean Separation: Debug settings don't affect production logic

Technical Implementation

  • Clean Architecture: Separated domain logic, UI, and data layers with dependency injection
  • Build Variants: Debug module only in debug builds, no-op implementation in release
  • Reactive State: Flow-based state management with proper coroutine handling
  • Material Design: Proper Material 3 components with ExposedDropdownMenuBox
  • Analytics Integration: Comprehensive tracking for review effectiveness
  • SharedPreferences Persistence: Debug settings stored locally via DebugModuleDataSource

Usage

Developers can now:

  1. Enable/disable in-app reviews during testing
  2. Switch between different criteria to test various user scenarios
  3. Monitor real-time conditions to understand when criteria will trigger
  4. Revert to production settings with one click
  5. See exactly which criteria is active and in what mode (live vs debug)

Sloy added 11 commits September 18, 2025 20:57
This commit introduces an in-app review prompting system that requests reviews from users at opportune "happy moments."

Key Changes:
- Add `HappyMomentCriteria` interface and concrete implementations:
    - `ReturningUserCriteria`: Triggers if the user has opened the app at least 3 times in the past 30 days.
    - `ReturningUserWithFavoritesCriteria`: Triggers if the user is logged in, has favorites, and meets the app open criteria.
    - `AlwaysTrueCriteria`: (Likely for testing/debugging) Always triggers.
- Implement `AppStartTrackingDataSource` to track app open frequency using DataStore.
- Create `InAppReviewHappyMomentService` to manage and select active happy moment criteria.
- Introduce `HappyMomentTracker`, a new `Tracker` implementation, to dispatch analytics events to the `InAppReviewHappyMomentService`.
- Add `InAppReviewViewModel` to observe happy moments and launch the review flow using `InAppReviewManager`.
- Provide `GoogleInAppReviewManager` for production and `FakeInAppReviewManager` for debug builds.
- Integrate the review flow into the main `App` composable, listening for review triggers.
- Pass event properties to Amplitude tracker.
- Add new analytics events: `ReviewDialogDismissed` (with duration) and `ReviewDialogFailed` (with reason).
- Update DI module to provide all new components.
This commit updates the InAppReviewHappyMomentService to specifically use the `ReturningUserWithFavoritesCriteria` for determining when to prompt users for an in-app review.

Previously, the service would use the first criteria found in the `criteriaList`, or specifically the `ReturningUserCriteria` if present. This change makes the selection more specific, targeting users who are returning and have favorited items, which is a stronger signal for a "happy moment".
This commit introduces a new debug module that allows developers to enable or disable in-app review prompts.

Key Changes:
- Added `InAppReviewDebugModule.kt` to provide a Composable UI for the debug toggle.
- Created `InAppReviewDebugModuleDataSource.kt` for both debug and release builds to manage the state of the toggle.
    - In debug builds, this uses `DebugModuleDataSource` to persist the setting.
    - In release builds, it defaults to in-app reviews being enabled.
- Implemented `InAppReviewDebugModuleState.kt` to define the state (enabled/disabled).
- Added `InAppReviewDebugModuleViewModel.kt` to handle the logic for the debug module.
- Updated `InAppReviewHappyMomentService.kt` to respect the debug toggle, preventing review prompts if disabled via the debug menu.
- Integrated the new debug module into the existing debug DI setup (`DebugDI.kt`) and the main debug menu UI (`SevDebugMenu.kt`).
- Ensured the `InAppReviewHappyMomentService` correctly combines the happy moment criteria with the debug setting.

This feature provides more control during development and testing by allowing easy suppression of in-app review prompts.
This commit enhances the in-app review debug module by displaying the name of the currently active happy moment criteria.

Key Changes:
- Add `activeCriteriaName` field to `InAppReviewDebugModuleState`.
- `InAppReviewHappyMomentService` now exposes an `observeActiveCriteriaName()` StateFlow.
- `InAppReviewDebugModuleViewModel` combines the base state with the active criteria name.
- The `InAppReviewDebugModule` composable now displays the active criteria name if available.
- Updated DI for `InAppReviewDebugModuleViewModel` to include `InAppReviewHappyMomentService`.
This commit introduces a new criterion for triggering in-app review prompts: when a user adds a new favorite stop, and it's not their first favorite (i.e., they already have at least one favorite).

Key Changes:
- Create `AddingFavoriteCriteria` class implementing `HappyMomentCriteria`.
- This new criteria checks if the user has existing favorites when an `AddFavoriteClicked` event is dispatched.
- If the user already has favorites, it sets the happy moment flag to true.
- Update `InAppReviewHappyMomentService` to prioritize `AddingFavoriteCriteria` over `ReturningUserWithFavoritesCriteria` when selecting the active criteria.
- Register `AddingFavoriteCriteria` in the Koin dependency injection module.

This change aims to prompt users for a review at a moment they are actively engaging with a positive feature of the app, potentially increasing the likelihood of positive reviews.
@Sloy Sloy requested a review from Copilot September 18, 2025 21:09

This comment was marked as outdated.

This comment was marked as outdated.

This commit enhances the In-App Review debug module by adding a dropdown menu to select and activate different "happy moment" criteria.

Key Changes:
- `InAppReviewDebugModuleState`: Added `availableCriteria` list.
- `InAppReviewHappyMomentService`:
    - Added `getAllCriteria()` to retrieve all defined criteria.
    - Added `setActiveCriteria(criteriaName: String)` to allow changing the active criteria for testing purposes.
- `InAppReviewDebugModuleViewModel`:
    - Updated to populate `availableCriteria` in the state.
    - Added `onCriteriaSelected(criteriaName: String)` to handle user selection from the debug menu.
- `InAppReviewDebugModule.kt` (UI):
    - Implemented an `ExposedDropdownMenuBox` to display available criteria.
    - Users can now select a criteria from the dropdown, which updates the active criteria in `InAppReviewHappyMomentService`.
    - The dropdown shows the currently active criteria or "None".

This allows for easier testing of different conditions that trigger the in-app review prompt.
This commit significantly improves the In-App Review debug module by allowing developers to override the active review criteria for testing purposes.

Key Changes:
- **Criteria Override:** Developers can now select a specific review criteria from the debug module, which will then be used by the `InAppReviewHappyMomentService` instead of the live/production criteria selection logic.
- **State Management:**
    - `InAppReviewDebugModuleState` and its release counterpart now include `selectedDebugCriteriaName` to store the overridden criteria.
    - `InAppReviewDebugModuleViewModel` handles the selection and persistence of the debug criteria via `InAppReviewDebugModuleDataSource`.
- **UI Enhancements:**
    - The debug module UI now indicates whether the active criteria is "live" or a "debug" override.
    - A "Revert to live criteria" button (refresh icon) is added, appearing only when a debug override is active. This allows easy switching back to the default criteria selection logic.
- **Service Logic Update:**
    - `InAppReviewHappyMomentService` now checks for a debug criteria override during initialization.
    - New methods `setActiveCriteria(criteriaName: String)` and `revertToLiveCriteria()` are added to manage the debug override.
    - Logging is improved to clearly indicate when a debug override is active.
- **Code Structure:**
    - `selectLiveCriteria()` private method introduced in `InAppReviewHappyMomentService` to encapsulate the production criteria selection logic.

This enhancement provides better control and visibility for testing different In-App Review scenarios without affecting production behavior.
This commit adds a "Current Conditions" section to the In-App Review debug module, displaying real-time data for:
- Number of favorites
- App open count (last 30 days)
- User login status

This provides developers with better insight into the conditions that trigger in-app review prompts.

Key Changes:
- Updated `InAppReviewDebugModuleState` to include `favoritesCount`, `appOpensCount`, and `isUserLoggedIn`.
- Modified `InAppReviewDebugModuleViewModel` to collect and expose these new state values by observing `FavoriteRepository`, `AppStartTrackingDataSource`, and `SessionService`.
- Updated the `InAppReviewDebugModule` UI to display the new "Current Conditions" section.
- Adjusted DI in `DebugDI.kt` to provide necessary dependencies to `InAppReviewDebugModuleViewModel`.
- Updated the release variant of `InAppReviewDebugModuleDataSource.kt` to include default values for the new state fields.
This commit renames the class `InAppReviewHappyMomentService` to the more concise `InAppReviewService`.

This change is applied across the codebase where this service is used, including:
- `InAppReviewDebugModuleViewModel`
- `HappyMomentTracker`
- Dependency injection configurations in `DI.kt`
- `InAppReviewViewModel`
@Sloy Sloy requested a review from Copilot September 19, 2025 11:12

This comment was marked as resolved.

This commit adds analytics tracking for when the in-app review dialog is requested.

Key Changes:
- Add `ReviewDialogRequested` event to `Events.kt`
- Track `ReviewDialogRequested` event in `InAppReviewViewModel.launch()`
@Sloy Sloy merged commit deb94e0 into master Sep 19, 2025
2 checks passed
@Sloy Sloy deleted the reviews branch September 19, 2025 13:13
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