generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
18
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 12 commits
Commits
Show all changes
18 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 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,206 @@ | ||
# Bugsee Integration Documentation | ||
|
||
This document provides a comprehensive guide to integrating and using **Bugsee** in your mobile application. Bugsee is a powerful tool for monitoring and debugging your app by capturing and reporting unhandled exceptions, providing insights into app crashes, user interactions, and more. | ||
|
||
## Overview | ||
|
||
**Bugsee** helps developers quickly identify and troubleshoot crashes, bugs, and performance issues in mobile applications. By integrating Bugsee, developers can capture detailed logs, screen recordings, and contextual data (such as user attributes) to understand and fix issues faster. | ||
|
||
--- | ||
|
||
## Features | ||
|
||
This implementation of Bugsee leverages the following features to provide robust exception tracking and reporting: | ||
|
||
### 1. Manual Invocation | ||
- Developers can trigger Bugsee for testing purposes or to verify the integration. You can also use different tokens for testing in different environments. | ||
- Documentation: [Bugsee SDK Docs](https://docs.bugsee.com/) | ||
|
||
### 2. Custom Data Reporting | ||
- Add additional user-specific data (like email addresses) or custom attributes to exception reports for better context. | ||
- **Email:** Helps identify the specific user experiencing issues. | ||
- **Attributes:** Attach custom key-value pairs for further context. | ||
- **Traces:** Track specific values or conditions before an exception occurs. | ||
- **Events:** Log events leading to exceptions and attach structured JSON data for detailed insights. | ||
- Documentation: [Bugsee Custom Data](https://docs.bugsee.com/) | ||
|
||
### 3. Exception Logging | ||
- Bugsee automatically captures unhandled exceptions in your Dart and Flutter code. | ||
- **Dart Exceptions:** Captures logic and data errors. | ||
- **Flutter Exceptions:** Captures rendering and layout errors. | ||
- You can also manually log exceptions with additional context, such as traces and events. | ||
- Documentation: [Bugsee Exception Logging](https://bugsee.com/) | ||
|
||
### 4. Video Capture | ||
- Bugsee automatically captures screen recordings of user interactions that lead to exceptions. This helps developers visually understand what the user was doing when the issue occurred. | ||
- You can disable video capture by setting the `videoEnabled` flag. | ||
- Documentation: [Bugsee Flutter Installation](https://docs.bugsee.com/sdk/flutter/installation/) | ||
|
||
### 5. Log Reporting and Filtering | ||
- Bugsee integrates with your app’s logging system. By default, logs are filtered to remove sensitive information to protect user privacy. | ||
- You can customize log collection behavior using configuration options. | ||
- Documentation: [Bugsee Log Reporting](https://docs.bugsee.com/sdk/flutter/installation/) | ||
|
||
### 6. Data Obfuscation | ||
- Sensitive user data (like passwords or personal information) in captured videos is automatically obscured by default to prevent leaks. | ||
- Documentation: [Bugsee Data Obscuration](https://docs.bugsee.com/sdk/flutter/installation/) | ||
|
||
--- | ||
|
||
## Default Configurations | ||
|
||
Bugsee’s behavior can be controlled via environment settings, particularly for data obscuration, log collection, and file attachment. The default configurations are defined in the `.env.staging` file as follows: | ||
|
||
```env | ||
BUGSEE_IS_DATA_OBSCURE=true # Enables data obscuration for captured videos | ||
BUGSEE_DISABLE_LOG_COLLECTION=true # Disables log collection by default | ||
BUGSEE_FILTER_LOG_COLLECTION=false # Allows all logs unless manually filtered | ||
BUGSEE_ATTACH_LOG_FILE=true # Attaches log files with Bugsee reports | ||
``` | ||
|
||
Ensure that these values are properly set for different environments (e.g., staging, production). | ||
|
||
--- | ||
|
||
## Implementation Details | ||
|
||
The Bugsee integration consists of several key components for handling configuration, exception tracking, and reporting. | ||
|
||
### 1. [Bugsee Manager](../src/app/lib/business/bugsee/bugsee_manager.dart) | ||
- Responsible for initializing Bugsee, capturing logs, and configuring Bugsee features (like video capture, data obfuscation, and log filtering). | ||
|
||
### 2. [Bugsee Config State](../src/app/lib/business/bugsee/bugsee_config_state.dart) | ||
- Maintains the current state of Bugsee’s features (enabled/disabled) within the app. | ||
|
||
### 3. [Bugsee Repository](../src/app/lib/access/bugsee/bugsee_repository.dart) | ||
- Handles the saving and retrieving of Bugsee configurations from shared preferences. | ||
|
||
### 4. [Bugsee Saved Configuration](../src/app/lib/access/bugsee/bugsee_configuration_data.dart) | ||
- Stores and manages the saved configurations used to initialize Bugsee upon app launch. | ||
|
||
--- | ||
|
||
## Exception Handling and Reporting | ||
|
||
### Intercepting Exceptions | ||
By default, Bugsee intercepts all unhandled Dart and Flutter exceptions globally: | ||
|
||
1. Dart Exceptions: | ||
- These are data or logic errors that happen within your Dart code. | ||
|
||
2. Flutter Exceptions: | ||
- These occur during layout or rendering issues. | ||
|
||
Both types of exceptions are captured and reported to Bugsee’s dashboard. | ||
|
||
The exceptions are intercepted using `runZonedGuarded` and `FlutterError.onError`: | ||
|
||
```dart | ||
// main.dart | ||
|
||
runZonedGuarded( | ||
() async { | ||
FlutterError.onError = | ||
GetIt.I.get<BugseeManager>().inteceptRenderExceptions; | ||
await initializeComponents(); | ||
await registerBugseeManager(); | ||
runApp(const App()); | ||
}, | ||
GetIt.I.get<BugseeManager>().inteceptExceptions, | ||
); | ||
|
||
// bugsee_manager.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, | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
Future<void> inteceptRenderExceptions(FlutterErrorDetails error) async { | ||
await logException( | ||
exception: Exception(error.exception), | ||
stackTrace: error.stack, | ||
); | ||
} | ||
``` | ||
|
||
### Manually Reporting Issues | ||
|
||
You can manually trigger Bugsee to capture logs and display a report dialog using the `showCaptureLogReport` method: | ||
|
||
```dart | ||
final bugseeManager = Get.I.get<BugseeManager>(); | ||
bugseeManager.showCaptureLogReport(); | ||
``` | ||
|
||
This is useful for debugging specific scenarios or reporting custom issues. | ||
|
||
### Manually Logging Exceptions | ||
|
||
To manually log an exception (with or without additional traces), use the `logException` method: | ||
|
||
```dart | ||
final bugseeManager = Get.I.get<BugseeManager>(); | ||
bugseeManager.logException(exception: Exception("Custom error")); | ||
``` | ||
|
||
You can add additional context **traces**: | ||
|
||
```dart | ||
bugseeManager.logException( | ||
exception: Exception("Custom error"), | ||
traces: ["Trace 1", "Trace 2"], // Add relevant traces | ||
); | ||
``` | ||
|
||
### Adding User Attributes | ||
|
||
To provide more context about the user experiencing the issue, you can add custom attributes such as an email address: | ||
|
||
- Add Email Attribute: | ||
|
||
```dart | ||
final bugseeManager = Get.I.get<BugseeManager>(); | ||
bugseeManager.addEmailAttribute("[email protected]"); | ||
``` | ||
|
||
- Clear Email Attribute: | ||
|
||
```dart | ||
bugseeManager.clearEmailAttribute(); | ||
``` | ||
|
||
- Add Custom Attributes: | ||
|
||
You can also add custom key-value pairs as additional attributes to enrich the exception reports: | ||
|
||
```dart | ||
bugseeManager.addAttributes({ | ||
"userType": "premium", | ||
"accountStatus": "active" | ||
}); | ||
``` | ||
|
||
## Additional Resources | ||
|
||
- [Bugsee SDK Documentation](https://docs.bugsee.com/) | ||
- [Bugsee Flutter Installation Guide](https://docs.bugsee.com/sdk/flutter/installation/) | ||
- [bugsee_flutter package](https://pub.dev/packages/bugsee_flutter) | ||
- [Handling Flutter errors](https://docs.flutter.dev/testing/errors) | ||
- [runZoneGuarded Error handling](https://api.flutter.dev/flutter/dart-async/runZonedGuarded.html) | ||
|
||
--- |
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 |
---|---|---|
@@ -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, | ||
]; | ||
} |
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.