diff --git a/CHANGELOG.md b/CHANGELOG.md index 39cf5413e..5dd2272e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # Changelog -## [Unreleased](https://github.com/Instabug/Instabug-Flutter/compare/v12.7.0...dev) +## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.0...dev) ### Added +- Adds custom app rating api ([#453](https://github.com/Instabug/Instabug-Flutter/pull/453)) - Add `SessionReplay.getSessionReplayLink` API which retrieves the current session's replay link ([#445](hhttps://github.com/Instabug/Instabug-Flutter/pull/445)). ## [12.7.0](https://github.com/Instabug/Instabug-Flutter/compare/v12.5.0...v12.7.0) (February 15, 2024) diff --git a/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java b/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java index 80e9cfa67..5cfc178e8 100644 --- a/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java +++ b/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java @@ -76,7 +76,7 @@ public void setCurrentPlatform() { @Override public void setEnabled(@NonNull Boolean isEnabled) { try { - if(isEnabled) + if (isEnabled) Instabug.enable(); else Instabug.disable(); @@ -171,13 +171,12 @@ public void setSessionProfilerEnabled(@NonNull Boolean enabled) { @Override public void setValueForStringWithKey(@NonNull String value, @NonNull String key) { - if(ArgsRegistry.placeholders.containsKey(key)) { + if (ArgsRegistry.placeholders.containsKey(key)) { InstabugCustomTextPlaceHolder.Key resolvedKey = ArgsRegistry.placeholders.get(key); placeHolder.set(resolvedKey, value); Instabug.setCustomTextPlaceHolders(placeHolder); - } - else { - Log.i(TAG, "Instabug: " + key + " is only relevant to iOS."); + } else { + Log.i(TAG, "Instabug: " + key + " is only relevant to iOS."); } } @@ -397,4 +396,9 @@ public void networkLog(@NonNull Map data) { Log.e(TAG, "Network logging failed"); } } + + @Override + public void willRedirectToStore() { + Instabug.willRedirectToStore(); + } } diff --git a/android/src/test/java/com/instabug/flutter/InstabugApiTest.java b/android/src/test/java/com/instabug/flutter/InstabugApiTest.java index 140daab65..b542259b6 100644 --- a/android/src/test/java/com/instabug/flutter/InstabugApiTest.java +++ b/android/src/test/java/com/instabug/flutter/InstabugApiTest.java @@ -493,7 +493,7 @@ public void testAddFileAttachmentWithURLWhenFileDoesNotExists() { @Test public void testAddFileAttachmentWithData() { - byte[] data = new byte[] {65, 100}; + byte[] data = new byte[]{65, 100}; String name = "Issue"; api.addFileAttachmentWithData(data, name); @@ -549,4 +549,10 @@ public void testNetworkLog() { mJSONObject.close(); } + + @Test + public void testWillRedirectToStore() { + api.willRedirectToStore(); + mInstabug.verify(Instabug::willRedirectToStore); + } } diff --git a/example/ios/InstabugTests/InstabugApiTests.m b/example/ios/InstabugTests/InstabugApiTests.m index 3b55e0c3f..9f9684120 100644 --- a/example/ios/InstabugTests/InstabugApiTests.m +++ b/example/ios/InstabugTests/InstabugApiTests.m @@ -398,4 +398,11 @@ - (void)testNetworkLog { ]); } +- (void)testWillRedirectToAppStore { + FlutterError *error; + [self.api willRedirectToStoreWithError:&error]; + + OCMVerify([self.mInstabug willRedirectToAppStore]); +} + @end diff --git a/ios/Classes/Modules/InstabugApi.m b/ios/Classes/Modules/InstabugApi.m index 7def622f0..493d1fc19 100644 --- a/ios/Classes/Modules/InstabugApi.m +++ b/ios/Classes/Modules/InstabugApi.m @@ -305,4 +305,8 @@ - (void)networkLogData:(NSDictionary *)data error:(FlutterError } } +- (void)willRedirectToStoreWithError:(FlutterError * _Nullable __autoreleasing *)error { + [Instabug willRedirectToAppStore]; +} + @end diff --git a/lib/src/modules/instabug.dart b/lib/src/modules/instabug.dart index 54450c1e5..ac6c49698 100644 --- a/lib/src/modules/instabug.dart +++ b/lib/src/modules/instabug.dart @@ -412,4 +412,13 @@ class Instabug { final darkKey = await dark.obtainKey(configuration); return _host.setCustomBrandingImage(lightKey.name, darkKey.name); } + + /// Allows detection of app review sessions which are submitted through custom prompts. + /// + /// Use this when utilizing a custom app rating prompt. It should be called + /// once the user clicks on the Call to Action (CTA) that redirects them to the app store. + /// Helps track session data for insights on user interactions during review submission. + static Future willRedirectToStore() async { + return _host.willRedirectToStore(); + } } diff --git a/pigeons/instabug.api.dart b/pigeons/instabug.api.dart index 2d1308ce1..7113f164c 100644 --- a/pigeons/instabug.api.dart +++ b/pigeons/instabug.api.dart @@ -54,4 +54,6 @@ abstract class InstabugHostApi { void clearFileAttachments(); void networkLog(Map data); + + void willRedirectToStore(); } diff --git a/test/instabug_test.dart b/test/instabug_test.dart index 8f623796e..78a370963 100644 --- a/test/instabug_test.dart +++ b/test/instabug_test.dart @@ -383,4 +383,13 @@ void main() { mHost.clearFileAttachments(), ).called(1); }); + + test('[willRedirectToStore] should call host method', () async { + await Instabug.willRedirectToStore(); + + //assert + verify( + mHost.willRedirectToStore(), + ).called(1); + }); }