diff --git a/CHANGELOG.md b/CHANGELOG.md index c7824fef1..324ce8a07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/android/src/main/java/com/instabug/flutter/modules/ApmApi.java b/android/src/main/java/com/instabug/flutter/modules/ApmApi.java index 607c569a4..b5ce437da 100644 --- a/android/src/main/java/com/instabug/flutter/modules/ApmApi.java +++ b/android/src/main/java/com/instabug/flutter/modules/ApmApi.java @@ -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; @@ -26,7 +25,6 @@ public class ApmApi implements ApmPigeon.ApmHostApi { private final String TAG = ApmApi.class.getName(); - private final HashMap traces = new HashMap<>(); public static void init(BinaryMessenger messenger) { final ApmApi api = new ApmApi(); @@ -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 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. @@ -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. diff --git a/android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java b/android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java index f3236bb4e..c845de0c1 100644 --- a/android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java +++ b/android/src/main/java/com/instabug/flutter/modules/BugReportingApi.java @@ -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 diff --git a/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java b/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java index f81cf3cc5..91782e85a 100644 --- a/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java +++ b/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java @@ -177,7 +177,6 @@ public void setWelcomeMessageMode(@NonNull String mode) { @Override public void setPrimaryColor(@NonNull Long color) { - Instabug.setPrimaryColor(color.intValue()); } @Override @@ -229,20 +228,7 @@ public void run() { ); } - @Override - public void addExperiments(@NonNull List experiments) { - Instabug.addExperiments(experiments); - } - @Override - public void removeExperiments(@NonNull List experiments) { - Instabug.removeExperiments(experiments); - } - - @Override - public void clearAllExperiments() { - Instabug.clearAllExperiments(); - } @Override public void addFeatureFlags(@NonNull Map featureFlags) { diff --git a/android/src/test/java/com/instabug/flutter/ApmApiTest.java b/android/src/test/java/com/instabug/flutter/ApmApiTest.java index 725d3bd98..39728c20c 100644 --- a/android/src/test/java/com/instabug/flutter/ApmApiTest.java +++ b/android/src/test/java/com/instabug/flutter/ApmApiTest.java @@ -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; @@ -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() { @@ -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 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 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() { diff --git a/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java b/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java index 6d22e26b8..50722762f 100644 --- a/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java +++ b/android/src/test/java/com/instabug/flutter/BugReportingApiTest.java @@ -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 diff --git a/android/src/test/java/com/instabug/flutter/InstabugApiTest.java b/android/src/test/java/com/instabug/flutter/InstabugApiTest.java index 158b67499..6be2eef92 100644 --- a/android/src/test/java/com/instabug/flutter/InstabugApiTest.java +++ b/android/src/test/java/com/instabug/flutter/InstabugApiTest.java @@ -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; @@ -348,30 +342,7 @@ public void testGetTags() { mInstabug.verify(Instabug::getTags); } - @Test - public void testAddExperiments() { - List experiments = Arrays.asList("premium", "star"); - - api.addExperiments(experiments); - - mInstabug.verify(() -> Instabug.addExperiments(experiments)); - } - @Test - public void testRemoveExperiments() { - List 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() { diff --git a/example/ios/InstabugTests/ApmApiTests.m b/example/ios/InstabugTests/ApmApiTests.m index bdb710ac7..3be2288d2 100644 --- a/example/ios/InstabugTests/ApmApiTests.m +++ b/example/ios/InstabugTests/ApmApiTests.m @@ -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; @@ -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"; diff --git a/example/ios/InstabugTests/BugReportingApiTests.m b/example/ios/InstabugTests/BugReportingApiTests.m index e01df21d2..5b6954d59 100644 --- a/example/ios/InstabugTests/BugReportingApiTests.m +++ b/example/ios/InstabugTests/BugReportingApiTests.m @@ -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 { @@ -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"; diff --git a/example/ios/InstabugTests/InstabugApiTests.m b/example/ios/InstabugTests/InstabugApiTests.m index 176e092a3..69b6343eb 100644 --- a/example/ios/InstabugTests/InstabugApiTests.m +++ b/example/ios/InstabugTests/InstabugApiTests.m @@ -200,31 +200,6 @@ - (void)testGetTags { [self waitForExpectations:@[expectation] timeout:5.0]; } -- (void)testAddExperiments { - NSArray *experiments = @[@"premium", @"star"]; - FlutterError *error; - - [self.api addExperimentsExperiments:experiments error:&error]; - - OCMVerify([self.mInstabug addExperiments:experiments]); -} - -- (void)testRemoveExperiments { - NSArray *experiments = @[@"premium", @"star"]; - FlutterError *error; - - [self.api removeExperimentsExperiments:experiments error:&error]; - - OCMVerify([self.mInstabug removeExperiments:experiments]); -} - -- (void)testClearAllExperiments { - FlutterError *error; - - [self.api clearAllExperimentsWithError:&error]; - - OCMVerify([self.mInstabug clearAllExperiments]); -} - (void)testAddFeatureFlags { NSDictionary *featureFlagsMap = @{ @"key13" : @"value1", @"key2" : @"value2"}; diff --git a/example/lib/main.dart b/example/lib/main.dart index 91b0a67e7..ca49f801e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -38,8 +38,6 @@ part 'src/components/network_content.dart'; part 'src/components/page.dart'; -part 'src/components/traces_content.dart'; - part 'src/components/flows_content.dart'; void main() { diff --git a/example/lib/src/components/traces_content.dart b/example/lib/src/components/traces_content.dart deleted file mode 100644 index 888460d43..000000000 --- a/example/lib/src/components/traces_content.dart +++ /dev/null @@ -1,157 +0,0 @@ -part of '../../main.dart'; - -class TracesContent extends StatefulWidget { - const TracesContent({Key? key}) : super(key: key); - - @override - State createState() => _TracesContentState(); -} - -class _TracesContentState extends State { - final traceNameController = TextEditingController(); - final traceKeyAttributeController = TextEditingController(); - final traceValueAttributeController = TextEditingController(); - - bool? didTraceEnd; - - Trace? trace; - - @override - Widget build(BuildContext context) { - final textTheme = Theme.of(context).textTheme; - return Column( - children: [ - InstabugTextField( - label: 'Trace name', - labelStyle: textTheme.labelMedium, - controller: traceNameController, - ), - SizedBox.fromSize( - size: const Size.fromHeight(10.0), - ), - Row( - children: [ - Flexible( - flex: 5, - child: InstabugButton.smallFontSize( - text: 'Start Trace', - onPressed: () => _startTrace(traceNameController.text), - margin: const EdgeInsetsDirectional.only( - start: 20.0, - end: 10.0, - ), - ), - ), - Flexible( - flex: 5, - child: InstabugButton.smallFontSize( - text: 'Start Trace With Delay', - onPressed: () => _startTrace( - traceNameController.text, - delayInMilliseconds: 5000, - ), - margin: const EdgeInsetsDirectional.only( - start: 10.0, - end: 20.0, - ), - ), - ), - ], - ), - Row( - children: [ - Flexible( - flex: 5, - child: InstabugTextField( - label: 'Trace Key Attribute', - controller: traceKeyAttributeController, - labelStyle: textTheme.labelMedium, - margin: const EdgeInsetsDirectional.only( - end: 10.0, - start: 20.0, - ), - ), - ), - Flexible( - flex: 5, - child: InstabugTextField( - label: 'Trace Value Attribute', - labelStyle: textTheme.labelMedium, - controller: traceValueAttributeController, - margin: const EdgeInsetsDirectional.only( - start: 10.0, - end: 20.0, - ), - ), - ), - ], - ), - SizedBox.fromSize( - size: const Size.fromHeight(10.0), - ), - InstabugButton( - text: 'Set Trace Attribute', - onPressed: () => _setTraceAttribute( - trace, - traceKeyAttribute: traceKeyAttributeController.text, - traceValueAttribute: traceValueAttributeController.text, - ), - ), - InstabugButton( - text: 'End Trace', - onPressed: () => _endTrace(), - ), - ], - ); - } - - void _startTrace( - String traceName, { - int delayInMilliseconds = 0, - }) { - if (traceName.trim().isNotEmpty) { - log('_startTrace — traceName: $traceName, delay in Milliseconds: $delayInMilliseconds'); - log('traceName: $traceName'); - Future.delayed( - Duration(milliseconds: delayInMilliseconds), - () => APM - .startExecutionTrace(traceName) - .then((value) => trace = value)); - } else { - log('startTrace - Please enter a trace name'); - } - } - - void _endTrace() { - if (didTraceEnd == true) { - log('_endTrace — Please, start a new trace before setting attributes.'); - } - if (trace == null) { - log('_endTrace — Please, start a trace before ending it.'); - } - log('_endTrace — ending Trace.'); - trace?.end(); - didTraceEnd = true; - } - - void _setTraceAttribute( - Trace? trace, { - required String traceKeyAttribute, - required String traceValueAttribute, - }) { - if (trace == null) { - log('_setTraceAttribute — Please, start a trace before setting attributes.'); - } - if (didTraceEnd == true) { - log('_setTraceAttribute — Please, start a new trace before setting attributes.'); - } - if (traceKeyAttribute.trim().isEmpty) { - log('_setTraceAttribute — Please, fill the trace key attribute input before settings attributes.'); - } - if (traceValueAttribute.trim().isEmpty) { - log('_setTraceAttribute — Please, fill the trace value attribute input before settings attributes.'); - } - log('_setTraceAttribute — setting attributes -> key: $traceKeyAttribute, value: $traceValueAttribute.'); - trace?.setAttribute(traceKeyAttribute, traceValueAttribute); - } -} diff --git a/example/lib/src/screens/apm_page.dart b/example/lib/src/screens/apm_page.dart index 798e906fa..d4ad53ca6 100644 --- a/example/lib/src/screens/apm_page.dart +++ b/example/lib/src/screens/apm_page.dart @@ -36,8 +36,6 @@ class _ApmPageState extends State { ), const SectionTitle('Network'), const NetworkContent(), - const SectionTitle('Traces'), - const TracesContent(), const SectionTitle('Flows'), const FlowsContent(), const SectionTitle('Screen Loading'), diff --git a/example/lib/src/screens/my_home_page.dart b/example/lib/src/screens/my_home_page.dart index 404d79cdd..5f7d50a88 100644 --- a/example/lib/src/screens/my_home_page.dart +++ b/example/lib/src/screens/my_home_page.dart @@ -114,10 +114,10 @@ class _MyHomePageState extends State { BugReporting.setInvocationEvents([invocationEvent]); } - void changePrimaryColor() { - String text = 'FF' + primaryColorController.text.replaceAll('#', ''); - Color color = Color(int.parse(text, radix: 16)); - Instabug.setPrimaryColor(color); + void changePrimaryColor() async { + String text = primaryColorController.text.replaceAll('#', ''); + await Instabug.setTheme(ThemeConfig(primaryColor: '#$text')); + await Future.delayed(const Duration(milliseconds: 500)); } void setColorTheme(ColorTheme colorTheme) { diff --git a/ios/Classes/Modules/ApmApi.m b/ios/Classes/Modules/ApmApi.m index c6295ce67..a8c5c1bd3 100644 --- a/ios/Classes/Modules/ApmApi.m +++ b/ios/Classes/Modules/ApmApi.m @@ -70,44 +70,6 @@ - (void)setAutoUITraceEnabledIsEnabled:(NSNumber *)isEnabled error:(FlutterError IBGAPM.autoUITraceEnabled = [isEnabled boolValue]; } -// This method is responsible for starting an execution trace -// with a given `id` and `name`. -// -// Deprecated - see [startFlowName, setFlowAttributeName & endFlowName]. -- (void)startExecutionTraceId:(NSString *)id name:(NSString *)name completion:(void(^)(NSString *_Nullable, FlutterError *_Nullable))completion { - IBGExecutionTrace *trace = [IBGAPM startExecutionTraceWithName:name]; - - if (trace != nil) { - [traces setObject:trace forKey:id]; - return completion(id, nil); - } else { - return completion(nil, nil); - } -} - -// This method is responsible for setting an attribute for a specific -// execution trace identified by the provided `id`. -// -// Deprecated - see [startFlowName, setFlowAttributeName & endFlowName]. -- (void)setExecutionTraceAttributeId:(NSString *)id key:(NSString *)key value:(NSString *)value error:(FlutterError *_Nullable *_Nonnull)error { - IBGExecutionTrace *trace = [traces objectForKey:id]; - - if (trace != nil) { - [trace setAttributeWithKey:key value:value]; - } -} - -// This method `endExecutionTraceId` is responsible for ending an execution trace identified by the -// provided `id`. -// -// Deprecated - see [startFlowName, setFlowAttributeName & endFlowName]. -- (void)endExecutionTraceId:(NSString *)id error:(FlutterError *_Nullable *_Nonnull)error { - IBGExecutionTrace *trace = [traces objectForKey:id]; - - if (trace != nil) { - [trace end]; - } -} // This method is responsible for starting a flow with the given `name`. This functionality is used to // track and monitor the performance of specific flows within the application. diff --git a/ios/Classes/Modules/BugReportingApi.m b/ios/Classes/Modules/BugReportingApi.m index bb97810b8..7a92a9563 100644 --- a/ios/Classes/Modules/BugReportingApi.m +++ b/ios/Classes/Modules/BugReportingApi.m @@ -151,8 +151,7 @@ - (void)setDisclaimerTextText:(NSString *)text error:(FlutterError *_Nullable *_ } - (void)setCommentMinimumCharacterCountLimit:(NSNumber *)limit reportTypes:(nullable NSArray *)reportTypes error:(FlutterError *_Nullable *_Nonnull)error { - IBGBugReportingReportType resolvedTypes = 0; - + IBGBugReportingType resolvedTypes = 0; if (![reportTypes count]) { resolvedTypes = (ArgsRegistry.reportTypes[@"ReportType.bug"]).integerValue | (ArgsRegistry.reportTypes[@"ReportType.feedback"]).integerValue | (ArgsRegistry.reportTypes[@"ReportType.question"]).integerValue; } @@ -162,7 +161,7 @@ - (void)setCommentMinimumCharacterCountLimit:(NSNumber *)limit reportTypes:(null } } - [IBGBugReporting setCommentMinimumCharacterCountForReportTypes:resolvedTypes withLimit:limit.intValue]; + [IBGBugReporting setCommentMinimumCharacterCount:[limit integerValue] forBugReportType:resolvedTypes]; } - (void)addUserConsentsKey:(NSString *)key diff --git a/ios/Classes/Modules/InstabugApi.m b/ios/Classes/Modules/InstabugApi.m index 01b271987..287071683 100644 --- a/ios/Classes/Modules/InstabugApi.m +++ b/ios/Classes/Modules/InstabugApi.m @@ -129,17 +129,7 @@ - (void)getTagsWithCompletion:(nonnull void (^)(NSArray * _Nullable, completion([Instabug getTags], nil); } -- (void)addExperimentsExperiments:(NSArray *)experiments error:(FlutterError *_Nullable *_Nonnull)error { - [Instabug addExperiments:experiments]; -} - -- (void)removeExperimentsExperiments:(NSArray *)experiments error:(FlutterError *_Nullable *_Nonnull)error { - [Instabug removeExperiments:experiments]; -} -- (void)clearAllExperimentsWithError:(FlutterError *_Nullable *_Nonnull)error { - [Instabug clearAllExperiments]; -} - (void)setUserAttributeValue:(NSString *)value key:(NSString *)key error:(FlutterError *_Nullable *_Nonnull)error { [Instabug setUserAttribute:value withKey:key]; diff --git a/lib/instabug_flutter.dart b/lib/instabug_flutter.dart index 66f74c2fb..2cc2e8eca 100644 --- a/lib/instabug_flutter.dart +++ b/lib/instabug_flutter.dart @@ -4,7 +4,6 @@ export 'src/models/exception_data.dart'; export 'src/models/feature_flag.dart'; export 'src/models/network_data.dart'; export 'src/models/theme_config.dart'; -export 'src/models/trace.dart'; export 'src/models/w3c_header.dart'; // Modules diff --git a/lib/src/models/trace.dart b/lib/src/models/trace.dart deleted file mode 100644 index bf267640b..000000000 --- a/lib/src/models/trace.dart +++ /dev/null @@ -1,44 +0,0 @@ -import 'package:instabug_flutter/src/modules/apm.dart'; - -class Trace { - Trace({ - required this.id, - required this.name, - }); - - final String id; - final String name; - final Map attributes = {}; - - /// Sets attribute of execution trace. - /// [String] id of the trace. - /// [String] key of attribute. - /// [String] value of attribute. - /// - /// Please migrate to the App Flows APIs: [APM.startFlow], [APM.setFlowAttribute], and [APM.endFlow]. - @Deprecated( - 'Please migrate to the App Flows APIs: APM.startAppFlow, APM.endFlow, and APM.setFlowAttribute. This feature was deprecated in v13.0.0', - ) - void setAttribute(String key, String value) { - APM.setExecutionTraceAttribute(id, key, value); - attributes[key] = value; - } - - /// Ends Execution Trace - /// - /// Please migrate to the App Flows APIs: [APM.startFlow], [APM.setFlowAttribute], and [APM.endFlow]. - @Deprecated( - 'Please migrate to the App Flows APIs: APM.startAppFlow, APM.endFlow, and APM.setFlowAttribute. This feature was deprecated in v13.0.0', - ) - void end() { - APM.endExecutionTrace(id); - } - - Map toJson() { - return { - 'id': id, - 'name': name, - 'attributes': attributes, - }; - } -} diff --git a/lib/src/modules/apm.dart b/lib/src/modules/apm.dart index a9f6e0a7c..970c9330e 100644 --- a/lib/src/modules/apm.dart +++ b/lib/src/modules/apm.dart @@ -5,9 +5,7 @@ import 'dart:async'; import 'package:flutter/widgets.dart' show WidgetBuilder; import 'package:instabug_flutter/src/generated/apm.api.g.dart'; import 'package:instabug_flutter/src/models/network_data.dart'; -import 'package:instabug_flutter/src/models/trace.dart'; import 'package:instabug_flutter/src/utils/ibg_build_info.dart'; -import 'package:instabug_flutter/src/utils/ibg_date_time.dart'; import 'package:instabug_flutter/src/utils/instabug_logger.dart'; import 'package:instabug_flutter/src/utils/screen_loading/screen_loading_manager.dart'; import 'package:meta/meta.dart'; @@ -72,58 +70,6 @@ class APM { return _host.setColdAppLaunchEnabled(isEnabled); } - /// Starts an execution trace. - /// [String] name of the trace. - /// - /// Please migrate to the App Flows APIs: [startFlow], [setFlowAttribute], and [endFlow]. - @Deprecated( - 'Please migrate to the App Flows APIs: APM.startAppFlow, APM.endFlow, and APM.setFlowAttribute. This feature was deprecated in v13.0.0', - ) - static Future startExecutionTrace(String name) async { - final id = IBGDateTime.instance.now(); - final traceId = await _host.startExecutionTrace(id.toString(), name); - - if (traceId == null) { - return Future.error( - "Execution trace $name wasn't created. Please make sure to enable APM first by following " - 'the instructions at this link: https://docs.instabug.com/reference#enable-or-disable-apm', - ); - } - - return Trace( - id: traceId, - name: name, - ); - } - - /// Sets attribute of an execution trace. - /// [String] id of the trace. - /// [String] key of attribute. - /// [String] value of attribute. - /// - /// Please migrate to the App Flows APIs: [startFlow], [setFlowAttribute], and [endFlow]. - @Deprecated( - 'Please migrate to the App Flows APIs: APM.startAppFlow, APM.endFlow, and APM.setFlowAttribute. This feature was deprecated in v13.0.0', - ) - static Future setExecutionTraceAttribute( - String id, - String key, - String value, - ) async { - return _host.setExecutionTraceAttribute(id, key, value); - } - - /// Ends an execution trace. - /// [String] id of the trace. - /// - /// Please migrate to the App Flows APIs: [startFlow], [setFlowAttribute], and [endFlow]. - @Deprecated( - 'Please migrate to the App Flows APIs: APM.startAppFlow, APM.endFlow, and APM.setFlowAttribute. This feature was deprecated in v13.0.0', - ) - static Future endExecutionTrace(String id) async { - return _host.endExecutionTrace(id); - } - /// Starts an AppFlow with the given [name]. /// /// The [name] must not be an empty string. It should be unique and not exceed 150 characters, diff --git a/lib/src/modules/instabug.dart b/lib/src/modules/instabug.dart index 41b66bc97..b36e60ab9 100644 --- a/lib/src/modules/instabug.dart +++ b/lib/src/modules/instabug.dart @@ -258,31 +258,6 @@ class Instabug { return tags?.cast(); } - /// Adds experiments to the next report. - @Deprecated( - 'Please migrate to the new feature flags APIs: Instabug.addFeatureFlags.', - ) - static Future addExperiments(List experiments) async { - return _host.addExperiments(experiments); - } - - /// Removes certain experiments from the next report. - @Deprecated( - 'Please migrate to the new feature flags APIs: Instabug.removeFeatureFlags.', - ) - static Future removeExperiments(List experiments) async { - return _host.removeExperiments(experiments); - } - - /// Clears all experiments from the next report. - - @Deprecated( - 'Please migrate to the new feature flags APIs: Instabug.clearAllFeatureFlags.', - ) - static Future clearAllExperiments() async { - return _host.clearAllExperiments(); - } - /// Adds feature flags to the next report. static Future addFeatureFlags(List featureFlags) async { final map = {}; @@ -358,8 +333,13 @@ class Instabug { /// Sets the primary color of the SDK's UI. /// Sets the color of UI elements indicating interactivity or call to action. /// [color] primaryColor A color to set the UI elements of the SDK to. + /// + /// Note: This API is deprecated. Please use `Instabug.setTheme` instead. + @Deprecated( + 'This API is deprecated. Please use Instabug.setTheme instead.', + ) static Future setPrimaryColor(Color color) async { - return _host.setPrimaryColor(color.value); + await setTheme(ThemeConfig(primaryColor: color.toString())); } /// Adds specific user data that you need to be added to the reports diff --git a/pigeons/apm.api.dart b/pigeons/apm.api.dart index 84fe9eb8e..25beca00e 100644 --- a/pigeons/apm.api.dart +++ b/pigeons/apm.api.dart @@ -11,18 +11,9 @@ abstract class ApmHostApi { void setColdAppLaunchEnabled(bool isEnabled); void setAutoUITraceEnabled(bool isEnabled); - @async - String? startExecutionTrace(String id, String name); - void startFlow(String name); void setFlowAttribute(String name, String key, String? value); void endFlow(String name); - void setExecutionTraceAttribute( - String id, - String key, - String value, - ); - void endExecutionTrace(String id); void startUITrace(String name); void endUITrace(); void endAppLaunch(); diff --git a/pigeons/instabug.api.dart b/pigeons/instabug.api.dart index 898199824..9ae724a66 100644 --- a/pigeons/instabug.api.dart +++ b/pigeons/instabug.api.dart @@ -37,9 +37,6 @@ abstract class InstabugHostApi { @async List? getTags(); - void addExperiments(List experiments); - void removeExperiments(List experiments); - void clearAllExperiments(); void addFeatureFlags(Map featureFlagsMap); void removeFeatureFlags(List featureFlags); void removeAllFeatureFlags(); diff --git a/test/apm_test.dart b/test/apm_test.dart index c801926f3..16cc2f26d 100644 --- a/test/apm_test.dart +++ b/test/apm_test.dart @@ -86,48 +86,6 @@ void main() { ).called(1); }); - test('[startExecutionTrace] should call host method', () async { - final id = DateTime.now(); - const name = "trace"; - - when(mDateTime.now()).thenAnswer((_) => id); - when(mHost.startExecutionTrace(id.toString(), name)) - .thenAnswer((_) async => id.toString()); - - // ignore: deprecated_member_use_from_same_package - final trace = await APM.startExecutionTrace(name); - - expect(trace.id, id.toString()); - - verify( - mHost.startExecutionTrace(id.toString(), name), - ).called(1); - }); - - test('[setExecutionTraceAttribute] should call host method', () async { - final id = DateTime.now().toString(); - const key = "attr-key"; - const attribute = "Trace Attribute"; - - // ignore: deprecated_member_use_from_same_package - await APM.setExecutionTraceAttribute(id, key, attribute); - - verify( - mHost.setExecutionTraceAttribute(id, key, attribute), - ).called(1); - }); - - test('[endExecutionTrace] should call host method', () async { - final id = DateTime.now().toString(); - - // ignore: deprecated_member_use_from_same_package - await APM.endExecutionTrace(id); - - verify( - mHost.endExecutionTrace(id), - ).called(1); - }); - test('[startFlow] should call host method', () async { const flowName = "flow-name"; await APM.startFlow(flowName); diff --git a/test/instabug_test.dart b/test/instabug_test.dart index e2fd7d298..5b5606b21 100644 --- a/test/instabug_test.dart +++ b/test/instabug_test.dart @@ -197,16 +197,6 @@ void main() { ).called(1); }); - test('[setPrimaryColor] should call host method', () async { - const color = Color(0x00000000); - - await Instabug.setPrimaryColor(color); - - verify( - mHost.setPrimaryColor(color.value), - ).called(1); - }); - test('[setSessionProfilerEnabled] should call host method', () async { const enabled = true; @@ -258,37 +248,6 @@ void main() { ).called(1); }); - test('[addExperiments] should call host method', () async { - const experiments = ["exp-1", "exp-2"]; - - // ignore: deprecated_member_use_from_same_package - await Instabug.addExperiments(experiments); - - verify( - mHost.addExperiments(experiments), - ).called(1); - }); - - test('[removeExperiments] should call host method', () async { - const experiments = ["exp-1", "exp-2"]; - - // ignore: deprecated_member_use_from_same_package - await Instabug.removeExperiments(experiments); - - verify( - mHost.removeExperiments(experiments), - ).called(1); - }); - - test('[clearAllExperiments] should call host method', () async { - // ignore: deprecated_member_use_from_same_package - await Instabug.clearAllExperiments(); - - verify( - mHost.clearAllExperiments(), - ).called(1); - }); - test('[addFeatureFlags] should call host method', () async { await Instabug.addFeatureFlags([ FeatureFlag(name: 'name1', variant: 'variant1'), @@ -474,4 +433,14 @@ void main() { mHost.willRedirectToStore(), ).called(1); }); + + test('[setTheme] should call host method with theme config', () async { + const themeConfig = ThemeConfig(primaryColor: '#FF0000'); + + await Instabug.setTheme(themeConfig); + + verify( + mHost.setTheme(themeConfig.toMap()), + ).called(1); + }); } diff --git a/test/trace_test.dart b/test/trace_test.dart deleted file mode 100644 index 2415420be..000000000 --- a/test/trace_test.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:flutter/widgets.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:instabug_flutter/instabug_flutter.dart'; -import 'package:instabug_flutter/src/generated/apm.api.g.dart'; -import 'package:mockito/annotations.dart'; -import 'package:mockito/mockito.dart'; - -import 'trace_test.mocks.dart'; - -@GenerateMocks([ - ApmHostApi, -]) -void main() { - TestWidgetsFlutterBinding.ensureInitialized(); - WidgetsFlutterBinding.ensureInitialized(); - - final mHost = MockApmHostApi(); - final trace = Trace( - id: "trace", - name: "Execution Trace", - ); - - setUpAll(() { - APM.$setHostApi(mHost); - }); - - test('[end] should call host method', () async { - // ignore: deprecated_member_use_from_same_package - trace.end(); - - verify( - mHost.endExecutionTrace(trace.id), - ).called(1); - }); - - test('[setAttribute] should call host method', () async { - const key = "attr-key"; - const attribute = "Trace Attribute"; - // ignore: deprecated_member_use_from_same_package - trace.setAttribute(key, attribute); - - verify( - mHost.setExecutionTraceAttribute(trace.id, key, attribute), - ).called(1); - }); -}