Sentry SDK
1 Introduction
2 Quickstart
3 Reference
3.1 Core API
sentry?
current-sentry
make-sentry
sentry-capture-exception!
sentry-stop
3.2 Users
sentry-user?
current-sentry-user
make-sentry-user
Index
8.12

Sentry SDK🔗ℹ

Bogdan Popa <bogdan@defn.io>

 (require sentry) package: sentry-lib

1 Introduction🔗ℹ

This library provides an interface for capturing and sending errors to either a managed or a self-hosted Sentry instance.

2 Quickstart🔗ℹ

Install the package from the package server with

$ raco pkg install sentry

Call make-sentry to create an instance of the sentry client. Keep a reference to the client around for as long as your application needs to run and you can start sending exceptions by calling sentry-capture-exception!:

(require sentry)
 
(parameterize ([current-sentry (make-sentry "https://key@sentry.io/12")])
  (sentry-capture-exception! (make-exn:fail "an error" (current-continuation-marks))))

3 Reference🔗ℹ

3.1 Core API🔗ℹ

procedure

(sentry? v)  boolean?

  v : any/c
Returns #t when v is a Sentry client.

parameter

(current-sentry)  (or/c #f sentry?)

(current-sentry client)  void?
  client : (or/c #f sentry?)
A parameter that can store the current Sentry client for use with sentry-capture-exception!.

procedure

(make-sentry dsn    
  [#:backlog backlog    
  #:release release    
  #:environment environment])  sentry?
  dsn : string?
  backlog : exact-positive-integer? = 128
  release : (or/c #f non-empty-string?)
   = (getenv "SENTRY_RELEASE")
  environment : (or/c #f non-empty-string?)
   = (getenv "SENTRY_ENVIRONMENT")
Initialize a Sentry client and start the background thread that will send errors to the API.

backlog specifies the size of the error queue. When the queue fills up, calls to sentry-capture-exception! will start to silently drop events.

release can be set to tag each error with the current release (usually a GIT SHA).

environment can be set to tag each error with the current environment (eg. "production" or "staging").

Sentry clients log messages to the 'sentry topic.

procedure

(sentry-capture-exception! e    
  [client    
  #:level level    
  #:timestamp timestamp    
  #:server-name server-name    
  #:environment environment    
  #:release release    
  #:request request    
  #:tags tags    
  #:user user])  void?
  e : exn?
  client : (or/c #f sentry?) = (current-sentry)
  level : (or/c 'fatal 'error 'warning 'info 'debug) = 'error
  timestamp : moment? = (now/moment)
  server-name : (or/c #f non-empty-string?) = #f
  environment : (or/c #f non-empty-string?) = #f
  release : (or/c #f non-empty-string?) = #f
  request : (or/c #f request?) = #f
  tags : (hash/c non-empty-string? string?) = (hash)
  user : sentry-user? = (current-sentry-user)
Asynchronously send an error to the Sentry API.

Does nothing when client is #f.

procedure

(sentry-stop [client])  void?

  client : sentry? = (current-sentry)
Waits for all pending events in client to be sent and then shuts down its event loop.

3.2 Users🔗ℹ

procedure

(sentry-user? v)  boolean?

  v : any/c
Returns #t when v represents a Sentry user.

parameter

(current-sentry-user)  (or/c #f sentry-user?)

(current-sentry-user user)  void?
  user : (or/c #f sentry-user?)
A parameter that keeps track of data for the current user.

sentry-capture-exception! automatically picks these values up unless a different value is specified via its #:user argument.

procedure

(make-sentry-user #:id id    
  [#:username username    
  #:email email    
  #:ip-address ip-address    
  #:subscription subscription])  sentry-user?
  id : non-empty-string?
  username : (or/c #f non-empty-string?) = #f
  email : (or/c #f non-empty-string?) = #f
  ip-address : (or/c #f non-empty-string?) = #f
  subscription : (or/c #f non-empty-string?) = #f
Creates an object that can store various bits of information about a user. These can then be passed to sentry-capture-exception! to have the data be associated with an error.

Index🔗ℹ

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 

Core API
current-sentry
current-sentry-user
Introduction
make-sentry
make-sentry-user
Quickstart
Reference
sentry
Sentry SDK
sentry-capture-exception!
sentry-stop
sentry-user?
sentry?
Users