Skip to content

Commit 0f12bb3

Browse files
committed
feat: implement custom attributes and attach file bugsee features
2 parents 621f58e + 3e1ff16 commit 0f12bb3

12 files changed

Lines changed: 233 additions & 19 deletions

build/steps-build-android.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ steps:
8989
profileMode: false
9090
projectDirectory: '${{ parameters.pathToSrc }}/app'
9191
verboseMode: true
92-
dartDefine: ENV=$(applicationEnvironment)
93-
dartDefine: BUGSEE_TOKEN=$(AndroidBugseeToken)
92+
dartDefineMulti: ENV=$(applicationEnvironment) BUGSEE_TOKEN=$(AndroidBugseeToken)
9493

9594
- template: templates/flutter-diagnostics.yml
9695
parameters:

build/steps-build-ios.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ steps:
9595
projectDirectory: '${{ parameters.pathToSrc }}/app'
9696
verboseMode: true
9797
exportOptionsPlist: '$(exportOptions.secureFilePath)'
98-
dartDefine: ENV=$(applicationEnvironment)
99-
dartDefine: BUGSEE_TOKEN=$(iOSBugseeToken)
98+
dartDefineMulti: ENV=$(applicationEnvironment) BUGSEE_TOKEN=$(iOSBugseeToken)
10099

101100
- template: templates/flutter-diagnostics.yml
102101
parameters:

src/app/.env.staging

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ REMOTE_CONFIG_FETCH_INTERVAL_MINUTES=1
88
DIAGNOSTIC_ENABLED=true
99
IS_DATA_OBSCURE=true
1010
DISABLE_LOG_COLLECTION=true
11-
FILTER_LOG_COLLECTION=true
11+
FILTER_LOG_COLLECTION=true
12+
ATTACH_LOG_FILE=true

src/app/lib/access/bugsee/bugsee_configuration_data.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ final class BugseeConfigurationData extends Equatable {
1616
/// Indicate whether logs are filtred during reports or not.
1717
final bool? isLogsFilterEnabled;
1818

19+
final bool? attachLogFileEnabled;
20+
1921
const BugseeConfigurationData({
2022
this.isBugseeEnabled,
2123
this.isVideoCaptureEnabled,
2224
this.isDataObscured,
2325
this.isLogCollectionEnabled,
2426
this.isLogsFilterEnabled,
27+
this.attachLogFileEnabled,
2528
});
2629

2730
BugseeConfigurationData copyWith({
@@ -30,6 +33,7 @@ final class BugseeConfigurationData extends Equatable {
3033
bool? isDataObscured,
3134
bool? isLogCollectionEnabled,
3235
bool? isLogsFilterEnabled,
36+
bool? attachLogFileEnabled,
3337
}) =>
3438
BugseeConfigurationData(
3539
isBugseeEnabled: isBugseeEnabled ?? this.isBugseeEnabled,
@@ -39,6 +43,7 @@ final class BugseeConfigurationData extends Equatable {
3943
isLogCollectionEnabled:
4044
isLogCollectionEnabled ?? this.isLogCollectionEnabled,
4145
isLogsFilterEnabled: isLogsFilterEnabled ?? this.isLogsFilterEnabled,
46+
attachLogFileEnabled: attachLogFileEnabled ?? this.attachLogFileEnabled,
4247
);
4348

4449
@override
@@ -48,5 +53,6 @@ final class BugseeConfigurationData extends Equatable {
4853
isDataObscured,
4954
isLogCollectionEnabled,
5055
isLogsFilterEnabled,
56+
attachLogFileEnabled,
5157
];
5258
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import 'package:bugsee_flutter/bugsee_flutter.dart';
2+
3+
AndroidLaunchOptions androidLaunchOptions = AndroidLaunchOptions()
4+
..captureDeviceAndNetworkNames = false
5+
..captureLogs = false
6+
..crashReport = false
7+
..defaultBugPriority = BugseeSeverityLevel.blocker
8+
..defaultCrashPriority = BugseeSeverityLevel.critical
9+
..frameRate = BugseeFrameRate.low
10+
..maxDataSize = 20
11+
..maxNetworkBodySize = 20
12+
..maxRecordingTime = 20
13+
..monitorNetwork = false
14+
..notificationBarTrigger = false
15+
..reportDescriptionRequired = false
16+
..reportEmailRequired = false
17+
..reportLabelsEnabled = false
18+
..reportLabelsRequired = false
19+
..reportPrioritySelector = false
20+
..reportSummaryRequired = false
21+
..screenshotEnabled = false
22+
..serviceMode = false
23+
..shakeToReport = false
24+
..videoEnabled = false
25+
..videoMode = BugseeVideoMode.v1
26+
..videoQuality = BugseeVideoQuality.defaultQuality
27+
..videoScale = 0.5
28+
..viewHierarchyEnabled = false
29+
..wifiOnlyUpload = true;
30+
31+
IOSLaunchOptions iOSLaunchOptions = IOSLaunchOptions()
32+
..captureDeviceAndNetworkNames = false
33+
..captureLogs = false
34+
..crashReport = false
35+
..defaultBugPriority = BugseeSeverityLevel.blocker
36+
..defaultCrashPriority = BugseeSeverityLevel.critical
37+
..frameRate = BugseeFrameRate.low
38+
..maxDataSize = 20
39+
..maxNetworkBodySize = 20
40+
..maxRecordingTime = 20
41+
..monitorNetwork = false
42+
..reportDescriptionRequired = false
43+
..reportEmailRequired = false
44+
..reportLabelsEnabled = false
45+
..reportLabelsRequired = false
46+
..reportPrioritySelector = false
47+
..reportSummaryRequired = false
48+
..screenshotEnabled = false
49+
..shakeToReport = false
50+
..videoEnabled = false
51+
..videoScale = 0.5
52+
..viewHierarchyEnabled = false
53+
..wifiOnlyUpload = true;

src/app/lib/access/bugsee/bugsee_repository.dart

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ abstract interface class BugseeRepository {
1717
/// Update whether data is obscure in shared prefs.
1818
Future setIsDataObscure(bool isDataObscure);
1919

20-
/// Update whether [disableLogCollectionKey] flag.
20+
/// Update the logCollection flag in shared prefs.
2121
Future setIsLogCollectionEnabled(bool isLogCollectionEnabled);
2222

23-
/// Update whether [disableLogFilterKey] flag.
23+
/// Update the logFilter flag in shared prefs.
2424
Future setIsLogFilterEnabled(bool isLogFilterEnabled);
25+
26+
/// Update the attachFile boolean flag in shared prefs.
27+
Future setAttachLogFileEnabled(bool attachLogFile);
2528
}
2629

2730
final class _BugseeRepository implements BugseeRepository {
@@ -30,6 +33,7 @@ final class _BugseeRepository implements BugseeRepository {
3033
final String _dataObscureKey = 'dataObscureKey';
3134
final String _disableLogCollectionKey = 'disableLogCollectionKey';
3235
final String _disableLogFilterKey = 'disableLogFilterKey';
36+
final String _attachLogFileKey = 'attachLogFileKey';
3337

3438
@override
3539
Future<BugseeConfigurationData> getBugseeConfiguration() async {
@@ -41,6 +45,7 @@ final class _BugseeRepository implements BugseeRepository {
4145
isLogCollectionEnabled:
4246
sharedPrefInstance.getBool(_disableLogCollectionKey),
4347
isLogsFilterEnabled: sharedPrefInstance.getBool(_disableLogFilterKey),
48+
attachLogFileEnabled: sharedPrefInstance.getBool(_attachLogFileKey),
4449
);
4550
}
4651

@@ -125,4 +130,20 @@ final class _BugseeRepository implements BugseeRepository {
125130
);
126131
}
127132
}
133+
134+
@override
135+
Future setAttachLogFileEnabled(bool attachLogFile) async {
136+
final sharedPrefInstance = await SharedPreferences.getInstance();
137+
138+
bool isSaved = await sharedPrefInstance.setBool(
139+
_attachLogFileKey,
140+
attachLogFile,
141+
);
142+
143+
if (!isSaved) {
144+
throw PersistenceException(
145+
message: 'Error while setting $_attachLogFileKey $attachLogFile',
146+
);
147+
}
148+
}
128149
}

src/app/lib/business/bugsee/bugsee_config_state.dart

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,56 @@ final class BugseeConfigState extends Equatable {
44
/// Indicate if the app require a restart to reactivate the bugsee configurations
55
///
66
/// `true` only if `isConfigurationValid == true` and bugsee is turned on
7-
bool isRestartRequired;
7+
final bool isRestartRequired;
88

99
/// Indicate if bugsee is enabled or not
1010
/// by default bugsee is enabled if `isConfigurationValid == true`.
11-
bool isBugseeEnabled;
11+
final bool isBugseeEnabled;
1212

1313
/// Indicate whether video capturing is enabled or not.
1414
/// enabled by default if `isBugseeEnabled == true`.
1515
///
1616
/// cannot be true if `isBugseeEnabled == false`.
17-
bool isVideoCaptureEnabled;
17+
final bool isVideoCaptureEnabled;
1818

1919
/// Indicate if bugsee configuration is valid
2020
/// config is valid if app in release mode and the provided token is valid
2121
/// following the [bugseeTokenFormat] regex.
22-
bool isConfigurationValid;
22+
final bool isConfigurationValid;
2323

2424
/// Indicate whether data is obscured in report videos
2525
///
2626
/// cannot be true if `isBugseeEnabled == false`.
27-
bool isDataObscured;
27+
final bool isDataObscured;
2828

2929
/// Indicate whether log will be collected during Bugsee reporting or not
3030
/// by default logs are collected but filterd.
3131
///
3232
/// This value is initialized from [dotenv.env] and shared prefs storage.
33-
bool isLogCollectionEnabled;
33+
final bool isLogCollectionEnabled;
3434

3535
/// Indicate whether log will be filterd or not
3636
/// by default all logs are filted using [bugseeFilterRegex] defined in [BugseeManager]
3737
///
3838
/// This value is initialized from [dotenv.env] map and shared prefs storage.
39-
bool isLogFilterEnabled;
39+
final bool isLogFilterEnabled;
4040

41-
BugseeConfigState({
41+
/// Indicate whether Bugsee will attach the log file when reporting crashes/exceptions
42+
/// or not
43+
///
44+
/// The initial value is taken from [dotenv.env] and shared prefs.
45+
/// By default it's enabled.
46+
final bool attachLogFile;
47+
48+
const BugseeConfigState({
4249
this.isRestartRequired = false,
4350
this.isBugseeEnabled = false,
4451
this.isVideoCaptureEnabled = false,
4552
this.isConfigurationValid = false,
4653
this.isDataObscured = false,
4754
this.isLogCollectionEnabled = false,
4855
this.isLogFilterEnabled = false,
56+
this.attachLogFile = false,
4957
});
5058

5159
BugseeConfigState copyWith({
@@ -56,13 +64,15 @@ final class BugseeConfigState extends Equatable {
5664
bool? isDataObscured,
5765
bool? isLogCollectionEnabled,
5866
bool? isLogFilterEnabled,
67+
bool? attachLogFile,
5968
}) =>
6069
BugseeConfigState(
6170
isRestartRequired: isRestartRequired ?? this.isRestartRequired,
6271
isBugseeEnabled: isBugseeEnabled ?? this.isBugseeEnabled,
6372
isConfigurationValid: isConfigurationValid ?? this.isConfigurationValid,
6473
isDataObscured: isDataObscured ?? this.isDataObscured,
6574
isLogFilterEnabled: isLogFilterEnabled ?? this.isLogFilterEnabled,
75+
attachLogFile: attachLogFile ?? this.attachLogFile,
6676
isLogCollectionEnabled:
6777
isLogCollectionEnabled ?? this.isLogCollectionEnabled,
6878
isVideoCaptureEnabled:

0 commit comments

Comments
 (0)