Skip to content

feat: map custom app rating api #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void setCurrentPlatform() {
@Override
public void setEnabled(@NonNull Boolean isEnabled) {
try {
if(isEnabled)
if (isEnabled)
Instabug.enable();
else
Instabug.disable();
Expand Down Expand Up @@ -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.");
}
}

Expand Down Expand Up @@ -397,4 +396,9 @@ public void networkLog(@NonNull Map<String, Object> data) {
Log.e(TAG, "Network logging failed");
}
}

@Override
public void willRedirectToStore() {
Instabug.willRedirectToStore();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -549,4 +549,10 @@ public void testNetworkLog() {

mJSONObject.close();
}

@Test
public void testWillRedirectToStore() {
api.willRedirectToStore();
mInstabug.verify(Instabug::willRedirectToStore);
}
}
7 changes: 7 additions & 0 deletions example/ios/InstabugTests/InstabugApiTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,11 @@ - (void)testNetworkLog {
]);
}

- (void)testWillRedirectToAppStore {
FlutterError *error;
[self.api willRedirectToStoreWithError:&error];

OCMVerify([self.mInstabug willRedirectToAppStore]);
}

@end
4 changes: 4 additions & 0 deletions ios/Classes/Modules/InstabugApi.m
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,8 @@ - (void)networkLogData:(NSDictionary<NSString *, id> *)data error:(FlutterError
}
}

- (void)willRedirectToStoreWithError:(FlutterError * _Nullable __autoreleasing *)error {
[Instabug willRedirectToAppStore];
}

@end
9 changes: 9 additions & 0 deletions lib/src/modules/instabug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> willRedirectToStore() async {
return _host.willRedirectToStore();
}
}
2 changes: 2 additions & 0 deletions pigeons/instabug.api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ abstract class InstabugHostApi {
void clearFileAttachments();

void networkLog(Map<String, Object> data);

void willRedirectToStore();
}
9 changes: 9 additions & 0 deletions test/instabug_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}