Open ueman opened 3 years ago
@ueman good catch. Is this something you'd like to contribute to? We'd be happy to get a PR to address it.
No, I'm not knowledgeable enough on that topic. I've just stumbled across this missing pieces while working on https://github.com/getsentry/sentry-dart/pull/203
Sure. Thanks for helping already with pointing it out.
On the Flutter side of https://github.com/getsentry/sentry-dart there are the following breadcrumbs:
With the following extra data fields state
, to_arguments
, from_arguments
. Also every data field is optional. The docs state that at least to
and from
are required, but from what I can tell it is not.
{
"type": "navigation",
"category": "navigation",
"timestamp": "2016-04-20T20:55:53.845Z",
"data": {
"from": "/login",
"from_arguments": "string or key-value-map",
"to": "/dashboard",
"to_arguments": "string or key-value-map",
"state": "type of navigation, for example didPush"
}
}
This one doesn't really make sense to me. Why is category ui.lifecycle
of type navigation
?
It is copied from here just to be consistent.
Now that I do some research this should be analog to this.
{
"type": "navigation",
"category": "ui.lifecycle",
"timestamp": "2016-04-20T20:55:53.845Z",
"data": {
"state": "new lifecycle state"
}
}
Same as above, why is it of type navigation
?
{
"message": "Screen size changed",
"type": "navigation",
"category": "device.screen",
"timestamp": "2016-04-20T20:55:53.845Z",
"data": {
"new_pixel_ratio": 3,
"new_height": 1920,
"new_width": 1080,
}
}
This was created to mimic this. Again just to be consistent. (I would love to have a dark breadcrumb in the UI for light/dark-mode changes)
{
"message": "Platform brightness was changed to {dark|light}.",
"type": "system",
"category": "device.event",
"timestamp": "2016-04-20T20:55:53.845Z",
"data": {
"action": "BRIGHTNESS_CHANGED_TO_{DARK|LIGHT}",
}
}
{
"message": "Text scale factor changed to {value}.",
"type": "system",
"category": "device.event",
"timestamp": "2016-04-20T20:55:53.845Z",
"data": {
"action": "TEXT_SCALE_CHANGED_TO_{value}",
}
}
{
"message": "App had memory pressure. This indicates that the operating system would like applications to release caches to free up more memory.",
"type": "system",
"category": "device.event",
"timestamp": "2016-04-20T20:55:53.845Z",
"data": {
"action": "LOW_MEMORY"
}
}
It doesn't seem to be really consistent to me.
type
and when a category
? data
field?I would really like to have examples for common breadcrumbs like navigation
, lifecycle
and system
-events.
Maybe the client SDKs should have known types
and category
as constants, so that the user can reuse them more easily.
/cc @marandaneto
Sentry frontend code for reference
@lucas-zimerman for the Xamarin side
it's a bit confusing, true, but there's no guideline between type
and category
to be honest (afaik), they are open and nullable fields, our UI special case some of them and render nicely, but that's all, they are not documented either except a few of them like HTTP or click events, those are documented.
most of them are new values that we came up with for Android and iOS also to keep compatibility with older SDK versions. I guess we'd be able to address this issue once we know which of them would be rendered nicely on the UI.
maybe @priscilawebdev would help.
@priscilawebdev is this something you can help us with? This seems to be a constant source of confusion to contributors and folks trying to implement a new SDK. Some clarifications on the docs could help here.
@bruno-garcia I'm glad you mentioned my name again because I was having trouble finding this issue ... Yes, I can help with that ... I just added this issue to my backlog and I will work on it as soon as I have some time 😉
So what exactly would need to be done here?
Already documented above
final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setType("navigation");
breadcrumb.setCategory("device.orientation");
breadcrumb.setData("position", orientation);
breadcrumb.setLevel(SentryLevel.INFO);
final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setType("system");
breadcrumb.setCategory("device.event");
breadcrumb.setMessage("Low memory");
breadcrumb.setData("action", "LOW_MEMORY");
breadcrumb.setLevel(SentryLevel.WARNING);
final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setType("navigation");
breadcrumb.setData("state", state);
breadcrumb.setCategory("app.lifecycle");
breadcrumb.setLevel(SentryLevel.INFO);
final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setType("session");
breadcrumb.setData("state", state);
breadcrumb.setCategory("app.lifecycle");
breadcrumb.setLevel(SentryLevel.INFO);
final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setType("system");
breadcrumb.setCategory("device.event");
breadcrumb.setData("action", "TYPE_AMBIENT_TEMPERATURE");
breadcrumb.setData("accuracy", event.accuracy);
breadcrumb.setData("timestamp", event.timestamp);
breadcrumb.setLevel(SentryLevel.INFO);
breadcrumb.setData("degree", event.values[0]); // Celsius
final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setType("system");
breadcrumb.setCategory("device.event");
breadcrumb.setData("action", "CALL_STATE_RINGING");
breadcrumb.setMessage("Device ringing");
breadcrumb.setLevel(SentryLevel.INFO);
Here's a lot of different stuff.
SentryBreadcrumb *crumb = [[SentryBreadcrumb alloc] initWithLevel:kSentryLevelInfo
category:@"device.event"];
crumb.type = @"system";
crumb.data = batteryData;
SentryBreadcrumb *crumb = [[SentryBreadcrumb alloc] initWithLevel:kSentryLevelInfo
category:@"device.orientation"];
UIDeviceOrientation currentOrientation = currentDevice.orientation;
// Ignore changes in device orientation if unknown, face up, or face down.
if (!UIDeviceOrientationIsValidInterfaceOrientation(currentOrientation)) {
[SentryLog logWithMessage:@"currentOrientation is unknown." andLevel:kSentryLevelDebug];
return;
}
if (UIDeviceOrientationIsLandscape(currentOrientation)) {
crumb.data = @{ @"position" : @"landscape" };
} else {
crumb.data = @{ @"position" : @"portrait" };
}
crumb.type = @"navigation";
Various System events
Integration::addBreadcrumb(new Breadcrumb(
Breadcrumb::LEVEL_INFO,
Breadcrumb::TYPE_NAVIGATION,
'route',
$routeName
));
Known types in Sentry https://github.com/getsentry/sentry/blob/3deff6bd884a66ec711925f0984590a2075129e1/static/app/components/events/interfaces/breadcrumbs/getCrumbDetails.tsx#L18-L98
Documented types: https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/
Sentry.addBreadcrumb(new Breadcrumb(...))
called by the user directlyThe breadcrumbs types should be added to https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/ And also the SDKs pages should be updated https://docs.sentry.io/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs
The documentation on breadcrumbs is missing device events like the ones which are used by Android.
See for example: