Skip to content

Commit 621f58e

Browse files
committed
feat: customize logs, traces and events reported to Bugsee dashboard
1 parent 4d9287a commit 621f58e

6 files changed

Lines changed: 248 additions & 25 deletions

File tree

src/app/.env.staging

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ APP_STORE_URL_IOS=https://apps.apple.com/us/app/uno-calculator/id1464736591
66
APP_STORE_URL_Android=https://play.google.com/store/apps/details?id=uno.platform.calculator
77
REMOTE_CONFIG_FETCH_INTERVAL_MINUTES=1
88
DIAGNOSTIC_ENABLED=true
9-
IS_DATA_OBSCURE=true
9+
IS_DATA_OBSCURE=true
10+
DISABLE_LOG_COLLECTION=true
11+
FILTER_LOG_COLLECTION=true
Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,52 @@
1-
final class BugseeConfigurationData {
1+
import 'package:equatable/equatable.dart';
2+
3+
final class BugseeConfigurationData extends Equatable {
24
/// Gets whether the Bugsee SDK is enabled or not. if [Null] it fallbacks to a new installed app so it will be enabled.
35
final bool? isBugseeEnabled;
46

57
/// Indicate whether the video capturing feature in Bugsee is enabled or not.
68
final bool? isVideoCaptureEnabled;
79

810
/// Indicate whether bugsee obscure application data in videos and images or not.
9-
final bool? isDataObscrured;
11+
final bool? isDataObscured;
12+
13+
/// Indicate whether logs are collected or not.
14+
final bool? isLogCollectionEnabled;
15+
16+
/// Indicate whether logs are filtred during reports or not.
17+
final bool? isLogsFilterEnabled;
1018

1119
const BugseeConfigurationData({
1220
this.isBugseeEnabled,
1321
this.isVideoCaptureEnabled,
14-
this.isDataObscrured,
22+
this.isDataObscured,
23+
this.isLogCollectionEnabled,
24+
this.isLogsFilterEnabled,
1525
});
26+
27+
BugseeConfigurationData copyWith({
28+
bool? isBugseeEnabled,
29+
bool? isVideoCaptureEnabled,
30+
bool? isDataObscured,
31+
bool? isLogCollectionEnabled,
32+
bool? isLogsFilterEnabled,
33+
}) =>
34+
BugseeConfigurationData(
35+
isBugseeEnabled: isBugseeEnabled ?? this.isBugseeEnabled,
36+
isVideoCaptureEnabled:
37+
isVideoCaptureEnabled ?? this.isVideoCaptureEnabled,
38+
isDataObscured: isDataObscured ?? this.isDataObscured,
39+
isLogCollectionEnabled:
40+
isLogCollectionEnabled ?? this.isLogCollectionEnabled,
41+
isLogsFilterEnabled: isLogsFilterEnabled ?? this.isLogsFilterEnabled,
42+
);
43+
44+
@override
45+
List<Object?> get props => [
46+
isBugseeEnabled,
47+
isVideoCaptureEnabled,
48+
isDataObscured,
49+
isLogCollectionEnabled,
50+
isLogsFilterEnabled,
51+
];
1652
}

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,31 @@ abstract interface class BugseeRepository {
1616

1717
/// Update whether data is obscure in shared prefs.
1818
Future setIsDataObscure(bool isDataObscure);
19+
20+
/// Update whether [disableLogCollectionKey] flag.
21+
Future setIsLogCollectionEnabled(bool isLogCollectionEnabled);
22+
23+
/// Update whether [disableLogFilterKey] flag.
24+
Future setIsLogFilterEnabled(bool isLogFilterEnabled);
1925
}
2026

2127
final class _BugseeRepository implements BugseeRepository {
2228
final String _bugseeEnabledKey = 'bugseeEnabledKey';
2329
final String _videoCaptureKey = 'videoCaptureKey';
2430
final String _dataObscureKey = 'dataObscureKey';
31+
final String _disableLogCollectionKey = 'disableLogCollectionKey';
32+
final String _disableLogFilterKey = 'disableLogFilterKey';
2533

2634
@override
2735
Future<BugseeConfigurationData> getBugseeConfiguration() async {
2836
final sharedPrefInstance = await SharedPreferences.getInstance();
2937
return BugseeConfigurationData(
3038
isBugseeEnabled: sharedPrefInstance.getBool(_bugseeEnabledKey),
3139
isVideoCaptureEnabled: sharedPrefInstance.getBool(_videoCaptureKey),
32-
isDataObscrured: sharedPrefInstance.getBool(_dataObscureKey),
40+
isDataObscured: sharedPrefInstance.getBool(_dataObscureKey),
41+
isLogCollectionEnabled:
42+
sharedPrefInstance.getBool(_disableLogCollectionKey),
43+
isLogsFilterEnabled: sharedPrefInstance.getBool(_disableLogFilterKey),
3344
);
3445
}
3546

@@ -80,4 +91,38 @@ final class _BugseeRepository implements BugseeRepository {
8091
);
8192
}
8293
}
94+
95+
@override
96+
Future setIsLogCollectionEnabled(bool isLogCollected) async {
97+
final sharedPrefInstance = await SharedPreferences.getInstance();
98+
99+
bool isSaved = await sharedPrefInstance.setBool(
100+
_disableLogCollectionKey,
101+
isLogCollected,
102+
);
103+
104+
if (!isSaved) {
105+
throw PersistenceException(
106+
message:
107+
'Error while setting $_disableLogCollectionKey $isLogCollected',
108+
);
109+
}
110+
}
111+
112+
@override
113+
Future setIsLogFilterEnabled(bool isLogFilterEnabled) async {
114+
final sharedPrefInstance = await SharedPreferences.getInstance();
115+
116+
bool isSaved = await sharedPrefInstance.setBool(
117+
_disableLogFilterKey,
118+
isLogFilterEnabled,
119+
);
120+
121+
if (!isSaved) {
122+
throw PersistenceException(
123+
message:
124+
'Error while setting $_disableLogFilterKey $isLogFilterEnabled',
125+
);
126+
}
127+
}
83128
}

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,51 @@
11
import 'package:equatable/equatable.dart';
22

33
final class BugseeConfigState extends Equatable {
4-
/// indicate if the app require a restart to reactivate the bugsee configurations
4+
/// Indicate if the app require a restart to reactivate the bugsee configurations
55
///
66
/// `true` only if `isConfigurationValid == true` and bugsee is turned on
77
bool isRestartRequired;
88

9-
/// indicate if bugsee is enabled or not
9+
/// Indicate if bugsee is enabled or not
1010
/// by default bugsee is enabled if `isConfigurationValid == true`.
1111
bool isBugseeEnabled;
1212

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

19-
/// indicate if bugsee configuration is valid
19+
/// 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.
2222
bool isConfigurationValid;
2323

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

29+
/// Indicate whether log will be collected during Bugsee reporting or not
30+
/// by default logs are collected but filterd.
31+
///
32+
/// This value is initialized from [dotenv.env] and shared prefs storage.
33+
bool isLogCollectionEnabled;
34+
35+
/// Indicate whether log will be filterd or not
36+
/// by default all logs are filted using [bugseeFilterRegex] defined in [BugseeManager]
37+
///
38+
/// This value is initialized from [dotenv.env] map and shared prefs storage.
39+
bool isLogFilterEnabled;
40+
2941
BugseeConfigState({
3042
this.isRestartRequired = false,
3143
this.isBugseeEnabled = false,
3244
this.isVideoCaptureEnabled = false,
3345
this.isConfigurationValid = false,
3446
this.isDataObscured = false,
47+
this.isLogCollectionEnabled = false,
48+
this.isLogFilterEnabled = false,
3549
});
3650

3751
BugseeConfigState copyWith({
@@ -40,12 +54,17 @@ final class BugseeConfigState extends Equatable {
4054
bool? isVideoCaptureEnabled,
4155
bool? isConfigurationValid,
4256
bool? isDataObscured,
57+
bool? isLogCollectionEnabled,
58+
bool? isLogFilterEnabled,
4359
}) =>
4460
BugseeConfigState(
4561
isRestartRequired: isRestartRequired ?? this.isRestartRequired,
4662
isBugseeEnabled: isBugseeEnabled ?? this.isBugseeEnabled,
4763
isConfigurationValid: isConfigurationValid ?? this.isConfigurationValid,
4864
isDataObscured: isDataObscured ?? this.isDataObscured,
65+
isLogFilterEnabled: isLogFilterEnabled ?? this.isLogFilterEnabled,
66+
isLogCollectionEnabled:
67+
isLogCollectionEnabled ?? this.isLogCollectionEnabled,
4968
isVideoCaptureEnabled:
5069
isVideoCaptureEnabled ?? this.isVideoCaptureEnabled,
5170
);

0 commit comments

Comments
 (0)