Skip to content

chore: remove deprecated apis #385

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 11 commits into from
Sep 26, 2023
Merged
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [Unreleased](https://github.com/Instabug/Instabug-Flutter/compare/v11.14.0...dev)

### Changed

- **BREAKING** Remove deprecated APIs ([#385](https://github.com/Instabug/Instabug-Flutter/pull/385)). See migration guide for more details.

## [11.14.0](https://github.com/Instabug/Instabug-Flutter/compare/v11.13.0...v11.14.0) (September 13, 2023)

### Added
Expand Down
13 changes: 1 addition & 12 deletions android/src/main/java/com/instabug/flutter/modules/ApmApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.flutter.generated.ApmPigeon;
import com.instabug.flutter.util.ArgsRegistry;
import com.instabug.flutter.util.Reflection;
import com.instabug.flutter.util.ThreadManager;

Expand Down Expand Up @@ -41,7 +40,7 @@ public void setEnabled(@NonNull Boolean isEnabled) {
@Override
public void setColdAppLaunchEnabled(@NonNull Boolean isEnabled) {
try {
APM.setAppLaunchEnabled(isEnabled);
APM.setColdAppLaunchEnabled(isEnabled);
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -56,16 +55,6 @@ public void setAutoUITraceEnabled(@NonNull Boolean isEnabled) {
}
}

@Override
public void setLogLevel(@NonNull String level) {
try {
final int resolvedLevel = ArgsRegistry.logLevels.get(level);
APM.setLogLevel(resolvedLevel);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void startExecutionTrace(@NonNull String id, @NonNull String name, ApmPigeon.Result<String> result) {
ThreadManager.runOnBackground(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,28 +275,6 @@ public void run() {
);
}

@Override
public void setDebugEnabled(@NonNull Boolean enabled) {
Instabug.setDebugEnabled(enabled);
}

@Override
public void setSdkDebugLogsLevel(@NonNull String level) {
// iOS Only
}

@SuppressWarnings("deprecation")
@Override
@Deprecated()
public void setReproStepsMode(@NonNull String mode) {
try {
final State resolvedMode = ArgsRegistry.reproStates.get(mode);
Instabug.setReproStepsState(resolvedMode);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void setReproStepsConfig(@Nullable String bugMode, @Nullable String crashMode) {
try {
Expand Down Expand Up @@ -394,16 +372,6 @@ public void clearFileAttachments() {
Instabug.clearFileAttachment();
}

@Override
public void enableAndroid() {
Instabug.enable();
}

@Override
public void disableAndroid() {
Instabug.disable();
}

@Override
public void networkLog(@NonNull Map<String, Object> data) {
try {
Expand Down
22 changes: 0 additions & 22 deletions android/src/main/java/com/instabug/flutter/util/ArgsRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.instabug.library.invocation.util.InstabugFloatingButtonEdge;
import com.instabug.library.invocation.util.InstabugVideoRecordingButtonPosition;
import com.instabug.library.ui.onboarding.WelcomeMessage;
import com.instabug.library.visualusersteps.State;

import java.util.HashMap;
import java.util.Objects;
Expand All @@ -34,23 +33,10 @@ public T get(Object key) {
public static final ArgsMap<Integer> sdkLogLevels = new ArgsMap<Integer>() {{
put("LogLevel.none", LogLevel.NONE);
put("LogLevel.error", LogLevel.ERROR);
put("LogLevel.warning", LogLevel.ERROR); // Deprecated
put("LogLevel.info", LogLevel.DEBUG); // Deprecated
put("LogLevel.debug", LogLevel.DEBUG);
put("LogLevel.verbose", LogLevel.VERBOSE);
}};

@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated()
public static final ArgsMap<Integer> logLevels = new ArgsMap<Integer>() {{
put("LogLevel.none", com.instabug.apm.model.LogLevel.NONE);
put("LogLevel.error", com.instabug.apm.model.LogLevel.ERROR);
put("LogLevel.warning", com.instabug.apm.model.LogLevel.WARNING);
put("LogLevel.info", com.instabug.apm.model.LogLevel.INFO);
put("LogLevel.debug", com.instabug.apm.model.LogLevel.DEBUG);
put("LogLevel.verbose", com.instabug.apm.model.LogLevel.VERBOSE);
}};

public static ArgsMap<InstabugInvocationEvent> invocationEvents = new ArgsMap<InstabugInvocationEvent>() {{
put("InvocationEvent.none", InstabugInvocationEvent.NONE);
put("InvocationEvent.shake", InstabugInvocationEvent.SHAKE);
Expand Down Expand Up @@ -112,13 +98,6 @@ public T get(Object key) {
put("ExtendedBugReportMode.disabled", ExtendedBugReport.State.DISABLED);
}};

@Deprecated()
public static final ArgsMap<State> reproStates = new ArgsMap<State>() {{
put("ReproStepsMode.enabledWithNoScreenshots", State.ENABLED_WITH_NO_SCREENSHOTS);
put("ReproStepsMode.enabled", State.ENABLED);
put("ReproStepsMode.disabled", State.DISABLED);
}};

public static final ArgsMap<Integer> reproModes = new ArgsMap<Integer>() {{
put("ReproStepsMode.enabledWithNoScreenshots", ReproMode.EnableWithNoScreenshots);
put("ReproStepsMode.enabled", ReproMode.EnableWithScreenshots);
Expand Down Expand Up @@ -158,7 +137,6 @@ public T get(Object key) {
put("CustomTextPlaceHolderKey.shakeHint", Key.SHAKE_HINT);
put("CustomTextPlaceHolderKey.swipeHint", Key.SWIPE_HINT);
put("CustomTextPlaceHolderKey.invalidEmailMessage", Key.INVALID_EMAIL_MESSAGE);
put("CustomTextPlaceHolderKey.invalidCommentMessage", Key.INVALID_COMMENT_MESSAGE);
put("CustomTextPlaceHolderKey.emailFieldHint", Key.EMAIL_FIELD_HINT);
put("CustomTextPlaceHolderKey.commentFieldHintForBugReport", Key.COMMENT_FIELD_HINT_FOR_BUG_REPORT);
put("CustomTextPlaceHolderKey.commentFieldHintForFeedback", Key.COMMENT_FIELD_HINT_FOR_FEEDBACK);
Expand Down
14 changes: 1 addition & 13 deletions android/src/test/java/com/instabug/flutter/ApmApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.instabug.flutter.modules.ApmApi;
import com.instabug.flutter.util.GlobalMocks;
import com.instabug.flutter.util.MockReflected;
import com.instabug.library.LogLevel;

import org.json.JSONObject;
import org.junit.After;
Expand Down Expand Up @@ -82,14 +81,13 @@ public void testSetEnabled() {
mAPM.verify(() -> APM.setEnabled(isEnabled));
}

@SuppressWarnings("deprecation")
@Test
public void testSetColdAppLaunchEnabled() {
boolean isEnabled = false;

api.setColdAppLaunchEnabled(isEnabled);

mAPM.verify(() -> APM.setAppLaunchEnabled(isEnabled));
mAPM.verify(() -> APM.setColdAppLaunchEnabled(isEnabled));
}

@Test
Expand All @@ -101,16 +99,6 @@ public void testSetAutoUITraceEnabled() {
mAPM.verify(() -> APM.setAutoUITraceEnabled(isEnabled));
}

@SuppressWarnings("deprecation")
@Test
public void testSetLogLevel() {
String logLevel = "LogLevel.none";

api.setLogLevel(logLevel);

mAPM.verify(() -> APM.setLogLevel(LogLevel.NONE));
}

@Test
public void testStartExecutionTraceWhenTraceNotNull() {
String expectedId = "trace-id";
Expand Down
33 changes: 0 additions & 33 deletions android/src/test/java/com/instabug/flutter/ArgsRegistryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.instabug.library.invocation.util.InstabugFloatingButtonEdge;
import com.instabug.library.invocation.util.InstabugVideoRecordingButtonPosition;
import com.instabug.library.ui.onboarding.WelcomeMessage;
import com.instabug.library.visualusersteps.State;

import org.junit.Test;

Expand All @@ -36,22 +35,6 @@ public void testSdkLogLevels() {
}
}

@Test
public void testLogLevels() {
Integer[] values = {
com.instabug.apm.model.LogLevel.NONE,
com.instabug.apm.model.LogLevel.ERROR,
com.instabug.apm.model.LogLevel.WARNING,
com.instabug.apm.model.LogLevel.INFO,
com.instabug.apm.model.LogLevel.DEBUG,
com.instabug.apm.model.LogLevel.VERBOSE,
};

for (Integer value : values) {
assertTrue(ArgsRegistry.logLevels.containsValue(value));
}
}

@Test
public void testInvocationEvents() {
InstabugInvocationEvent[] values = {
Expand Down Expand Up @@ -183,21 +166,6 @@ public void testExtendedBugReportStates() {
}
}


@SuppressWarnings("deprecation")
@Test
public void testReproStates() {
State[] values = {
State.ENABLED_WITH_NO_SCREENSHOTS,
State.ENABLED,
State.DISABLED,
};

for (State value : values) {
assertTrue(ArgsRegistry.reproStates.containsValue(value));
}
}

@Test
public void testReproModes() {
Integer[] values = {
Expand Down Expand Up @@ -255,7 +223,6 @@ public void testPlaceholder() {
Key.SHAKE_HINT,
Key.SWIPE_HINT,
Key.INVALID_EMAIL_MESSAGE,
Key.INVALID_COMMENT_MESSAGE,
Key.EMAIL_FIELD_HINT,
Key.COMMENT_FIELD_HINT_FOR_BUG_REPORT,
Key.COMMENT_FIELD_HINT_FOR_FEEDBACK,
Expand Down
22 changes: 0 additions & 22 deletions android/src/test/java/com/instabug/flutter/InstabugApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -39,7 +38,6 @@
import com.instabug.library.invocation.InstabugInvocationEvent;
import com.instabug.library.model.NetworkLog;
import com.instabug.library.ui.onboarding.WelcomeMessage;
import com.instabug.library.visualusersteps.State;

import org.json.JSONObject;
import org.junit.After;
Expand Down Expand Up @@ -377,26 +375,6 @@ public void testGetUserAttributes() {
mInstabug.verify(Instabug::getAllUserAttributes);
}

@SuppressWarnings("deprecation")
@Test
public void testSetDebugEnabled() {
boolean isEnabled = true;

api.setDebugEnabled(isEnabled);

mInstabug.verify(() -> Instabug.setDebugEnabled(isEnabled));
}

@SuppressWarnings("deprecation")
@Test
public void testSetReproStepsMode() {
String mode = "ReproStepsMode.enabled";

api.setReproStepsMode(mode);

mInstabug.verify(() -> Instabug.setReproStepsState(State.ENABLED));
}

@Test
public void testSetReproStepsConfig() {
String bug = "ReproStepsMode.enabled";
Expand Down
11 changes: 1 addition & 10 deletions example/ios/InstabugTests/ApmApiTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (void)testSetColdAppLaunchEnabled {

[self.api setColdAppLaunchEnabledIsEnabled:isEnabled error:&error];

OCMVerify([self.mAPM setAppLaunchEnabled:YES]);
OCMVerify([self.mAPM setColdAppLaunchEnabled:YES]);
}

- (void)testSetAutoUITraceEnabled {
Expand All @@ -56,15 +56,6 @@ - (void)testSetAutoUITraceEnabled {
OCMVerify([self.mAPM setAutoUITraceEnabled:YES]);
}

- (void)testSetLogLevel {
NSString *level = @"LogLevel.warning";
FlutterError *error;

[self.api setLogLevelLevel:level error:&error];

OCMVerify([self.mAPM setLogLevel:IBGLogLevelWarning]);
}

- (void)testStartExecutionTraceWhenTraceNotNil {
NSString *expectedId = @"trace-id";
NSString *name = @"trace-name";
Expand Down
16 changes: 0 additions & 16 deletions example/ios/InstabugTests/ArgsRegistryTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ - (void)testSdkLogLevels {
}
}

- (void)testLogLevels {
NSArray *values = @[
@(IBGLogLevelNone),
@(IBGLogLevelError),
@(IBGLogLevelWarning),
@(IBGLogLevelInfo),
@(IBGLogLevelDebug),
@(IBGLogLevelVerbose)
];

for (NSNumber *value in values) {
XCTAssertTrue([[ArgsRegistry.logLevels allValues] containsObject:value]);
}
}

- (void)testInvocationEvents {
NSArray *values = @[
@(IBGInvocationEventNone),
Expand Down Expand Up @@ -208,7 +193,6 @@ - (void)testPlaceholders {
kIBGShakeStartAlertTextStringName,
kIBGEdgeSwipeStartAlertTextStringName,
kIBGInvalidEmailMessageStringName,
kIBGInvalidCommentMessageStringName,
kIBGInvocationTitleStringName,
kIBGAskAQuestionStringName,
kIBGReportBugStringName,
Expand Down
18 changes: 0 additions & 18 deletions example/ios/InstabugTests/InstabugApiTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -282,24 +282,6 @@ - (void)testGetUserAttributes {
[self waitForExpectations:@[expectation] timeout:5.0];
}

- (void)testSetSdkDebugLogsLevel {
NSString *level = @"IBGSDKDebugLogsLevel.error";
FlutterError *error;

[self.api setSdkDebugLogsLevelLevel:level error:&error];

OCMVerify([self.mInstabug setSdkDebugLogsLevel:IBGSDKDebugLogsLevelError]);
}

- (void)testSetReproStepsMode {
NSString *mode = @"ReproStepsMode.enabled";
FlutterError *error;

[self.api setReproStepsModeMode:mode error:&error];

OCMVerify([self.mInstabug setReproStepsMode:IBGUserStepsModeEnable]);
}

- (void)testSetReproStepsConfig {
NSString *bugMode = @"ReproStepsMode.enabled";
NSString *crashMode = @"ReproStepsMode.disabled";
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 637e800c0a0982493b68adb612d2dd60c15c8e5c

COCOAPODS: 1.11.3
COCOAPODS: 1.12.1
7 changes: 1 addition & 6 deletions ios/Classes/Modules/ApmApi.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@ - (void)setEnabledIsEnabled:(NSNumber *)isEnabled error:(FlutterError *_Nullable
}

- (void)setColdAppLaunchEnabledIsEnabled:(NSNumber *)isEnabled error:(FlutterError *_Nullable *_Nonnull)error {
IBGAPM.appLaunchEnabled = [isEnabled boolValue];
IBGAPM.coldAppLaunchEnabled = [isEnabled boolValue];
}

- (void)setAutoUITraceEnabledIsEnabled:(NSNumber *)isEnabled error:(FlutterError *_Nullable *_Nonnull)error {
IBGAPM.autoUITraceEnabled = [isEnabled boolValue];
}

- (void)setLogLevelLevel:(NSString *)level error:(FlutterError *_Nullable *_Nonnull)error {
IBGLogLevel resolvedLevel = (ArgsRegistry.logLevels[level]).integerValue;
IBGAPM.logLevel = resolvedLevel;
}

- (void)startExecutionTraceId:(NSString *)id name:(NSString *)name completion:(void(^)(NSString *_Nullable, FlutterError *_Nullable))completion {
IBGExecutionTrace *trace = [IBGAPM startExecutionTraceWithName:name];

Expand Down
Loading