Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sentry-ruby/lib/sentry/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(configuration)
end

def capture_event(event, scope, hint = {})
return false unless configuration.sending_allowed?
return unless configuration.sending_allowed?

scope.apply_to_event(event, hint)

Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/lib/sentry/hub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def capture_event(event, **options, &block)

event = current_client.capture_event(event, scope, hint)

@last_event_id = event.event_id
@last_event_id = event&.event_id
event
end

Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/spec/sentry/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def sentry_context

returned = subject.capture_event(event, scope)

expect(returned).to eq(false)
expect(returned).to eq(nil)
end

context "when async raises an exception" do
Expand Down
15 changes: 14 additions & 1 deletion sentry-ruby/spec/sentry/hub_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
subject { described_class.new(client, scope) }

shared_examples "capture_helper" do
context "with sending_allowed? condition" do
before do
expect(configuration).to receive(:sending_allowed?).and_return(false)
end

it "doesn't send the event nor assign last_event_id" do
subject.send(capture_helper, capture_subject)

expect(transport.events).to be_empty
expect(subject.last_event_id).to eq(nil)
end
end

context "with custom attributes" do
it "updates the event with custom attributes" do
subject.send(capture_helper, capture_subject, tags: { foo: "bar" })
Expand Down Expand Up @@ -147,7 +160,7 @@
describe '#capture_event' do
let(:exception) { ZeroDivisionError.new("divided by 0") }
let!(:event) do
subject.capture_exception(exception)
client.event_from_exception(exception)
end

it "returns an Event instance" do
Expand Down