Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breadcrumbs documentation for device events #213

Open
ueman opened this issue Nov 30, 2020 · 13 comments
Open

Breadcrumbs documentation for device events #213

ueman opened this issue Nov 30, 2020 · 13 comments

Comments

@ueman
Copy link
Contributor

ueman commented Nov 30, 2020

@bruno-garcia
Copy link
Member

@ueman good catch. Is this something you'd like to contribute to?
We'd be happy to get a PR to address it.

@ueman
Copy link
Contributor Author

ueman commented Dec 10, 2020

No, I'm not knowledgeable enough on that topic. I've just stumbled across this missing pieces while working on getsentry/sentry-dart#203

@bruno-garcia
Copy link
Member

Sure. Thanks for helping already with pointing it out.

@ueman
Copy link
Contributor Author

ueman commented Dec 11, 2020

On the Flutter side of https://github.com/getsentry/sentry-dart there are the following breadcrumbs:

🗺 Navigation

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"
  }
}

Navigation Lifecycle

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"
  }
}

Navigation Device

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,
  }
}

💻 System

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"
  }
}

❓ Concluding remarks & questions

It doesn't seem to be really consistent to me.

  1. When do I have to use a type and when a category?
  2. What sould I put inside the data field?
  3. Which breadcrumbs have a visual representation and what do the look like?
  4. When do I use a message for a breadcrumb?
  5. Are there really any required breadcrumb fields?
  6. Maybe also update this page?

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.

@bruno-garcia
Copy link
Member

/cc @marandaneto

@ueman
Copy link
Contributor Author

ueman commented Jan 4, 2021

@bruno-garcia
Copy link
Member

@lucas-zimerman for the Xamarin side

@marandaneto
Copy link
Contributor

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.

@bruno-garcia
Copy link
Member

@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.

@priscilawebdev
Copy link
Member

@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 😉

@ueman
Copy link
Contributor Author

ueman commented Apr 28, 2021

So what exactly would need to be done here?

@ueman
Copy link
Contributor Author

ueman commented Apr 30, 2021

Dart & Flutter

Already documented above

Java

Device Orientation

https://github.com/getsentry/sentry-java/blob/e1a7226bead691b2a824332f3d3a0930e68e33cc/sentry-android-core/src/main/java/io/sentry/android/core/AppComponentsBreadcrumbsIntegration.java#L89-L94

final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setType("navigation");
breadcrumb.setCategory("device.orientation");
breadcrumb.setData("position", orientation);
breadcrumb.setLevel(SentryLevel.INFO);

Low Memory

https://github.com/getsentry/sentry-java/blob/e1a7226bead691b2a824332f3d3a0930e68e33cc/sentry-android-core/src/main/java/io/sentry/android/core/AppComponentsBreadcrumbsIntegration.java#L108-L133

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);

Lifecycle

https://github.com/getsentry/sentry-java/blob/e1a7226bead691b2a824332f3d3a0930e68e33cc/sentry-android-core/src/main/java/io/sentry/android/core/LifecycleWatcher.java#L120-L125

final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setType("navigation");
breadcrumb.setData("state", state);
breadcrumb.setCategory("app.lifecycle");
breadcrumb.setLevel(SentryLevel.INFO);

https://github.com/getsentry/sentry-java/blob/e1a7226bead691b2a824332f3d3a0930e68e33cc/sentry-android-core/src/main/java/io/sentry/android/core/LifecycleWatcher.java#L131-L135

final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setType("session");
breadcrumb.setData("state", state);
breadcrumb.setCategory("app.lifecycle");
breadcrumb.setLevel(SentryLevel.INFO);

Temperature Sensor

https://github.com/getsentry/sentry-java/blob/e1a7226bead691b2a824332f3d3a0930e68e33cc/sentry-android-core/src/main/java/io/sentry/android/core/TempSensorBreadcrumbsIntegration.java#L92-L99

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

Phone State

https://github.com/getsentry/sentry-java/blob/e1a7226bead691b2a824332f3d3a0930e68e33cc/sentry-android-core/src/main/java/io/sentry/android/core/PhoneStateBreadcrumbsIntegration.java#L94-L99

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);

System events

https://github.com/getsentry/sentry-java/blob/e1a7226bead691b2a824332f3d3a0930e68e33cc/sentry-android-core/src/main/java/io/sentry/android/core/SystemEventsBreadcrumbsIntegration.java#L176-L205

Here's a lot of different stuff.

Cocoa

Battery

https://github.com/getsentry/sentry-cocoa/blob/88c5af0a004951f1ea3ac6274686534fde03f5b3/Sources/Sentry/SentrySystemEventsBreadcrumbs.m#L78-L81

SentryBreadcrumb *crumb = [[SentryBreadcrumb alloc] initWithLevel:kSentryLevelInfo
                                                            category:@"device.event"];
crumb.type = @"system";
crumb.data = batteryData;

Device Orientation

https://github.com/getsentry/sentry-cocoa/blob/88c5af0a004951f1ea3ac6274686534fde03f5b3/Sources/Sentry/SentrySystemEventsBreadcrumbs.m#L127-L143

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";

System events

Xamarin

Xamarin Forms

Various System events

https://github.com/getsentry/sentry-xamarin/blob/63e764393415324f7fa0356e62d679d64f8d34ff/Src/Sentry.Xamarin.Forms/Internals/SentryXamarinFormsIntegration.cs

  • Theme changed
  • Logs
  • Navigation: Page appears, page disappears

Xamarin.iOS

https://github.com/getsentry/sentry-xamarin/blob/63e764393415324f7fa0356e62d679d64f8d34ff/Src/Sentry.Xamarin/Internals/NativeIntegration.ios.cs

  • Entered foreground, entered background
  • Low Memory Warning

Xamarin.Android

https://github.com/getsentry/sentry-xamarin/blob/63e764393415324f7fa0356e62d679d64f8d34ff/Src/Sentry.Xamarin/Internals/NativeIntegration.droid.cs

  • Activity Lifecycle

.NET

  • logging integrations

Cordova

  • none

React-Native

JavaScript

Laravel

https://github.com/getsentry/sentry-laravel/blob/65ba0ea34ce124b48f50fb59b80c701bf76f4b12/src/Sentry/Laravel/EventHandler.php#L76-L109

  • SQL Queries
  • SQL Bindings
  • Logs
  • Queue Info
  • Commands (Artisan)

Navigation

https://github.com/getsentry/sentry-laravel/blob/65ba0ea34ce124b48f50fb59b80c701bf76f4b12/src/Sentry/Laravel/EventHandler.php#L223-L228

Integration::addBreadcrumb(new Breadcrumb(
    Breadcrumb::LEVEL_INFO,
    Breadcrumb::TYPE_NAVIGATION,
    'route',
    $routeName
));

Python

Sentry

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/

Findings

  • There should be Low Memory Breadcrumb definition + icon
  • System events are not really consolidated and vary greatly in type, category and additional data.
    • I think there's benefit in consolidation
  • There's no differentiation between user generated breadcrumbs and logs. I.e. Breadcrumbs generated via Logging integrations and Sentry.addBreadcrumb(new Breadcrumb(...)) called by the user directly
  • There's no guideline on which Breadcrumb should have which level/severity

@krystofwoldrich
Copy link
Member

The 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

5 participants