packages feed

bugsnag-types-1.1.0.1: src/Data/Bugsnag/Types/Breadcrumb.hs

module Data.Bugsnag.Types.Breadcrumb
  ( Breadcrumb (..)
  , exampleBreadcrumb
  ) where

import Data.Bugsnag.Types.Prelude

import Data.Bugsnag.Types.BreadcrumbType

data Breadcrumb = Breadcrumb
  { timestamp :: Text
  -- ^ The time at which the event occurred, in
  -- <https://tools.ietf.org/html/rfc3339#section-5.8 ISO 8601 format>.
  , name :: Text
  -- ^ A short summary describing the event, such as the user action taken or a
  -- new application state.
  , type_ :: BreadcrumbType
  -- ^ A category which describes the breadcrumb, from the list of allowed
  -- values.
  --
  -- -   @navigation@ - Changing screens or content being displayed, with a
  --     defined destination and optionally a previous location.
  --
  -- -   @request@ - Sending and receiving requests and responses.
  --
  -- -   @process@ - Performing an intensive task or query.
  --
  -- -   @log@ - Messages and severity sent to a logging platform.
  --
  -- -   @user@ - Actions performed by the user, like text input, button
  --     presses, or confirming\/cancelling an alert dialog.
  --
  -- -   @state@ - Changing the overall state of an app, such as closing,
  --     pausing, or being moved to the background, as well as device state
  --     changes like memory or battery warnings and network connectivity
  --     changes.
  --
  -- -   @error@ - An error which was reported to BugSnag encountered in the
  --     same session.
  --
  -- -   @manual@ - User-defined, manually added breadcrumbs.
  , metaData :: Maybe (KeyMap Text)
  -- ^ Additional information about the event, as key\/value pairs.
  --
  -- > {
  -- >     "to": "PauseView",
  -- >     "from": "PodBayDoorView"
  -- > }
  }
  deriving stock (Eq, Show, Generic)

instance FromJSON Breadcrumb where
  parseJSON = genericParseJSON aesonOptions

instance ToJSON Breadcrumb where
  toJSON = genericToJSON aesonOptions
  toEncoding = genericToEncoding aesonOptions

exampleBreadcrumb :: Breadcrumb
exampleBreadcrumb = Breadcrumb
  { timestamp = "2016-07-19T12:17:27-0700"
  , name = "Open menu"
  , type_ = exampleBreadcrumbType
  , metaData = Nothing
  }