Skip to content

chore: remove deprecated apis #614

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

Open
wants to merge 12 commits into
base: feat/support-advanced-UI-customization
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

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

### Changed

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

- Add support for Advanced UI customization with comprehensive theming capabilities ([#599](https://github.com/Instabug/Instabug-Flutter/pull/599))
Expand Down
74 changes: 1 addition & 73 deletions android/src/main/java/com/instabug/flutter/modules/ApmApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.instabug.apm.InternalAPM;
import com.instabug.apm.configuration.cp.APMFeature;
import com.instabug.apm.configuration.cp.FeatureAvailabilityCallback;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
import com.instabug.flutter.generated.ApmPigeon;
Expand All @@ -26,7 +25,6 @@

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

public static void init(BinaryMessenger messenger) {
final ApmApi api = new ApmApi();
Expand Down Expand Up @@ -98,45 +96,7 @@ public void setAutoUITraceEnabled(@NonNull Boolean isEnabled) {
*
* @deprecated see {@link #startFlow}
*/
@Override
public void startExecutionTrace(@NonNull String id, @NonNull String name, ApmPigeon.Result<String> result) {
ThreadManager.runOnBackground(
new Runnable() {
@Override
public void run() {
try {
ExecutionTrace trace = APM.startExecutionTrace(name);
if (trace != null) {
traces.put(id, trace);

ThreadManager.runOnMainThread(new Runnable() {
@Override
public void run() {
result.success(id);
}
});
} else {
ThreadManager.runOnMainThread(new Runnable() {
@Override
public void run() {
result.success(null);
}
});
}
} catch (Exception e) {
e.printStackTrace();

ThreadManager.runOnMainThread(new Runnable() {
@Override
public void run() {
result.success(null);
}
});
}
}
}
);
}


/**
* Starts an AppFlow with the specified name.
Expand Down Expand Up @@ -201,39 +161,7 @@ public void endFlow(@NonNull String name) {
}
}

/**
* 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}
*/
@Override
public void setExecutionTraceAttribute(@NonNull String id, @NonNull String key, @NonNull String value) {
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}
*/
@Override
public void endExecutionTrace(@NonNull String id) {
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 @@ -184,7 +184,7 @@ public void setCommentMinimumCharacterCount(@NonNull Long limit, @Nullable List<
reportTypesArray[i] = ArgsRegistry.reportTypes.get(key);
}
}
BugReporting.setCommentMinimumCharacterCount(limit.intValue(), reportTypesArray);
BugReporting.setCommentMinimumCharacterCountForBugReportType(limit.intValue(), reportTypesArray);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ public void setWelcomeMessageMode(@NonNull String mode) {

@Override
public void setPrimaryColor(@NonNull Long color) {
Instabug.setPrimaryColor(color.intValue());
}

@Override
Expand Down Expand Up @@ -229,20 +228,7 @@ public void run() {
);
}

@Override
public void addExperiments(@NonNull List<String> experiments) {
Instabug.addExperiments(experiments);
}

@Override
public void removeExperiments(@NonNull List<String> experiments) {
Instabug.removeExperiments(experiments);
}

@Override
public void clearAllExperiments() {
Instabug.clearAllExperiments();
}

@Override
public void addFeatureFlags(@NonNull Map<String, String> featureFlags) {
Expand Down
57 changes: 0 additions & 57 deletions android/src/test/java/com/instabug/flutter/ApmApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.instabug.apm.InternalAPM;
import com.instabug.apm.configuration.cp.APMFeature;
import com.instabug.apm.configuration.cp.FeatureAvailabilityCallback;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.flutter.generated.ApmPigeon;
import com.instabug.flutter.modules.ApmApi;
Expand Down Expand Up @@ -68,16 +67,6 @@ public void cleanUp() {
GlobalMocks.close();
}

private ExecutionTrace mockTrace(String id) {
String name = "trace-name";
ExecutionTrace mTrace = mock(ExecutionTrace.class);

mAPM.when(() -> APM.startExecutionTrace(name)).thenReturn(mTrace);

api.startExecutionTrace(id, name, makeResult());

return mTrace;
}

@Test
public void testInit() {
Expand Down Expand Up @@ -115,53 +104,7 @@ public void testSetAutoUITraceEnabled() {
mAPM.verify(() -> APM.setAutoUITraceEnabled(isEnabled));
}

@Test
public void testStartExecutionTraceWhenTraceNotNull() {
String expectedId = "trace-id";
String name = "trace-name";
ApmPigeon.Result<String> result = makeResult((String actualId) -> assertEquals(expectedId, actualId));

mAPM.when(() -> APM.startExecutionTrace(name)).thenReturn(new ExecutionTrace(name));

api.startExecutionTrace(expectedId, name, result);

mAPM.verify(() -> APM.startExecutionTrace(name));
}

@Test
public void testStartExecutionTraceWhenTraceIsNull() {
String id = "trace-id";
String name = "trace-name";
ApmPigeon.Result<String> result = makeResult(Assert::assertNull);

mAPM.when(() -> APM.startExecutionTrace(name)).thenReturn(null);

api.startExecutionTrace(id, name, result);

mAPM.verify(() -> APM.startExecutionTrace(name));
}

@Test
public void testSetExecutionTraceAttribute() {
String id = "trace-id";
String key = "is_premium";
String value = "true";
ExecutionTrace mTrace = mockTrace(id);

api.setExecutionTraceAttribute(id, key, value);

verify(mTrace).setAttribute(key, value);
}

@Test
public void testEndExecutionTrace() {
String id = "trace-id";
ExecutionTrace mTrace = mockTrace(id);

api.endExecutionTrace(id);

verify(mTrace).end();
}

@Test
public void testStartFlow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void testSetCommentMinimumCharacterCount() {

api.setCommentMinimumCharacterCount(limit, reportTypes);

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

@Test
Expand Down
29 changes: 0 additions & 29 deletions android/src/test/java/com/instabug/flutter/InstabugApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,7 @@ public void testSetWelcomeMessageMode() {

@Test
public void testSetPrimaryColor() {
Long color = 0xFF0000L;

api.setPrimaryColor(color);

mInstabug.verify(() -> Instabug.setPrimaryColor(0xFF0000));
}

@Test
public void testSetSessionProfilerEnabledGivenTrue() {
Boolean isEnabled = true;
Expand Down Expand Up @@ -348,30 +342,7 @@ public void testGetTags() {
mInstabug.verify(Instabug::getTags);
}

@Test
public void testAddExperiments() {
List<String> experiments = Arrays.asList("premium", "star");

api.addExperiments(experiments);

mInstabug.verify(() -> Instabug.addExperiments(experiments));
}

@Test
public void testRemoveExperiments() {
List<String> experiments = Arrays.asList("premium", "star");

api.removeExperiments(experiments);

mInstabug.verify(() -> Instabug.removeExperiments(experiments));
}

@Test
public void testClearAllExperiments() {
api.clearAllExperiments();

mInstabug.verify(Instabug::clearAllExperiments);
}

@Test
public void testAddFeatureFlags() {
Expand Down
67 changes: 0 additions & 67 deletions example/ios/InstabugTests/ApmApiTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ - (void)setUp {
self.api = [[ApmApi alloc] init];
}

- (IBGExecutionTrace *)mockTraceWithId:(NSString *)traceId {
NSString* name = @"trace-name";
IBGExecutionTrace *mTrace = OCMClassMock([IBGExecutionTrace class]);

OCMStub([self.mAPM startExecutionTraceWithName:name]).andReturn(mTrace);

[self.api startExecutionTraceId:traceId name:name completion:^(NSString * _Nullable _, FlutterError * _Nullable __) {}];

return mTrace;
}

- (void)testSetEnabled {
NSNumber *isEnabled = @1;
Expand Down Expand Up @@ -116,63 +106,6 @@ - (void)testSetAutoUITraceEnabled {
OCMVerify([self.mAPM setAutoUITraceEnabled:YES]);
}

- (void)testStartExecutionTraceWhenTraceNotNil {
NSString *expectedId = @"trace-id";
NSString *name = @"trace-name";
XCTestExpectation *expectation = [self expectationWithDescription:@"Call completion handler"];

IBGExecutionTrace *mTrace = OCMClassMock([IBGExecutionTrace class]);
OCMStub([self.mAPM startExecutionTraceWithName:name]).andReturn(mTrace);

[self.api startExecutionTraceId:expectedId name:name completion:^(NSString *actualId, FlutterError *error) {
[expectation fulfill];
XCTAssertEqual(actualId, expectedId);
XCTAssertNil(error);
}];

OCMVerify([self.mAPM startExecutionTraceWithName:name]);
[self waitForExpectations:@[expectation] timeout:5.0];
}

- (void)testStartExecutionTraceWhenTraceIsNil {
NSString *traceId = @"trace-id";
NSString *name = @"trace-name";
XCTestExpectation *expectation = [self expectationWithDescription:@"Call completion handler"];

OCMStub([self.mAPM startExecutionTraceWithName:name]).andReturn(nil);

[self.api startExecutionTraceId:traceId name:name completion:^(NSString *actualId, FlutterError *error) {
[expectation fulfill];
XCTAssertNil(actualId);
XCTAssertNil(error);
}];

OCMVerify([self.mAPM startExecutionTraceWithName:name]);
[self waitForExpectations:@[expectation] timeout:5.0];
}


- (void)testSetExecutionTraceAttribute {
NSString *traceId = @"trace-id";
NSString *key = @"is_premium";
NSString *value = @"true";
FlutterError *error;
id mTrace = [self mockTraceWithId:traceId];

[self.api setExecutionTraceAttributeId:traceId key:key value:value error:&error];

OCMVerify([mTrace setAttributeWithKey:key value:value]);
}

- (void)testEndExecutionTrace {
NSString *traceId = @"trace-id";
FlutterError *error;
IBGExecutionTrace *mTrace = [self mockTraceWithId:traceId];

[self.api endExecutionTraceId:traceId error:&error];

OCMVerify([mTrace end]);
}

- (void) testStartFlow {
NSString* appFlowName = @"app-flow-name";
Expand Down
4 changes: 2 additions & 2 deletions example/ios/InstabugTests/BugReportingApiTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ - (void)testSetCommentMinimumCharacterCountGivenReportTypes {

[self.api setCommentMinimumCharacterCountLimit:limit reportTypes:reportTypes error:&error];

OCMVerify([self.mBugReporting setCommentMinimumCharacterCountForReportTypes:IBGBugReportingReportTypeBug | IBGBugReportingReportTypeQuestion withLimit:limit.intValue]);
OCMVerify([self.mBugReporting setCommentMinimumCharacterCount:limit.intValue forBugReportType:IBGBugReportingReportTypeBug | IBGBugReportingReportTypeQuestion]);
}

- (void)testSetCommentMinimumCharacterCountGivenNoReportTypes {
Expand All @@ -172,7 +172,7 @@ - (void)testSetCommentMinimumCharacterCountGivenNoReportTypes {

[self.api setCommentMinimumCharacterCountLimit:limit reportTypes:reportTypes error:&error];

OCMVerify([self.mBugReporting setCommentMinimumCharacterCountForReportTypes:IBGBugReportingReportTypeBug | IBGBugReportingReportTypeFeedback | IBGBugReportingReportTypeQuestion withLimit:limit.intValue]);
OCMVerify([self.mBugReporting setCommentMinimumCharacterCount:limit.intValue forBugReportType:IBGBugReportingReportTypeBug | IBGBugReportingReportTypeFeedback | IBGBugReportingReportTypeQuestion]);
}
- (void)testAddUserConsentWithKey {
NSString *key = @"testKey";
Expand Down
Loading