@@ -27,30 +27,35 @@ defmodule Sentry.Client do
2727 @ max_message_length 8_192
2828
2929 @ spec send_check_in ( CheckIn . t ( ) , keyword ( ) ) ::
30- { :ok , check_in_id :: String . t ( ) } | { :error , ClientError . t ( ) }
30+ { :ok , check_in_id :: String . t ( ) } | :ignored | { :error , ClientError . t ( ) }
3131 def send_check_in ( % CheckIn { } = check_in , opts ) when is_list ( opts ) do
32- if Config . telemetry_processor_category? ( :check_in ) do
33- case TelemetryProcessor . add ( check_in ) do
34- { :ok , { :rate_limited , data_category } } ->
35- ClientReport.Sender . record_discarded_events ( :ratelimit_backoff , data_category )
32+ cond do
33+ is_nil ( Config . dsn ( ) ) ->
34+ :ignored
3635
37- :ok ->
38- :ok
39- end
36+ Config . telemetry_processor_category? ( :check_in ) ->
37+ case TelemetryProcessor . add ( check_in ) do
38+ { :ok , { :rate_limited , data_category } } ->
39+ ClientReport.Sender . record_discarded_events ( :ratelimit_backoff , data_category )
4040
41- { :ok , check_in . check_in_id }
42- else
43- client = Keyword . get_lazy ( opts , :client , & Config . client / 0 )
41+ :ok ->
42+ :ok
43+ end
4444
45- # This is a "private" option, only really used in testing.
46- request_retries =
47- Keyword . get_lazy ( opts , :request_retries , fn ->
48- Application . get_env ( :sentry , :request_retries , Transport . default_retries ( ) )
49- end )
45+ { :ok , check_in . check_in_id }
46+
47+ true ->
48+ client = Keyword . get_lazy ( opts , :client , & Config . client / 0 )
5049
51- check_in
52- |> Envelope . from_check_in ( )
53- |> Transport . encode_and_post_envelope ( client , request_retries )
50+ # This is a "private" option, only really used in testing.
51+ request_retries =
52+ Keyword . get_lazy ( opts , :request_retries , fn ->
53+ Application . get_env ( :sentry , :request_retries , Transport . default_retries ( ) )
54+ end )
55+
56+ check_in
57+ |> Envelope . from_check_in ( )
58+ |> Transport . encode_and_post_envelope ( client , request_retries )
5459 end
5560 end
5661
@@ -59,6 +64,7 @@ defmodule Sentry.Client do
5964 @ spec send_event ( Event . t ( ) , keyword ( ) ) ::
6065 { :ok , event_id :: String . t ( ) }
6166 | { :error , ClientError . t ( ) }
67+ | :ignored
6268 | :unsampled
6369 | :excluded
6470 def send_event ( % Event { } = event , opts ) when is_list ( opts ) do
@@ -78,6 +84,7 @@ defmodule Sentry.Client do
7884
7985 result =
8086 with { :ok , % Event { } = event } <- maybe_call_before_send ( event , before_send ) ,
87+ :ok <- ensure_dsn_configured ( ) ,
8188 :ok <- sample_event ( sample_rate ) ,
8289 :ok <- maybe_dedupe ( event ) do
8390 send_result = encode_and_send ( event , result_type , client , request_retries )
@@ -99,6 +106,9 @@ defmodule Sentry.Client do
99106 :excluded ->
100107 :excluded
101108
109+ :ignored ->
110+ :ignored
111+
102112 { :error , % ClientError { } = error } ->
103113 { :error , error }
104114 end
@@ -120,6 +130,7 @@ defmodule Sentry.Client do
120130 @ spec send_transaction ( Transaction . t ( ) , keyword ( ) ) ::
121131 { :ok , transaction_id :: String . t ( ) }
122132 | { :error , ClientError . t ( ) }
133+ | :ignored
123134 | :excluded
124135 def send_transaction ( % Transaction { } = transaction , opts \\ [ ] ) do
125136 opts = NimbleOptions . validate! ( opts , Options . send_transaction_schema ( ) )
@@ -134,16 +145,24 @@ defmodule Sentry.Client do
134145 Application . get_env ( :sentry , :request_retries , Transport . default_retries ( ) )
135146 end )
136147
137- with { :ok , % Transaction { } = transaction } <- maybe_call_before_send ( transaction , before_send ) do
148+ with { :ok , % Transaction { } = transaction } <- maybe_call_before_send ( transaction , before_send ) ,
149+ :ok <- ensure_dsn_configured ( ) do
138150 send_result = encode_and_send ( transaction , result_type , client , request_retries )
139151 _ignored = maybe_call_after_send ( transaction , send_result , after_send_event )
140152 send_result
141153 else
142154 :excluded ->
143155 :excluded
156+
157+ :ignored ->
158+ :ignored
144159 end
145160 end
146161
162+ defp ensure_dsn_configured do
163+ if Config . dsn ( ) , do: :ok , else: :ignored
164+ end
165+
147166 defp sample_event ( sample_rate ) do
148167 cond do
149168 sample_rate == 1 -> :ok
0 commit comments