Skip to content

Commit eaf55a1

Browse files
committed
update test
1 parent 036f278 commit eaf55a1

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

lib/sentry/application.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ defmodule Sentry.Application do
1919
[]
2020
end
2121

22+
# if Config.dsn() && Config.send_client_reports?() do
2223
client_report_enabled =
23-
if Config.dsn() && Config.send_client_reports?() do
24-
Sentry.ClientReport
24+
if Config.send_client_reports?() do
25+
[Sentry.ClientReport]
2526
end
2627

2728
integrations_config = Config.integrations()

lib/sentry/client_report.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ defmodule Sentry.ClientReport do
9494
}
9595

9696
Client.send_client_report(updated_state)
97+
9798
schedule_report()
9899
{:noreply, %__MODULE__{}}
99100
else
100101
# state is nil so nothing to send but keep looping
101102
schedule_report()
102103
IO.inspect(state)
103-
{:noreply, state}
104+
{:noreply, %__MODULE__{}}
104105
end
105106
end
106107

lib/sentry/transport.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ defmodule Sentry.Transport do
2525
{:ok, envelope_id :: String.t()} | {:error, ClientError.t()}
2626
def encode_and_post_envelope(%Envelope{} = envelope, client, retries \\ @default_retries)
2727
when is_atom(client) and is_list(retries) do
28+
IO.inspect(envelope)
29+
2830
result =
2931
case Envelope.to_binary(envelope) do
3032
{:ok, body} ->

test/sentry/client_report_test.exs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
defmodule Sentry.ClientReportTest do
2+
use Sentry.Case, async: false
3+
4+
alias Sentry.ClientReport
5+
6+
describe "add_discarded_event/1" do
7+
test "records discarded event to state" do
8+
assert :sys.get_state(ClientReport) == %Sentry.ClientReport{
9+
discarded_events: nil
10+
}
11+
12+
ClientReport.add_discarded_event({:event_processor, "error"})
13+
14+
assert :sys.get_state(ClientReport) == %Sentry.ClientReport{
15+
discarded_events: %{{:event_processor, "error"} => 1}
16+
}
17+
18+
ClientReport.add_discarded_event({:event_processor, "error"})
19+
ClientReport.add_discarded_event({:event_processor, "error"})
20+
ClientReport.add_discarded_event({:network_error, "error"})
21+
22+
# updates quantity when duplcate events are sent
23+
assert :sys.get_state(ClientReport) == %Sentry.ClientReport{
24+
discarded_events: %{
25+
{:event_processor, "error"} => 3,
26+
{:network_error, "error"} => 1
27+
}
28+
}
29+
end
30+
end
31+
end

0 commit comments

Comments
 (0)