NoRedInk/elm-rollbar/2.0.1

Rollbar

Send reports to Rollbar.

Types

type alias Rollbar =
{ critical : String -> Dict String Value -> Task Error Uuid
, error : String -> Dict String Value -> Task Error Uuid
, warning : String -> Dict String Value -> Task Error Uuid
, info : String -> Dict String Value -> Task Error Uuid
, debug : String -> Dict String Value -> Task Error Uuid
}

Functions preapplied with access tokens, scopes, and environments, separated by Level.

Create one using scoped.

type Level
= Critical
| Error
| Warning
| Info
| Debug

Severity levels.

type Token

A Rollbar API access token.

Create one using token.

Rollbar.token "12c99de67a444c229fca100e0967486f"
token : String -> Token

Create a Token

Rollbar.token "12c99de67a444c229fca100e0967486f"

For example, "production", "development", or "staging".

Create one using environment.

Rollbar.environment "production"

Create an Environment

Rollbar.environment "production"
type Scope

A scope, for example "login".

Create one using scope.

Rollbar.scope "login"
scope : String -> Scope

Create a Scope.

Rollbar.scope "login"

A code version, for example - a git commit hash.

Create one using codeVersion.

Rollbar.codeVersion "24dcf3a9a9cf1a5e2ea319018644a68f4743a731"

Create a CodeVersion.

Rollbar.codeVersion "24dcf3a9a9cf1a5e2ea319018644a68f4743a731"

Types

scoped : Token -> CodeVersion -> Environment -> String -> Rollbar

Return a Rollbar record configured with the given Environment and Scope string.

If the HTTP request to Rollbar fails because of an exceeded rate limit (status code 429), this will retry the HTTP request once per second, up to 60 times.

rollbar = Rollbar.scoped "Page/Home.elm"


rollbar.debug "Hitting the hats API." Dict.empty


[ ( "Payload", toString payload ) ]
    |> Dict.fromList
    |> rollbar.error "Unexpected payload from the hats API."
-> Scope
-> Int
-> Level
-> String
-> Dict String Value
-> Task Error Uuid

Send a message to Rollbar. scoped provides a nice wrapper around this.

Arguments:

  • Token - The Rollbar API token required to authenticate the request.
  • Scope - Scoping messages essentially namespaces them. For example, this might be the name of the page the user was on when the message was sent.
  • Environment - e.g. "production", "development", "staging", etc.
  • Int - maximum retry attempts - if the response is that the message was rate limited, try resending again (once per second) up to this many times. (0 means "do not retry.")
  • Level - severity, e.g. Error, Warning, Debug
  • String - message, e.g. "Auth server was down when user tried to sign in."
  • Dict String Value - arbitrary metadata, e.g. {"username": "rtfeldman"}

If the message was successfully sent to Rollbar, the Task succeeds with the Uuid it generated and sent to Rollbar to identify the message. Otherwise it fails with the Http.Error responsible.