Skip to content

Instantly share code, notes, and snippets.

@brianr
Created October 30, 2013 21:16
Show Gist options
  • Save brianr/7240413 to your computer and use it in GitHub Desktop.
Save brianr/7240413 to your computer and use it in GitHub Desktop.
Example of adding `report_message_with_person` to the Rollbar class so you can send person data (which will be indexed) with a `report_message`-like call. To use, put both files in a directory somewhere and: bundle install bundle exec ruby report_message_with_person.rb
source 'https://rubygems.org'
gem 'rollbar'
require 'rollbar'
Rollbar.configure do |config|
config.access_token = 'aaaabbbbccccddddeeeeffff00001111'
end
module Rollbar
class << self
def report_message_with_person(message, person, level = 'info', extra_data = {})
return 'disabled' unless configuration.enabled
data = message_data(message, level, extra_data)
data[:person] = person
payload = build_payload(data)
schedule_payload(payload)
log_instance_link(data)
data
rescue => e
report_internal_error(e)
'error'
end
end
end
email = "foo@example.com"
# id (string) is required. username and email are optional.
person = {:id => email, :email => email}
Rollbar.report_message("here is a regular message", "debug", :other => "data")
Rollbar.report_message_with_person("here is a message with person data:", person, "debug", :other => "data")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment