Skip to content

Commit 3a28199

Browse files
committed
chore: remove deprecated apis
1 parent dd69dcc commit 3a28199

File tree

20 files changed

+11
-538
lines changed

20 files changed

+11
-538
lines changed

android/src/main/java/com/instabug/flutter/modules/ApmApi.java

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.instabug.apm.InternalAPM;
1010
import com.instabug.apm.configuration.cp.APMFeature;
1111
import com.instabug.apm.configuration.cp.FeatureAvailabilityCallback;
12-
import com.instabug.apm.model.ExecutionTrace;
1312
import com.instabug.apm.networking.APMNetworkLogger;
1413
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
1514
import com.instabug.flutter.generated.ApmPigeon;
@@ -26,7 +25,6 @@
2625

2726
public class ApmApi implements ApmPigeon.ApmHostApi {
2827
private final String TAG = ApmApi.class.getName();
29-
private final HashMap<String, ExecutionTrace> traces = new HashMap<>();
3028

3129
public static void init(BinaryMessenger messenger) {
3230
final ApmApi api = new ApmApi();
@@ -98,45 +96,7 @@ public void setAutoUITraceEnabled(@NonNull Boolean isEnabled) {
9896
*
9997
* @deprecated see {@link #startFlow}
10098
*/
101-
@Override
102-
public void startExecutionTrace(@NonNull String id, @NonNull String name, ApmPigeon.Result<String> result) {
103-
ThreadManager.runOnBackground(
104-
new Runnable() {
105-
@Override
106-
public void run() {
107-
try {
108-
ExecutionTrace trace = APM.startExecutionTrace(name);
109-
if (trace != null) {
110-
traces.put(id, trace);
111-
112-
ThreadManager.runOnMainThread(new Runnable() {
113-
@Override
114-
public void run() {
115-
result.success(id);
116-
}
117-
});
118-
} else {
119-
ThreadManager.runOnMainThread(new Runnable() {
120-
@Override
121-
public void run() {
122-
result.success(null);
123-
}
124-
});
125-
}
126-
} catch (Exception e) {
127-
e.printStackTrace();
128-
129-
ThreadManager.runOnMainThread(new Runnable() {
130-
@Override
131-
public void run() {
132-
result.success(null);
133-
}
134-
});
135-
}
136-
}
137-
}
138-
);
139-
}
99+
140100

141101
/**
142102
* Starts an AppFlow with the specified name.
@@ -201,39 +161,7 @@ public void endFlow(@NonNull String name) {
201161
}
202162
}
203163

204-
/**
205-
* Adds a new attribute to trace
206-
*
207-
* @param id String id of the trace.
208-
* @param key attribute key
209-
* @param value attribute value. Null to remove attribute
210-
*
211-
* @deprecated see {@link #setFlowAttribute}
212-
*/
213-
@Override
214-
public void setExecutionTraceAttribute(@NonNull String id, @NonNull String key, @NonNull String value) {
215-
try {
216-
traces.get(id).setAttribute(key, value);
217-
} catch (Exception e) {
218-
e.printStackTrace();
219-
}
220-
}
221164

222-
/**
223-
* Ends a trace
224-
*
225-
* @param id string id of the trace.
226-
*
227-
* @deprecated see {@link #endFlow}
228-
*/
229-
@Override
230-
public void endExecutionTrace(@NonNull String id) {
231-
try {
232-
traces.get(id).end();
233-
} catch (Exception e) {
234-
e.printStackTrace();
235-
}
236-
}
237165

238166
/**
239167
* Starts a UI trace.

android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void setCommentMinimumCharacterCount(@NonNull Long limit, @Nullable List<
184184
reportTypesArray[i] = ArgsRegistry.reportTypes.get(key);
185185
}
186186
}
187-
BugReporting.setCommentMinimumCharacterCount(limit.intValue(), reportTypesArray);
187+
BugReporting.setCommentMinimumCharacterCountForBugReportType(limit.intValue(), reportTypesArray);
188188
}
189189

190190
@Override

android/src/main/java/com/instabug/flutter/modules/InstabugApi.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ public void setWelcomeMessageMode(@NonNull String mode) {
176176

177177
@Override
178178
public void setPrimaryColor(@NonNull Long color) {
179-
Instabug.setPrimaryColor(color.intValue());
180179
}
181180

182181
@Override
@@ -228,20 +227,7 @@ public void run() {
228227
);
229228
}
230229

231-
@Override
232-
public void addExperiments(@NonNull List<String> experiments) {
233-
Instabug.addExperiments(experiments);
234-
}
235230

236-
@Override
237-
public void removeExperiments(@NonNull List<String> experiments) {
238-
Instabug.removeExperiments(experiments);
239-
}
240-
241-
@Override
242-
public void clearAllExperiments() {
243-
Instabug.clearAllExperiments();
244-
}
245231

246232
@Override
247233
public void addFeatureFlags(@NonNull Map<String, String> featureFlags) {

android/src/test/java/com/instabug/flutter/ApmApiTest.java

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.instabug.apm.InternalAPM;
1818
import com.instabug.apm.configuration.cp.APMFeature;
1919
import com.instabug.apm.configuration.cp.FeatureAvailabilityCallback;
20-
import com.instabug.apm.model.ExecutionTrace;
2120
import com.instabug.apm.networking.APMNetworkLogger;
2221
import com.instabug.flutter.generated.ApmPigeon;
2322
import com.instabug.flutter.modules.ApmApi;
@@ -68,16 +67,6 @@ public void cleanUp() {
6867
GlobalMocks.close();
6968
}
7069

71-
private ExecutionTrace mockTrace(String id) {
72-
String name = "trace-name";
73-
ExecutionTrace mTrace = mock(ExecutionTrace.class);
74-
75-
mAPM.when(() -> APM.startExecutionTrace(name)).thenReturn(mTrace);
76-
77-
api.startExecutionTrace(id, name, makeResult());
78-
79-
return mTrace;
80-
}
8170

8271
@Test
8372
public void testInit() {
@@ -115,53 +104,7 @@ public void testSetAutoUITraceEnabled() {
115104
mAPM.verify(() -> APM.setAutoUITraceEnabled(isEnabled));
116105
}
117106

118-
@Test
119-
public void testStartExecutionTraceWhenTraceNotNull() {
120-
String expectedId = "trace-id";
121-
String name = "trace-name";
122-
ApmPigeon.Result<String> result = makeResult((String actualId) -> assertEquals(expectedId, actualId));
123-
124-
mAPM.when(() -> APM.startExecutionTrace(name)).thenReturn(new ExecutionTrace(name));
125-
126-
api.startExecutionTrace(expectedId, name, result);
127-
128-
mAPM.verify(() -> APM.startExecutionTrace(name));
129-
}
130-
131-
@Test
132-
public void testStartExecutionTraceWhenTraceIsNull() {
133-
String id = "trace-id";
134-
String name = "trace-name";
135-
ApmPigeon.Result<String> result = makeResult(Assert::assertNull);
136-
137-
mAPM.when(() -> APM.startExecutionTrace(name)).thenReturn(null);
138-
139-
api.startExecutionTrace(id, name, result);
140-
141-
mAPM.verify(() -> APM.startExecutionTrace(name));
142-
}
143-
144-
@Test
145-
public void testSetExecutionTraceAttribute() {
146-
String id = "trace-id";
147-
String key = "is_premium";
148-
String value = "true";
149-
ExecutionTrace mTrace = mockTrace(id);
150-
151-
api.setExecutionTraceAttribute(id, key, value);
152-
153-
verify(mTrace).setAttribute(key, value);
154-
}
155-
156-
@Test
157-
public void testEndExecutionTrace() {
158-
String id = "trace-id";
159-
ExecutionTrace mTrace = mockTrace(id);
160-
161-
api.endExecutionTrace(id);
162107

163-
verify(mTrace).end();
164-
}
165108

166109
@Test
167110
public void testStartFlow() {

android/src/test/java/com/instabug/flutter/BugReportingApiTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public void testSetCommentMinimumCharacterCount() {
192192

193193
api.setCommentMinimumCharacterCount(limit, reportTypes);
194194

195-
mBugReporting.verify(() -> BugReporting.setCommentMinimumCharacterCount(limit.intValue(), BugReporting.ReportType.BUG, BugReporting.ReportType.QUESTION));
195+
mBugReporting.verify(() -> BugReporting.setCommentMinimumCharacterCountForBugReportType(limit.intValue(), BugReporting.ReportType.BUG, BugReporting.ReportType.QUESTION));
196196
}
197197

198198
@Test

android/src/test/java/com/instabug/flutter/InstabugApiTest.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,7 @@ public void testSetWelcomeMessageMode() {
276276

277277
@Test
278278
public void testSetPrimaryColor() {
279-
Long color = 0xFF0000L;
280-
281-
api.setPrimaryColor(color);
282-
283-
mInstabug.verify(() -> Instabug.setPrimaryColor(0xFF0000));
284279
}
285-
286280
@Test
287281
public void testSetSessionProfilerEnabledGivenTrue() {
288282
Boolean isEnabled = true;
@@ -346,30 +340,7 @@ public void testGetTags() {
346340
mInstabug.verify(Instabug::getTags);
347341
}
348342

349-
@Test
350-
public void testAddExperiments() {
351-
List<String> experiments = Arrays.asList("premium", "star");
352-
353-
api.addExperiments(experiments);
354-
355-
mInstabug.verify(() -> Instabug.addExperiments(experiments));
356-
}
357343

358-
@Test
359-
public void testRemoveExperiments() {
360-
List<String> experiments = Arrays.asList("premium", "star");
361-
362-
api.removeExperiments(experiments);
363-
364-
mInstabug.verify(() -> Instabug.removeExperiments(experiments));
365-
}
366-
367-
@Test
368-
public void testClearAllExperiments() {
369-
api.clearAllExperiments();
370-
371-
mInstabug.verify(Instabug::clearAllExperiments);
372-
}
373344

374345
@Test
375346
public void testAddFeatureFlags() {

example/ios/InstabugTests/ApmApiTests.m

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -116,40 +116,7 @@ - (void)testSetAutoUITraceEnabled {
116116
OCMVerify([self.mAPM setAutoUITraceEnabled:YES]);
117117
}
118118

119-
- (void)testStartExecutionTraceWhenTraceNotNil {
120-
NSString *expectedId = @"trace-id";
121-
NSString *name = @"trace-name";
122-
XCTestExpectation *expectation = [self expectationWithDescription:@"Call completion handler"];
123-
124-
IBGExecutionTrace *mTrace = OCMClassMock([IBGExecutionTrace class]);
125-
OCMStub([self.mAPM startExecutionTraceWithName:name]).andReturn(mTrace);
126-
127-
[self.api startExecutionTraceId:expectedId name:name completion:^(NSString *actualId, FlutterError *error) {
128-
[expectation fulfill];
129-
XCTAssertEqual(actualId, expectedId);
130-
XCTAssertNil(error);
131-
}];
132-
133-
OCMVerify([self.mAPM startExecutionTraceWithName:name]);
134-
[self waitForExpectations:@[expectation] timeout:5.0];
135-
}
136119

137-
- (void)testStartExecutionTraceWhenTraceIsNil {
138-
NSString *traceId = @"trace-id";
139-
NSString *name = @"trace-name";
140-
XCTestExpectation *expectation = [self expectationWithDescription:@"Call completion handler"];
141-
142-
OCMStub([self.mAPM startExecutionTraceWithName:name]).andReturn(nil);
143-
144-
[self.api startExecutionTraceId:traceId name:name completion:^(NSString *actualId, FlutterError *error) {
145-
[expectation fulfill];
146-
XCTAssertNil(actualId);
147-
XCTAssertNil(error);
148-
}];
149-
150-
OCMVerify([self.mAPM startExecutionTraceWithName:name]);
151-
[self waitForExpectations:@[expectation] timeout:5.0];
152-
}
153120

154121

155122
- (void)testSetExecutionTraceAttribute {

example/ios/InstabugTests/InstabugApiTests.m

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -200,31 +200,6 @@ - (void)testGetTags {
200200
[self waitForExpectations:@[expectation] timeout:5.0];
201201
}
202202

203-
- (void)testAddExperiments {
204-
NSArray<NSString *> *experiments = @[@"premium", @"star"];
205-
FlutterError *error;
206-
207-
[self.api addExperimentsExperiments:experiments error:&error];
208-
209-
OCMVerify([self.mInstabug addExperiments:experiments]);
210-
}
211-
212-
- (void)testRemoveExperiments {
213-
NSArray<NSString *> *experiments = @[@"premium", @"star"];
214-
FlutterError *error;
215-
216-
[self.api removeExperimentsExperiments:experiments error:&error];
217-
218-
OCMVerify([self.mInstabug removeExperiments:experiments]);
219-
}
220-
221-
- (void)testClearAllExperiments {
222-
FlutterError *error;
223-
224-
[self.api clearAllExperimentsWithError:&error];
225-
226-
OCMVerify([self.mInstabug clearAllExperiments]);
227-
}
228203

229204
- (void)testAddFeatureFlags {
230205
NSDictionary *featureFlagsMap = @{ @"key13" : @"value1", @"key2" : @"value2"};

ios/Classes/Modules/ApmApi.m

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -70,44 +70,6 @@ - (void)setAutoUITraceEnabledIsEnabled:(NSNumber *)isEnabled error:(FlutterError
7070
IBGAPM.autoUITraceEnabled = [isEnabled boolValue];
7171
}
7272

73-
// This method is responsible for starting an execution trace
74-
// with a given `id` and `name`.
75-
//
76-
// Deprecated - see [startFlowName, setFlowAttributeName & endFlowName].
77-
- (void)startExecutionTraceId:(NSString *)id name:(NSString *)name completion:(void(^)(NSString *_Nullable, FlutterError *_Nullable))completion {
78-
IBGExecutionTrace *trace = [IBGAPM startExecutionTraceWithName:name];
79-
80-
if (trace != nil) {
81-
[traces setObject:trace forKey:id];
82-
return completion(id, nil);
83-
} else {
84-
return completion(nil, nil);
85-
}
86-
}
87-
88-
// This method is responsible for setting an attribute for a specific
89-
// execution trace identified by the provided `id`.
90-
//
91-
// Deprecated - see [startFlowName, setFlowAttributeName & endFlowName].
92-
- (void)setExecutionTraceAttributeId:(NSString *)id key:(NSString *)key value:(NSString *)value error:(FlutterError *_Nullable *_Nonnull)error {
93-
IBGExecutionTrace *trace = [traces objectForKey:id];
94-
95-
if (trace != nil) {
96-
[trace setAttributeWithKey:key value:value];
97-
}
98-
}
99-
100-
// This method `endExecutionTraceId` is responsible for ending an execution trace identified by the
101-
// provided `id`.
102-
//
103-
// Deprecated - see [startFlowName, setFlowAttributeName & endFlowName].
104-
- (void)endExecutionTraceId:(NSString *)id error:(FlutterError *_Nullable *_Nonnull)error {
105-
IBGExecutionTrace *trace = [traces objectForKey:id];
106-
107-
if (trace != nil) {
108-
[trace end];
109-
}
110-
}
11173

11274
// This method is responsible for starting a flow with the given `name`. This functionality is used to
11375
// track and monitor the performance of specific flows within the application.

0 commit comments

Comments
 (0)