Giter Club home page Giter Club logo

rollbar-haskell's Introduction

rollbar-haskell

send error notifications to rollbar.com

I have used a few different error notification services.

Rollbar has:

  • good support for client-side javascript errors
  • a nice UI
  • a complete feature set (for me at least)

Usage

Below is some example Yesod code. Integration should be similar elsewhere:

  1. (optional) save Settings at startup
  2. have a global exception handler that notifies Rollbar
-- initialization code
-- in Yesod, this is in makeFoundation in Application.hs
    hn <- getHostName
    let rc = Rollbar.Settings
               { Rollbar.environment = Rollbar.Environment $ tshow $ appEnv conf
               , Rollbar.token =
                     Rollbar.ApiToken $ rollbarApiKeyServer $ appExtra conf
               , Rollbar.hostName = hn
               }
    -- put rc into the foundation type

-- using in a global exception handler
-- in Yesod, this is in the Yesod typeclass in Foundation.hs
import qualified Rollbar
import Rollbar.MonadLogger (reportErrorS)

-- Add a field to the foundation data type
data App = App {
    ...
  , appRollbar :: Rollbar.Settings
  }


errorHandler err@(InternalError e) = do
    app <- getYesod
    -- forking means error reporting to Rollbar won't hold up
    -- the response to the client
    unless development $ forkHandler ($logErrorS "errorHandler" . tshow) $ do
        muser <- maybeAuth
        let rollbarPerson (Entity uid user) =
               Rollbar.Person
                 { Rollbar.id       = toPathPiece uid
                 , Rollbar.username = Nothing
                 , Rollbar.email    = Just $ emailToText $ userEmail user
                 }
        let rPerson = fmap rollbarPerson muser
        reportErrorS (appRollbar app)
                     (Rollbar.Options rPerson Nothing)
                     "errorHandler"
                     ($logDebugS) e
    defaultErrorHandler err 

errorHandler err = defaultErrorHandler err

rollbar-haskell's People

Contributors

gregwebs avatar jetaggart avatar owengraves avatar onslaughtq avatar 4e6 avatar seanhess avatar ysangkok avatar qxjit avatar jappeace avatar jezen avatar mountaindesert avatar spl avatar

Stargazers

Tomas Zemanovic avatar Jon Schoning avatar Miki Oracle avatar Aaron McAdam avatar  avatar Matt Parsons avatar Pooyan Khosravi avatar  avatar James Dabbs avatar Elliot Cameron avatar David Johnson avatar Hercules Merscher avatar Sergey B avatar Shamil Fattakhov avatar Angus H. avatar Eric Bailey avatar Chris A. avatar Reto Kramer avatar Anton Astashov avatar Daisuke Fujimura avatar Luke Randall avatar Brian Rue avatar Wojtek Narczyński avatar

Watchers

Brian Rue avatar Trevis Elser avatar  avatar Max Cantor avatar Sebastian Enguidanos avatar James Cloos avatar Stefan Beeman avatar Eden Delgado avatar  avatar  avatar  avatar Jennifer Shola avatar Rob Magary avatar  avatar  avatar  avatar Nebula Lavelle avatar  avatar  avatar  avatar

rollbar-haskell's Issues

Add compatibility with Aeson 1.2

Starting from version 1.2 module Data.Aeson exports Options which clashes with one defined in Rollbar:

[1 of 2] Compiling Rollbar          ( src/Rollbar.hs, .stack-work/dist/x86_64-linux/Cabal-2.0.0.2/build/Rollbar.o )
             
/home/dbushev/projects/rollbar-haskell/src/Rollbar.hs:48:17: error:
    Ambiguous occurrence ‘Options’
    It could refer to either ‘Data.Aeson.Options’,
                             imported from ‘Data.Aeson’ at src/Rollbar.hs:7:1-17
                             (and originally defined in ‘aeson-1.2.3.0:Data.Aeson.Types.Internal’)
                          or ‘Rollbar.Options’, defined at src/Rollbar.hs:43:1
   |         
48 | emptyOptions :: Options
   |                 ^^^^^^^

Package not on Stackage

Hi, thanks for the great package.

I noticed it isn't on Stackage, which would be nice, because then people can use it without adding an extra-dep.

The instructions say that should request it from the maintainer, which is why I create the issue here.

If you wouldn't like to submit it to Stackage, I can do it. But I thought I'd like to give you the chance since that is the proper process.

Regards!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.