Add send crash logs toggle
This commit is contained in:
parent
d3e6308d25
commit
00ba8a5b49
6 changed files with 62 additions and 14 deletions
|
|
@ -5,7 +5,10 @@ const clientId = String.fromEnvironment('CLIENT_ID');
|
|||
const secret = String.fromEnvironment('SECRET');
|
||||
|
||||
/// The current version of the app.
|
||||
const version = '1.0.0-beta+5';
|
||||
const appVersion = '1.0.0-beta+5';
|
||||
|
||||
/// The tracesSampleRate for sentry crash reporting.
|
||||
const sampleRate = 1.0;
|
||||
|
||||
/// BTTV emotes with zero width to allow for overlaying other emotes.
|
||||
const zeroWidthEmotes = [
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:frosty/constants/constants.dart';
|
||||
import 'package:frosty/core/auth/auth_store.dart';
|
||||
import 'package:frosty/screens/home/home.dart';
|
||||
import 'package:frosty/screens/home/stores/categories_store.dart';
|
||||
|
|
@ -33,18 +34,21 @@ Future<void> main() async {
|
|||
// Create a MobX reaction that will save the settings on disk every time they are changed.
|
||||
autorun((_) => preferences.setString('settings', jsonEncode(settingsStore)));
|
||||
|
||||
await SentryFlutter.init(
|
||||
(options) {
|
||||
options.tracesSampleRate = 1.0;
|
||||
},
|
||||
appRunner: () => runApp(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
Provider<AuthStore>(create: (_) => authStore),
|
||||
Provider<SettingsStore>(create: (_) => settingsStore),
|
||||
],
|
||||
child: const MyApp(),
|
||||
),
|
||||
if (settingsStore.sendCrashLogs) {
|
||||
await SentryFlutter.init(
|
||||
(options) {
|
||||
options.tracesSampleRate = sampleRate;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
runApp(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
Provider<AuthStore>(create: (_) => authStore),
|
||||
Provider<SettingsStore>(create: (_) => settingsStore),
|
||||
],
|
||||
child: const MyApp(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:frosty/constants/constants.dart';
|
||||
import 'package:frosty/screens/settings/stores/settings_store.dart';
|
||||
import 'package:frosty/widgets/section_header.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
class OtherSettings extends StatelessWidget {
|
||||
final SettingsStore settingsStore;
|
||||
|
|
@ -27,6 +29,22 @@ class OtherSettings extends StatelessWidget {
|
|||
applicationLegalese: '\u{a9} 2022 Tommy Chow',
|
||||
),
|
||||
),
|
||||
Observer(
|
||||
builder: (_) => SwitchListTile.adaptive(
|
||||
title: const Text('Send anonymous crash logs'),
|
||||
value: settingsStore.sendCrashLogs,
|
||||
onChanged: (newValue) {
|
||||
if (newValue == true) {
|
||||
SentryFlutter.init((options) {
|
||||
options.tracesSampleRate = sampleRate;
|
||||
});
|
||||
} else {
|
||||
Sentry.close();
|
||||
}
|
||||
settingsStore.sendCrashLogs = newValue;
|
||||
},
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
width: double.infinity,
|
||||
|
|
|
|||
|
|
@ -76,6 +76,11 @@ abstract class _SettingsStoreBase with Store {
|
|||
@observable
|
||||
var emoteHeight = 30.0;
|
||||
|
||||
// Other settings
|
||||
@JsonKey(defaultValue: true)
|
||||
@observable
|
||||
var sendCrashLogs = true;
|
||||
|
||||
// Global configs
|
||||
@JsonKey(defaultValue: false)
|
||||
@observable
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ SettingsStore _$SettingsStoreFromJson(Map<String, dynamic> json) =>
|
|||
..messageSpacing = (json['messageSpacing'] as num?)?.toDouble() ?? 10.0
|
||||
..badgeHeight = (json['badgeHeight'] as num?)?.toDouble() ?? 20.0
|
||||
..emoteHeight = (json['emoteHeight'] as num?)?.toDouble() ?? 30.0
|
||||
..sendCrashLogs = json['sendCrashLogs'] as bool? ?? true
|
||||
..fullScreen = json['fullScreen'] as bool? ?? false
|
||||
..expandInfo = json['expandInfo'] as bool? ?? true;
|
||||
|
||||
|
|
@ -48,6 +49,7 @@ Map<String, dynamic> _$SettingsStoreToJson(SettingsStore instance) =>
|
|||
'messageSpacing': instance.messageSpacing,
|
||||
'badgeHeight': instance.badgeHeight,
|
||||
'emoteHeight': instance.emoteHeight,
|
||||
'sendCrashLogs': instance.sendCrashLogs,
|
||||
'fullScreen': instance.fullScreen,
|
||||
'expandInfo': instance.expandInfo,
|
||||
};
|
||||
|
|
@ -302,6 +304,21 @@ mixin _$SettingsStore on _SettingsStoreBase, Store {
|
|||
});
|
||||
}
|
||||
|
||||
final _$sendCrashLogsAtom = Atom(name: '_SettingsStoreBase.sendCrashLogs');
|
||||
|
||||
@override
|
||||
bool get sendCrashLogs {
|
||||
_$sendCrashLogsAtom.reportRead();
|
||||
return super.sendCrashLogs;
|
||||
}
|
||||
|
||||
@override
|
||||
set sendCrashLogs(bool value) {
|
||||
_$sendCrashLogsAtom.reportWrite(value, super.sendCrashLogs, () {
|
||||
super.sendCrashLogs = value;
|
||||
});
|
||||
}
|
||||
|
||||
final _$fullScreenAtom = Atom(name: '_SettingsStoreBase.fullScreen');
|
||||
|
||||
@override
|
||||
|
|
@ -350,6 +367,7 @@ fontSize: ${fontSize},
|
|||
messageSpacing: ${messageSpacing},
|
||||
badgeHeight: ${badgeHeight},
|
||||
emoteHeight: ${emoteHeight},
|
||||
sendCrashLogs: ${sendCrashLogs},
|
||||
fullScreen: ${fullScreen},
|
||||
expandInfo: ${expandInfo}
|
||||
''';
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ packages:
|
|||
name: json_serializable
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.3"
|
||||
version: "6.1.4"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue