|
128 | 128 | client.event_from_exception(ZeroDivisionError.new("divided by 0"))
|
129 | 129 | end
|
130 | 130 |
|
| 131 | + let(:check_in_event) { client.event_from_check_in("test_slug", :ok) } |
| 132 | + |
131 | 133 | shared_examples "Event in send_event" do
|
132 | 134 | context "when there's an exception" do
|
133 | 135 | before do
|
|
140 | 142 | end.to raise_error(Sentry::ExternalError, "networking error")
|
141 | 143 | end
|
142 | 144 | end
|
| 145 | + |
143 | 146 | it "sends data through the transport" do
|
144 | 147 | expect(client.transport).to receive(:send_event).with(event)
|
145 | 148 | client.send_event(event)
|
|
155 | 158 | expect(event.tags[:called]).to eq(true)
|
156 | 159 | end
|
157 | 160 |
|
158 |
| - context "for check in events" do |
159 |
| - let(:event_object) { client.event_from_check_in("test_slug", :ok) } |
160 |
| - |
161 |
| - it "does not fail due to before_send" do |
162 |
| - configuration.before_send = lambda { |e, _h| e } |
163 |
| - client.send_event(event) |
164 |
| - |
165 |
| - expect(client.transport).to receive(:send_event).with(event) |
166 |
| - client.send_event(event) |
167 |
| - end |
168 |
| - end |
169 |
| - |
170 | 161 | it "doesn't apply before_send_transaction to Event" do
|
171 | 162 | dbl = double("before_send_transaction")
|
172 | 163 | allow(dbl).to receive(:call)
|
|
200 | 191 | expect(string_io.string).to include("Discarded event because before_send didn't return a Sentry::ErrorEvent object but an instance of Integer")
|
201 | 192 | expect(return_value).to eq(nil)
|
202 | 193 | end
|
203 |
| - |
204 |
| - it "warns about Hash value's deprecation" do |
205 |
| - string_io = StringIO.new |
206 |
| - logger = Logger.new(string_io, level: :debug) |
207 |
| - configuration.sdk_logger = logger |
208 |
| - configuration.before_send = lambda do |_event, _hint| |
209 |
| - { foo: "bar" } |
210 |
| - end |
211 |
| - |
212 |
| - return_value = client.send_event(event) |
213 |
| - expect(string_io.string).to include("Returning a Hash from before_send is deprecated and will be removed in the next major version.") |
214 |
| - expect(return_value).to eq({ foo: "bar" }) |
215 |
| - end |
216 | 194 | end
|
217 | 195 |
|
218 | 196 | it_behaves_like "Event in send_event" do
|
|
254 | 232 | expect(string_io.string).to include("Discarded event because before_send_transaction didn't return a Sentry::TransactionEvent object but an instance of NilClass")
|
255 | 233 | expect(return_value).to be_nil
|
256 | 234 | end
|
| 235 | + end |
| 236 | + |
| 237 | + it_behaves_like "TransactionEvent in send_event" do |
| 238 | + let(:event) { transaction_event } |
| 239 | + end |
| 240 | + |
| 241 | + shared_examples "CheckInEvent in send_event" do |
| 242 | + it "sends data through the transport" do |
| 243 | + client.send_event(event) |
| 244 | + end |
| 245 | + |
| 246 | + it "doesn't apply before_send to CheckInEvent" do |
| 247 | + configuration.before_send = lambda do |event, _hint| |
| 248 | + raise "shouldn't trigger me" |
| 249 | + end |
| 250 | + |
| 251 | + client.send_event(event) |
| 252 | + end |
| 253 | + |
| 254 | + it "doesn't apply before_send_transaction to CheckInEvent" do |
| 255 | + configuration.before_send_transaction = lambda do |event, _hint| |
| 256 | + raise "shouldn't trigger me" |
| 257 | + end |
| 258 | + |
| 259 | + client.send_event(event) |
| 260 | + end |
257 | 261 |
|
258 |
| - it "warns about Hash value's deprecation" do |
| 262 | + it "applies before_send_check_in callback before sending the event" do |
| 263 | + called = false |
| 264 | + configuration.before_send_check_in = lambda do |event, _hint| |
| 265 | + called = true |
| 266 | + event |
| 267 | + end |
| 268 | + |
| 269 | + client.send_event(event) |
| 270 | + expect(called).to eq(true) |
| 271 | + end |
| 272 | + |
| 273 | + it "warns if before_send_check_in returns nil" do |
259 | 274 | string_io = StringIO.new
|
260 | 275 | logger = Logger.new(string_io, level: :debug)
|
261 | 276 | configuration.sdk_logger = logger
|
262 |
| - configuration.before_send_transaction = lambda do |_event, _hint| |
263 |
| - { foo: "bar" } |
| 277 | + configuration.before_send_check_in = lambda do |_event, _hint| |
| 278 | + nil |
264 | 279 | end
|
265 | 280 |
|
266 | 281 | return_value = client.send_event(event)
|
267 |
| - expect(string_io.string).to include("Returning a Hash from before_send_transaction is deprecated and will be removed in the next major version.") |
268 |
| - expect(return_value).to eq({ foo: "bar" }) |
| 282 | + expect(string_io.string).to include("Discarded event because before_send_check_in didn't return a Sentry::CheckInEvent object but an instance of NilClass") |
| 283 | + expect(return_value).to be_nil |
269 | 284 | end
|
270 | 285 | end
|
271 | 286 |
|
272 |
| - it_behaves_like "TransactionEvent in send_event" do |
273 |
| - let(:event) { transaction_event } |
| 287 | + it_behaves_like "CheckInEvent in send_event" do |
| 288 | + let(:event) { check_in_event } |
274 | 289 | end
|
275 | 290 | end
|
276 | 291 |
|
|
0 commit comments