{"id":19149280,"url":"https://github.com/nervous-systems/cljs-rollbar","last_synced_at":"2025-05-07T04:42:48.951Z","repository":{"id":62433031,"uuid":"53055996","full_name":"nervous-systems/cljs-rollbar","owner":"nervous-systems","description":"Clojurescript/Node-friendly Rollbar client","archived":false,"fork":false,"pushed_at":"2016-08-19T11:59:18.000Z","size":199,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-07T04:42:39.580Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nervous-systems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-03T14:23:13.000Z","updated_at":"2018-06-16T20:23:54.000Z","dependencies_parsed_at":"2022-11-01T21:15:33.731Z","dependency_job_id":null,"html_url":"https://github.com/nervous-systems/cljs-rollbar","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervous-systems%2Fcljs-rollbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervous-systems%2Fcljs-rollbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervous-systems%2Fcljs-rollbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervous-systems%2Fcljs-rollbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nervous-systems","download_url":"https://codeload.github.com/nervous-systems/cljs-rollbar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252816517,"owners_count":21808702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:07:27.660Z","updated_at":"2025-05-07T04:42:48.932Z","avatar_url":"https://github.com/nervous-systems.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cljs-rollbar\n\nA client for [Rollbar](https://rollbar.com) currently geared towards\nClojurescript running on Node.  It'd be trivial to extend it to browser\nenvironments, or the JVM, though the initial target was [Clojurescript AWS\nLambda functions](https://github.com/nervous-systems/cljs-lambda).  Features\nintrinsic support for [Timbre](https://github.com/ptaoussanis/timbre).\n\n[![Clojars Project](https://img.shields.io/clojars/v/io.nervous/cljs-rollbar.svg)](https://clojars.org/io.nervous/cljs-rollbar)\n\n# Usage\n\nThe model ought to be fairly familiar - there's a function `rollbar!`, which\ntakes a map \u0026 transforms it before issuing it as a `POST` request to the Rollbar\nAPI, returning a [promesa](https://github.com/funcool/promesa) promise.\n\nThere are environment-specific modules (currently only `cljs-rollbar.node`)\nwhich provide default maps containing information about the runtime environment.\n\n```clojure\n(...\n  (:require [cljs-rollbar.core :as rollbar]\n            [cljs-rollbar.node]))\n\n(def report!\n  (-\u003e rollbar/rollbar!\n      (rollbar/defaulting cljs-rollbar.node/default-payload)\n      (rollbar/defaulting {:token \"SECRET\"})))\n```\n\nThe simplest possible request:\n\n```clojure\n(report! {:info \"Hello\"})\n```\n\nIn a Node REPL on my laptop with the `report!` definition above, I get the\nfollowing sent to Rollbar:\n\n```clojure\n{:access_token \"SECRET\"\n :data\n {:server\n  {:code_version \"0.1.0\"\n   :host         \"brinstar.local\"\n   :argv         [\"/usr/local/Cellar/node/6.3.1/bin/node\"]\n   :pid          69652}\n\n  :level       :info\n  :language    \"clojurescript\"\n  :notifier    {:name \"rollbar-cljs-node\" :version \"0.1.0\"}\n  :environment \"unspecified\"\n  :timestamp   1470412615834\n  :body        {:message {:body \"Hello\"}}\n  :framework   \"node-js\"\n  :platform    \"darwin\"}}\n```\n\nIf I don't like any of those values, I can specify them when I define my\nreporter, or when I emit the message, e.g:\n\n```clojure\n(def report!\n  (-\u003e rollbar/rollbar!\n      (rollbar/defaulting {:env \"prod\"})))\n\n;; `:env` is a supported abbreviation, as are `:host` \u0026 `:version`:\n\n(report! {:info \"Hello\" :env \"prod\" :version \"0.0.0\"})\n```\n\nSimilarly, it's easy to emit messages at different levels:\n\n```clojure\n;; Report an error, attach a `person` to the error\n(report! {:error (ex-info \"Oops\" {:x 1}) :person {:id \"boss\"}})\n;; Log an error instance without using the `error` level\n(promesa.core/then\n  (report! {:debug (js/Error. \"Oops\")})\n  println)\n;; =\u003e {:err 0, :result {:id nil, :uuid \"dbd8081e330b4abf8c6f86586d26d863\"}}\n````\n\n![Screenshot](https://raw.githubusercontent.com/nervous-systems/cljs-rollbar/master/doc/exception.png)\n\nAside from the keys expected by Rollbar, ad-hoc data can be put into the map\npassed to the reporting function.\n\nAdditionally, the map attached to an `ExceptionInfo` instance (i.e. as in the\n`ex-info` example above) will be merged into the toplevel Rollbar map and\nassociated with the error item.\n\n# Timbre\n\nIf you're using [Timbre](https://github.com/ptaoussanis/timbre), it's\nstraightforward to configure a cljs-rollbar appender.\n\n```clojure\n(timbre/merge-config!\n  {:appenders {:rollbar (rollbar/timbre-appender report!)}})\n;; (Where report! is the function we defined above - rollbar! + some defaults)\n```\n\nWe can then proceed to log as normal:\n\n```clojure\n(timbre/info \"Hello\" {:x 1})\n```\n\nAny map arguments which are passed to a Timbre logging call are merged into the\nmap supplied to the appender's reporting function \u0026 will become attributes of\nthe resulting Rollbar item.  Additionally, `line` and `file` toplevel attributes\nare set to the information received from Timbre, when not reporting an error\n(errors have their own designated line/file attrs in the Rollbar API -- non errors\ndo not, AFAICT)\n\n```clojure\n(timbre/error (js/Error. \"Oops\") {:version \"0.2.0-final\"})\n(timbre/info {:env \"dev\"} \"Stuff seems pretty good\"     )\n```\n\n# Lambda\n\nIf you're using [cljs-lambda](https://github.com/nervous-systems/cljs-lambda),\nconnecting its error handling mechanism to cljs-rollbar is straightforward:\n\n```clojure\n(...\n  (:require [cljs-lambda.util :refer [async-lambda-fn]]\n            [cljs-rollbar.lambda]))\n\n(def ^:export blow-up\n  (async-lambda-fn\n    (fn [event ctx]\n      (throw (ex-info \"Sorry\" {::x 2})))\n    {:error-handler (cljs-rollbar.lambda/reporting-errors report!)}))\n```\n\nThis'll cause errors thrown inside `blow-up` (or asynchronously realized errors)\nto be sent via our Rollbar reporting function `report!`.  The Lambda function\nwon't return to the caller until the error is acknowledged by Rollbar.  In the\nevent of a successful Rollbar API response, the underlying error will be passed\nthrough to the caller as if the error handler wasn't in between.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervous-systems%2Fcljs-rollbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnervous-systems%2Fcljs-rollbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervous-systems%2Fcljs-rollbar/lists"}