git.iko.soy/typeable/rollbar-hs
on 55643af help sign in
13 files changed+92−186
since splitsnapshots
unifiedsplit
.circleci/config.yml+34−18 .gitignore+2−1 package.yaml+46 rollbar-hs.cabal−93 src/Rollbar/Aeson.hs−22 src/Rollbar/Item.hs−8 src/Rollbar/Item/Body.hs+4−10 src/Rollbar/Item/MissingHeaders.hs+3−8 src/Rollbar/Item/Request.hs+2−12 src/Rollbar/Item/Server.hs−5 stack.yaml−6 test/Rollbar/Item/Data/Test.hs+1−1 test/Rollbar/Item/MissingHeaders/Test.hs−2
.circleci/config.yml+34−18
@@ -1,26 +1,40 @@
11version: 2
2+
3+build-steps: &build-steps
4+ steps:
5+ - checkout
6+ - restore_cache:
7+ keys:
8+ - v2-nix-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.yaml" }}
9+ - v2-nix-{{ .Environment.CIRCLE_JOB }}-
10+ - v2-nix-
11+ name: Restoring cache
12+ - run:
13+ name: Compile
14+ command: nix-shell --argstr compiler "${COMPILER}" --run 'make sdist test --jobs=2'
15+ environment:
16+ CABAL_BUILD_FLAGS: --jobs=2
17+ - save_cache:
18+ key: v2-nix-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.yaml" }}
19+ name: Caching nix
20+ paths:
21+ - /nix
22+ - dist
23+
224jobs:
325 ghc-8.2.2:
26+ <<: *build-steps
427 docker:
528 - image: nixorg/nix@sha256:96c3f56563a3b9549ac1da12ff7567c39cb6e648afd6a17d4a1a41f0596ad8f6
6− steps:
7− - checkout
8− - restore_cache:
9− keys:
10− - v2-nix-{{ checksum "package.yaml" }}
11− - v2-nix-
12− name: Restoring cache
13− - run:
14− name: Compile
15− command: nix-shell --run 'make sdist test --jobs=2'
16− environment:
17− CABAL_BUILD_FLAGS: --jobs=2
18− - save_cache:
19− key: v2-nix-{{ checksum "package.yaml" }}
20− name: Caching nix
21− paths:
22− - /nix
23− - dist
29+ environment:
30+ COMPILER: ghc822
31+
32+ ghc-8.4.3:
33+ <<: *build-steps
34+ docker:
35+ - image: nixorg/nix@sha256:96c3f56563a3b9549ac1da12ff7567c39cb6e648afd6a17d4a1a41f0596ad8f6
36+ environment:
37+ COMPILER: ghc843
2438
2539 for-github:
2640 docker:
@@ -37,4 +51,6 @@ workflows:
3751 - for-github:
3852 requires:
3953 - ghc-8.2.2
54+ - ghc-8.4.3
4055 - ghc-8.2.2
56+ - ghc-8.4.3
.gitignore+2−1
@@ -1,5 +1,6 @@
11### Project specific ###
22
3+*.cabal
34.make
45bin
56
@@ -185,4 +186,4 @@ $RECYCLE.BIN/
185186*.lnk
186187
187188
188−# End of https://www.gitignore.io/api/vim,osx,linux,macos,emacs,windows,haskell,visualstudiocode
189+# End of https://www.gitignore.io/api/vim,osx,linux,macos,emacs,windows,haskell,visualstudiocode
package.yamlnew file+46
@@ -0,0 +1,46 @@
1+author: Hardy Jones
2+category: Web
3+copyright: 2018 Hardy Jones
4+description: |
5+ Provides a type-safe encoding of the Rollbar API.
6+ Also provides functions to communicate with the Rollbar API.
7+extra-source-files:
8+ - CHANGELOG.md
9+ - README.md
10+github: joneshf/rollbar-hs
11+library:
12+ dependencies:
13+ - aeson >= 1.0 && < 1.5
14+ - base >= 4.9 && < 5
15+ - bytestring >= 0.10 && < 0.11
16+ - case-insensitive >= 1.2 && < 1.3
17+ - hostname >= 1.0 && < 1.1
18+ - http-client >= 0.5 && < 0.6
19+ - http-conduit >= 2.2 && < 2.4
20+ - http-types >= 0.9 && < 0.13
21+ - network >= 2.6 && < 2.8
22+ - text >= 1.2 && < 1.3
23+ - time >= 1.6 && < 1.9
24+ - unordered-containers >= 0.2 && < 0.3
25+ - uuid >= 1.3 && < 1.4
26+ source-dirs: src
27+license: BSD3
28+maintainer: jones3.hardy@gmail.com
29+name: rollbar-hs
30+synopsis: Core Rollbar data types and APIs.
31+tests:
32+ doc-test:
33+ dependencies:
34+ - QuickCheck >= 2.9
35+ - aeson >= 1.0
36+ - base >= 4.9
37+ - bytestring >= 0.10
38+ - case-insensitive >= 1.2
39+ - hspec >= 2.4
40+ - hspec-golden-aeson >= 0.2
41+ - rollbar-hs
42+ - text >= 1.2
43+ - unordered-containers >= 0.2
44+ main: Main.hs
45+ source-dirs: test
46+version: '0.3.1.0'
rollbar-hs.cabaldeleted−93
@@ -1,93 +0,0 @@
1−cabal-version: 1.12
2−
3−-- This file has been generated from package.yaml by hpack version 0.31.2.
4−--
5−-- see: https://github.com/sol/hpack
6−--
7−-- hash: ac4c551193d60902c95f89512121ee67cb0cafb3a6662796e40323bd0cedff7c
8−
9−name: rollbar-hs
10−version: 0.3.1.0
11−synopsis: Core Rollbar data types and APIs.
12−description: Provides a type-safe encoding of the Rollbar API.
13− Also provides functions to communicate with the Rollbar API.
14−category: Web
15−homepage: https://github.com/joneshf/rollbar-hs#readme
16−bug-reports: https://github.com/joneshf/rollbar-hs/issues
17−author: Hardy Jones
18−maintainer: jones3.hardy@gmail.com
19−copyright: 2018 Hardy Jones
20−license: BSD3
21−license-file: LICENSE
22−build-type: Simple
23−extra-source-files:
24− CHANGELOG.md
25− README.md
26−
27−source-repository head
28− type: git
29− location: https://github.com/joneshf/rollbar-hs
30−
31−library
32− exposed-modules:
33− Rollbar.AccessToken
34− Rollbar.API
35− Rollbar.Item
36− Rollbar.Item.Body
37− Rollbar.Item.CodeVersion
38− Rollbar.Item.Data
39− Rollbar.Item.Environment
40− Rollbar.Item.Hardcoded
41− Rollbar.Item.Internal.Notifier
42− Rollbar.Item.Internal.Platform
43− Rollbar.Item.Level
44− Rollbar.Item.MissingHeaders
45− Rollbar.Item.Person
46− Rollbar.Item.Request
47− Rollbar.Item.Server
48− Rollbar.Aeson
49− other-modules:
50− Paths_rollbar_hs
51− hs-source-dirs:
52− src
53− build-depends:
54− aeson >=1.1
55− , base >=4.9
56− , bytestring >=0.10
57− , case-insensitive >=1.2
58− , hostname >=1.0
59− , http-client >=0.5
60− , http-conduit >=2.2
61− , http-types >=0.8.6
62− , network >=2.6.3
63− , text >=1.2
64− , time >=1.6
65− , unordered-containers >=0.2
66− , uuid >=1.3
67− default-language: Haskell2010
68−
69−test-suite doc-test
70− type: exitcode-stdio-1.0
71− main-is: Main.hs
72− other-modules:
73− Rollbar.Golden
74− Rollbar.Item.Data.Test
75− Rollbar.Item.MissingHeaders.Test
76− Rollbar.Item.Request.Test
77− Rollbar.QuickCheck
78− Paths_rollbar_hs
79− hs-source-dirs:
80− test
81− build-depends:
82− QuickCheck >=2.9
83− , aeson
84− , base
85− , bytestring
86− , case-insensitive
87− , hashable
88− , hspec >=2.4
89− , hspec-golden-aeson >=0.2
90− , rollbar-hs
91− , text
92− , unordered-containers
93− default-language: Haskell2010
src/Rollbar/Aeson.hsdeleted−22
@@ -1,22 +0,0 @@
1−{-# LANGUAGE CPP #-}
2−
3−module Rollbar.Aeson
4− ( Key
5− , textToKey
6− ) where
7−
8−import Data.Text (Text)
9−#if MIN_VERSION_aeson(2,0,0)
10−import Data.Aeson.Key (Key)
11−import qualified Data.Aeson.Key as Key
12−#else
13−#endif
14−
15−#if MIN_VERSION_aeson(2,0,0)
16−textToKey :: Text -> Key
17−textToKey = Key.fromText
18−#else
19−type Key = Text
20−textToKey :: Text -> Key
21−textToKey = id
22−#endif
src/Rollbar/Item.hs−8
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# LANGUAGE DataKinds #-}
32{-# LANGUAGE DeriveGeneric #-}
43{-# LANGUAGE NamedFieldPuns #-}
@@ -198,17 +197,10 @@ data Item a headers
198197 }
199198 deriving (Eq, Generic, Show)
200199
201−#if MIN_VERSION_aeson(2, 2, 0)
202−itemKVs
203− :: (KeyValue e kv, RemoveHeaders headers, ToJSON v)
204− => Item v headers
205− -> [kv]
206−#else
207200itemKVs
208201 :: (KeyValue kv, RemoveHeaders headers, ToJSON v)
209202 => Item v headers
210203 -> [kv]
211−#endif
212204itemKVs Item{accessToken, itemData} =
213205 [ "access_token" .= accessToken
214206 , "data" .= itemData
src/Rollbar/Item/Body.hs+4−10
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# LANGUAGE DeriveGeneric #-}
32{-# LANGUAGE GeneralizedNewtypeDeriving #-}
43{-# LANGUAGE NamedFieldPuns #-}
@@ -34,7 +33,7 @@ import Data.Aeson
3433 , (.=)
3534 )
3635import Data.Aeson.Encoding (pair)
37−import Data.Aeson.Types (explicitParseField, typeMismatch)
36+import Data.Aeson.Types (typeMismatch)
3837import Data.String (IsString)
3938
4039import GHC.Generics (Generic)
@@ -53,21 +52,16 @@ data Body arbitrary
5352 }
5453 deriving (Eq, Generic, Show)
5554
56−#if MIN_VERSION_aeson(2, 2, 0)
57−bodyKVs :: (KeyValue e kv, ToJSON v) => Body v -> [kv]
58−#else
5955bodyKVs :: (KeyValue kv, ToJSON v) => Body v -> [kv]
60−#endif
6156bodyKVs Message{messageBody, messageData} =
6257 [ "body" .= messageBody
6358 , "data" .= messageData
6459 ]
6560
6661instance FromJSON arbitrary => FromJSON (Body arbitrary) where
67− parseJSON (Object o') = explicitParseField parseMessage o' "message"
68− where
69− parseMessage (Object o) = Message <$> o .: "body" <*> o .: "data"
70− parseMessage v = typeMismatch "Body arbitrary (message)" v
62+ parseJSON (Object o') = do
63+ o <- o' .: "message"
64+ Message <$> o .: "body" <*> o .: "data"
7165 parseJSON v = typeMismatch "Body arbitrary" v
7266
7367instance ToJSON arbitrary => ToJSON (Body arbitrary) where
src/Rollbar/Item/MissingHeaders.hs+3−8
@@ -3,7 +3,6 @@
33{-# LANGUAGE KindSignatures #-}
44{-# LANGUAGE ScopedTypeVariables #-}
55{-# LANGUAGE TypeOperators #-}
6−{-# LANGUAGE CPP #-}
76
87{-|
98 Module : Rollbar.Item.MissingHeaders
@@ -21,7 +20,6 @@ module Rollbar.Item.MissingHeaders
2120
2221import Data.Aeson
2322 (FromJSON, KeyValue, ToJSON, object, parseJSON, toJSON, (.=))
24−import Rollbar.Aeson
2523import Data.Bifunctor (bimap)
2624import Data.CaseInsensitive (mk, original)
2725import Data.Maybe (catMaybes)
@@ -33,6 +31,7 @@ import Network.HTTP.Types (Header, RequestHeaders)
3331
3432import qualified Data.ByteString as BS
3533import qualified Data.ByteString.Char8 as BSC8
34+import qualified Data.Text as T
3635import qualified Data.Text.Encoding as TE
3736
3837-- | The request headers with some missing
@@ -64,11 +63,7 @@ instance FromJSON (MissingHeaders headers) where
6463instance RemoveHeaders headers => ToJSON (MissingHeaders headers) where
6564 toJSON = object . catMaybes . requestHeadersKVs . removeHeaders
6665
67−#if MIN_VERSION_aeson(2, 2, 0)
68−requestHeadersKVs :: forall e kv. KeyValue e kv => RequestHeaders -> [Maybe kv]
69−#else
7066requestHeadersKVs :: forall kv. KeyValue kv => RequestHeaders -> [Maybe kv]
71−#endif
7267requestHeadersKVs = fmap go
7368 where
7469 go :: Header -> Maybe kv
@@ -77,5 +72,5 @@ requestHeadersKVs = fmap go
7772 val <- myDecodeUtf8 val'
7873 pure (key .= val)
7974
80−myDecodeUtf8 :: BS.ByteString -> Maybe Key
81−myDecodeUtf8 = either (const Nothing) (Just . textToKey) . TE.decodeUtf8'
75+myDecodeUtf8 :: BS.ByteString -> Maybe T.Text
76+myDecodeUtf8 = either (const Nothing) Just . TE.decodeUtf8'
src/Rollbar/Item/Request.hs+2−12
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# LANGUAGE DeriveGeneric #-}
32{-# LANGUAGE GeneralizedNewtypeDeriving #-}
43{-# LANGUAGE NamedFieldPuns #-}
@@ -49,7 +48,6 @@ import GHC.Generics (Generic)
4948import Network.HTTP.Types (Query)
5049import Network.Socket (SockAddr(SockAddrInet), tupleToHostAddress)
5150
52−import Rollbar.Aeson
5351import Rollbar.Item.MissingHeaders
5452
5553import Text.Read (readMaybe)
@@ -98,18 +96,14 @@ instance ToJSON Get where
9896 toJSON (Get q) = object . catMaybes . queryKVs $ q
9997 toEncoding (Get q) = pairs . mconcat . catMaybes . queryKVs $ q
10098
101−#if MIN_VERSION_aeson(2, 2, 0)
102−queryKVs :: forall e kv. KeyValue e kv => Query -> [Maybe kv]
103−#else
104−queryKVs :: forall kv. KeyValue kv => Query -> [Maybe kv]
105−#endif
99+queryKVs :: forall kv. (KeyValue kv) => Query -> [Maybe kv]
106100queryKVs = fmap go
107101 where
108102 go :: (BS.ByteString, Maybe BS.ByteString) -> Maybe kv
109103 go (key', val') = do
110104 key <- myDecodeUtf8 key'
111105 let val = val' >>= myDecodeUtf8
112− pure (textToKey key .= val)
106+ pure (key .= val)
113107
114108-- | The HTTP Verb
115109newtype Method
@@ -155,11 +149,7 @@ instance ToJSON IP where
155149 toJSON (IP ip) = toJSON (show ip)
156150 toEncoding (IP ip) = toEncoding (show ip)
157151
158−#if MIN_VERSION_aeson(2, 2, 0)
159−requestKVs :: (KeyValue e kv, RemoveHeaders headers) => Request headers -> [kv]
160−#else
161152requestKVs :: (KeyValue kv, RemoveHeaders headers) => Request headers -> [kv]
162−#endif
163153requestKVs Request{get, headers, method, queryString, rawBody, url, userIP} =
164154 [ "body" .= rawBody
165155 , "GET" .= get
src/Rollbar/Item/Server.hs−5
@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# LANGUAGE DeriveGeneric #-}
32{-# LANGUAGE GeneralizedNewtypeDeriving #-}
43{-# LANGUAGE NamedFieldPuns #-}
@@ -58,11 +57,7 @@ data Server
5857 }
5958 deriving (Eq, Generic, Show)
6059
61−#if MIN_VERSION_aeson(2, 2, 0)
62−serverKVs :: KeyValue e kv => Server -> [Maybe kv]
63−#else
6460serverKVs :: KeyValue kv => Server -> [Maybe kv]
65−#endif
6661serverKVs Server{branch, host, root, serverCodeVersion} =
6762 [ ("host" .=) <$> host
6863 , ("root" .=) <$> root
stack.yamldeleted−6
@@ -1,6 +0,0 @@
1−resolver: lts-23.7
2−packages:
3−- .
4−
5−nix:
6− packages: [ zlib ]
test/Rollbar/Item/Data/Test.hs+1−1
@@ -39,6 +39,6 @@ requiredBodyKeys = ["trace", "trace_chain", "message", "crash_report"]
3939key :: Text -> Value -> [(Text, Value)]
4040key k = \case
4141 Object o -> case Data.HashMap.Strict.lookupDefault Null k o of
42− Object o' -> Data.HashMap.Strict.toList o'
42+ Object o -> Data.HashMap.Strict.toList o
4343 _ -> mempty
4444 _ -> mempty
test/Rollbar/Item/MissingHeaders/Test.hs−2
@@ -9,7 +9,6 @@ module Rollbar.Item.MissingHeaders.Test where
99import Data.Aeson (Value (Object), decode', encode,
1010 toJSON)
1111import Data.Functor (void)
12−import Data.Hashable
1312import Data.HashSet (HashSet)
1413import Data.Text (Text)
1514
@@ -92,5 +91,4 @@ keys = \case
9291 Object o -> Data.HashSet.fromMap (void o)
9392 _ -> mempty
9493
95−notMember :: (Eq a, Hashable a) => a -> HashSet a -> Bool
9694notMember x = not . Data.HashSet.member x