bugsnag-types-1.1.0.0: src/Data/Bugsnag/Types/Event.hs
module Data.Bugsnag.Types.Event
( Event (..)
, exampleEvent
) where
import Data.Bugsnag.Types.Prelude
import Data.Bugsnag.Types.Exception
import Data.Bugsnag.Types.Breadcrumb
import Data.Bugsnag.Types.Request
import Data.Bugsnag.Types.Thread
import Data.Bugsnag.Types.Severity
import Data.Bugsnag.Types.SeverityReason
import Data.Bugsnag.Types.User
import Data.Bugsnag.Types.Application
import Data.Bugsnag.Types.Device
import Data.Bugsnag.Types.Session
import Data.Bugsnag.Types.FeatureFlag
data Event = Event
{ exceptions :: [Exception]
-- ^ An array of exceptions that occurred during this event. There must be at
-- least one entry. Most of the time there will only be one exception, but some
-- languages support "nested" or "caused by" exceptions. In this case,
-- exceptions should be unwrapped and added to the array one at a time. The
-- array should be in order from the outermost error to the innermost. For
-- example, the first element in the array should be the error caused by the
-- second element, and so on.
, breadcrumbs :: Maybe [Breadcrumb]
-- ^ An array of user- and system-initiated events which led up to an error,
-- providing additional context. This list is sequential and ordered newest to
-- oldest.
, request :: Maybe Request
-- ^ Details about the web request from the client that experienced the error,
-- if relevant. To display custom request data alongside these standard fields
-- on the Bugsnag website, the custom data should be included in the `metaData`
-- object in a `request` object.
, threads :: Maybe [Thread]
-- ^ An array of background threads. This is optional but recommended for apps
-- that rely heavily on threading. Threads should be in an order that makes
-- sense for your application.
, context :: Maybe Text
-- ^ A string representing what was happening in the application at the time of
-- the error. This string could be used for grouping purposes, depending on the
-- event. Usually this would represent the controller and action in a server
-- based project. It could represent the screen that the user was interacting
-- with in a client side project.
-- For example:
--
-- * On Ruby on Rails the context could be `controller#action`.
--
-- * In Android, the context could be the top most Activity.
--
-- * In iOS, the context could be the name of the top most
-- UIViewController.
, groupingHash :: Maybe Text
-- ^ Bugsnag's [default
-- error grouping](https://docs.bugsnag.com/product/error-grouping) can be
-- overridden by specifying a custom grouping hash.
, unhandled :: Maybe Bool
-- ^ Whether the error was unhandled. If true, the error was detected by the
-- notifier because it was not handled by the application. If false, the errors
-- was handled and reported using Bugsnag.notify.
, severity :: Maybe Severity
-- ^ The severity of the error
, severityReason :: Maybe SeverityReason
-- ^ Information about why the severity was picked.
, projectPackages :: Maybe [Text]
-- ^ Sets which package names Bugsnag should consider as a part of the running
-- application. We mark stacktrace lines as in-project if they originate from
-- any of these packages and this allows us to improve the visual display of the
-- stacktrace on the dashboard.
, user :: Maybe User
-- ^ Information about the user affected by the error. These fields are optional
-- but highly recommended. To display custom user data alongside these standard
-- fields on the Bugsnag website, the custom data should be included in the
-- `metaData` object in a `user` object.
, app :: Maybe Application
-- ^ Information about the app where the error occurred. These fields are
-- optional but highly recommended. To display custom app data alongside these
-- standard fields on the Bugsnag website, the custom data should be included
-- in the `metaData` object in an `app` object.
, device :: Maybe Device
-- ^ Information about the computer/device running the app. These fields are
-- optional but highly recommended. To display custom device data alongside
-- these standard fields on the Bugsnag website, the custom data should be
-- included in the `metaData` object in a `device` object.
, session :: Maybe Session
-- ^ Details of any session information associated with the event.
--
-- This can be used alongside the [Bugsnag Session Tracking API](https://bugsnagsessiontrackingapi.docs.apiary.io) to associate the event with a session so that a release's crash rate can be determined.
, featureFlags :: Maybe [FeatureFlag]
-- ^ Details of the feature flags (experiments) and associated variants that were active when the error occurred.
, metaData :: Maybe (KeyMap (KeyMap Text))
-- ^ An object containing any further data you wish to attach to this
-- error event. This should contain one or more objects, with each
-- object being displayed in its own tab on the event details on Bugsnag.
--
-- ```
-- {
-- // Custom user data to be displayed in the User tab along with standard
-- // user fields on the Bugsnag website.
-- "user": {
-- ...
-- },
--
-- // Custom app data to be displayed in the App tab along with standard
-- // app fields on the Bugsnag website.
-- "app": {
-- ...
-- },
--
-- // Custom device data to be displayed in the Device tab along with
-- //standard device fields on the Bugsnag website.
-- "device": {
-- ...
-- },
--
-- Custom request data to be displayed in the Request tab along with
-- standard request fields on the Bugsnag website.
-- "request": {
-- ...
-- },
--
-- // This will be displayed as an extra tab on the Bugsnag website.
-- "Some data": {
--
-- // A key value pair that will be displayed in the first tab.
-- "key": "value",
--
-- // Key value pairs can be contained in nested objects which helps
-- // to organise the information presented in the tab.
-- "setOfKeys": {
-- "key": "value",
-- "key2": "value"
-- }
-- },
--
-- // This would be the second extra tab on the Bugsnag website.
-- "Some more data": {
-- ...
-- }
-- }
-- ```
}
deriving stock (Eq, Show, Generic)
instance FromJSON Event where
parseJSON = genericParseJSON aesonOptions
instance ToJSON Event where
toJSON = genericToJSON aesonOptions
toEncoding = genericToEncoding aesonOptions
exampleEvent :: Event
exampleEvent = Event
{ exceptions = [exampleException]
, breadcrumbs = Just [exampleBreadcrumb]
, request = Just exampleRequest
, threads = Just [exampleThread]
, context = Just "auth/session#create"
, groupingHash = Just "buggy_file.rb"
, unhandled = Just True
, severity = Just exampleSeverity
, severityReason = Just exampleSeverityReason
, projectPackages = Just ["com.example.package1"]
, user = Just exampleUser
, app = Just exampleApplication
, device = Just exampleDevice
, session = Just exampleSession
, featureFlags = Just [exampleFeatureFlag]
, metaData = Just mempty
}