Skip to content

Instantly share code, notes, and snippets.

@jondeandres
Last active August 29, 2015 14:13
Show Gist options
  • Save jondeandres/d264ec55db3fb21411a2 to your computer and use it in GitHub Desktop.
Save jondeandres/d264ec55db3fb21411a2 to your computer and use it in GitHub Desktop.
Sinatra person data for Rollbar
require 'sinatra/base'
require 'rollbar'
require 'rollbar/middleware/sinatra'
Rollbar.configure do |config|
config.access_token = 'bfec94a1ede64984b862880224edd0ed'
config.enabled = true
end
class App < Sinatra::Base
use Rollbar::Middleware::Sinatra
helpers do
def current_user
@current_user ||= User.find_by_token(params[:token])
end
def rollbar_person_data
{
id: current_user.id,
username: current_user.username,
email: current_user.email
}
end
end
before do
request.env['rollbar.person_data'] = rollbar_person_data
end
get '/' do
a = e
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment