11defmodule Sentry.Config do
22 @ moduledoc false
33
4- @ default_exclude_patterns [ ~r" /_build/" , ~r" /deps/" , ~r" /priv/" , ~r" /test/" ]
5- @ private_env_keys [ :sender_pool_size ]
6-
74 basic_opts_schema = [
85 dsn: [
96 type: { :or , [ :string , nil ] } ,
@@ -232,7 +229,7 @@ defmodule Sentry.Config do
232229 type:
233230 { :list ,
234231 { :custom , __MODULE__ , :__validate_struct__ , [ :source_code_exclude_patterns , Regex ] } } ,
235- default: @ default_exclude_patterns ,
232+ default: [ ~r " /_build/ " , ~r " /deps/ " , ~r " /priv/ " , ~r " /test/ " ] ,
236233 type_doc: "list of `t:Regex.t/0`" ,
237234 doc: """
238235 A list of regular expressions used to determine which files to
@@ -309,7 +306,6 @@ defmodule Sentry.Config do
309306 def validate! ( config ) when is_list ( config ) do
310307 config_opts =
311308 config
312- |> Keyword . drop ( @ private_env_keys )
313309 |> Keyword . take ( @ valid_keys )
314310 |> fill_in_from_env ( :dsn , "SENTRY_DSN" )
315311 |> fill_in_from_env ( :release , "SENTRY_RELEASE" )
@@ -325,7 +321,8 @@ defmodule Sentry.Config do
325321
326322 { :error , error } ->
327323 raise ArgumentError , """
328- invalid configuration for the :sentry application, so we cannot start it. The error was:
324+ invalid configuration for the :sentry application, so we cannot start or update
325+ its configuration. The error was:
329326
330327 #{ Exception . message ( error ) }
331328
@@ -336,11 +333,9 @@ defmodule Sentry.Config do
336333
337334 @ spec persist ( keyword ( ) ) :: :ok
338335 def persist ( config ) when is_list ( config ) do
339- for { key , value } <- config do
336+ Enum . each ( config , fn { key , value } ->
340337 :persistent_term . put ( { :sentry_config , key } , value )
341- end
342-
343- :ok
338+ end )
344339 end
345340
346341 @ spec docs ( ) :: String . t ( )
@@ -370,10 +365,6 @@ defmodule Sentry.Config do
370365 """
371366 end
372367
373- # Also exposed as a function to be used in docs in the Sentry module.
374- @ spec default_source_code_exclude_patterns ( ) :: [ Regex . t ( ) , ... ]
375- def default_source_code_exclude_patterns , do: @ default_exclude_patterns
376-
377368 @ spec dsn ( ) :: String . t ( ) | nil
378369 def dsn , do: get ( :dsn )
379370
@@ -460,27 +451,20 @@ defmodule Sentry.Config do
460451
461452 @ spec put_config ( atom ( ) , term ( ) ) :: :ok
462453 def put_config ( key , value ) when is_atom ( key ) do
463- case NimbleOptions . validate ( [ { key , value } ] , @ opts_schema ) do
464- { :ok , options } ->
465- renamed_key =
466- case key do
467- :before_send_event -> :before_send
468- other -> other
469- end
470-
471- options
472- |> handle_deprecated_before_send ( )
473- |> Keyword . take ( [ renamed_key ] )
474- |> persist ( )
475-
476- { :error , error } ->
477- raise ArgumentError , """
478- invalid configuration to update. The error was:
454+ unless key in @ valid_keys do
455+ raise ArgumentError , "unknown option #{ inspect ( key ) } "
456+ end
479457
480- #{ Exception . message ( error ) }
458+ renamed_key =
459+ case key do
460+ :before_send_event -> :before_send
461+ other -> other
462+ end
481463
482- """
483- end
464+ [ { key , value } ]
465+ |> validate! ( )
466+ |> Keyword . take ( [ renamed_key ] )
467+ |> persist ( )
484468 end
485469
486470 ## Helpers
0 commit comments