Skip to content

Commit

Permalink
Don't throw error on arbitrary arguments being passed to `capture_eve…
Browse files Browse the repository at this point in the history
…nt` options (#2301)
  • Loading branch information
sl0thentr0py committed Apr 23, 2024
1 parent 0c06281 commit 07aaf5e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,11 @@

Rails users will be able to use `bin/rails generate sentry` to generate their `config/initializers/sentry.rb` file.

### Bug Fixes

- Don't throw error on arbitrary arguments being passed to `capture_event` options [#2301](https://github.com/getsentry/sentry-ruby/pull/2301)
- Fixes [#2299](https://github.com/getsentry/sentry-ruby/issues/2299)

## 5.17.3

### Internal
Expand Down
3 changes: 2 additions & 1 deletion sentry-ruby/lib/sentry/scope.rb
Expand Up @@ -135,7 +135,8 @@ def update_from_options(
tags: nil,
user: nil,
level: nil,
fingerprint: nil
fingerprint: nil,
**options
)
self.contexts.merge!(contexts) if contexts
self.extra.merge!(extra) if extra
Expand Down
26 changes: 26 additions & 0 deletions sentry-ruby/spec/sentry/scope_spec.rb
Expand Up @@ -336,4 +336,30 @@
subject.generate_propagation_context(env)
end
end

describe '#update_from_options' do
it 'updates data from arguments' do
subject.update_from_options(
contexts: { context: 1 },
extra: { foo: 42 },
tags: { tag: 2 },
user: { name: 'jane' },
level: :info,
fingerprint: 'ABCD'
)

expect(subject.contexts).to include(context: 1)
expect(subject.extra).to eq({ foo: 42 })
expect(subject.tags).to eq({ tag: 2 })
expect(subject.user).to eq({ name: 'jane' })
expect(subject.level).to eq(:info)
expect(subject.fingerprint).to eq('ABCD')
end

it 'does not throw when arbitrary options passed' do
expect do
subject.update_from_options(foo: 42)
end.not_to raise_error
end
end
end

0 comments on commit 07aaf5e

Please sign in to comment.