Skip to content

Commit f31ad84

Browse files
Merge pull request #1424 from Instabug/feat/Remove-SDK-Deprecated-Public-APIs
chore: remove deprecated APIs
2 parents 4571451 + 48fc00a commit f31ad84

29 files changed

+28
-712
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

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

5+
### Changed
6+
7+
- **BREAKING** Remove deprecated APIs ([#1424](https://github.com/Instabug/Instabug-React-Native/pull/1424)). See migration guide for more details.
8+
59
### Added
610

711
- Add Support Advanced UI customization. ([#1411](https://github.com/Instabug/Instabug-React-Native/pull/1411))

android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.facebook.react.bridge.ReactMethod;
1313
import com.facebook.react.bridge.ReadableMap;
1414
import com.instabug.apm.APM;
15-
import com.instabug.apm.model.ExecutionTrace;
1615
import com.instabug.apm.networking.APMNetworkLogger;
1716
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
1817
import com.instabug.reactlibrary.utils.EventEmitterModule;
@@ -33,8 +32,6 @@ public RNInstabugAPMModule(ReactApplicationContext reactApplicationContext) {
3332
super(reactApplicationContext);
3433
}
3534

36-
@Deprecated
37-
HashMap<String, ExecutionTrace> traces = new HashMap<String, ExecutionTrace>();
3835

3936
@Nonnull
4037
@Override
@@ -207,81 +204,6 @@ public void run() {
207204
});
208205
}
209206

210-
/**
211-
* Starts an execution trace
212-
*
213-
* @param name string name of the trace.
214-
*
215-
* @deprecated see {@link #startFlow(String)}
216-
*/
217-
@Deprecated
218-
@ReactMethod
219-
public void startExecutionTrace(final String name, final String id, final Promise promise) {
220-
MainThreadHandler.runOnMainThread(new Runnable() {
221-
@Override
222-
public void run() {
223-
try {
224-
String result = "";
225-
ExecutionTrace trace = APM.startExecutionTrace(name);
226-
if (trace != null) {
227-
result = id;
228-
traces.put(id, trace);
229-
}
230-
promise.resolve(result);
231-
} catch (Exception e) {
232-
e.printStackTrace();
233-
promise.resolve(null);
234-
}
235-
}
236-
});
237-
}
238-
239-
/**
240-
* Adds a new attribute to trace
241-
*
242-
* @param id String id of the trace.
243-
* @param key attribute key
244-
* @param value attribute value. Null to remove attribute
245-
*
246-
* @deprecated see {@link #setFlowAttribute}
247-
*/
248-
@Deprecated
249-
@ReactMethod
250-
public void setExecutionTraceAttribute(final String id, final String key, final String value) {
251-
MainThreadHandler.runOnMainThread(new Runnable() {
252-
@Override
253-
public void run() {
254-
try {
255-
traces.get(id).setAttribute(key, value);
256-
} catch (Exception e) {
257-
e.printStackTrace();
258-
}
259-
}
260-
});
261-
}
262-
263-
/**
264-
* Ends a trace
265-
*
266-
* @param id string id of the trace.
267-
*
268-
* @deprecated see {@link #endFlow}
269-
*/
270-
@Deprecated
271-
@ReactMethod
272-
public void endExecutionTrace(final String id) {
273-
MainThreadHandler.runOnMainThread(new Runnable() {
274-
@Override
275-
public void run() {
276-
try {
277-
traces.get(id).end();
278-
} catch (Exception e) {
279-
e.printStackTrace();
280-
}
281-
}
282-
});
283-
}
284-
285207
/**
286208
* Starts a UI trace
287209
*

android/src/main/java/com/instabug/reactlibrary/RNInstabugBugReportingModule.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ public void run() {
389389
}
390390
});
391391
}
392-
393392
/**
394393
* Sets a minimum number of characters as a requirement for the comments field in the different report types.
395394
* @param limit int number of characters.
@@ -410,8 +409,7 @@ public void run() {
410409
typesInts[i] = types.get(i);
411410
}
412411

413-
BugReporting.setCommentMinimumCharacterCount(limit, typesInts);
414-
} catch (Exception e) {
412+
BugReporting.setCommentMinimumCharacterCountForBugReportType(limit, typesInts); } catch (Exception e) {
415413
e.printStackTrace();
416414
}
417415
}

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -286,26 +286,6 @@ public void run() {
286286
});
287287
}
288288

289-
/**
290-
* Set the primary color that the SDK will use to tint certain UI elements in the SDK
291-
*
292-
* @param primaryColor The value of the primary color ,
293-
* whatever this color was parsed from a resource color or hex color
294-
* or RGB color values
295-
*/
296-
@ReactMethod
297-
public void setPrimaryColor(final int primaryColor) {
298-
MainThreadHandler.runOnMainThread(new Runnable() {
299-
@Override
300-
public void run() {
301-
try {
302-
Instabug.setPrimaryColor(primaryColor);
303-
} catch (Exception e) {
304-
e.printStackTrace();
305-
}
306-
}
307-
});
308-
}
309289

310290
/**
311291
* Gets tags.
@@ -1041,60 +1021,7 @@ public void run() {
10411021
});
10421022
}
10431023

1044-
/**
1045-
* @deprecated see {@link #addFeatureFlags(ReadableArray)}
1046-
*/
1047-
@ReactMethod
1048-
public void addExperiments(final ReadableArray experiments) {
1049-
MainThreadHandler.runOnMainThread(new Runnable() {
1050-
@Override
1051-
public void run() {
1052-
try {
1053-
Object[] objectArray = ArrayUtil.toArray(experiments);
1054-
String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);
1055-
Instabug.addExperiments(Arrays.asList(stringArray));
1056-
} catch (Exception e) {
1057-
e.printStackTrace();
1058-
}
1059-
}
1060-
});
1061-
}
1062-
1063-
/**
1064-
* @deprecated see {@link #removeFeatureFlags(ReadableArray)}
1065-
*/
1066-
@ReactMethod
1067-
public void removeExperiments(final ReadableArray experiments) {
1068-
MainThreadHandler.runOnMainThread(new Runnable() {
1069-
@Override
1070-
public void run() {
1071-
try {
1072-
Object[] objectArray = ArrayUtil.toArray(experiments);
1073-
String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);
1074-
Instabug.removeExperiments(Arrays.asList(stringArray));
1075-
} catch (Exception e) {
1076-
e.printStackTrace();
1077-
}
1078-
}
1079-
});
1080-
}
1081-
1082-
/**
1083-
* @deprecated see {@link #removeAllFeatureFlags()}
1084-
*/
1085-
@ReactMethod
1086-
public void clearAllExperiments() {
1087-
MainThreadHandler.runOnMainThread(new Runnable() {
1088-
@Override
1089-
public void run() {
1090-
try {
1091-
Instabug.clearAllExperiments();
1092-
} catch (Exception e) {
1093-
e.printStackTrace();
1094-
}
1095-
}
1096-
});
1097-
}
1024+
10981025

10991026
@ReactMethod
11001027
public void addFeatureFlags(final ReadableMap featureFlagsMap) {

android/src/test/java/com/instabug/reactlibrary/RNInstabugAPMModuleTest.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,6 @@ public void givenTruesetEnabled_whenQuery_thenShouldCallNativeApiWithEnabled() {
114114
APM.endAppLaunch();
115115
}
116116

117-
@Test
118-
public void givenString$startExecutionTrace_whenQuery_thenShouldCallNativeApi() {
119-
Promise promise = mock(Promise.class);
120-
// when
121-
apmModule.startExecutionTrace("trace", "1", promise);
122-
// then
123-
verify(APM.class, times(1));
124-
APM.startExecutionTrace("trace");
125-
verify(promise).resolve(any());
126-
}
127-
128117
@Test
129118
public void testStartFlow() {
130119
String appFlowName = "appFlowName";
@@ -156,34 +145,6 @@ public void testSetFlowAttribute() {
156145
mockAPM.verifyNoMoreInteractions();
157146
}
158147

159-
// @Test
160-
// public void givenString$setExecutionTraceAttribute_whenQuery_thenShouldCallNativeApiWithIntArgs() {
161-
// // given
162-
// PowerMockito.mockStatic(APM.class);
163-
// ExecutionTrace trace = mock(ExecutionTrace.class);
164-
// Callback callback = mock(Callback.class);
165-
// // when
166-
// PowerMockito.whenNew(ExecutionTrace.class).withArguments("trace").thenReturn(trace);
167-
// apmModule.startExecutionTrace("trace", "1", callback);
168-
// apmModule.setExecutionTraceAttribute("trace", "key", "value");
169-
// // then
170-
// verify(trace).setAttribute("key", "value");
171-
// }
172-
173-
// @Test
174-
// public void givenTrace$endExecutionTrace_whenQuery_thenShouldCallNativeApiWithIntArgs() {
175-
// // given
176-
// PowerMockito.mockStatic(APM.class);
177-
// ExecutionTrace trace = mock(ExecutionTrace.class);
178-
// Callback callback = mock(Callback.class);
179-
// // when
180-
// PowerMockito.whenNew(ExecutionTrace.class).withArguments("trace").thenReturn(trace);
181-
// apmModule.startExecutionTrace("trace", "1", callback);
182-
// apmModule.endExecutionTrace("1");
183-
// // then
184-
// verify(trace).end();
185-
// }
186-
187148
@Test
188149
public void givenString$startUITrace_whenQuery_thenShouldCallNativeApiWithEnabled() {
189150

android/src/test/java/com/instabug/reactlibrary/RNInstabugBugReportingModuleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ public Object answer(InvocationOnMock invocation) {
359359
// then
360360
verify(BugReporting.class, VerificationModeFactory.times(1));
361361
int type1 = args.get(keysArray[0]);
362-
363-
BugReporting.setCommentMinimumCharacterCount(count, type1);
362+
363+
BugReporting.setCommentMinimumCharacterCountForBugReportType(count, type1);
364364
}
365365
@Test
366366
public void TestAddUserConsent() {

android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,6 @@ public void tearDown() {
193193
Instabug.setUserData(data);
194194
}
195195

196-
@Test
197-
public void givenArg$setPrimaryColor_whenQuery_thenShouldCallNativeApiWithArg() {
198-
// given
199-
200-
int color = 3902;
201-
// when
202-
rnModule.setPrimaryColor(color);
203-
// then
204-
verify(Instabug.class,times(1));
205-
Instabug.setPrimaryColor(color);
206-
}
207-
208196
@Test
209197
public void testSetCodePushVersion() {
210198
String codePushVersion = "123";
@@ -535,51 +523,6 @@ public void testIdentifyUserWithId() {
535523

536524
}
537525

538-
@Test
539-
public void givenArg$addExperiments_whenQuery_thenShouldCallNativeApiWithArg() {
540-
// given
541-
JavaOnlyArray array = new JavaOnlyArray();
542-
array.pushString("exp1");
543-
array.pushString("exp2");
544-
545-
// when
546-
rnModule.addExperiments(array);
547-
548-
// then
549-
verify(Instabug.class,times(1));
550-
List<String> expectedList = new ArrayList<String>();
551-
expectedList.add("exp1");
552-
expectedList.add("exp2");
553-
Instabug.addExperiments(expectedList);
554-
}
555-
556-
@Test
557-
public void givenArg$removeExperiments_whenQuery_thenShouldCallNativeApiWithArg() {
558-
// given
559-
JavaOnlyArray array = new JavaOnlyArray();
560-
array.pushString("exp1");
561-
array.pushString("exp2");
562-
563-
// when
564-
rnModule.removeExperiments(array);
565-
566-
// then
567-
verify(Instabug.class,times(1));
568-
List<String> expectedList = new ArrayList<String>();
569-
expectedList.add("exp1");
570-
expectedList.add("exp2");
571-
Instabug.removeExperiments(expectedList);
572-
}
573-
574-
@Test
575-
public void given$clearAllExperiments_whenQuery_thenShouldCallNativeApi() {
576-
// when
577-
rnModule.clearAllExperiments();
578-
579-
// then
580-
verify(Instabug.class,times(1));
581-
Instabug.clearAllExperiments();
582-
}
583526

584527
@Test
585528
public void testAddFeatureFlags() {

0 commit comments

Comments
 (0)