Add sentry provider observer
This commit is contained in:
@@ -64,6 +64,7 @@ Future<void> lazyBootstrap(
|
||||
options.enableNdkScopeSync = true;
|
||||
options.attachThreads = true;
|
||||
options.tracesSampleRate = 0.25;
|
||||
options.enableUserInteractionTracing = true;
|
||||
options.addIntegration(sentryLogger);
|
||||
},
|
||||
appRunner: () => _lazyBootstrap(widgetsBinding, container, env),
|
||||
@@ -100,6 +101,7 @@ Future<void> _lazyBootstrap(
|
||||
runApp(
|
||||
ProviderScope(
|
||||
parent: container,
|
||||
observers: [SentryRiverpodObserver()],
|
||||
child: SentryUserInteractionWidget(
|
||||
child: const AppView(),
|
||||
),
|
||||
|
||||
@@ -106,6 +106,7 @@ class _ConnectionButton extends StatelessWidget {
|
||||
width: 148,
|
||||
height: 148,
|
||||
child: Material(
|
||||
key: const ValueKey("home_connection_button"),
|
||||
shape: const CircleBorder(),
|
||||
color: Colors.white,
|
||||
child: InkWell(
|
||||
|
||||
@@ -96,6 +96,7 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
_Button(
|
||||
key: const ValueKey("add_from_clipboard_button"),
|
||||
label: t.profile.add.fromClipboard,
|
||||
icon: Icons.content_paste,
|
||||
size: buttonWidth,
|
||||
@@ -124,6 +125,7 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
const Gap(buttonsGap),
|
||||
if (!PlatformUtils.isDesktop)
|
||||
_Button(
|
||||
key: const ValueKey("add_by_qr_code_button"),
|
||||
label: t.profile.add.scanQr,
|
||||
icon: Icons.qr_code_scanner,
|
||||
size: buttonWidth,
|
||||
@@ -154,6 +156,7 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
)
|
||||
else
|
||||
_Button(
|
||||
key: const ValueKey("add_manually_button"),
|
||||
label: t.profile.add.manually,
|
||||
icon: Icons.add,
|
||||
size: buttonWidth,
|
||||
@@ -176,6 +179,7 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
child: SizedBox(
|
||||
height: 36,
|
||||
child: Material(
|
||||
key: const ValueKey("add_manually_button"),
|
||||
elevation: 8,
|
||||
color: theme.colorScheme.surface,
|
||||
surfaceTintColor: theme.colorScheme.surfaceTint,
|
||||
@@ -225,6 +229,7 @@ class AddProfileModal extends HookConsumerWidget {
|
||||
|
||||
class _Button extends StatelessWidget {
|
||||
const _Button({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.icon,
|
||||
required this.size,
|
||||
|
||||
44
lib/utils/sentry_riverpod_observer.dart
Normal file
44
lib/utils/sentry_riverpod_observer.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
class SentryRiverpodObserver extends ProviderObserver {
|
||||
void addBreadcrumb(String message, {Map<String, dynamic>? data}) {
|
||||
Sentry.addBreadcrumb(
|
||||
Breadcrumb(
|
||||
category: "Provider",
|
||||
message: message,
|
||||
data: data,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didAddProvider(
|
||||
ProviderBase<Object?> provider,
|
||||
Object? value,
|
||||
ProviderContainer container,
|
||||
) {
|
||||
super.didAddProvider(provider, value, container);
|
||||
addBreadcrumb(
|
||||
'Provider [${provider.name ?? provider.runtimeType}] was ADDED',
|
||||
data: value != null ? {"initial-value": value} : null,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateProvider(
|
||||
ProviderBase<Object?> provider,
|
||||
Object? previousValue,
|
||||
Object? newValue,
|
||||
ProviderContainer container,
|
||||
) {
|
||||
super.didUpdateProvider(provider, previousValue, newValue, container);
|
||||
addBreadcrumb(
|
||||
'Provider [${provider.name ?? provider.runtimeType}] was UPDATED',
|
||||
data: {
|
||||
"new-value": newValue,
|
||||
"old-value": previousValue,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ export 'number_formatters.dart';
|
||||
export 'placeholders.dart';
|
||||
export 'platform_utils.dart';
|
||||
export 'sentry_loggy_integration.dart';
|
||||
export 'sentry_riverpod_observer.dart';
|
||||
export 'text_utils.dart';
|
||||
export 'uri_utils.dart';
|
||||
export 'validators.dart';
|
||||
|
||||
Reference in New Issue
Block a user