Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better DX for submitting dynamic custom data on automatically reported errors #1130

Open
madejejej opened this issue Sep 7, 2023 · 0 comments

Comments

@madejejej
Copy link

I wish to add dynamic custom data in Rollbar, so that the data is visible in the errors reported by my system,

It seems there should be a method where you can do something like this:

Rollbar.with_extra(a: 1, b: 2) do
  # all errors within the block should send the additional parameters passed to the method
end

Initially I thought I could use the Rollbar.scoped method, but it doesn't seem to accept any extra fields. The documentation shows the following example:

  # Overwrites any existing person data
  scope = {
    :person => {:id => user.id, :username => user.username, :email => user.email}
  }

  Rollbar.scoped(scope)

But it only overrides Rollbar-defined data. I tried the simple thing to do which is Rollbar.scoped(a: 1, b:2), but those parameters aren't being passed as extra arguments.I even went as far as this:

Rollbar.scoped(body: { message: { extra: { my_params: { param1: 'abc', param2: 'def' } } })

but unfortunately, it got rejected by Rollbar, because it overwrites message.body:

API error: Invalid format. data.body.message.body is a required property. data.body must have exactly one of the properties: 'trace', 'trace_chain', 'message', or 'crash_report'.

I'm also aware of the existence of the custom_data_method, but I have no clue how to pass the data to it from the scoped method and it also seems like an overkill for this use-case.

Is there a chance for us to have a methods that work similar to Rollbar.scoped, Rollbar.scope! pair, or enhance those methods to make passing extra arguments easier?

Or perhaps it's already possible but I'm missing something because it's not well-documented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant