Skip to content

Commit 553eda6

Browse files
Merge pull request #246 from getsentry/1.6.0
use Elixir 1.6.0 and formatter [WIP]
2 parents b234f21 + 46a3ac8 commit 553eda6

32 files changed

+1284
-678
lines changed

.formatter.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
inputs: [
3+
"lib/**/*.ex",
4+
"config/*.exs",
5+
"test/**/*.exs",
6+
"mix.exs"
7+
]
8+
]

.travis.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,32 @@ elixir:
33
- 1.3.4
44
- 1.4
55
- 1.5
6-
- 1.6.0-rc.0
6+
- 1.6.0
77
otp_release:
88
- 18.3
99
- 19.3
1010
- 20.0
11-
11+
env:
12+
- MIX_FORMAT=true
13+
- MIX_FORMAT=false
1214
matrix:
13-
allow_failures:
15+
exclude:
16+
- elixir: 1.6.0
17+
env: MIX_FORMAT=false
1418
- elixir: 1.3.4
15-
- elixir: 1.6.0-rc.0
16-
19+
env: MIX_FORMAT=true
20+
- elixir: 1.4
21+
env: MIX_FORMAT=true
22+
- elixir: 1.5
23+
env: MIX_FORMAT=true
24+
- elixir: 1.6.0
25+
otp_release: 18.3
26+
- elixir: 1.3.4
27+
otp_release: 20.0
1728
notifications:
1829
email:
1930
2031
script:
2132
- mix test
2233
- mix credo
34+
- if [ "$MIX_FORMAT" = "true" ]; then mix format --dry-run --check-formatted; fi

config/config.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ config :sentry,
77
enable_source_code_context: true,
88
root_source_code_path: File.cwd!()
99

10-
import_config "#{Mix.env}.exs"
10+
import_config "#{Mix.env()}.exs"

config/dev.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
use Mix.Config
22

3-
config :sentry,
4-
environment_name: :dev
3+
config :sentry, environment_name: :dev

config/prod.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
use Mix.Config
22

3-
config :sentry,
4-
environment_name: :prod
3+
config :sentry, environment_name: :prod

lib/mix/tasks/sentry.send_test_event.ex

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,31 @@ defmodule Mix.Tasks.Sentry.SendTestEvent do
1414

1515
Application.ensure_all_started(:sentry)
1616

17-
Sentry.Client.get_dsn!
17+
Sentry.Client.get_dsn!()
1818
|> print_environment_info()
1919

20-
2120
maybe_send_event()
2221
end
2322

2423
defp print_environment_info({endpoint, public_key, secret_key}) do
25-
Mix.shell.info "Client configuration:"
26-
Mix.shell.info "server: #{endpoint}"
27-
Mix.shell.info "public_key: #{public_key}"
28-
Mix.shell.info "secret_key: #{secret_key}"
29-
Mix.shell.info "included_environments: #{inspect included_environments()}"
30-
Mix.shell.info "current environment_name: #{inspect Config.environment_name()}"
31-
Mix.shell.info "hackney_opts: #{inspect Config.hackney_opts()}\n"
24+
Mix.shell().info("Client configuration:")
25+
Mix.shell().info("server: #{endpoint}")
26+
Mix.shell().info("public_key: #{public_key}")
27+
Mix.shell().info("secret_key: #{secret_key}")
28+
Mix.shell().info("included_environments: #{inspect(included_environments())}")
29+
Mix.shell().info("current environment_name: #{inspect(Config.environment_name())}")
30+
Mix.shell().info("hackney_opts: #{inspect(Config.hackney_opts())}\n")
3231
end
3332

3433
defp included_environments do
3534
case Application.fetch_env(:sentry, :included_environments) do
36-
{:ok, envs} when is_list(envs) -> envs
35+
{:ok, envs} when is_list(envs) ->
36+
envs
37+
3738
_ ->
38-
Mix.raise "Sentry included_environments is not configured in :sentry, :included_environments"
39+
Mix.raise(
40+
"Sentry included_environments is not configured in :sentry, :included_environments"
41+
)
3942
end
4043
end
4144

@@ -44,23 +47,27 @@ defmodule Mix.Tasks.Sentry.SendTestEvent do
4447
included_envs = included_environments()
4548

4649
if env_name in included_envs do
47-
Mix.shell.info "Sending test event..."
50+
Mix.shell().info("Sending test event...")
4851

49-
result = "Testing sending Sentry event"
50-
|> RuntimeError.exception
51-
|> Sentry.capture_exception(result: :sync)
52+
result =
53+
"Testing sending Sentry event"
54+
|> RuntimeError.exception()
55+
|> Sentry.capture_exception(result: :sync)
5256

5357
case result do
5458
{:ok, id} ->
55-
Mix.shell.info "Test event sent! Event ID: #{id}"
59+
Mix.shell().info("Test event sent! Event ID: #{id}")
60+
5661
:error ->
57-
Mix.shell.info "Error sending event!"
62+
Mix.shell().info("Error sending event!")
63+
5864
:excluded ->
59-
Mix.shell.info "No test event was sent because the event was excluded by a filter"
65+
Mix.shell().info("No test event was sent because the event was excluded by a filter")
6066
end
61-
6267
else
63-
Mix.shell.info "#{inspect env_name} is not in #{inspect included_envs} so no test event will be sent"
68+
Mix.shell().info(
69+
"#{inspect(env_name)} is not in #{inspect(included_envs)} so no test event will be sent"
70+
)
6471
end
6572
end
6673
end

lib/sentry.ex

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,18 @@ defmodule Sentry do
9191
See `Sentry.Logger`
9292
"""
9393

94-
@type task :: {:ok, Task.t} | :error | :excluded | :ignored
94+
@type task :: {:ok, Task.t()} | :error | :excluded | :ignored
9595

9696
def start(_type, _opts) do
9797
children = [
9898
supervisor(Task.Supervisor, [[name: Sentry.TaskSupervisor]]),
99-
:hackney_pool.child_spec(Sentry.Client.hackney_pool_name(), [timeout: Config.hackney_timeout(), max_connections: Config.max_hackney_connections()])
99+
:hackney_pool.child_spec(
100+
Sentry.Client.hackney_pool_name(),
101+
timeout: Config.hackney_timeout(),
102+
max_connections: Config.max_hackney_connections()
103+
)
100104
]
105+
101106
opts = [strategy: :one_for_one, name: Sentry.Supervisor]
102107

103108
Supervisor.start_link(children, opts)
@@ -107,7 +112,7 @@ defmodule Sentry do
107112
Parses and submits an exception to Sentry if current environment is in included_environments.
108113
`opts` argument is passed as the second argument to `Sentry.send_event/2`.
109114
"""
110-
@spec capture_exception(Exception.t, Keyword.t) :: task
115+
@spec capture_exception(Exception.t(), Keyword.t()) :: task
111116
def capture_exception(exception, opts \\ []) do
112117
filter_module = Config.filter()
113118
{source, opts} = Keyword.pop(opts, :event_source)
@@ -126,7 +131,7 @@ defmodule Sentry do
126131
127132
`opts` argument is passed as the second argument to `Sentry.send_event/2`.
128133
"""
129-
@spec capture_message(String.t, Keyword.t) :: task
134+
@spec capture_message(String.t(), Keyword.t()) :: task
130135
def capture_message(message, opts \\ []) do
131136
opts
132137
|> Keyword.put(:message, message)
@@ -139,13 +144,15 @@ defmodule Sentry do
139144
140145
`opts` argument is passed as the second argument to `send_event/2` of the configured `Sentry.HTTPClient`. See `Sentry.Client.send_event/2` for more information.
141146
"""
142-
@spec send_event(Event.t, Keyword.t) :: task
147+
@spec send_event(Event.t(), Keyword.t()) :: task
143148
def send_event(event, opts \\ [])
149+
144150
def send_event(%Event{message: nil, exception: nil}, _opts) do
145151
Logger.warn("Sentry: unable to parse exception")
146152

147153
:ignored
148154
end
155+
149156
def send_event(%Event{} = event, opts) do
150157
included_environments = Config.included_environments()
151158
environment_name = Config.environment_name()

0 commit comments

Comments
 (0)