diff --git a/README.md b/README.md index 6d387e826..acdb7a306 100644 --- a/README.md +++ b/README.md @@ -26,29 +26,29 @@ The table below contains a list of APIs we're planning to implement for our 1.0 | API Method | Native Equivalent (Android/iOS) | |------------|-----------------------------------------------------------------------------------------------------------------------------------------| -| `start(String token, List invocationEvents)` | `new Instabug.Builder(this, "APP_TOKEN").build()`
`+ [Instabug startWithToken:invocationEvents:]` | -|`showWelcomeMessageWithMode(WelcomeMessageMode welcomeMessageMode)`| `Instabug.showWelcomeMessage(WelcomeMessage.State state)`
`+ [Instabug showWelcomeMessageWithMode:]` | -|`identifyUserWithEmail(String email, [String name])`| `Instabug.identifyUser(String username, String email)`
`+ [Instabug identifyUserWithEmail:name:]` | -|`logOut()`| `Instabug.logoutUser()`
`+ [Instabug logOut]` | -|`setLocale(Locale locale)`| `Instabug.setLocale(Locale locale)`
`+ [Instabug setLocale:]` | -|`InstabugFlutter.setColorTheme(ColorTheme colorTheme)`| `Instabug.setColorTheme(InstabugColorTheme theme)`
`+ [Instabug setColorTheme:]` | -|`InstabugFlutter.appendTags(List tags)`| `Instabug.addTags(String... tags)`
`+ [Instabug appendTags:]` | -|`InstabugFlutter.resetTags()`| `Instabug.resetTags()`
`+ [Instabug resetTags]` | -|`InstabugFlutter.getTags()`| `Instabug.getTags()`
`+ [Instabug getTags]` | -| | `Instabug.setCustomTextPlaceHolders(InstabugCustomTextPlaceHolder placeholder)`
`+ [Instabug setValue:forStringWithKey:]` | -|`InstabugFlutter.setUserAttributeWithKey(String value, String key)`| `Instabug.setUserAttribute(String key, String value)`
`+ [Instabug setUserAttribute:withKey:]` | -|`Instabugflutter.getUserAttributeForKey(Sring Key)`| `Instabug.getUserAttribute(String key)`
`+ [Instabug userAttributeForKey:]` | -|`InstabugFlutter.removeUserAttributeForKey(String key)`| `Instabug.removeUserAttribute(String key)`
`+ [Instabug removeUserAttributeForKey:]` | -|`InstabugFlutter.getUserAttributes()`| `Instabug.getAllUserAttributes()`
`+ [Instabug userAttributes:]` | -|`logUserEventWithName(String name)`| `Instabug.logUserEvent(String name)`
`+ [Instabug logUserEventWithName:]` | -|`show()`| `Instabug.show()`
`+ [Instabug show]` | -|`invokeWithMode(InvocationMode invocationMode, [List invocationOptions])`| `BugReporting.invoke(InvocationMode mode, @InvocationOption int... options)`
`+ [IBGBugReporting invokeWithMode:options:]` | -|`logDebug(String message)`| `InstabugLog.d(String message)`
`+ [IBGLog logDebug:]` | -|`logVerbose(String message)`| `InstabugLog.v(String message)`
`+ [IBGLog logVerbose:]` | -|`logInfo(String message)`| `InstabugLog.i(String message)`
`+ [IBGLog logInfo:]` | -|`logWarn(String message)`| `InstabugLog.w(String message)`
`+ [IBGLog logWarn:]` | -|`logError(String message)`| `InstabugLog.e(String message)`
`+ [IBGLog logError:]` | -|`clearAllLogs(String message)`| `Instabug.clearLogs()`
`+ [IBGLog clearAllLogs:]` | +| `Instabug.start(String token, List invocationEvents)` | `new Instabug.Builder(this, "APP_TOKEN").build()`
`+ [Instabug startWithToken:invocationEvents:]` | +|`Instabug.showWelcomeMessageWithMode(WelcomeMessageMode welcomeMessageMode)`| `Instabug.showWelcomeMessage(WelcomeMessage.State state)`
`+ [Instabug showWelcomeMessageWithMode:]` | +|`Instabug.identifyUserWithEmail(String email, [String name])`| `Instabug.identifyUser(String username, String email)`
`+ [Instabug identifyUserWithEmail:name:]` | +|`Instabug.logOut()`| `Instabug.logoutUser()`
`+ [Instabug logOut]` | +|`Instabug.setLocale(Locale locale)`| `Instabug.setLocale(Locale locale)`
`+ [Instabug setLocale:]` | +|`Instabug.setColorTheme(ColorTheme colorTheme)`| `Instabug.setColorTheme(InstabugColorTheme theme)`
`+ [Instabug setColorTheme:]` | +|`Instabug.appendTags(List tags)`| `Instabug.addTags(String... tags)`
`+ [Instabug appendTags:]` | +|`Instabug.resetTags()`| `Instabug.resetTags()`
`+ [Instabug resetTags]` | +|`Instabug.getTags()`| `Instabug.getTags()`
`+ [Instabug getTags]` | +|`Instabug.setStringForKey(String value, String key)`| `Instabug.setCustomTextPlaceHolders(InstabugCustomTextPlaceHolder placeholder)`
`+ [Instabug setValue:forStringWithKey:]` | +|`Instabug.setUserAttributeWithKey(String value, String key)`| `Instabug.setUserAttribute(String key, String value)`
`+ [Instabug setUserAttribute:withKey:]` | +|`Instabug.getUserAttributeForKey(Sring Key)`| `Instabug.getUserAttribute(String key)`
`+ [Instabug userAttributeForKey:]` | +|`Instabug.removeUserAttributeForKey(String key)`| `Instabug.removeUserAttribute(String key)`
`+ [Instabug removeUserAttributeForKey:]` | +|`Instabug.getUserAttributes()`| `Instabug.getAllUserAttributes()`
`+ [Instabug userAttributes:]` | +|`Instabug.logUserEventWithName(String name)`| `Instabug.logUserEvent(String name)`
`+ [Instabug logUserEventWithName:]` | +|`Instabug.show()`| `Instabug.show()`
`+ [Instabug show]` | +|`Instabug.invokeWithMode(InvocationMode invocationMode, [List invocationOptions])`| `BugReporting.invoke(InvocationMode mode, @InvocationOption int... options)`
`+ [IBGBugReporting invokeWithMode:options:]` | +|`Instabug.logDebug(String message)`| `InstabugLog.d(String message)`
`+ [IBGLog logDebug:]` | +|`Instabug.logVerbose(String message)`| `InstabugLog.v(String message)`
`+ [IBGLog logVerbose:]` | +|`Instabug.logInfo(String message)`| `InstabugLog.i(String message)`
`+ [IBGLog logInfo:]` | +|`Instabug.logWarn(String message)`| `InstabugLog.w(String message)`
`+ [IBGLog logWarn:]` | +|`Instabug.logError(String message)`| `InstabugLog.e(String message)`
`+ [IBGLog logError:]` | +|`Instabug.clearAllLogs(String message)`| `Instabug.clearLogs()`
`+ [IBGLog clearAllLogs:]` | ## Integration diff --git a/android/src/main/java/com/instabug/instabugflutter/ArgsRegistry.java b/android/src/main/java/com/instabug/instabugflutter/ArgsRegistry.java index 39ee7e569..c4c1fa6a0 100644 --- a/android/src/main/java/com/instabug/instabugflutter/ArgsRegistry.java +++ b/android/src/main/java/com/instabug/instabugflutter/ArgsRegistry.java @@ -6,6 +6,7 @@ import com.instabug.bug.BugReporting; import com.instabug.bug.invocation.Option; import com.instabug.library.InstabugColorTheme; +import com.instabug.library.InstabugCustomTextPlaceHolder; import java.util.HashMap; import java.util.Locale; @@ -55,6 +56,7 @@ final class ArgsRegistry { registerLocaleArgs(ARGS); registerInvocationModeArgs(ARGS); registerInvocationOptionsArgs(ARGS); + registerCustomTextPlaceHolderKeysArgs(ARGS); } /** @@ -160,4 +162,40 @@ static void registerLocaleArgs(Map args) { args.put("Locale.Slovak", new Locale(SLOVAK.getCode(), SLOVAK.getCountry())); args.put("Locale.Czech", new Locale(CZECH.getCode(), CZECH.getCountry())); } + + @VisibleForTesting + static void registerCustomTextPlaceHolderKeysArgs(Map args) { + args.put("IBGCustomTextPlaceHolderKey.SHAKE_HINT", InstabugCustomTextPlaceHolder.Key.SHAKE_HINT); + args.put("IBGCustomTextPlaceHolderKey.SWIPE_HINT", InstabugCustomTextPlaceHolder.Key.SWIPE_HINT); + args.put("IBGCustomTextPlaceHolderKey.INVALID_EMAIL_MESSAGE", InstabugCustomTextPlaceHolder.Key.INVALID_EMAIL_MESSAGE); + args.put("IBGCustomTextPlaceHolderKey.INVALID_COMMENT_MESSAGE", InstabugCustomTextPlaceHolder.Key.INVALID_COMMENT_MESSAGE); + args.put("IBGCustomTextPlaceHolderKey.INVOCATION_HEADER", InstabugCustomTextPlaceHolder.Key.INVOCATION_HEADER); + args.put("IBGCustomTextPlaceHolderKey.START_CHATS", InstabugCustomTextPlaceHolder.Key.START_CHATS); + args.put("IBGCustomTextPlaceHolderKey.REPORT_BUG", InstabugCustomTextPlaceHolder.Key.REPORT_BUG); + args.put("IBGCustomTextPlaceHolderKey.REPORT_FEEDBACK", InstabugCustomTextPlaceHolder.Key.REPORT_FEEDBACK); + args.put("IBGCustomTextPlaceHolderKey.EMAIL_FIELD_HINT", InstabugCustomTextPlaceHolder.Key.EMAIL_FIELD_HINT); + args.put("IBGCustomTextPlaceHolderKey.COMMENT_FIELD_HINT_FOR_BUG_REPORT", InstabugCustomTextPlaceHolder.Key.COMMENT_FIELD_HINT_FOR_BUG_REPORT); + args.put("IBGCustomTextPlaceHolderKey.COMMENT_FIELD_HINT_FOR_FEEDBACK", InstabugCustomTextPlaceHolder.Key.COMMENT_FIELD_HINT_FOR_FEEDBACK); + args.put("IBGCustomTextPlaceHolderKey.ADD_VOICE_MESSAGE", InstabugCustomTextPlaceHolder.Key.ADD_VOICE_MESSAGE); + args.put("IBGCustomTextPlaceHolderKey.ADD_IMAGE_FROM_GALLERY", InstabugCustomTextPlaceHolder.Key.ADD_IMAGE_FROM_GALLERY); + args.put("IBGCustomTextPlaceHolderKey.ADD_EXTRA_SCREENSHOT", InstabugCustomTextPlaceHolder.Key.ADD_EXTRA_SCREENSHOT); + args.put("IBGCustomTextPlaceHolderKey.CONVERSATIONS_LIST_TITLE", InstabugCustomTextPlaceHolder.Key.CONVERSATIONS_LIST_TITLE); + args.put("IBGCustomTextPlaceHolderKey.AUDIO_RECORDING_PERMISSION_DENIED", InstabugCustomTextPlaceHolder.Key.AUDIO_RECORDING_PERMISSION_DENIED); + args.put("IBGCustomTextPlaceHolderKey.CONVERSATION_TEXT_FIELD_HINT", InstabugCustomTextPlaceHolder.Key.CONVERSATION_TEXT_FIELD_HINT); + args.put("IBGCustomTextPlaceHolderKey.BUG_REPORT_HEADER", InstabugCustomTextPlaceHolder.Key.BUG_REPORT_HEADER); + args.put("IBGCustomTextPlaceHolderKey.FEEDBACK_REPORT_HEADER", InstabugCustomTextPlaceHolder.Key.FEEDBACK_REPORT_HEADER); + args.put("IBGCustomTextPlaceHolderKey.VOICE_MESSAGE_PRESS_AND_HOLD_TO_RECORD", InstabugCustomTextPlaceHolder.Key.VOICE_MESSAGE_PRESS_AND_HOLD_TO_RECORD); + args.put("IBGCustomTextPlaceHolderKey.VOICE_MESSAGE_RELEASE_TO_ATTACH", InstabugCustomTextPlaceHolder.Key.VOICE_MESSAGE_RELEASE_TO_ATTACH); + args.put("IBGCustomTextPlaceHolderKey.REPORT_SUCCESSFULLY_SENT", InstabugCustomTextPlaceHolder.Key.REPORT_SUCCESSFULLY_SENT); + args.put("IBGCustomTextPlaceHolderKey.SUCCESS_DIALOG_HEADER", InstabugCustomTextPlaceHolder.Key.SUCCESS_DIALOG_HEADER); + args.put("IBGCustomTextPlaceHolderKey.ADD_VIDEO", InstabugCustomTextPlaceHolder.Key.ADD_VIDEO); + args.put("IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_WELCOME_STEP_TITLE", InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_WELCOME_STEP_TITLE); + args.put("IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_WELCOME_STEP_CONTENT", InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_WELCOME_STEP_CONTENT); + args.put("IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_TITLE", InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_TITLE); + args.put("IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_CONTENT", InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_CONTENT); + args.put("IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_FINISH_STEP_TITLE", InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_FINISH_STEP_TITLE); + args.put("IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_FINISH_STEP_CONTENT", InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_FINISH_STEP_CONTENT); + args.put("IBGCustomTextPlaceHolderKey.LIVE_WELCOME_MESSAGE_TITLE", InstabugCustomTextPlaceHolder.Key.LIVE_WELCOME_MESSAGE_TITLE); + args.put("IBGCustomTextPlaceHolderKey.LIVE_WELCOME_MESSAGE_CONTENT", InstabugCustomTextPlaceHolder.Key.LIVE_WELCOME_MESSAGE_CONTENT); + } } diff --git a/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java b/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java index 2c478dffc..f63819f6c 100644 --- a/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java +++ b/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java @@ -11,6 +11,7 @@ import com.instabug.chat.Replies; import com.instabug.library.Instabug; import com.instabug.library.InstabugColorTheme; +import com.instabug.library.InstabugCustomTextPlaceHolder; import com.instabug.library.invocation.InstabugInvocationEvent; import com.instabug.library.logging.InstabugLog; import com.instabug.library.ui.onboarding.WelcomeMessage; @@ -40,6 +41,8 @@ public class InstabugFlutterPlugin implements MethodCallHandler { final public static String INVOCATION_EVENT_FLOATING_BUTTON = "InvocationEvent.floatingButton"; final public static String INVOCATION_EVENT_SHAKE = "InvocationEvent.shake"; + private InstabugCustomTextPlaceHolder placeHolder = new InstabugCustomTextPlaceHolder(); + /** * Plugin registration. */ @@ -323,5 +326,17 @@ public void invokeWithMode(String invocationMode, List invocationOptions */ public void logUserEventWithName(String name) { Instabug.logUserEvent(name); - } + } + + + /** + * Overrides any of the strings shown in the SDK with custom ones. + * @param value String value to override the default one. + * @param forStringWithKey Key of string to override. + */ + public void setValue(String value, String forStringWithKey) { + InstabugCustomTextPlaceHolder.Key key = ArgsRegistry.getDeserializedValue(forStringWithKey, InstabugCustomTextPlaceHolder.Key.class); + placeHolder.set(key, value); + Instabug.setCustomTextPlaceHolders(placeHolder); + } } diff --git a/android/src/test/java/com/instabug/instabugflutter/ArgsRegistryTest.java b/android/src/test/java/com/instabug/instabugflutter/ArgsRegistryTest.java index f85a2a3f7..7436376a1 100644 --- a/android/src/test/java/com/instabug/instabugflutter/ArgsRegistryTest.java +++ b/android/src/test/java/com/instabug/instabugflutter/ArgsRegistryTest.java @@ -3,10 +3,12 @@ import com.instabug.bug.BugReporting; import com.instabug.bug.invocation.Option; import com.instabug.library.InstabugColorTheme; +import com.instabug.library.InstabugCustomTextPlaceHolder; import com.instabug.library.invocation.InstabugInvocationEvent; import com.instabug.library.ui.onboarding.WelcomeMessage; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import java.util.ArrayList; @@ -58,6 +60,7 @@ public class ArgsRegistryTest { assertAllColorThemesArePresent(args); assertAllInvocationModesArePresent(args); assertAllInvocationOptionsArePresent(args); + assertAllSupportedCustomTextPlaceHolderKeysArePresent(args); } @Test @@ -99,6 +102,38 @@ public class ArgsRegistryTest { assertAllColorThemesArePresent(map); } + @Test + public void givenShakeHintIsPresent_when$getDeserializedValue_thenShouldReturnNonNullKey() { + // when + InstabugCustomTextPlaceHolder.Key actualKey = + ArgsRegistry.getDeserializedValue("IBGCustomTextPlaceHolderKey.SHAKE_HINT", InstabugCustomTextPlaceHolder.Key.class); + // then + Assert.assertNotNull(actualKey); + Assert.assertEquals(InstabugCustomTextPlaceHolder.Key.SHAKE_HINT, actualKey); + + } + + @Test + public void given$registerPlaceHolderKeysArgsIsCalledOnAMap_whenQuery_thenShouldMatchCriteria() { + // given + Map map = new HashMap<>(); + // when + ArgsRegistry.registerCustomTextPlaceHolderKeysArgs(map); + // then + assertAllSupportedCustomTextPlaceHolderKeysArePresent(map); + } + + @Ignore + @Test + public void duplicate_given$registerPlaceHolderKeysArgsIsCalledOnAMap_whenQuery_thenShouldMatchCriteria() { + // given + Map map = new HashMap<>(); + // when + ArgsRegistry.registerCustomTextPlaceHolderKeysArgs(map); + // then + assertAllSupportedCustomTextPlaceHolderKeysArePresent(map, getAllCustomTextPlaceHolderKeys()); + } + private void assertAllInvocationEventsArePresent(Map map) { Assert.assertTrue(map.containsValue(InstabugInvocationEvent.NONE)); Assert.assertTrue(map.containsValue(InstabugInvocationEvent.SHAKE)); @@ -113,6 +148,8 @@ private void assertAllWelcomeMessageStatesArePresent(Map map) { Assert.assertTrue(map.containsValue(WelcomeMessage.State.DISABLED)); } + + private void assertAllSupportedLocalesArePresent(Map map) { // source of truth List expectedLocales = getCurrentlySupportLanguagesByTheSDK(); @@ -156,6 +193,34 @@ private void assertAllInvocationOptionsArePresent(Map map) { Assert.assertTrue(map.containsValue(Option.EMAIL_FIELD_OPTIONAL)); } + private void assertAllSupportedCustomTextPlaceHolderKeysArePresent(Map map, List expectedKeys) { + // actual + List actualKeys = new ArrayList<>(); + for (Map.Entry m : map.entrySet()) { + if (m.getValue() instanceof InstabugCustomTextPlaceHolder.Key) { + actualKeys.add((InstabugCustomTextPlaceHolder.Key) m.getValue()); + } + } + StringBuilder stringBuilder = new StringBuilder(); + for (InstabugCustomTextPlaceHolder.Key expectedKey : expectedKeys) { + if (!actualKeys.contains(expectedKey)) { + stringBuilder.append(expectedKey) + .append(" is missing") + .append("\n"); + } + } + String missingKeys = stringBuilder.toString(); + if (!missingKeys.isEmpty()) { + Assert.fail(missingKeys); + } + } + + private void assertAllSupportedCustomTextPlaceHolderKeysArePresent(Map map) { + // source of truth + List expectedKeys = getCurrentlySupportedKeysBySDK(); + assertAllSupportedCustomTextPlaceHolderKeysArePresent(map, expectedKeys); + } + private List getCurrentlySupportLanguagesByTheSDK() { List langs = new ArrayList<>(); langs.add(new Locale("en", "")); @@ -182,4 +247,86 @@ private List getCurrentlySupportLanguagesByTheSDK() { langs.add(new Locale("no", "")); return langs; } + + private List getCurrentlySupportedKeysBySDK() { + List keys = new ArrayList<>(); + keys.add(InstabugCustomTextPlaceHolder.Key.SHAKE_HINT); + keys.add(InstabugCustomTextPlaceHolder.Key.SWIPE_HINT); + keys.add(InstabugCustomTextPlaceHolder.Key.INVALID_EMAIL_MESSAGE); + keys.add(InstabugCustomTextPlaceHolder.Key.INVALID_COMMENT_MESSAGE); + keys.add(InstabugCustomTextPlaceHolder.Key.INVOCATION_HEADER); + keys.add(InstabugCustomTextPlaceHolder.Key.START_CHATS); + keys.add(InstabugCustomTextPlaceHolder.Key.REPORT_BUG); + keys.add(InstabugCustomTextPlaceHolder.Key.REPORT_FEEDBACK); + keys.add(InstabugCustomTextPlaceHolder.Key.EMAIL_FIELD_HINT); + keys.add(InstabugCustomTextPlaceHolder.Key.COMMENT_FIELD_HINT_FOR_BUG_REPORT); + keys.add(InstabugCustomTextPlaceHolder.Key.COMMENT_FIELD_HINT_FOR_FEEDBACK); + keys.add(InstabugCustomTextPlaceHolder.Key.ADD_VOICE_MESSAGE); + keys.add(InstabugCustomTextPlaceHolder.Key.ADD_IMAGE_FROM_GALLERY); + keys.add(InstabugCustomTextPlaceHolder.Key.ADD_EXTRA_SCREENSHOT); + keys.add(InstabugCustomTextPlaceHolder.Key.CONVERSATIONS_LIST_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.AUDIO_RECORDING_PERMISSION_DENIED); + keys.add(InstabugCustomTextPlaceHolder.Key.CONVERSATION_TEXT_FIELD_HINT); + keys.add(InstabugCustomTextPlaceHolder.Key.BUG_REPORT_HEADER); + keys.add(InstabugCustomTextPlaceHolder.Key.FEEDBACK_REPORT_HEADER); + keys.add(InstabugCustomTextPlaceHolder.Key.VOICE_MESSAGE_PRESS_AND_HOLD_TO_RECORD); + keys.add(InstabugCustomTextPlaceHolder.Key.VOICE_MESSAGE_RELEASE_TO_ATTACH); + keys.add(InstabugCustomTextPlaceHolder.Key.REPORT_SUCCESSFULLY_SENT); + keys.add(InstabugCustomTextPlaceHolder.Key.SUCCESS_DIALOG_HEADER); + keys.add(InstabugCustomTextPlaceHolder.Key.ADD_VIDEO); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_WELCOME_STEP_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_WELCOME_STEP_CONTENT); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_CONTENT); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_FINISH_STEP_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_FINISH_STEP_CONTENT); + keys.add(InstabugCustomTextPlaceHolder.Key.LIVE_WELCOME_MESSAGE_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.LIVE_WELCOME_MESSAGE_CONTENT); + return keys; + } + + private List getAllCustomTextPlaceHolderKeys() { + List keys = new ArrayList<>(); + keys.add(InstabugCustomTextPlaceHolder.Key.SHAKE_HINT); + keys.add(InstabugCustomTextPlaceHolder.Key.SWIPE_HINT); + keys.add(InstabugCustomTextPlaceHolder.Key.INVALID_EMAIL_MESSAGE); + keys.add(InstabugCustomTextPlaceHolder.Key.INVALID_COMMENT_MESSAGE); + keys.add(InstabugCustomTextPlaceHolder.Key.INVOCATION_HEADER); + keys.add(InstabugCustomTextPlaceHolder.Key.START_CHATS); + keys.add(InstabugCustomTextPlaceHolder.Key.REPORT_BUG); + keys.add(InstabugCustomTextPlaceHolder.Key.REPORT_FEEDBACK); + keys.add(InstabugCustomTextPlaceHolder.Key.EMAIL_FIELD_HINT); + keys.add(InstabugCustomTextPlaceHolder.Key.COMMENT_FIELD_HINT_FOR_BUG_REPORT); + keys.add(InstabugCustomTextPlaceHolder.Key.COMMENT_FIELD_HINT_FOR_FEEDBACK); + keys.add(InstabugCustomTextPlaceHolder.Key.ADD_VOICE_MESSAGE); + keys.add(InstabugCustomTextPlaceHolder.Key.ADD_IMAGE_FROM_GALLERY); + keys.add(InstabugCustomTextPlaceHolder.Key.ADD_EXTRA_SCREENSHOT); + keys.add(InstabugCustomTextPlaceHolder.Key.CONVERSATIONS_LIST_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.AUDIO_RECORDING_PERMISSION_DENIED); + keys.add(InstabugCustomTextPlaceHolder.Key.CONVERSATION_TEXT_FIELD_HINT); + keys.add(InstabugCustomTextPlaceHolder.Key.BUG_REPORT_HEADER); + keys.add(InstabugCustomTextPlaceHolder.Key.FEEDBACK_REPORT_HEADER); + keys.add(InstabugCustomTextPlaceHolder.Key.VOICE_MESSAGE_PRESS_AND_HOLD_TO_RECORD); + keys.add(InstabugCustomTextPlaceHolder.Key.VOICE_MESSAGE_RELEASE_TO_ATTACH); + keys.add(InstabugCustomTextPlaceHolder.Key.REPORT_SUCCESSFULLY_SENT); + keys.add(InstabugCustomTextPlaceHolder.Key.SUCCESS_DIALOG_HEADER); + keys.add(InstabugCustomTextPlaceHolder.Key.ADD_VIDEO); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_WELCOME_STEP_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_WELCOME_STEP_CONTENT); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_CONTENT); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_FINISH_STEP_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.BETA_WELCOME_MESSAGE_FINISH_STEP_CONTENT); + keys.add(InstabugCustomTextPlaceHolder.Key.LIVE_WELCOME_MESSAGE_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.LIVE_WELCOME_MESSAGE_CONTENT); + keys.add(InstabugCustomTextPlaceHolder.Key.VIDEO_PLAYER_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.FEATURES_REQUEST); + keys.add(InstabugCustomTextPlaceHolder.Key.FEATURES_REQUEST_ADD_FEATURE_TOAST); + keys.add(InstabugCustomTextPlaceHolder.Key.FEATURES_REQUEST_ADD_FEATURE_THANKS_MESSAGE); + keys.add(InstabugCustomTextPlaceHolder.Key.SURVEYS_WELCOME_SCREEN_TITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.SURVEYS_WELCOME_SCREEN_SUBTITLE); + keys.add(InstabugCustomTextPlaceHolder.Key.SURVEYS_WELCOME_SCREEN_BUTTON); + keys.add(InstabugCustomTextPlaceHolder.Key.REQUEST_FEATURE); + return keys; + } } diff --git a/example/lib/main.dart b/example/lib/main.dart index 61cd829a0..183170ecf 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,6 +1,6 @@ -import 'package:flutter/material.dart'; import 'dart:async'; import 'dart:io' show Platform; +import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:instabug_flutter/instabug_flutter.dart'; @@ -26,29 +26,30 @@ class _MyAppState extends State { // Platform messages may fail, so we use a try/catch PlatformException. try { if (Platform.isIOS) { - InstabugFlutter.start('9582e6cfe34e2b8897f48cfa3b617adb', [InvocationEvent.floatingButton, InvocationEvent.shake]); + Instabug.start('9582e6cfe34e2b8897f48cfa3b617adb', [InvocationEvent.floatingButton, InvocationEvent.shake]); } - InstabugFlutter.showWelcomeMessageWithMode(WelcomeMessageMode.beta); - InstabugFlutter.identifyUserWithEmail("aezz@instabug.com", "Aly Ezz"); - InstabugFlutter.logInfo("Test Log Info Message from Flutter!"); - InstabugFlutter.logDebug("Test Debug Message from Flutter!"); - InstabugFlutter.logVerbose("Test Verbose Message from Flutter!"); - InstabugFlutter.clearAllLogs(); - InstabugFlutter.logError("Test Error Message from Flutter!"); - InstabugFlutter.logWarn("Test Warn Message from Flutter!"); - InstabugFlutter.logOut(); - InstabugFlutter.setLocale(Locale.German); - //InstabugFlutter.setLocale(Locale.German); - InstabugFlutter.setColorTheme(ColorTheme.dark); - InstabugFlutter.appendTags(['tag1', 'tag2']); - InstabugFlutter.setUserAttributeWithKey('19', 'Age'); - InstabugFlutter.setUserAttributeWithKey('female', 'gender'); - InstabugFlutter.removeUserAttributeForKey('gender'); - final String value = await InstabugFlutter.getUserAttributeForKey('Age'); + Instabug.showWelcomeMessageWithMode(WelcomeMessageMode.beta); + Instabug.identifyUserWithEmail('aezz@instabug.com', 'Aly Ezz'); + Instabug.logInfo('Test Log Info Message from Flutter!'); + Instabug.logDebug('Test Debug Message from Flutter!'); + Instabug.logVerbose('Test Verbose Message from Flutter!'); + Instabug.clearAllLogs(); + Instabug.logError('Test Error Message from Flutter!'); + Instabug.logWarn('Test Warn Message from Flutter!'); + Instabug.logOut(); + Instabug.setLocale(Locale.German); + Instabug.setColorTheme(ColorTheme.dark); + Instabug.appendTags(['tag1', 'tag2']); + Instabug.setUserAttributeWithKey('19', 'Age'); + Instabug.setUserAttributeWithKey('female', 'gender'); + Instabug.removeUserAttributeForKey('gender'); + final String value = await Instabug.getUserAttributeForKey('Age'); print('User Attribute ' + value); - final Map userAttributes = await InstabugFlutter.getUserAttributes(); + final Map userAttributes = await Instabug.getUserAttributes(); print(userAttributes.toString()); - InstabugFlutter.logUserEventWithName('Aly Event'); + Instabug.logUserEventWithName('Aly Event'); + Instabug.setValueForStringWithKey('What\'s the problem', IBGCustomTextPlaceHolderKey.REPORT_BUG); + Instabug.setValueForStringWithKey('Send some ideas', IBGCustomTextPlaceHolderKey.REPORT_FEEDBACK); } on PlatformException { platformVersion = 'Failed to get platform version.'; @@ -64,19 +65,19 @@ class _MyAppState extends State { } void resetTags() { - InstabugFlutter.resetTags(); + Instabug.resetTags(); } void show() { - InstabugFlutter.show(); + Instabug.show(); } void invokeWithMode() { - InstabugFlutter.invokeWithMode(InvocationMode.BUG, [InvocationOption.EMAIL_FIELD_HIDDEN]); + Instabug.invokeWithMode(InvocationMode.BUG, [InvocationOption.EMAIL_FIELD_HIDDEN]); } void getTags() async { - final List tags = await InstabugFlutter.getTags(); + final List tags = await Instabug.getTags(); print(tags.toString()); } diff --git a/ios/Classes/InstabugFlutterPlugin.m b/ios/Classes/InstabugFlutterPlugin.m index 9d228fdad..069ddde0e 100644 --- a/ios/Classes/InstabugFlutterPlugin.m +++ b/ios/Classes/InstabugFlutterPlugin.m @@ -277,6 +277,18 @@ + (void) logUserEventWithName:(NSString *) name { [Instabug logUserEventWithName:name]; } +/** + * Overrides any of the strings shown in the SDK with custom ones. + * Allows you to customize any of the strings shown to users in the SDK. + * @param value String value to override the default one. + * @param key Key of string to override. Use predefined keys like kIBGShakeStartAlertTextStringName, + * kIBGEmailFieldPlaceholderStringName, etc. + */ ++ (void) setValue: (NSString*) value forStringWithKey: (NSString*) key { + NSDictionary *constants = [self constants]; + [Instabug setValue:value forStringWithKey:constants[key]]; +} + + (NSDictionary *)constants { return @{ @"InvocationEvent.shake": @(IBGInvocationEventShake), @@ -318,6 +330,39 @@ + (NSDictionary *)constants { @"Locale.Spanish": @(IBGLocaleSpanish), @"Locale.Swedish": @(IBGLocaleSwedish), @"Locale.Turkish": @(IBGLocaleTurkish), + + @"IBGCustomTextPlaceHolderKey.SHAKE_HINT": kIBGShakeStartAlertTextStringName, + @"IBGCustomTextPlaceHolderKey.SWIPE_HINT": kIBGEdgeSwipeStartAlertTextStringName, + @"IBGCustomTextPlaceHolderKey.INVALID_EMAIL_MESSAGE": kIBGInvalidEmailMessageStringName, + @"IBGCustomTextPlaceHolderKey.INVALID_COMMENT_MESSAGE": kIBGInvalidCommentMessageStringName, + @"IBGCustomTextPlaceHolderKey.INVOCATION_HEADER": kIBGInvocationTitleStringName, + @"IBGCustomTextPlaceHolderKey.START_CHATS": kIBGChatsTitleStringName, + @"IBGCustomTextPlaceHolderKey.REPORT_BUG": kIBGReportBugStringName, + @"IBGCustomTextPlaceHolderKey.REPORT_FEEDBACK": kIBGReportFeedbackStringName, + @"IBGCustomTextPlaceHolderKey.EMAIL_FIELD_HINT": kIBGEmailFieldPlaceholderStringName, + @"IBGCustomTextPlaceHolderKey.COMMENT_FIELD_HINT_FOR_BUG_REPORT": kIBGCommentFieldPlaceholderForBugReportStringName, + @"IBGCustomTextPlaceHolderKey.COMMENT_FIELD_HINT_FOR_FEEDBACK": kIBGCommentFieldPlaceholderForFeedbackStringName, + @"IBGCustomTextPlaceHolderKey.ADD_VOICE_MESSAGE": kIBGAddVoiceMessageStringName, + @"IBGCustomTextPlaceHolderKey.ADD_IMAGE_FROM_GALLERY": kIBGAddImageFromGalleryStringName, + @"IBGCustomTextPlaceHolderKey.ADD_EXTRA_SCREENSHOT": kIBGAddExtraScreenshotStringName, + @"IBGCustomTextPlaceHolderKey.CONVERSATIONS_LIST_TITLE": kIBGChatsTitleStringName, + @"IBGCustomTextPlaceHolderKey.AUDIO_RECORDING_PERMISSION_DENIED": kIBGAudioRecordingPermissionDeniedTitleStringName, + @"IBGCustomTextPlaceHolderKey.CONVERSATION_TEXT_FIELD_HINT": kIBGChatReplyFieldPlaceholderStringName, + @"IBGCustomTextPlaceHolderKey.BUG_REPORT_HEADER": kIBGReportBugStringName, + @"IBGCustomTextPlaceHolderKey.FEEDBACK_REPORT_HEADER": kIBGReportFeedbackStringName, + @"IBGCustomTextPlaceHolderKey.VOICE_MESSAGE_PRESS_AND_HOLD_TO_RECORD": kIBGRecordingMessageToHoldTextStringName, + @"IBGCustomTextPlaceHolderKey.VOICE_MESSAGE_RELEASE_TO_ATTACH": kIBGRecordingMessageToReleaseTextStringName, + @"IBGCustomTextPlaceHolderKey.REPORT_SUCCESSFULLY_SENT": kIBGThankYouAlertMessageStringName, + @"IBGCustomTextPlaceHolderKey.SUCCESS_DIALOG_HEADER": kIBGThankYouAlertTitleStringName, + @"IBGCustomTextPlaceHolderKey.ADD_VIDEO": kIBGAddScreenRecordingMessageStringName, + @"IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_WELCOME_STEP_TITLE": kIBGBetaWelcomeMessageWelcomeStepTitle, + @"IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_WELCOME_STEP_CONTENT": kIBGBetaWelcomeMessageWelcomeStepContent, + @"IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_TITLE": kIBGBetaWelcomeMessageHowToReportStepTitle, + @"IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_CONTENT": kIBGBetaWelcomeMessageHowToReportStepContent, + @"IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_FINISH_STEP_TITLE": kIBGBetaWelcomeMessageFinishStepTitle, + @"IBGCustomTextPlaceHolderKey.BETA_WELCOME_MESSAGE_FINISH_STEP_CONTENT": kIBGBetaWelcomeMessageFinishStepContent, + @"IBGCustomTextPlaceHolderKey.LIVE_WELCOME_MESSAGE_TITLE": kIBGLiveWelcomeMessageTitle, + @"IBGCustomTextPlaceHolderKey.LIVE_WELCOME_MESSAGE_CONTENT": kIBGLiveWelcomeMessageContent, }; }; diff --git a/lib/instabug_flutter.dart b/lib/instabug_flutter.dart index de6924285..2599fed01 100644 --- a/lib/instabug_flutter.dart +++ b/lib/instabug_flutter.dart @@ -1,6 +1,4 @@ import 'dart:async'; -import 'dart:collection'; - import 'package:flutter/services.dart'; enum InvocationEvent { @@ -55,7 +53,42 @@ enum InvocationOption { enum ColorTheme { dark, light } -class InstabugFlutter { +enum IBGCustomTextPlaceHolderKey { + SHAKE_HINT, + SWIPE_HINT, + INVALID_EMAIL_MESSAGE, + INVALID_COMMENT_MESSAGE, + INVOCATION_HEADER, + START_CHATS, + REPORT_BUG, + REPORT_FEEDBACK, + EMAIL_FIELD_HINT, + COMMENT_FIELD_HINT_FOR_BUG_REPORT, + COMMENT_FIELD_HINT_FOR_FEEDBACK, + ADD_VOICE_MESSAGE, + ADD_IMAGE_FROM_GALLERY, + ADD_EXTRA_SCREENSHOT, + CONVERSATIONS_LIST_TITLE, + AUDIO_RECORDING_PERMISSION_DENIED, + CONVERSATION_TEXT_FIELD_HINT, + BUG_REPORT_HEADER, + FEEDBACK_REPORT_HEADER, + VOICE_MESSAGE_PRESS_AND_HOLD_TO_RECORD, + VOICE_MESSAGE_RELEASE_TO_ATTACH, + REPORT_SUCCESSFULLY_SENT, + SUCCESS_DIALOG_HEADER, + ADD_VIDEO, + BETA_WELCOME_MESSAGE_WELCOME_STEP_TITLE, + BETA_WELCOME_MESSAGE_WELCOME_STEP_CONTENT, + BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_TITLE, + BETA_WELCOME_MESSAGE_HOW_TO_REPORT_STEP_CONTENT, + BETA_WELCOME_MESSAGE_FINISH_STEP_TITLE, + BETA_WELCOME_MESSAGE_FINISH_STEP_CONTENT, + LIVE_WELCOME_MESSAGE_TITLE, + LIVE_WELCOME_MESSAGE_CONTENT +} + +class Instabug { static const MethodChannel _channel = MethodChannel('instabug_flutter'); static Future get platformVersion async { @@ -99,7 +132,6 @@ class InstabugFlutter { /// Sets the default value of the user's email to nil and show email field and remove user name /// from all reports /// It also reset the chats on device and removes user attributes, user data and completed surveys. - static void logOut() async { await _channel.invokeMethod('logOut'); } @@ -237,6 +269,13 @@ class InstabugFlutter { final List params = [name]; await _channel.invokeMethod('logUserEventWithName:', params); } + + /// Overrides any of the strings shown in the SDK with custom ones. + /// Allows you to customize a [value] shown to users in the SDK using a predefined [key]. + static void setValueForStringWithKey(String value, IBGCustomTextPlaceHolderKey key) async { + final List params = [value, key.toString()]; + await _channel.invokeMethod('setValue:forStringWithKey:', params); + } } diff --git a/test/instabug_flutter_test.dart b/test/instabug_flutter_test.dart index b74cb8e5d..9085fef9f 100644 --- a/test/instabug_flutter_test.dart +++ b/test/instabug_flutter_test.dart @@ -37,7 +37,7 @@ void main() { }); test('startWithToken:invocationEvents: Test', () async { - InstabugFlutter.start(appToken, invocationEvents); + Instabug.start(appToken, invocationEvents); final List args = [appToken, [InvocationEvent.floatingButton.toString()]]; expect(log, [ isMethodCall('startWithToken:invocationEvents:', @@ -47,7 +47,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('showWelcomeMessageWithMode: Test', () async { - InstabugFlutter.showWelcomeMessageWithMode(WelcomeMessageMode.beta); + Instabug.showWelcomeMessageWithMode(WelcomeMessageMode.beta); final List args = [WelcomeMessageMode.beta.toString()]; expect(log, [ isMethodCall('showWelcomeMessageWithMode:', @@ -57,7 +57,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('identifyUserWithEmail:name: Test', () async { - InstabugFlutter.identifyUserWithEmail(email, name); + Instabug.identifyUserWithEmail(email, name); final List args = [email, name]; expect(log, [ isMethodCall('identifyUserWithEmail:name:', @@ -67,7 +67,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('identifyUserWithEmail:name: Test Optional Parameter', () async { - InstabugFlutter.identifyUserWithEmail(email); + Instabug.identifyUserWithEmail(email); final List args = [email, null]; expect(log, [ isMethodCall('identifyUserWithEmail:name:', @@ -77,7 +77,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('logOut Test', () async { - InstabugFlutter.logOut(); + Instabug.logOut(); expect(log, [ isMethodCall('logOut', arguments: null) @@ -85,7 +85,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('setLocale:', () async { - InstabugFlutter.setLocale(Locale.German); + Instabug.setLocale(Locale.German); final List args = [Locale.German.toString()]; expect(log, [ isMethodCall('setLocale:', @@ -96,7 +96,7 @@ test('startWithToken:invocationEvents: Test', () async { test('logVerbose: Test', () async { - InstabugFlutter.logVerbose(message); + Instabug.logVerbose(message); final List args = [message]; expect(log, [ isMethodCall('logVerbose:', @@ -106,7 +106,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('logDebug: Test', () async { - InstabugFlutter.logDebug(message); + Instabug.logDebug(message); final List args = [message]; expect(log, [ isMethodCall('logDebug:', @@ -116,7 +116,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('logInfo: Test', () async { - InstabugFlutter.logInfo(message); + Instabug.logInfo(message); final List args = [message]; expect(log, [ isMethodCall('logInfo:', @@ -126,7 +126,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('clearAllLogs: Test', () async { - InstabugFlutter.clearAllLogs(); + Instabug.clearAllLogs(); expect(log, [ isMethodCall('clearAllLogs', arguments: null @@ -135,7 +135,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('logError: Test', () async { - InstabugFlutter.logError(message); + Instabug.logError(message); final List args = [message]; expect(log, [ isMethodCall('logError:', @@ -145,7 +145,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('logWarn: Test', () async { - InstabugFlutter.logWarn(message); + Instabug.logWarn(message); final List args = [message]; expect(log, [ isMethodCall('logWarn:', @@ -156,7 +156,7 @@ test('startWithToken:invocationEvents: Test', () async { test('test setColorTheme should be called with argument colorTheme', () async { const ColorTheme colorTheme = ColorTheme.dark; - InstabugFlutter.setColorTheme(colorTheme); + Instabug.setColorTheme(colorTheme); final List args = [colorTheme.toString()]; expect(log, [ isMethodCall('setColorTheme:', @@ -167,7 +167,7 @@ test('startWithToken:invocationEvents: Test', () async { test('test appendTags should be called with argument List of strings', () async { const List tags = ['tag1', 'tag2']; - InstabugFlutter.appendTags(tags); + Instabug.appendTags(tags); final List args = [tags]; expect(log, [ isMethodCall('appendTags:', @@ -177,7 +177,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('test resetTags should be called with no arguments', () async { - InstabugFlutter.resetTags(); + Instabug.resetTags(); expect(log, [ isMethodCall('resetTags', arguments: null @@ -186,7 +186,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('test getTags should be called with no arguments and returns list of tags', () async { - List tags = await InstabugFlutter.getTags(); + List tags = await Instabug.getTags(); expect(log, [ isMethodCall('getTags', arguments: null @@ -198,7 +198,7 @@ test('startWithToken:invocationEvents: Test', () async { test('test setUserAttributeWithKey should be called with two string arguments', () async { const String value = '19'; const String key = 'Age'; - InstabugFlutter.setUserAttributeWithKey(value, key); + Instabug.setUserAttributeWithKey(value, key); final List args = [value, key]; expect(log, [ isMethodCall('setUserAttribute:withKey:', @@ -209,7 +209,7 @@ test('startWithToken:invocationEvents: Test', () async { test('test removeUserAttributeForKey should be called with a string argument', () async { const String key = 'Age'; - InstabugFlutter.removeUserAttributeForKey(key); + Instabug.removeUserAttributeForKey(key); final List args = [key]; expect(log, [ isMethodCall('removeUserAttributeForKey:', @@ -220,7 +220,7 @@ test('startWithToken:invocationEvents: Test', () async { test('test getUserAttributeForKey should be called with a string argument and return a string', () async { const String key = 'Age'; - final String value = await InstabugFlutter.getUserAttributeForKey(key); + final String value = await Instabug.getUserAttributeForKey(key); expect(log, [ isMethodCall('getUserAttributeForKey:', arguments: [key] @@ -230,7 +230,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('test getuserAttributes should be called with no arguments and returns a Map', () async { - final Map result = await InstabugFlutter.getUserAttributes(); + final Map result = await Instabug.getUserAttributes(); expect(log, [ isMethodCall('getUserAttributes', arguments: null @@ -240,7 +240,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('show Test', () async { - InstabugFlutter.show(); + Instabug.show(); expect(log, [ isMethodCall('show', arguments: null, @@ -250,7 +250,7 @@ test('startWithToken:invocationEvents: Test', () async { test('invokeWithMode:options: Test', () async { - InstabugFlutter.invokeWithMode(InvocationMode.BUG, [InvocationOption.COMMENT_FIELD_REQUIRED]); + Instabug.invokeWithMode(InvocationMode.BUG, [InvocationOption.COMMENT_FIELD_REQUIRED]); final List args = [InvocationMode.BUG.toString(), [InvocationOption.COMMENT_FIELD_REQUIRED.toString()]]; expect(log, [ isMethodCall('invokeWithMode:options:', @@ -260,7 +260,7 @@ test('startWithToken:invocationEvents: Test', () async { }); test('logUserEventWithName: Test', () async { - InstabugFlutter.logUserEventWithName(name); + Instabug.logUserEventWithName(name); final List args = [name]; expect(log, [ isMethodCall('logUserEventWithName:', @@ -269,6 +269,18 @@ test('startWithToken:invocationEvents: Test', () async { ]); }); + test('test setValueForStringWithKey should be called with two arguments', () async { + const String value = 'Some key'; + const IBGCustomTextPlaceHolderKey key = IBGCustomTextPlaceHolderKey.SHAKE_HINT; + Instabug.setValueForStringWithKey(value, key); + final List args = [value, key.toString()]; + expect(log, [ + isMethodCall('setValue:forStringWithKey:', + arguments: args, + ) + ]); + }); + }