Skip to content

Commit 0a8887c

Browse files
authored
Add fields fingerprint, title, uuid, custom (#53)
1 parent b377017 commit 0a8887c

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

rollbar-client/rollbar-client.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ library
5757
, mtl >=2.2 && <3
5858
, process >=1.6 && <2
5959
, req >=2.1 && <4
60-
, text >=1.2 && <2
60+
, text >=1.2 && <2.1
6161
, unordered-containers >=0.2 && <1
6262
, yaml >=0.11 && <1
6363
default-language: Haskell2010

rollbar-client/src/Rollbar/Client/Item.hs

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,38 @@ data Item = Item
8080
, itemServer :: Maybe Server
8181
-- ^ Data about the server related to this event.
8282
-- client
83-
-- custom
84-
-- fingerprint
85-
-- title
86-
-- uuid
83+
, custom :: Maybe Object
84+
-- ^ Any arbitrary metadata you want to send.
85+
, title :: Maybe Text
86+
-- ^ A string that will be used as the title of the Item occurrences will be grouped into.
87+
, uuid :: Maybe Text
88+
-- ^ Identifies this occurrence.
89+
, fingerprint :: Maybe Text
90+
-- ^ Controlls how this occurrence should be grouped.
8791
, itemNotifier :: Notifier
8892
-- ^ Describes the library used to send this event.
8993
} deriving (Eq, Show)
9094

9195
instance ToJSON Item where
92-
toJSON Item{..} = object
93-
[ "data" .= object
94-
[ "environment" .= itemEnvironment
95-
, "body" .= itemBody
96-
, "level" .= itemLevel
97-
, "platform" .= itemPlatform
98-
, "language" .= itemLanguage
99-
, "framework" .= itemFramework
100-
, "request" .= itemRequest
101-
, "server" .= itemServer
102-
, "notifier" .= itemNotifier
103-
]
104-
]
96+
toJSON Item{..} =
97+
let dataFields =
98+
[ "environment" .= itemEnvironment
99+
, "body" .= itemBody
100+
, "level" .= itemLevel
101+
, "platform" .= itemPlatform
102+
, "language" .= itemLanguage
103+
, "framework" .= itemFramework
104+
, "request" .= itemRequest
105+
, "server" .= itemServer
106+
, "notifier" .= itemNotifier
107+
] ++ catMaybes
108+
[ ("custom" .=) <$> custom
109+
, ("fingerprint" .=) <$> fingerprint
110+
, ("title" .=) <$> title
111+
, ("uuid" .=) <$> uuid
112+
]
113+
in
114+
object [ "data" .= object dataFields ]
105115

106116
-- | Builds an 'Item' based on a 'Payload'.
107117
mkItem
@@ -129,6 +139,10 @@ mkItem payload = do
129139
, serverCodeVersion = Nothing
130140
}
131141
, itemNotifier = defaultNotifier
142+
, custom = Nothing
143+
, title = Nothing
144+
, uuid = Nothing
145+
, fingerprint = Nothing
132146
}
133147

134148
-- | The main data being sent. It can either be a message, an exception, or a

rollbar-wai/rollbar-wai.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ library
5151
, case-insensitive >=1.2 && <2
5252
, http-types >=0.12 && <1
5353
, rollbar-client >=1.0 && <2
54-
, text >=1.2 && <2
54+
, text >=1.2 && <2.1
5555
, unordered-containers >=0.2 && <1
5656
, wai >=3.2 && <4
5757
, wai-extra >=3.0 && <4

0 commit comments

Comments
 (0)