i'm looking for example how to capture custom key-value, like Device-Model
, Android Version
and class & method etc to sentry.io. but not found so far.
For example below code:
Future doWatchVideo(BuildContext context) async {
RewardedVideoAd.instance.show().catchError((error, stackTrace) {
sentry.capture(
event: null,
stackFrameFilter: null,
)
sentry.captureException(
exception: error,
stackTrace: stackTrace,
);
});
}
Error & StackTrace are reported but i dont know how to send User's Device Info, also in what class and method this error was fire.
Any Idea ?
Thank You
You need to use the extra
params in the event class
final Event event = Event(
loggerName: '',
exception: error,
stackTrace: stackTrace,
release: '${info.version}_${info.buildNumber}',
environment: 'qa',
tags: tags,
extra: extra,
);
And of course you have to use the device_info
plugin to get info about the device :
final PackageInfo info = await PackageInfo.fromPlatform();
Map<String, dynamic> extra = {};
if (defaultTargetPlatform == TargetPlatform.android) {
extra['device_info'] = await DeviceInfoPlugin.channel.invokeMethod('getAndroidDeviceInfo');
}
else if (defaultTargetPlatform == TargetPlatform.iOS) {
extra['device_info'] = await DeviceInfoPlugin.channel.invokeMethod('getIosDeviceInfo');
}
For more info consider reading this full example by Simon Lightfoot