mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
feat: make sentry logging optional.
This commit is contained in:
parent
f1261398e9
commit
6d35c47b6b
6 changed files with 74 additions and 3 deletions
|
@ -106,6 +106,7 @@
|
||||||
"teamSectionTitle": "Team",
|
"teamSectionTitle": "Team",
|
||||||
"infoSectionTitle": "Info",
|
"infoSectionTitle": "Info",
|
||||||
"advancedSectionTitle": "Advanced",
|
"advancedSectionTitle": "Advanced",
|
||||||
|
"privacySectionTitle": "Privacy",
|
||||||
"darkThemeLabel": "Dark Mode",
|
"darkThemeLabel": "Dark Mode",
|
||||||
"darkThemeHint": "Welcome to the Dark Side",
|
"darkThemeHint": "Welcome to the Dark Side",
|
||||||
"dynamicThemeLabel": "Material You",
|
"dynamicThemeLabel": "Material You",
|
||||||
|
@ -130,7 +131,10 @@
|
||||||
"apiURLHint": "Configure your custom API URL",
|
"apiURLHint": "Configure your custom API URL",
|
||||||
"selectApiURL": "Select URL",
|
"selectApiURL": "Select URL",
|
||||||
"aboutLabel": "About",
|
"aboutLabel": "About",
|
||||||
"snackbarMessage": "Copied to clipboard"
|
"snackbarMessage": "Copied to clipboard",
|
||||||
|
"sentryLabel": "Sentry Logging",
|
||||||
|
"sentryHint": "Send anonymous logs to help us improve ReVanced Manager",
|
||||||
|
"restartAppForChanges": "Restart the app to apply changes"
|
||||||
},
|
},
|
||||||
"appInfoView": {
|
"appInfoView": {
|
||||||
"widgetTitle": "App Info",
|
"widgetTitle": "App Info",
|
||||||
|
|
|
@ -20,19 +20,30 @@ Future main() async {
|
||||||
await locator<ManagerAPI>().initialize();
|
await locator<ManagerAPI>().initialize();
|
||||||
String apiUrl = locator<ManagerAPI>().getApiUrl();
|
String apiUrl = locator<ManagerAPI>().getApiUrl();
|
||||||
await locator<RevancedAPI>().initialize(apiUrl);
|
await locator<RevancedAPI>().initialize(apiUrl);
|
||||||
|
bool isSentryEnabled = locator<ManagerAPI>().isSentryEnabled();
|
||||||
locator<GithubAPI>().initialize();
|
locator<GithubAPI>().initialize();
|
||||||
await locator<PatcherAPI>().initialize();
|
await locator<PatcherAPI>().initialize();
|
||||||
tz.initializeTimeZones();
|
tz.initializeTimeZones();
|
||||||
await SentryFlutter.init(
|
await SentryFlutter.init(
|
||||||
(options) {
|
(options) {
|
||||||
options
|
options
|
||||||
..dsn = Env.SENTRY_DSN
|
..dsn = isSentryEnabled ? Env.SENTRY_DSN : ''
|
||||||
..environment = 'alpha'
|
..environment = 'alpha'
|
||||||
..release = '0.1'
|
..release = '0.1'
|
||||||
..tracesSampleRate = 1.0
|
..tracesSampleRate = 1.0
|
||||||
..anrEnabled = true
|
..anrEnabled = true
|
||||||
..enableOutOfMemoryTracking = true
|
..enableOutOfMemoryTracking = true
|
||||||
..sampleRate = 1.0;
|
..sampleRate = isSentryEnabled ? 1.0 : 0.0
|
||||||
|
..beforeSend = (event, hint) {
|
||||||
|
print('isSentryEnabled: $isSentryEnabled');
|
||||||
|
if (isSentryEnabled) {
|
||||||
|
print("Sentry event sent");
|
||||||
|
return event;
|
||||||
|
} else {
|
||||||
|
print("Sentry is disabled");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} as BeforeSendCallback?;
|
||||||
},
|
},
|
||||||
appRunner: () => runApp(const MyApp()),
|
appRunner: () => runApp(const MyApp()),
|
||||||
);
|
);
|
||||||
|
|
|
@ -82,6 +82,15 @@ class ManagerAPI {
|
||||||
await _prefs.setBool('useDarkTheme', value);
|
await _prefs.setBool('useDarkTheme', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isSentryEnabled() {
|
||||||
|
return _prefs.getBool('sentryEnabled') ?? true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setSentryStatus(bool value) async {
|
||||||
|
await _prefs.setBool('sentryEnabled', value);
|
||||||
|
print('Sentry status: $value');
|
||||||
|
}
|
||||||
|
|
||||||
List<PatchedApplication> getPatchedApps() {
|
List<PatchedApplication> getPatchedApps() {
|
||||||
List<String> apps = _prefs.getStringList('patchedApps') ?? [];
|
List<String> apps = _prefs.getStringList('patchedApps') ?? [];
|
||||||
return apps.map((a) => PatchedApplication.fromJson(jsonDecode(a))).toList();
|
return apps.map((a) => PatchedApplication.fromJson(jsonDecode(a))).toList();
|
||||||
|
|
|
@ -20,4 +20,15 @@ class Toast {
|
||||||
gravity: t.ToastGravity.CENTER,
|
gravity: t.ToastGravity.CENTER,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showBottom(String text) {
|
||||||
|
t.Fluttertoast.showToast(
|
||||||
|
msg: FlutterI18n.translate(
|
||||||
|
_fToast.context!,
|
||||||
|
text,
|
||||||
|
),
|
||||||
|
toastLength: t.Toast.LENGTH_LONG,
|
||||||
|
gravity: t.ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,28 @@ class SettingsView extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
_settingsDivider,
|
_settingsDivider,
|
||||||
|
SettingsSection(
|
||||||
|
title: 'settingsView.privacySectionTitle',
|
||||||
|
children: <Widget>[
|
||||||
|
CustomSwitchTile(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
|
title: I18nText(
|
||||||
|
'settingsView.sentryLabel',
|
||||||
|
child: const Text(
|
||||||
|
'',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: I18nText('settingsView.sentryHint'),
|
||||||
|
value: model.isSentryEnabled(),
|
||||||
|
onTap: (value) => model.useSentry(value),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
_settingsDivider,
|
||||||
SettingsSection(
|
SettingsSection(
|
||||||
title: 'settingsView.infoSectionTitle',
|
title: 'settingsView.infoSectionTitle',
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|
|
@ -10,6 +10,7 @@ import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:revanced_manager/app/app.locator.dart';
|
import 'package:revanced_manager/app/app.locator.dart';
|
||||||
import 'package:revanced_manager/app/app.router.dart';
|
import 'package:revanced_manager/app/app.router.dart';
|
||||||
import 'package:revanced_manager/services/manager_api.dart';
|
import 'package:revanced_manager/services/manager_api.dart';
|
||||||
|
import 'package:revanced_manager/services/toast.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/settingsView/custom_text_field.dart';
|
import 'package:revanced_manager/ui/widgets/settingsView/custom_text_field.dart';
|
||||||
import 'package:share_extend/share_extend.dart';
|
import 'package:share_extend/share_extend.dart';
|
||||||
|
@ -23,6 +24,7 @@ const int ANDROID_12_SDK_VERSION = 31;
|
||||||
class SettingsViewModel extends BaseViewModel {
|
class SettingsViewModel extends BaseViewModel {
|
||||||
final NavigationService _navigationService = locator<NavigationService>();
|
final NavigationService _navigationService = locator<NavigationService>();
|
||||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||||
|
final Toast _toast = locator<Toast>();
|
||||||
final TextEditingController _orgPatSourceController = TextEditingController();
|
final TextEditingController _orgPatSourceController = TextEditingController();
|
||||||
final TextEditingController _patSourceController = TextEditingController();
|
final TextEditingController _patSourceController = TextEditingController();
|
||||||
final TextEditingController _orgIntSourceController = TextEditingController();
|
final TextEditingController _orgIntSourceController = TextEditingController();
|
||||||
|
@ -313,6 +315,18 @@ class SettingsViewModel extends BaseViewModel {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disable sentry using switch boolean
|
||||||
|
|
||||||
|
bool isSentryEnabled() {
|
||||||
|
return _managerAPI.isSentryEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void useSentry(bool value) {
|
||||||
|
_managerAPI.setSentryStatus(value);
|
||||||
|
_toast.showBottom('settingsView.restartAppForChanges');
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> getSdkVersion() async {
|
Future<int> getSdkVersion() async {
|
||||||
AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
|
AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
|
||||||
return info.version.sdkInt ?? -1;
|
return info.version.sdkInt ?? -1;
|
||||||
|
|
Loading…
Reference in a new issue