From 03309e4556b6e9d106fb8f69212d6e30ae27f1b5 Mon Sep 17 00:00:00 2001 From: ahmed alaa <154802748+ahmedAlaaInstabug@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:55:30 +0200 Subject: [PATCH 01/10] Release: v14.1.0 (#542) * fix: add support for newer gradle versions (#512) * feat: attach w3c header (#481) * feat: add android feature flag * fix: test cases * fix: test cases * fix: test cases * fix: test cases * fix: add more test cases * fix: add more test cases * fix: add more test cases * fix: add more test cases * Release: v14.0.0 (#532) * chore(android): bump sdk to v14.0.0 * chore(ios): bump sdk to v14.0.0 * Release: v14.0.0 * Release: v14.0.0 * Release: v14.0.0 * chore: change release date (#535) * Release: 14.1.0 (#539) * release: 14.1.0 * release: 14.1.0 * release: v14.1.0 * release: v14.1.0 --------- Co-authored-by: kholood --- CHANGELOG.md | 7 +++++++ android/build.gradle | 4 ++-- example/ios/Podfile.lock | 10 +++++----- example/pubspec.lock | 2 +- ios/instabug_flutter.podspec | 2 +- pubspec.yaml | 2 +- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70fdddc34..98aa7239f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [14.1.0](https://github.com/Instabug/Instabug-Flutter/compare/v14.0.0...v14.1.0) (January 2, 2025) + +### Changed + +- Bump Instabug Android SDK to v14.1.0 ([#539](https://github.com/Instabug/Instabug-Flutter/pull/539)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v14.1.0). +- Bump Instabug iOS SDK to v14.1.0 ([#539](https://github.com/Instabug/Instabug-Flutter/pull/539)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/14.1.0), + ## [14.0.0](https://github.com/Instabug/Instabug-Flutter/compare/v13.4.0...v14.0.0) (November 18, 2024) ### Added diff --git a/android/build.gradle b/android/build.gradle index ebaccfa51..e3b5d0bca 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ group 'com.instabug.flutter' -version '14.0.0' +version '14.1.0' buildscript { repositories { @@ -44,7 +44,7 @@ android { } dependencies { - api 'com.instabug.library:instabug:14.0.0' + api 'com.instabug.library:instabug:14.1.0' testImplementation 'junit:junit:4.13.2' testImplementation "org.mockito:mockito-inline:3.12.1" testImplementation "io.mockk:mockk:1.13.13" diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index f6cd7d9de..8072dd94f 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,9 +1,9 @@ PODS: - Flutter (1.0.0) - - Instabug (14.0.0) - - instabug_flutter (13.4.0): + - Instabug (14.1.0) + - instabug_flutter (14.0.0): - Flutter - - Instabug (= 14.0.0) + - Instabug (= 14.1.0) - OCMock (3.6) DEPENDENCIES: @@ -24,8 +24,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - Instabug: a0beffc01658773e2fac549845782f8937707dc4 - instabug_flutter: 71ec9d13d57a4958cabab59fe06792cade3bf754 + Instabug: 8cbca8974168c815658133e2813f5ac3a36f8e20 + instabug_flutter: a24751dfaedd29475da2af062d3e19d697438f72 OCMock: 5ea90566be239f179ba766fd9fbae5885040b992 PODFILE CHECKSUM: 8f7552fd115ace1988c3db54a69e4a123c448f84 diff --git a/example/pubspec.lock b/example/pubspec.lock index ebdc6b68c..6550e5302 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -107,7 +107,7 @@ packages: path: ".." relative: true source: path - version: "14.0.0" + version: "14.1.0" instabug_http_client: dependency: "direct main" description: diff --git a/ios/instabug_flutter.podspec b/ios/instabug_flutter.podspec index 4d610ddbf..f339d7fe0 100644 --- a/ios/instabug_flutter.podspec +++ b/ios/instabug_flutter.podspec @@ -17,6 +17,6 @@ Pod::Spec.new do |s| s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-framework "Flutter" -framework "Instabug"'} s.dependency 'Flutter' - s.dependency 'Instabug', '14.0.0' + s.dependency 'Instabug', '14.1.0' end diff --git a/pubspec.yaml b/pubspec.yaml index 05e312cdb..7b2a91e17 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: instabug_flutter -version: 14.0.0 +version: 14.1.0 description: >- Instabug empowers mobile teams to monitor, prioritize, and debug performance and stability issues throughout the app development lifecycle. From c2725a6d78856129c79adb4e3298dd39eb2287ec Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Sun, 9 Mar 2025 23:17:12 +0200 Subject: [PATCH 02/10] feat: add proactive bug reporting --- CHANGELOG.md | 7 +++ .../flutter/modules/BugReportingApi.java | 18 ++++++ .../instabug/flutter/BugReportingApiTest.java | 21 +++++++ .../ios/InstabugTests/BugReportingApiTests.m | 24 +++++++ example/ios/Podfile.lock | 2 +- example/lib/main.dart | 7 +++ example/pubspec.lock | 34 +++++----- ios/Classes/Modules/BugReportingApi.m | 9 +++ lib/instabug_flutter.dart | 2 +- .../models/proactive_reporting_config.dart | 62 +++++++++++++++++++ lib/src/modules/bug_reporting.dart | 9 +++ pigeons/bug_reporting.api.dart | 8 +-- test/bug_reporting_test.dart | 18 +++++- 13 files changed, 197 insertions(+), 24 deletions(-) create mode 100644 lib/src/models/proactive_reporting_config.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 98aa7239f..356858b33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [Unreleased](https://github.com/Instabug/Instabug-Flutter/compare/v14.1.0...dev) + +### Added + +- Add support proactive bug-reporting ([#471](https://github.com/Instabug/Instabug-Flutter/pull/471)). + + ## [14.1.0](https://github.com/Instabug/Instabug-Flutter/compare/v14.0.0...v14.1.0) (January 2, 2025) ### Changed diff --git a/android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java b/android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java index 56d91600b..7832e1830 100644 --- a/android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java +++ b/android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java @@ -6,6 +6,7 @@ import androidx.annotation.Nullable; import com.instabug.bug.BugReporting; +import com.instabug.bug.ProactiveReportingConfigs; import com.instabug.flutter.generated.BugReportingPigeon; import com.instabug.flutter.util.ArgsRegistry; import com.instabug.flutter.util.ThreadManager; @@ -186,4 +187,21 @@ public void setCommentMinimumCharacterCount(@NonNull Long limit, @Nullable List< } BugReporting.setCommentMinimumCharacterCount(limit.intValue(), reportTypesArray); } + + @Override + public void setProactiveReportingConfigurations(@NonNull Boolean enabled, @NonNull Long gapBetweenModals, @NonNull Long modalDelayAfterDetection) { + ThreadManager.runOnMainThread(new Runnable() { + @Override + public void run() { + ProactiveReportingConfigs configs = new ProactiveReportingConfigs.Builder() + .setGapBetweenModals(gapBetweenModals) // Time in seconds + .setModalDelayAfterDetection(modalDelayAfterDetection) // Time in seconds + .isEnabled(enabled) //Enable/disable + .build(); + BugReporting.setProactiveReportingConfigurations(configs); + + + } + }); + } } diff --git a/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java b/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java index 683b5f49a..b051a1550 100644 --- a/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java +++ b/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java @@ -1,6 +1,7 @@ package com.instabug.flutter; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; @@ -194,4 +195,24 @@ public void testSetCommentMinimumCharacterCount() { mBugReporting.verify(() -> BugReporting.setCommentMinimumCharacterCount(limit.intValue(), BugReporting.ReportType.BUG, BugReporting.ReportType.QUESTION)); } + + @Test + public void testSetProactiveReportingConfigurations() { + // given + boolean enabled = true; + long gapBetweekDialogs = 20; + long modeDelay = 30; + + // when + api.setProactiveReportingConfigurations(enabled, gapBetweekDialogs, modeDelay); + + // then + mBugReporting.verify(() -> BugReporting.setProactiveReportingConfigurations(argThat(config -> + config.getModalsGap() == gapBetweekDialogs && + config.getDetectionGap() == modeDelay && + config.isEnabled() == enabled + ))); + + + } } diff --git a/example/ios/InstabugTests/BugReportingApiTests.m b/example/ios/InstabugTests/BugReportingApiTests.m index 16f5fbee0..93d229031 100644 --- a/example/ios/InstabugTests/BugReportingApiTests.m +++ b/example/ios/InstabugTests/BugReportingApiTests.m @@ -174,5 +174,29 @@ - (void)testSetCommentMinimumCharacterCountGivenNoReportTypes { OCMVerify([self.mBugReporting setCommentMinimumCharacterCountForReportTypes:IBGBugReportingReportTypeBug | IBGBugReportingReportTypeFeedback | IBGBugReportingReportTypeQuestion withLimit:limit.intValue]); } +- (void) testSetProactiveReportingConfigurations { + BOOL enabled = true; + NSNumber* gap = @2; + NSNumber* delay = @4; + NSNumber *enabledNum = [NSNumber numberWithBool:enabled]; + FlutterError *error; + + IBGProactiveReportingConfigurations *configurations = [[IBGProactiveReportingConfigurations alloc] init]; + configurations.enabled = enabled; //Enable/disable + configurations.gapBetweenModals = gap; // Time in seconds + configurations.modalDelayAfterDetection = delay; // Time in seconds + + OCMStub([self.mBugReporting setProactiveReportingConfigurations:OCMOCK_ANY]); + + [self.api setProactiveReportingConfigurationsEnabled:enabledNum gapBetweenModals:gap modalDelayAfterDetection:delay error:&error]; + + // Verify that the method is called with the correct properties (using OCMArg to match properties) + OCMVerify([self.mBugReporting setProactiveReportingConfigurations:[OCMArg checkWithBlock:^BOOL(id obj) { + IBGProactiveReportingConfigurations *config = (IBGProactiveReportingConfigurations *)obj; + return config.enabled == enabled && + [config.gapBetweenModals isEqualToNumber:gap] && + [config.modalDelayAfterDetection isEqualToNumber:delay]; + }]]); +} @end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 8072dd94f..d29f0ccd0 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -25,7 +25,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 Instabug: 8cbca8974168c815658133e2813f5ac3a36f8e20 - instabug_flutter: a24751dfaedd29475da2af062d3e19d697438f72 + instabug_flutter: 6552acbd6ba0806e02ed478040d7b7e8a6d53121 OCMock: 5ea90566be239f179ba766fd9fbae5885040b992 PODFILE CHECKSUM: 8f7552fd115ace1988c3db54a69e4a123c448f84 diff --git a/example/lib/main.dart b/example/lib/main.dart index cda7ff3ec..3a8492a09 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -56,6 +56,13 @@ void main() { Zone.current.handleUncaughtError(details.exception, details.stack!); }; + BugReporting.setProactiveReportingConfigurations( + ProactiveReportingConfigsBuilder() + .setModalDelayAfterDetection(1) + .setGapBetweenModals(1) + .isEnabled(true) + .build()); + runApp(const MyApp()); }, CrashReporting.reportCrash, diff --git a/example/pubspec.lock b/example/pubspec.lock index 6550e5302..6ecb21e87 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.19.0" fake_async: dependency: transitive description: @@ -120,18 +120,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.7" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379" url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.8" leak_tracker_testing: dependency: transitive description: @@ -200,7 +200,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: @@ -213,10 +213,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.0" stream_channel: dependency: transitive description: @@ -229,10 +229,10 @@ packages: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.0" sync_http: dependency: transitive description: @@ -253,10 +253,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.3" typed_data: dependency: transitive description: @@ -277,18 +277,18 @@ packages: dependency: transitive description: name: vm_service - sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" + sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b url: "https://pub.dev" source: hosted - version: "14.2.5" + version: "14.3.0" webdriver: dependency: transitive description: name: webdriver - sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e" + sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8" url: "https://pub.dev" source: hosted - version: "3.0.3" + version: "3.0.4" sdks: dart: ">=3.5.0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/ios/Classes/Modules/BugReportingApi.m b/ios/Classes/Modules/BugReportingApi.m index 3c914b789..0e99108e9 100644 --- a/ios/Classes/Modules/BugReportingApi.m +++ b/ios/Classes/Modules/BugReportingApi.m @@ -165,4 +165,13 @@ - (void)setCommentMinimumCharacterCountLimit:(NSNumber *)limit reportTypes:(null [IBGBugReporting setCommentMinimumCharacterCountForReportTypes:resolvedTypes withLimit:limit.intValue]; } +- (void)setProactiveReportingConfigurationsEnabled:(nonnull NSNumber *)enabled gapBetweenModals:(nonnull NSNumber *)gapBetweenModals modalDelayAfterDetection:(nonnull NSNumber *)modalDelayAfterDetection error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error { + IBGProactiveReportingConfigurations *configurations = [[IBGProactiveReportingConfigurations alloc] init]; + configurations.enabled = [enabled boolValue]; //Enable/disable + configurations.gapBetweenModals = gapBetweenModals; // Time in seconds + configurations.modalDelayAfterDetection = modalDelayAfterDetection; // Time in seconds + [IBGBugReporting setProactiveReportingConfigurations:configurations]; +} + + @end diff --git a/lib/instabug_flutter.dart b/lib/instabug_flutter.dart index e38545897..797073f71 100644 --- a/lib/instabug_flutter.dart +++ b/lib/instabug_flutter.dart @@ -3,9 +3,9 @@ export 'src/models/crash_data.dart'; export 'src/models/exception_data.dart'; export 'src/models/feature_flag.dart'; export 'src/models/network_data.dart'; +export 'src/models/proactive_reporting_config.dart'; export 'src/models/trace.dart'; export 'src/models/w3c_header.dart'; - // Modules export 'src/modules/apm.dart'; export 'src/modules/bug_reporting.dart'; diff --git a/lib/src/models/proactive_reporting_config.dart b/lib/src/models/proactive_reporting_config.dart new file mode 100644 index 000000000..2fa6f6add --- /dev/null +++ b/lib/src/models/proactive_reporting_config.dart @@ -0,0 +1,62 @@ +import 'package:flutter/foundation.dart'; + +class ProactiveReportingConfigs { + final int gapBetweenModals; // Time in seconds + final int modalDelayAfterDetection; // Time in seconds + final bool enabled; + + // Private constructor to ensure it can only be created through the builder + const ProactiveReportingConfigs._({ + required this.gapBetweenModals, + required this.modalDelayAfterDetection, + required this.enabled, + }); +} + +// Builder class for ProactiveReportingConfigs +class ProactiveReportingConfigsBuilder { + int gapBetweenModals = 30; // Default: 30 seconds + int modalDelayAfterDetection = 15; // Default: 15 seconds + bool enabled = true; // Default: enabled + + // Logger method to handle logging + void _logWarning(String message) { + if (kDebugMode) { + print('Warning: $message'); + } + } + + /// Controls the time gap between showing 2 proactive reporting dialogs in seconds + ProactiveReportingConfigsBuilder setGapBetweenModals(int gap) { + if (gap <= 0) { + _logWarning('gapBetweenModals must be a positive number. Using default value of 30 seconds.'); + return this; + } + gapBetweenModals = gap; + return this; + } + + /// Controls the time gap between detecting a frustrating experience + ProactiveReportingConfigsBuilder setModalDelayAfterDetection(int delay) { + if (delay <= 0) { + _logWarning('modalDelayAfterDetection must be a positive number. Using default value of 15 seconds.'); + return this; + } + modalDelayAfterDetection = delay; + return this; + } + + /// Controls the state of the feature + ProactiveReportingConfigsBuilder isEnabled(bool value) { + enabled = value; + return this; + } + + ProactiveReportingConfigs build() { + return ProactiveReportingConfigs._( + gapBetweenModals: gapBetweenModals, + modalDelayAfterDetection: modalDelayAfterDetection, + enabled: enabled, + ); + } +} diff --git a/lib/src/modules/bug_reporting.dart b/lib/src/modules/bug_reporting.dart index bf2bca82c..f96173bd9 100644 --- a/lib/src/modules/bug_reporting.dart +++ b/lib/src/modules/bug_reporting.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:instabug_flutter/src/generated/bug_reporting.api.g.dart'; +import 'package:instabug_flutter/src/models/proactive_reporting_config.dart'; import 'package:instabug_flutter/src/modules/instabug.dart'; import 'package:instabug_flutter/src/utils/enum_converter.dart'; import 'package:instabug_flutter/src/utils/ibg_build_info.dart'; @@ -255,4 +256,12 @@ class BugReporting implements BugReportingFlutterApi { reportTypes?.mapToString(), ); } + + /// prompts end users to submit their feedback after our SDK automatically detects a frustrating experience. + /// [config] configuration of proActive bug report. + static Future setProactiveReportingConfigurations( + ProactiveReportingConfigs config,) async { + _host.setProactiveReportingConfigurations(config.enabled, + config.gapBetweenModals, config.modalDelayAfterDetection); + } } diff --git a/pigeons/bug_reporting.api.dart b/pigeons/bug_reporting.api.dart index faa180893..0c9d705de 100644 --- a/pigeons/bug_reporting.api.dart +++ b/pigeons/bug_reporting.api.dart @@ -28,8 +28,8 @@ abstract class BugReportingHostApi { void bindOnInvokeCallback(); void bindOnDismissCallback(); void setDisclaimerText(String text); - void setCommentMinimumCharacterCount( - int limit, - List? reportTypes, - ); + void setCommentMinimumCharacterCount(int limit, + List? reportTypes,); + void setProactiveReportingConfigurations(bool enabled, int gapBetweenModals, + int modalDelayAfterDetection); } diff --git a/test/bug_reporting_test.dart b/test/bug_reporting_test.dart index 12dfd6062..e0422252b 100644 --- a/test/bug_reporting_test.dart +++ b/test/bug_reporting_test.dart @@ -2,6 +2,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:instabug_flutter/instabug_flutter.dart'; import 'package:instabug_flutter/src/generated/bug_reporting.api.g.dart'; +import 'package:instabug_flutter/src/models/proactive_reporting_config.dart'; import 'package:instabug_flutter/src/utils/enum_converter.dart'; import 'package:instabug_flutter/src/utils/ibg_build_info.dart'; import 'package:mockito/annotations.dart'; @@ -99,7 +100,7 @@ void main() { test( '[setVideoRecordingFloatingButtonPosition] should call host method', - () async { + () async { const position = Position.topLeft; await BugReporting.setVideoRecordingFloatingButtonPosition(position); @@ -199,4 +200,19 @@ void main() { mHost.setCommentMinimumCharacterCount(count, reportTypes.mapToString()), ).called(1); }); + + test('[setProactiveReportingConfigurations] should call host method', + () async { + await BugReporting.setProactiveReportingConfigurations( + ProactiveReportingConfigsBuilder() + .setGapBetweenModals(1) + .setModalDelayAfterDetection(1) + .isEnabled(true) + .build()); + + verify( + mHost.setProactiveReportingConfigurations( + true, 1, 1 + )).called(1); + }); } From c3c3ddc3cebdd889601609f9cd433b9b9b3fbb6f Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Sun, 9 Mar 2025 23:18:11 +0200 Subject: [PATCH 03/10] feat: add proactive bug reporting --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 356858b33..f4ed59ec7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added -- Add support proactive bug-reporting ([#471](https://github.com/Instabug/Instabug-Flutter/pull/471)). +- Add support proactive bug-reporting ([#559](https://github.com/Instabug/Instabug-Flutter/pull/559)). ## [14.1.0](https://github.com/Instabug/Instabug-Flutter/compare/v14.0.0...v14.1.0) (January 2, 2025) From fbdfe4b2228ad13f3971ae0938073be6959687fe Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Sun, 9 Mar 2025 23:21:49 +0200 Subject: [PATCH 04/10] feat: add proactive bug reporting --- .../models/proactive_reporting_config.dart | 6 +++-- lib/src/modules/bug_reporting.dart | 3 ++- pigeons/bug_reporting.api.dart | 10 +++++--- test/bug_reporting_test.dart | 25 ++++++++----------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/lib/src/models/proactive_reporting_config.dart b/lib/src/models/proactive_reporting_config.dart index 2fa6f6add..a52c17d28 100644 --- a/lib/src/models/proactive_reporting_config.dart +++ b/lib/src/models/proactive_reporting_config.dart @@ -29,7 +29,8 @@ class ProactiveReportingConfigsBuilder { /// Controls the time gap between showing 2 proactive reporting dialogs in seconds ProactiveReportingConfigsBuilder setGapBetweenModals(int gap) { if (gap <= 0) { - _logWarning('gapBetweenModals must be a positive number. Using default value of 30 seconds.'); + _logWarning( + 'gapBetweenModals must be a positive number. Using default value of 30 seconds.'); return this; } gapBetweenModals = gap; @@ -39,7 +40,8 @@ class ProactiveReportingConfigsBuilder { /// Controls the time gap between detecting a frustrating experience ProactiveReportingConfigsBuilder setModalDelayAfterDetection(int delay) { if (delay <= 0) { - _logWarning('modalDelayAfterDetection must be a positive number. Using default value of 15 seconds.'); + _logWarning( + 'modalDelayAfterDetection must be a positive number. Using default value of 15 seconds.'); return this; } modalDelayAfterDetection = delay; diff --git a/lib/src/modules/bug_reporting.dart b/lib/src/modules/bug_reporting.dart index f96173bd9..0c2b029ef 100644 --- a/lib/src/modules/bug_reporting.dart +++ b/lib/src/modules/bug_reporting.dart @@ -260,7 +260,8 @@ class BugReporting implements BugReportingFlutterApi { /// prompts end users to submit their feedback after our SDK automatically detects a frustrating experience. /// [config] configuration of proActive bug report. static Future setProactiveReportingConfigurations( - ProactiveReportingConfigs config,) async { + ProactiveReportingConfigs config, + ) async { _host.setProactiveReportingConfigurations(config.enabled, config.gapBetweenModals, config.modalDelayAfterDetection); } diff --git a/pigeons/bug_reporting.api.dart b/pigeons/bug_reporting.api.dart index 0c9d705de..5a96117af 100644 --- a/pigeons/bug_reporting.api.dart +++ b/pigeons/bug_reporting.api.dart @@ -28,8 +28,10 @@ abstract class BugReportingHostApi { void bindOnInvokeCallback(); void bindOnDismissCallback(); void setDisclaimerText(String text); - void setCommentMinimumCharacterCount(int limit, - List? reportTypes,); - void setProactiveReportingConfigurations(bool enabled, int gapBetweenModals, - int modalDelayAfterDetection); + void setCommentMinimumCharacterCount( + int limit, + List? reportTypes, + ); + void setProactiveReportingConfigurations( + bool enabled, int gapBetweenModals, int modalDelayAfterDetection); } diff --git a/test/bug_reporting_test.dart b/test/bug_reporting_test.dart index e0422252b..c899fc1d1 100644 --- a/test/bug_reporting_test.dart +++ b/test/bug_reporting_test.dart @@ -100,7 +100,7 @@ void main() { test( '[setVideoRecordingFloatingButtonPosition] should call host method', - () async { + () async { const position = Position.topLeft; await BugReporting.setVideoRecordingFloatingButtonPosition(position); @@ -202,17 +202,14 @@ void main() { }); test('[setProactiveReportingConfigurations] should call host method', - () async { - await BugReporting.setProactiveReportingConfigurations( - ProactiveReportingConfigsBuilder() - .setGapBetweenModals(1) - .setModalDelayAfterDetection(1) - .isEnabled(true) - .build()); - - verify( - mHost.setProactiveReportingConfigurations( - true, 1, 1 - )).called(1); - }); + () async { + await BugReporting.setProactiveReportingConfigurations( + ProactiveReportingConfigsBuilder() + .setGapBetweenModals(1) + .setModalDelayAfterDetection(1) + .isEnabled(true) + .build()); + + verify(mHost.setProactiveReportingConfigurations(true, 1, 1)).called(1); + }); } From 0221b0120173a5c5af2734fd51226405e7587d0b Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Mon, 10 Mar 2025 00:20:29 +0200 Subject: [PATCH 05/10] feat: add proactive bug reporting --- lib/src/models/proactive_reporting_config.dart | 4 ++-- lib/src/modules/bug_reporting.dart | 2 +- pigeons/bug_reporting.api.dart | 2 +- test/bug_reporting_test.dart | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/src/models/proactive_reporting_config.dart b/lib/src/models/proactive_reporting_config.dart index a52c17d28..39eafbed8 100644 --- a/lib/src/models/proactive_reporting_config.dart +++ b/lib/src/models/proactive_reporting_config.dart @@ -30,7 +30,7 @@ class ProactiveReportingConfigsBuilder { ProactiveReportingConfigsBuilder setGapBetweenModals(int gap) { if (gap <= 0) { _logWarning( - 'gapBetweenModals must be a positive number. Using default value of 30 seconds.'); + 'gapBetweenModals must be a positive number. Using default value of 30 seconds.',); return this; } gapBetweenModals = gap; @@ -41,7 +41,7 @@ class ProactiveReportingConfigsBuilder { ProactiveReportingConfigsBuilder setModalDelayAfterDetection(int delay) { if (delay <= 0) { _logWarning( - 'modalDelayAfterDetection must be a positive number. Using default value of 15 seconds.'); + 'modalDelayAfterDetection must be a positive number. Using default value of 15 seconds.',); return this; } modalDelayAfterDetection = delay; diff --git a/lib/src/modules/bug_reporting.dart b/lib/src/modules/bug_reporting.dart index 0c2b029ef..d437784c4 100644 --- a/lib/src/modules/bug_reporting.dart +++ b/lib/src/modules/bug_reporting.dart @@ -263,6 +263,6 @@ class BugReporting implements BugReportingFlutterApi { ProactiveReportingConfigs config, ) async { _host.setProactiveReportingConfigurations(config.enabled, - config.gapBetweenModals, config.modalDelayAfterDetection); + config.gapBetweenModals, config.modalDelayAfterDetection,); } } diff --git a/pigeons/bug_reporting.api.dart b/pigeons/bug_reporting.api.dart index 5a96117af..6317e6ca0 100644 --- a/pigeons/bug_reporting.api.dart +++ b/pigeons/bug_reporting.api.dart @@ -33,5 +33,5 @@ abstract class BugReportingHostApi { List? reportTypes, ); void setProactiveReportingConfigurations( - bool enabled, int gapBetweenModals, int modalDelayAfterDetection); + bool enabled, int gapBetweenModals, int modalDelayAfterDetection,); } diff --git a/test/bug_reporting_test.dart b/test/bug_reporting_test.dart index c899fc1d1..c84be772c 100644 --- a/test/bug_reporting_test.dart +++ b/test/bug_reporting_test.dart @@ -2,7 +2,6 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:instabug_flutter/instabug_flutter.dart'; import 'package:instabug_flutter/src/generated/bug_reporting.api.g.dart'; -import 'package:instabug_flutter/src/models/proactive_reporting_config.dart'; import 'package:instabug_flutter/src/utils/enum_converter.dart'; import 'package:instabug_flutter/src/utils/ibg_build_info.dart'; import 'package:mockito/annotations.dart'; @@ -208,7 +207,7 @@ void main() { .setGapBetweenModals(1) .setModalDelayAfterDetection(1) .isEnabled(true) - .build()); + .build(),); verify(mHost.setProactiveReportingConfigurations(true, 1, 1)).called(1); }); From be719939e530d3791d3a66b4e8f4705d981d5277 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Mon, 10 Mar 2025 00:23:42 +0200 Subject: [PATCH 06/10] feat: add proactive bug reporting --- lib/src/models/proactive_reporting_config.dart | 6 ++++-- lib/src/modules/bug_reporting.dart | 7 +++++-- pigeons/bug_reporting.api.dart | 5 ++++- test/bug_reporting_test.dart | 11 ++++++----- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/src/models/proactive_reporting_config.dart b/lib/src/models/proactive_reporting_config.dart index 39eafbed8..28f7fe087 100644 --- a/lib/src/models/proactive_reporting_config.dart +++ b/lib/src/models/proactive_reporting_config.dart @@ -30,7 +30,8 @@ class ProactiveReportingConfigsBuilder { ProactiveReportingConfigsBuilder setGapBetweenModals(int gap) { if (gap <= 0) { _logWarning( - 'gapBetweenModals must be a positive number. Using default value of 30 seconds.',); + 'gapBetweenModals must be a positive number. Using default value of 30 seconds.', + ); return this; } gapBetweenModals = gap; @@ -41,7 +42,8 @@ class ProactiveReportingConfigsBuilder { ProactiveReportingConfigsBuilder setModalDelayAfterDetection(int delay) { if (delay <= 0) { _logWarning( - 'modalDelayAfterDetection must be a positive number. Using default value of 15 seconds.',); + 'modalDelayAfterDetection must be a positive number. Using default value of 15 seconds.', + ); return this; } modalDelayAfterDetection = delay; diff --git a/lib/src/modules/bug_reporting.dart b/lib/src/modules/bug_reporting.dart index d437784c4..416d38cdc 100644 --- a/lib/src/modules/bug_reporting.dart +++ b/lib/src/modules/bug_reporting.dart @@ -262,7 +262,10 @@ class BugReporting implements BugReportingFlutterApi { static Future setProactiveReportingConfigurations( ProactiveReportingConfigs config, ) async { - _host.setProactiveReportingConfigurations(config.enabled, - config.gapBetweenModals, config.modalDelayAfterDetection,); + _host.setProactiveReportingConfigurations( + config.enabled, + config.gapBetweenModals, + config.modalDelayAfterDetection, + ); } } diff --git a/pigeons/bug_reporting.api.dart b/pigeons/bug_reporting.api.dart index 6317e6ca0..a83bb2d23 100644 --- a/pigeons/bug_reporting.api.dart +++ b/pigeons/bug_reporting.api.dart @@ -33,5 +33,8 @@ abstract class BugReportingHostApi { List? reportTypes, ); void setProactiveReportingConfigurations( - bool enabled, int gapBetweenModals, int modalDelayAfterDetection,); + bool enabled, + int gapBetweenModals, + int modalDelayAfterDetection, + ); } diff --git a/test/bug_reporting_test.dart b/test/bug_reporting_test.dart index c84be772c..40a4923ee 100644 --- a/test/bug_reporting_test.dart +++ b/test/bug_reporting_test.dart @@ -203,11 +203,12 @@ void main() { test('[setProactiveReportingConfigurations] should call host method', () async { await BugReporting.setProactiveReportingConfigurations( - ProactiveReportingConfigsBuilder() - .setGapBetweenModals(1) - .setModalDelayAfterDetection(1) - .isEnabled(true) - .build(),); + ProactiveReportingConfigsBuilder() + .setGapBetweenModals(1) + .setModalDelayAfterDetection(1) + .isEnabled(true) + .build(), + ); verify(mHost.setProactiveReportingConfigurations(true, 1, 1)).called(1); }); From 9bdf51308dc63995122d09f2d6e8cb554e28672f Mon Sep 17 00:00:00 2001 From: Andrew Amin <160974398+AndrewAminInstabug@users.noreply.github.com> Date: Thu, 13 Mar 2025 11:13:03 +0200 Subject: [PATCH 07/10] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f69df2e6..fc0a0e0f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added -- Add support proactive bug-reporting ([#559](https://github.com/Instabug/Instabug-Flutter/pull/559)). +- Add support for proactive bug-reporting ([#559](https://github.com/Instabug/Instabug-Flutter/pull/559)). ## [14.1.0](https://github.com/Instabug/Instabug-Flutter/compare/v14.0.0...v14.1.0) (January 2, 2025) From 608260238d102939e8f5bb7e8fd453db2b42535e Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Mon, 17 Mar 2025 20:38:14 +0200 Subject: [PATCH 08/10] feat: remove builder --- .../instabug/flutter/BugReportingApiTest.java | 6 +- example/lib/main.dart | 6 +- .../models/proactive_reporting_config.dart | 61 ++----------------- test/bug_reporting_test.dart | 9 ++- 4 files changed, 12 insertions(+), 70 deletions(-) diff --git a/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java b/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java index b051a1550..6d8384eb8 100644 --- a/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java +++ b/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java @@ -200,15 +200,15 @@ public void testSetCommentMinimumCharacterCount() { public void testSetProactiveReportingConfigurations() { // given boolean enabled = true; - long gapBetweekDialogs = 20; + long gapBetweenDialogs = 20; long modeDelay = 30; // when - api.setProactiveReportingConfigurations(enabled, gapBetweekDialogs, modeDelay); + api.setProactiveReportingConfigurations(enabled, gapBetweenDialogs, modeDelay); // then mBugReporting.verify(() -> BugReporting.setProactiveReportingConfigurations(argThat(config -> - config.getModalsGap() == gapBetweekDialogs && + config.getModalsGap() == gapBetweenDialogs && config.getDetectionGap() == modeDelay && config.isEnabled() == enabled ))); diff --git a/example/lib/main.dart b/example/lib/main.dart index 9ee39cec3..5f6af8b89 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -58,11 +58,7 @@ void main() { }; BugReporting.setProactiveReportingConfigurations( - ProactiveReportingConfigsBuilder() - .setModalDelayAfterDetection(1) - .setGapBetweenModals(1) - .isEnabled(true) - .build()); + ProactiveReportingConfigs()); runApp(const MyApp()); }, diff --git a/lib/src/models/proactive_reporting_config.dart b/lib/src/models/proactive_reporting_config.dart index 28f7fe087..d4652f339 100644 --- a/lib/src/models/proactive_reporting_config.dart +++ b/lib/src/models/proactive_reporting_config.dart @@ -5,62 +5,9 @@ class ProactiveReportingConfigs { final int modalDelayAfterDetection; // Time in seconds final bool enabled; - // Private constructor to ensure it can only be created through the builder - const ProactiveReportingConfigs._({ - required this.gapBetweenModals, - required this.modalDelayAfterDetection, - required this.enabled, + const ProactiveReportingConfigs({ + this.gapBetweenModals = 24, + this.modalDelayAfterDetection = 20, + this.enabled = true, }); } - -// Builder class for ProactiveReportingConfigs -class ProactiveReportingConfigsBuilder { - int gapBetweenModals = 30; // Default: 30 seconds - int modalDelayAfterDetection = 15; // Default: 15 seconds - bool enabled = true; // Default: enabled - - // Logger method to handle logging - void _logWarning(String message) { - if (kDebugMode) { - print('Warning: $message'); - } - } - - /// Controls the time gap between showing 2 proactive reporting dialogs in seconds - ProactiveReportingConfigsBuilder setGapBetweenModals(int gap) { - if (gap <= 0) { - _logWarning( - 'gapBetweenModals must be a positive number. Using default value of 30 seconds.', - ); - return this; - } - gapBetweenModals = gap; - return this; - } - - /// Controls the time gap between detecting a frustrating experience - ProactiveReportingConfigsBuilder setModalDelayAfterDetection(int delay) { - if (delay <= 0) { - _logWarning( - 'modalDelayAfterDetection must be a positive number. Using default value of 15 seconds.', - ); - return this; - } - modalDelayAfterDetection = delay; - return this; - } - - /// Controls the state of the feature - ProactiveReportingConfigsBuilder isEnabled(bool value) { - enabled = value; - return this; - } - - ProactiveReportingConfigs build() { - return ProactiveReportingConfigs._( - gapBetweenModals: gapBetweenModals, - modalDelayAfterDetection: modalDelayAfterDetection, - enabled: enabled, - ); - } -} diff --git a/test/bug_reporting_test.dart b/test/bug_reporting_test.dart index 40a4923ee..134278893 100644 --- a/test/bug_reporting_test.dart +++ b/test/bug_reporting_test.dart @@ -203,11 +203,10 @@ void main() { test('[setProactiveReportingConfigurations] should call host method', () async { await BugReporting.setProactiveReportingConfigurations( - ProactiveReportingConfigsBuilder() - .setGapBetweenModals(1) - .setModalDelayAfterDetection(1) - .isEnabled(true) - .build(), + const ProactiveReportingConfigs( + gapBetweenModals: 1, + modalDelayAfterDetection: 1, + ), ); verify(mHost.setProactiveReportingConfigurations(true, 1, 1)).called(1); From fe4786e67b3151c7f0a9dcf14446820ffbfdb0ac Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Mon, 17 Mar 2025 20:46:23 +0200 Subject: [PATCH 09/10] feat: remove builder --- example/lib/main.dart | 2 +- lib/src/models/proactive_reporting_config.dart | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 5f6af8b89..c36757001 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -58,7 +58,7 @@ void main() { }; BugReporting.setProactiveReportingConfigurations( - ProactiveReportingConfigs()); + const ProactiveReportingConfigs()); runApp(const MyApp()); }, diff --git a/lib/src/models/proactive_reporting_config.dart b/lib/src/models/proactive_reporting_config.dart index d4652f339..a9b6fa72e 100644 --- a/lib/src/models/proactive_reporting_config.dart +++ b/lib/src/models/proactive_reporting_config.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; class ProactiveReportingConfigs { final int gapBetweenModals; // Time in seconds From dbee49087946f245f9e0004575375e461c9ffa8e Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Mon, 17 Mar 2025 20:49:11 +0200 Subject: [PATCH 10/10] feat: remove builder --- example/lib/main.dart | 2 +- lib/src/models/proactive_reporting_config.dart | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index c36757001..55bb6ad33 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -58,7 +58,7 @@ void main() { }; BugReporting.setProactiveReportingConfigurations( - const ProactiveReportingConfigs()); + const ProactiveReportingConfigs()); runApp(const MyApp()); }, diff --git a/lib/src/models/proactive_reporting_config.dart b/lib/src/models/proactive_reporting_config.dart index a9b6fa72e..a60fd6df7 100644 --- a/lib/src/models/proactive_reporting_config.dart +++ b/lib/src/models/proactive_reporting_config.dart @@ -1,4 +1,3 @@ - class ProactiveReportingConfigs { final int gapBetweenModals; // Time in seconds final int modalDelayAfterDetection; // Time in seconds