Skip to content

Commit a960fe8

Browse files
committed
feat(app_review): add positive feedback follow-up toggle
- Introduce `isPositiveFeedbackFollowUpEnabled` flag in AppReviewConfig - Update logic for handling positive feedback to respect the new flag - Modify fixtures and tests to include the new configuration option
1 parent 24c01bc commit a960fe8

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

lib/src/fixtures/remote_configs.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ final remoteConfigsFixturesData = <RemoteConfig>[
232232
// to become eligible for the review prompt.
233233
positiveInteractionThreshold: 5,
234234
initialPromptCooldownDays: 3,
235+
isPositiveFeedbackFollowUpEnabled: true,
235236
isNegativeFeedbackFollowUpEnabled: true,
236237
),
237238
),

lib/src/models/config/app_review_config.dart

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ part 'app_review_config.g.dart';
2626
///
2727
/// 3. **User Interaction & State Change**:
2828
/// - **On "Yes" (Positive Feedback)**:
29-
/// - An `AppReview` record is created/updated with `initialFeedback: positive`
30-
/// and `wasStoreReviewRequested` is set to `true`.
31-
/// - The native OS in-app review dialog is immediately triggered. This is a
32-
/// "fire-and-forget" action; the OS controls if the dialog appears and
33-
/// provides no feedback to the app.
34-
/// - The `UserFeedDecoratorStatus` for `rateApp` has its `isCompleted` flag
29+
/// - An `AppReview` record is created/updated with `initialFeedback: positive`.
30+
/// - If [isPositiveFeedbackFollowUpEnabled] is `true`, the native OS
31+
/// in-app review dialog is triggered. `wasStoreReviewRequested` is set
32+
/// to `true` to record that the attempt was made.
33+
/// - Regardless of whether the dialog was requested, the
34+
/// `UserFeedDecoratorStatus` for `rateApp` has its `isCompleted` flag
3535
/// set to `true`, **permanently preventing the internal prompt from
3636
/// appearing again for this user.**
3737
///
@@ -53,6 +53,7 @@ class AppReviewConfig extends Equatable {
5353
required this.positiveInteractionThreshold,
5454
required this.initialPromptCooldownDays,
5555
required this.isNegativeFeedbackFollowUpEnabled,
56+
required this.isPositiveFeedbackFollowUpEnabled,
5657
});
5758

5859
/// Creates a [AppReviewConfig] from JSON data.
@@ -74,6 +75,12 @@ class AppReviewConfig extends Equatable {
7475
/// text reason after a user provides negative feedback.
7576
final bool isNegativeFeedbackFollowUpEnabled;
7677

78+
/// A switch to enable or disable invoking the native OS in-app review dialog
79+
/// after a user provides positive feedback.
80+
///
81+
/// This allows for testing the positive flow without consuming review quotas.
82+
final bool isPositiveFeedbackFollowUpEnabled;
83+
7784
/// Converts this [AppReviewConfig] instance to JSON data.
7885
Map<String, dynamic> toJson() => _$AppReviewConfigToJson(this);
7986

@@ -83,6 +90,7 @@ class AppReviewConfig extends Equatable {
8390
positiveInteractionThreshold,
8491
initialPromptCooldownDays,
8592
isNegativeFeedbackFollowUpEnabled,
93+
isPositiveFeedbackFollowUpEnabled,
8694
];
8795

8896
/// Creates a copy of this [AppReviewConfig] but with the given fields
@@ -92,6 +100,7 @@ class AppReviewConfig extends Equatable {
92100
int? positiveInteractionThreshold,
93101
int? initialPromptCooldownDays,
94102
bool? isNegativeFeedbackFollowUpEnabled,
103+
bool? isPositiveFeedbackFollowUpEnabled,
95104
}) {
96105
return AppReviewConfig(
97106
enabled: enabled ?? this.enabled,
@@ -102,6 +111,9 @@ class AppReviewConfig extends Equatable {
102111
isNegativeFeedbackFollowUpEnabled:
103112
isNegativeFeedbackFollowUpEnabled ??
104113
this.isNegativeFeedbackFollowUpEnabled,
114+
isPositiveFeedbackFollowUpEnabled:
115+
isPositiveFeedbackFollowUpEnabled ??
116+
this.isPositiveFeedbackFollowUpEnabled,
105117
);
106118
}
107119
}

lib/src/models/config/app_review_config.g.dart

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/src/models/config/app_review_config_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ void main() {
1111
expect(appReviewConfigFixture, isA<AppReviewConfig>());
1212
expect(appReviewConfigFixture.enabled, isTrue);
1313
expect(appReviewConfigFixture.isNegativeFeedbackFollowUpEnabled, isTrue);
14+
expect(appReviewConfigFixture.isPositiveFeedbackFollowUpEnabled, isTrue);
1415
});
1516

1617
test('supports value equality', () {
@@ -34,11 +35,13 @@ void main() {
3435
enabled: false,
3536
positiveInteractionThreshold: 10,
3637
isNegativeFeedbackFollowUpEnabled: false,
38+
isPositiveFeedbackFollowUpEnabled: false,
3739
);
3840

3941
expect(updatedConfig.enabled, isFalse);
4042
expect(updatedConfig.positiveInteractionThreshold, 10);
4143
expect(updatedConfig.isNegativeFeedbackFollowUpEnabled, isFalse);
44+
expect(updatedConfig.isPositiveFeedbackFollowUpEnabled, isFalse);
4245
expect(updatedConfig, isNot(equals(appReviewConfigFixture)));
4346
});
4447
});

0 commit comments

Comments
 (0)