@@ -187,6 +187,7 @@ defmodule Sentry.Client do
187187
188188 query =
189189 data
190+ |> Enum . filter ( fn { _ , value } -> value != nil end )
190191 |> Enum . map ( fn { name , value } -> "#{ name } =#{ value } " end )
191192 |> Enum . join ( ", " )
192193
@@ -203,15 +204,15 @@ defmodule Sentry.Client do
203204 @ doc """
204205 Get a Sentry DSN which is simply a URI.
205206
206- {PROTOCOL}://{PUBLIC_KEY}:{SECRET_KEY}@{HOST}/{PATH}{PROJECT_ID}
207+ {PROTOCOL}://{PUBLIC_KEY}[ :{SECRET_KEY}] @{HOST}/{PATH}{PROJECT_ID}
207208 """
208209 @ spec get_dsn :: dsn
209210 def get_dsn do
210211 dsn = Config . dsn ( )
211212
212213 with % URI { userinfo: userinfo , host: host , port: port , path: path , scheme: protocol }
213- when is_binary ( path ) <- URI . parse ( dsn ) ,
214- [ public_key , secret_key ] <- String . split ( userinfo , ":" , parts: 2 ) ,
214+ when is_binary ( path ) and is_binary ( userinfo ) <- URI . parse ( dsn ) ,
215+ [ public_key , secret_key ] <- keys_from_userinfo ( userinfo ) ,
215216 [ _ , binary_project_id ] <- String . split ( path , "/" ) ,
216217 { project_id , "" } <- Integer . parse ( binary_project_id ) ,
217218 endpoint <- "#{ protocol } ://#{ host } :#{ port } /api/#{ project_id } /store/" do
@@ -304,6 +305,14 @@ defmodule Sentry.Client do
304305 end
305306 end
306307
308+ defp keys_from_userinfo ( userinfo ) do
309+ case String . split ( userinfo , ":" , parts: 2 ) do
310+ [ public , secret ] -> [ public , secret ]
311+ [ public ] -> [ public , nil ]
312+ _ -> :error
313+ end
314+ end
315+
307316 defp get_headers_and_endpoint do
308317 case get_dsn ( ) do
309318 { endpoint , public_key , secret_key } ->
0 commit comments