Skip to content

Commit 08a6fdd

Browse files
Merge pull request #453 from Instabug/feat/map_custom_app_rating_api
feat: map custom app rating api
2 parents ae1f238 + 5a190d5 commit 08a6fdd

File tree

8 files changed

+49
-7
lines changed

8 files changed

+49
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Changelog
22

3-
## [Unreleased](https://github.com/Instabug/Instabug-Flutter/compare/v12.7.0...dev)
3+
## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.0...dev)
44

55
### Added
66

7+
- Adds custom app rating api ([#453](https://github.com/Instabug/Instabug-Flutter/pull/453))
78
- Add `SessionReplay.getSessionReplayLink` API which retrieves the current session's replay link ([#445](hhttps://github.com/Instabug/Instabug-Flutter/pull/445)).
89

910
## [12.7.0](https://github.com/Instabug/Instabug-Flutter/compare/v12.5.0...v12.7.0) (February 15, 2024)

android/src/main/java/com/instabug/flutter/modules/InstabugApi.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void setCurrentPlatform() {
7676
@Override
7777
public void setEnabled(@NonNull Boolean isEnabled) {
7878
try {
79-
if(isEnabled)
79+
if (isEnabled)
8080
Instabug.enable();
8181
else
8282
Instabug.disable();
@@ -171,13 +171,12 @@ public void setSessionProfilerEnabled(@NonNull Boolean enabled) {
171171

172172
@Override
173173
public void setValueForStringWithKey(@NonNull String value, @NonNull String key) {
174-
if(ArgsRegistry.placeholders.containsKey(key)) {
174+
if (ArgsRegistry.placeholders.containsKey(key)) {
175175
InstabugCustomTextPlaceHolder.Key resolvedKey = ArgsRegistry.placeholders.get(key);
176176
placeHolder.set(resolvedKey, value);
177177
Instabug.setCustomTextPlaceHolders(placeHolder);
178-
}
179-
else {
180-
Log.i(TAG, "Instabug: " + key + " is only relevant to iOS.");
178+
} else {
179+
Log.i(TAG, "Instabug: " + key + " is only relevant to iOS.");
181180
}
182181
}
183182

@@ -397,4 +396,9 @@ public void networkLog(@NonNull Map<String, Object> data) {
397396
Log.e(TAG, "Network logging failed");
398397
}
399398
}
399+
400+
@Override
401+
public void willRedirectToStore() {
402+
Instabug.willRedirectToStore();
403+
}
400404
}

android/src/test/java/com/instabug/flutter/InstabugApiTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ public void testAddFileAttachmentWithURLWhenFileDoesNotExists() {
493493

494494
@Test
495495
public void testAddFileAttachmentWithData() {
496-
byte[] data = new byte[] {65, 100};
496+
byte[] data = new byte[]{65, 100};
497497
String name = "Issue";
498498

499499
api.addFileAttachmentWithData(data, name);
@@ -549,4 +549,10 @@ public void testNetworkLog() {
549549

550550
mJSONObject.close();
551551
}
552+
553+
@Test
554+
public void testWillRedirectToStore() {
555+
api.willRedirectToStore();
556+
mInstabug.verify(Instabug::willRedirectToStore);
557+
}
552558
}

example/ios/InstabugTests/InstabugApiTests.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,4 +398,11 @@ - (void)testNetworkLog {
398398
]);
399399
}
400400

401+
- (void)testWillRedirectToAppStore {
402+
FlutterError *error;
403+
[self.api willRedirectToStoreWithError:&error];
404+
405+
OCMVerify([self.mInstabug willRedirectToAppStore]);
406+
}
407+
401408
@end

ios/Classes/Modules/InstabugApi.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,8 @@ - (void)networkLogData:(NSDictionary<NSString *, id> *)data error:(FlutterError
305305
}
306306
}
307307

308+
- (void)willRedirectToStoreWithError:(FlutterError * _Nullable __autoreleasing *)error {
309+
[Instabug willRedirectToAppStore];
310+
}
311+
308312
@end

lib/src/modules/instabug.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,13 @@ class Instabug {
412412
final darkKey = await dark.obtainKey(configuration);
413413
return _host.setCustomBrandingImage(lightKey.name, darkKey.name);
414414
}
415+
416+
/// Allows detection of app review sessions which are submitted through custom prompts.
417+
///
418+
/// Use this when utilizing a custom app rating prompt. It should be called
419+
/// once the user clicks on the Call to Action (CTA) that redirects them to the app store.
420+
/// Helps track session data for insights on user interactions during review submission.
421+
static Future<void> willRedirectToStore() async {
422+
return _host.willRedirectToStore();
423+
}
415424
}

pigeons/instabug.api.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,6 @@ abstract class InstabugHostApi {
5454
void clearFileAttachments();
5555

5656
void networkLog(Map<String, Object> data);
57+
58+
void willRedirectToStore();
5759
}

test/instabug_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,4 +383,13 @@ void main() {
383383
mHost.clearFileAttachments(),
384384
).called(1);
385385
});
386+
387+
test('[willRedirectToStore] should call host method', () async {
388+
await Instabug.willRedirectToStore();
389+
390+
//assert
391+
verify(
392+
mHost.willRedirectToStore(),
393+
).called(1);
394+
});
386395
}

0 commit comments

Comments
 (0)