iBet uBet web content aggregator. Adding the entire web to your favor.
iBet uBet web content aggregator. Adding the entire web to your favor.



Link to original content: http://github.com/ragnard/clj-squash/tree/master/doc
clj-squash/doc at master · ragnard/clj-squash · GitHub
Skip to content

Latest commit

 

History

History

doc

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

clj-squash

Clojure client library for the Squash bug killer by Square.

NOTE: This is currently the result of a few hours of hacking with the purpose of trying out Squash for Clojure applications. No thourough testing has been performed.

Artifacts

clj-squash is available on Clojars and the current version is:

[clj-squash "0.1.1"]

Usage

Use the notifier function in com.github.ragnard.clj-squash.api to create a function that when applied to an Exception will send a notification to a Squash instance:

(require '[com.github.ragnard.clj-squash.api :as squash])
    
(let [notify (squash/notifier {:api-host "http://localhost:8081"
                               :api-key "fa2818ce-5480-4aa0-87a9-43a342bf425a"
                               :environment "dev"})]
  (notify (ex-info "Invalid use of robot" {:robot-id 42})))

An optional update function can also be passed as second argument to a notification function. This function will be applied to the map of notification data before it is transmitted, and is expected to return a new, potentially different map. This can be used to extend, inspect or alter the update data in any way imaginable, like so:

(require '[com.github.ragnard.clj-squash.api :as squash])

(let [notify (squash/notifier {:api-host "http://localhost:8081"
                               :api-key "fa2818ce-5480-4aa0-87a9-43a342bf425a"
                               :environment "dev"})]
  (notify (ex-info "Invalid use of robot" {:robot-id 42})
          (fn [notification-data]
            (update-in notification-data [:user_data] assoc :robot-favourite-pet "Turtle"))))

See doc for notifier for info on available options.

Any data conveyed with ex-info will be submitted as user_data to Squash and is therefore nicely available in the UI.

Ring Middleware

A Ring middleware for sending notifications of unhandled exceptions is available in the com.ragnard.clj-squash.ring namespace.

(require '[com.github.ragnard.clj-squash.ring :as squash])
    
(-> handler
    (squash/wrap-squash {:api-host "http://localhost:8081"
                         :api-key "fa2818ce-5480-4aa0-87a9-43a342bf425a"
                         :environment "dev"}))

License

Copyright © 2013 Ragnar Dahlén

Distributed under the Eclipse Public License, the same as Clojure.