-
Notifications
You must be signed in to change notification settings - Fork 2
Integrate advanced Bugsee features #49
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
koukibadr
wants to merge
19
commits into
main
Choose a base branch
from
config/bk/integrate-advanced-bugsee
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4d9287a
feat: implement bugsee data obscure from reported videos
koukibadr 621f58e
feat: customize logs, traces and events reported to Bugsee dashboard
koukibadr 0f12bb3
feat: implement custom attributes and attach file bugsee features
koukibadr 12f2d65
feat: implement global bugsee exception handler
koukibadr 0f27491
chore: add flutter framework rendering error interceptor handler
koukibadr 7f20a67
docs: update project changelog
koukibadr ac885a0
chore: update bugsee manager singleton registration in main file
koukibadr f6a6938
chore: add mock attribute to bugsee manager initialization
koukibadr 9906020
chore: add platform check when intializing Bugsee
koukibadr e7cb678
docs: add Bugsee implementation documentation
koukibadr 934f7f6
chore: update Bugsee integration documentation and event caputring me…
koukibadr 035775e
chore: create global exception interceptor
koukibadr b545120
Merge branch 'main' into config/bk/integrate-advanced-bugsee
koukibadr 5ac9d49
chore: update code documentation in exception interceptor
koukibadr b87addb
chore: update production env variables
koukibadr cced807
chore: update changelog documentation
koukibadr f8182fc
Merge branch 'main' into config/bk/integrate-advanced-bugsee
koukibadr 99049c3
Merge branch 'main' into config/bk/integrate-advanced-bugsee
carlh98 c754cc7
Merge branch 'main' into config/bk/integrate-advanced-bugsee
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| # Bugsee | ||
|
|
||
| This project include [Bugsee](https://www.bugsee.com/) reporting and Logging, for both Android and iOS apps. | ||
| Bugsee lets you monitor and get instant log of unhandled exceptions with traces, events, stacktrace and videos/screenshots of the reported exception. More features are provided by Bugsee like data obscuration and log filter. | ||
|
|
||
| For this implementation we've used [bugsee_flutter](https://pub.dev/packages/bugsee_flutter) package. | ||
|
|
||
| - By default only release apps will have Bugsee reporting enabled, to enable Bugsee in debug mode add your token in `launch.json` add remove the check on debug mode in `BugseeManager` class. | ||
| - **Token** | ||
| - Generate your token in order to test Bugsee logging and reporting | ||
| - Head to [Bugsee dashboard](https://www.bugsee.com/) | ||
| - Create a new account | ||
| - Create a new Android/iOS (choose Flutter framework) | ||
| - Copy-paste the generated token into `launch.json` | ||
|
|
||
|
|
||
| ## 1) Features | ||
|
|
||
| In this project we've implemented the following features of Bugsee: | ||
| - [Manual invocation](https://docs.bugsee.com/sdk/flutter/manual/) helpfull for developers to test their Bugsee integration and setup with new tokens. | ||
| - [Custom data](https://docs.bugsee.com/sdk/flutter/custom/) custom data could be attached to the logged exceptions (emails or other type of data) | ||
| - [Email](https://docs.bugsee.com/sdk/flutter/custom/#:~:text=Adding%20custom%20data-,User%20email,-When%20you%20already) this will identify the user whom experienced the exception/bug this will update the exception dashboard item from anonymous to the user's mail this data will be reported with every logged exception unless the app is deleted or removed manually. | ||
| - [Attributes](https://docs.bugsee.com/sdk/flutter/custom/#:~:text=User/Session%20attributes) attributes related to the user info, will be reported with every logged exception unless the app is deleted or removed manually. | ||
| - [Traces](https://docs.bugsee.com/sdk/flutter/custom/#:~:text=them%0ABugsee.clearAllAttributes()%3B-,Custom%20traces,-Traces%20may%20be) helpfull when developer want to track the change of specific value before the logging of the exception. | ||
| - [Events](https://docs.bugsee.com/sdk/flutter/custom/#:~:text=Custom%20events-,Events,-are%20identified%20by) highlight on which event the exception is logged, accept also json data attached to it. | ||
| - [Exception Logging](https://docs.bugsee.com/sdk/flutter/logs/) the app automatically log every unhandled exception: Dart SDK exception are related to data or logic errors and Flutter SDK errors that are related to layout and rendering issues. The implementation also offer an API to manually log an exception with traces and events. | ||
| - [Video Capturing](https://docs.bugsee.com/sdk/flutter/privacy/video/) video capturing is by default enabled in this project, but it can be turned off using the `videoEnabled` flag in the launchOptions object for Android and iOS. | ||
| - [Log reporting](https://docs.bugsee.com/sdk/flutter/privacy/logs/) all logs are filtered by default using the `_filterBugseeLogs` method, this can be turned off from the app or by removing the call to `setLogFilter` Bugsee method. | ||
| - [Obscure Data](https://docs.bugsee.com/sdk/flutter/privacy/video/#:~:text=Protecting%20flutter%20views): data obscuration is by default enabled in the project in order to protect user-related data from being leaked through captured videos. | ||
|
koukibadr marked this conversation as resolved.
Outdated
|
||
|
|
||
| **Default configurations:** | ||
| Data obscuration, log collection, log filter and attaching log file features are initialized from the `.env.staging` file. | ||
| ``` | ||
| BUGSEE_IS_DATA_OBSCURE=true | ||
| BUGSEE_DISABLE_LOG_COLLECTION=true | ||
| BUGSEE_FILTER_LOG_COLLECTION=false | ||
| BUGSEE_ATTACH_LOG_FILE=true | ||
| ``` | ||
|
|
||
| ## 2) Implementation | ||
| - [Bugsee Manager](../src/app/lib/business/bugsee/bugsee_manager.dart): a service class that handle the Bugsee intialization, capturing logs, customize Bugsee fields and features (Video capture, data obscure, logs filter...) . | ||
| - [Bugsee Config State](../src/app/lib/business/bugsee/bugsee_config_state.dart): a state class holds all the actual Bugsee features status (whether enabled or not). | ||
| - [Bugsee Repository](../src/app/lib/access/bugsee/bugsee_repository.dart): save and retrieve Bugsee configuration from the shared preference storage. | ||
| - [Bugsee saved configuration](../src/app/lib/access/bugsee/bugsee_configuration_data.dart): holds the Bugsee saved configuration in shared preference, used in [Bugsee Manager](../src/app/lib/business/bugsee/bugsee_manager.dart) to initialize [Bugsee Config State](../src/app/lib/business/bugsee/bugsee_config_state.dart). | ||
|
|
||
| ### Intecepting exceptions | ||
| Bugsee implementation in this project, by default intecepts all the unhandled Dart and Flutter exception. | ||
|
|
||
| `main.dart` | ||
| ```dart | ||
| runZonedGuarded( | ||
| () async { | ||
| FlutterError.onError = | ||
| GetIt.I.get<BugseeManager>().inteceptRenderExceptions; | ||
| await initializeComponents(); | ||
| await registerBugseeManager(); | ||
| runApp(const App()); | ||
| }, | ||
| GetIt.I.get<BugseeManager>().inteceptExceptions, | ||
| ); | ||
| ``` | ||
| the `inteceptExceptions` and `inteceptRenderExceptions` recerespectively report Dart and Flutter exceptions to the Bugsee Dashboard. | ||
|
koukibadr marked this conversation as resolved.
Outdated
|
||
|
|
||
| `inteceptExceptions` | ||
| ```dart | ||
| @override | ||
| Future<void> inteceptExceptions( | ||
| Object error, | ||
| StackTrace stackTrace, | ||
| ) async { | ||
| String? message = switch (error.runtimeType) { | ||
| const (PersistenceException) => (error as PersistenceException).message, | ||
| _ => null, | ||
| }; | ||
| await logException( | ||
| exception: Exception(error), | ||
| stackTrace: stackTrace, | ||
| traces: { | ||
| 'message': message, | ||
| }, | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| `inteceptRenderExceptions` | ||
| ```dart | ||
| @override | ||
| Future<void> inteceptRenderExceptions(FlutterErrorDetails error) async { | ||
| await logException( | ||
| exception: Exception(error.exception), | ||
| stackTrace: error.stack, | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ### Manually invoke report dialog | ||
|
|
||
| To manually display the report dialog, you call the `showCaptureLogReport` method from the `BugseeManager` class. | ||
|
|
||
| ```dart | ||
| final bugseeManager = Get.I.get<BugseeManager>(); | ||
| bugseeManger.showCaptureLogReport(); | ||
| ``` | ||
|
|
||
|
|
||
| ### Manually log an exception | ||
|
|
||
| To manually log an exception, you call the `logException` method from the `BugseeManager` class. You can add traces and events to the reported exception. | ||
|
|
||
| ```dart | ||
| final bugseeManager = Get.I.get<BugseeManager>(); | ||
| bugseeManger.logException(exception: Exception()); | ||
| ``` | ||
|
|
||
|
|
||
| ### Add attributes | ||
|
|
||
| To attach the user's email to the logged exception use `addEmailAttribute` method and to clear this attribute you can use `clearEmailAttribute`. | ||
|
|
||
| ```dart | ||
| final bugseeManager = Get.I.get<BugseeManager>(); | ||
| bugseeManger.addEmailAttribute("johndoe@nventive.com"); | ||
| //some other code.. | ||
| bugseeManger.clearEmailAttribute(); | ||
| ``` | ||
|
|
||
| for other attributes you can use `addAttributes` with a map where key is the attribute name and value is the attribute value. To clear these attributes use `clearAttribute` and pass the attribute name to it. | ||
|
|
||
| ```dart | ||
| final bugseeManager = Get.I.get<BugseeManager>(); | ||
| bugseeManger.addAttributes({ | ||
| 'name': 'john', | ||
| 'age': 45, | ||
| }); | ||
| //some other code.. | ||
| bugseeManger.clearAttribute('name'); | ||
| ``` | ||
|
|
||
| ## 3) Deployment | ||
|
|
||
| The Bugsee token is injected directly in the azure devops pipeline when building the Android/iOS app for release mode in the [Android Build Job](../build/steps-build-android.yml) and [iOS Build Job](../build/steps-build-ios.yml) under the `multiDartDefine` parameter. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
|
|
||
| /// Test all Bugsee setup features | ||
| Future<void> bugseeSetupTest() async { | ||
| testWidgets( | ||
| 'Test Bugsee configuration', | ||
| (tester) async {}, | ||
|
koukibadr marked this conversation as resolved.
Outdated
|
||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,59 @@ | ||
| final class BugseeConfigurationData { | ||
| import 'package:equatable/equatable.dart'; | ||
|
|
||
| final class BugseeConfigurationData extends Equatable { | ||
| /// Gets whether the Bugsee SDK is enabled or not. if [Null] it fallbacks to a new installed app so it will be enabled. | ||
| final bool? isBugseeEnabled; | ||
|
|
||
| /// Indicate whether the video capturing feature in Bugsee is enabled or not. | ||
| /// Indicates whether the video capturing feature in Bugsee is enabled or not. | ||
| final bool? isVideoCaptureEnabled; | ||
|
|
||
| /// Indicates whether Bugsee obscures application data in videos and images or not. | ||
| final bool? isDataObscured; | ||
|
|
||
| /// Indicates whether logs are collected or not. | ||
| final bool? isLogCollectionEnabled; | ||
|
|
||
| /// Indicates whether logs are filtred during reports or not. | ||
| final bool? isLogsFilterEnabled; | ||
|
|
||
| /// Indicates whether attaching file in the Bugsee report is enabled or not | ||
| final bool? attachLogFileEnabled; | ||
|
|
||
| const BugseeConfigurationData({ | ||
| required this.isBugseeEnabled, | ||
| required this.isVideoCaptureEnabled, | ||
| this.isBugseeEnabled, | ||
| this.isVideoCaptureEnabled, | ||
| this.isDataObscured, | ||
| this.isLogCollectionEnabled, | ||
| this.isLogsFilterEnabled, | ||
| this.attachLogFileEnabled, | ||
| }); | ||
|
|
||
| BugseeConfigurationData copyWith({ | ||
| bool? isBugseeEnabled, | ||
| bool? isVideoCaptureEnabled, | ||
| bool? isDataObscured, | ||
| bool? isLogCollectionEnabled, | ||
| bool? isLogsFilterEnabled, | ||
| bool? attachLogFileEnabled, | ||
| }) => | ||
| BugseeConfigurationData( | ||
| isBugseeEnabled: isBugseeEnabled ?? this.isBugseeEnabled, | ||
| isVideoCaptureEnabled: | ||
| isVideoCaptureEnabled ?? this.isVideoCaptureEnabled, | ||
| isDataObscured: isDataObscured ?? this.isDataObscured, | ||
| isLogCollectionEnabled: | ||
| isLogCollectionEnabled ?? this.isLogCollectionEnabled, | ||
| isLogsFilterEnabled: isLogsFilterEnabled ?? this.isLogsFilterEnabled, | ||
| attachLogFileEnabled: attachLogFileEnabled ?? this.attachLogFileEnabled, | ||
| ); | ||
|
|
||
| @override | ||
| List<Object?> get props => [ | ||
| isBugseeEnabled, | ||
| isVideoCaptureEnabled, | ||
| isDataObscured, | ||
| isLogCollectionEnabled, | ||
| isLogsFilterEnabled, | ||
| attachLogFileEnabled, | ||
| ]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.