Skip to content

chore: remove deprecated APIs #1424

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
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v15.0.1...dev)

### Changed

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

### Added

- Add Support Advanced UI customization. ([#1411](https://github.com/Instabug/Instabug-React-Native/pull/1411))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.instabug.apm.APM;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
import com.instabug.reactlibrary.utils.EventEmitterModule;
Expand All @@ -33,8 +32,6 @@ public RNInstabugAPMModule(ReactApplicationContext reactApplicationContext) {
super(reactApplicationContext);
}

@Deprecated
HashMap<String, ExecutionTrace> traces = new HashMap<String, ExecutionTrace>();

@Nonnull
@Override
Expand Down Expand Up @@ -207,81 +204,6 @@ public void run() {
});
}

/**
* Starts an execution trace
*
* @param name string name of the trace.
*
* @deprecated see {@link #startFlow(String)}
*/
@Deprecated
@ReactMethod
public void startExecutionTrace(final String name, final String id, final Promise promise) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
String result = "";
ExecutionTrace trace = APM.startExecutionTrace(name);
if (trace != null) {
result = id;
traces.put(id, trace);
}
promise.resolve(result);
} catch (Exception e) {
e.printStackTrace();
promise.resolve(null);
}
}
});
}

/**
* Adds a new attribute to trace
*
* @param id String id of the trace.
* @param key attribute key
* @param value attribute value. Null to remove attribute
*
* @deprecated see {@link #setFlowAttribute}
*/
@Deprecated
@ReactMethod
public void setExecutionTraceAttribute(final String id, final String key, final String value) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
traces.get(id).setAttribute(key, value);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Ends a trace
*
* @param id string id of the trace.
*
* @deprecated see {@link #endFlow}
*/
@Deprecated
@ReactMethod
public void endExecutionTrace(final String id) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
traces.get(id).end();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Starts a UI trace
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ public void run() {
}
});
}

/**
* Sets a minimum number of characters as a requirement for the comments field in the different report types.
* @param limit int number of characters.
Expand All @@ -410,8 +409,7 @@ public void run() {
typesInts[i] = types.get(i);
}

BugReporting.setCommentMinimumCharacterCount(limit, typesInts);
} catch (Exception e) {
BugReporting.setCommentMinimumCharacterCountForBugReportType(limit, typesInts); } catch (Exception e) {
e.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,26 +286,6 @@ public void run() {
});
}

/**
* Set the primary color that the SDK will use to tint certain UI elements in the SDK
*
* @param primaryColor The value of the primary color ,
* whatever this color was parsed from a resource color or hex color
* or RGB color values
*/
@ReactMethod
public void setPrimaryColor(final int primaryColor) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
Instabug.setPrimaryColor(primaryColor);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Gets tags.
Expand Down Expand Up @@ -1041,60 +1021,7 @@ public void run() {
});
}

/**
* @deprecated see {@link #addFeatureFlags(ReadableArray)}
*/
@ReactMethod
public void addExperiments(final ReadableArray experiments) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
Object[] objectArray = ArrayUtil.toArray(experiments);
String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);
Instabug.addExperiments(Arrays.asList(stringArray));
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* @deprecated see {@link #removeFeatureFlags(ReadableArray)}
*/
@ReactMethod
public void removeExperiments(final ReadableArray experiments) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
Object[] objectArray = ArrayUtil.toArray(experiments);
String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);
Instabug.removeExperiments(Arrays.asList(stringArray));
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* @deprecated see {@link #removeAllFeatureFlags()}
*/
@ReactMethod
public void clearAllExperiments() {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
Instabug.clearAllExperiments();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}


@ReactMethod
public void addFeatureFlags(final ReadableMap featureFlagsMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,6 @@ public void givenTruesetEnabled_whenQuery_thenShouldCallNativeApiWithEnabled() {
APM.endAppLaunch();
}

@Test
public void givenString$startExecutionTrace_whenQuery_thenShouldCallNativeApi() {
Promise promise = mock(Promise.class);
// when
apmModule.startExecutionTrace("trace", "1", promise);
// then
verify(APM.class, times(1));
APM.startExecutionTrace("trace");
verify(promise).resolve(any());
}

@Test
public void testStartFlow() {
String appFlowName = "appFlowName";
Expand Down Expand Up @@ -156,34 +145,6 @@ public void testSetFlowAttribute() {
mockAPM.verifyNoMoreInteractions();
}

// @Test
// public void givenString$setExecutionTraceAttribute_whenQuery_thenShouldCallNativeApiWithIntArgs() {
// // given
// PowerMockito.mockStatic(APM.class);
// ExecutionTrace trace = mock(ExecutionTrace.class);
// Callback callback = mock(Callback.class);
// // when
// PowerMockito.whenNew(ExecutionTrace.class).withArguments("trace").thenReturn(trace);
// apmModule.startExecutionTrace("trace", "1", callback);
// apmModule.setExecutionTraceAttribute("trace", "key", "value");
// // then
// verify(trace).setAttribute("key", "value");
// }

// @Test
// public void givenTrace$endExecutionTrace_whenQuery_thenShouldCallNativeApiWithIntArgs() {
// // given
// PowerMockito.mockStatic(APM.class);
// ExecutionTrace trace = mock(ExecutionTrace.class);
// Callback callback = mock(Callback.class);
// // when
// PowerMockito.whenNew(ExecutionTrace.class).withArguments("trace").thenReturn(trace);
// apmModule.startExecutionTrace("trace", "1", callback);
// apmModule.endExecutionTrace("1");
// // then
// verify(trace).end();
// }

@Test
public void givenString$startUITrace_whenQuery_thenShouldCallNativeApiWithEnabled() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ public Object answer(InvocationOnMock invocation) {
// then
verify(BugReporting.class, VerificationModeFactory.times(1));
int type1 = args.get(keysArray[0]);
BugReporting.setCommentMinimumCharacterCount(count, type1);

BugReporting.setCommentMinimumCharacterCountForBugReportType(count, type1);
}
@Test
public void TestAddUserConsent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,6 @@ public void tearDown() {
Instabug.setUserData(data);
}

@Test
public void givenArg$setPrimaryColor_whenQuery_thenShouldCallNativeApiWithArg() {
// given

int color = 3902;
// when
rnModule.setPrimaryColor(color);
// then
verify(Instabug.class,times(1));
Instabug.setPrimaryColor(color);
}

@Test
public void testSetCodePushVersion() {
String codePushVersion = "123";
Expand Down Expand Up @@ -535,51 +523,6 @@ public void testIdentifyUserWithId() {

}

@Test
public void givenArg$addExperiments_whenQuery_thenShouldCallNativeApiWithArg() {
// given
JavaOnlyArray array = new JavaOnlyArray();
array.pushString("exp1");
array.pushString("exp2");

// when
rnModule.addExperiments(array);

// then
verify(Instabug.class,times(1));
List<String> expectedList = new ArrayList<String>();
expectedList.add("exp1");
expectedList.add("exp2");
Instabug.addExperiments(expectedList);
}

@Test
public void givenArg$removeExperiments_whenQuery_thenShouldCallNativeApiWithArg() {
// given
JavaOnlyArray array = new JavaOnlyArray();
array.pushString("exp1");
array.pushString("exp2");

// when
rnModule.removeExperiments(array);

// then
verify(Instabug.class,times(1));
List<String> expectedList = new ArrayList<String>();
expectedList.add("exp1");
expectedList.add("exp2");
Instabug.removeExperiments(expectedList);
}

@Test
public void given$clearAllExperiments_whenQuery_thenShouldCallNativeApi() {
// when
rnModule.clearAllExperiments();

// then
verify(Instabug.class,times(1));
Instabug.clearAllExperiments();
}

@Test
public void testAddFeatureFlags() {
Expand Down
Loading