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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def add(name, started, _finished, _unique_id, data)

def inject
@subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
add(name, started, finished, unique_id, data)
# we only record events that has a started timestamp
if started.is_a?(Time)
add(name, started, finished, unique_id, data)
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@
Sentry.get_current_scope.clear_breadcrumbs
end

let(:transport) do
Sentry.get_current_client.transport
end

after do
transport.events = []
end

it "captures correct data" do
get "/exception"

expect(response.status).to eq(500)
event = Sentry.get_current_client.transport.events.first.to_json_compatible
event = transport.events.first.to_json_compatible
breadcrumbs = event.dig("breadcrumbs", "values")
expect(breadcrumbs.count).to eq(2)

Expand Down Expand Up @@ -55,4 +63,12 @@
)
end
end

it "ignores events that doesn't have a started timestamp" do
expect do
ActiveSupport::Notifications.publish "foo", Object.new
end.not_to raise_error

expect(transport.events).to be_empty
end
end