Skip to content

Commit 071b747

Browse files
authored
Replace rollbax with sentry (#50)
1 parent 6485b9d commit 071b747

File tree

10 files changed

+32
-76
lines changed

10 files changed

+32
-76
lines changed

Diff for: Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM hexpm/elixir:1.17.3-erlang-27.1.2-alpine-3.20.3 as build
1+
FROM hexpm/elixir:1.17.3-erlang-27.1.2-alpine-3.20.3 AS build
22

33
# install build dependencies
44
RUN apk add --no-cache --update git
@@ -27,7 +27,7 @@ RUN mix compile
2727

2828
# build release
2929
COPY rel rel
30-
RUN mix release
30+
RUN mix do sentry.package_source_code, release
3131

3232
# prepare release image
3333
FROM alpine:3.20.3 AS app

Diff for: config/config.exs

-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ config :hexdocs, :docs_private_bucket, name: "hexdocs-private-staging"
3737

3838
config :hexdocs, :docs_public_bucket, name: "hexdocs-public-staging"
3939

40-
config :rollbax, enabled: false
41-
4240
config :logger, :console, format: "[$level] $metadata$message\n"
4341

4442
import_config "#{Mix.env()}.exs"

Diff for: config/prod.exs

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ config :hexdocs, :docs_public_bucket, implementation: Hexdocs.Store.GS
1717
config :ex_aws,
1818
json_codec: Jason
1919

20-
config :rollbax,
21-
environment: "prod",
22-
enabled: true,
23-
enable_crash_reports: true
20+
config :sentry,
21+
enable_source_code_context: true,
22+
root_source_code_paths: [File.cwd!()]
2423

2524
config :sasl, sasl_error_logger: false
2625

Diff for: config/runtime.exs

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ if config_env() == :prod do
2727
access_key_id: System.fetch_env!("HEXDOCS_AWS_ACCESS_KEY_ID"),
2828
secret_access_key: System.fetch_env!("HEXDOCS_AWS_ACCESS_KEY_SECRET")
2929

30-
config :rollbax,
31-
access_token: System.fetch_env!("HEXDOCS_ROLLBAR_ACCESS_TOKEN")
30+
config :sentry,
31+
dsn: System.fetch_env!("HEXDOCS_SENTRY_DSN"),
32+
environment_name: System.fetch_env!("HEXDOCS_ENV")
3233

3334
config :kernel,
3435
inet_dist_listen_min: String.to_integer(System.fetch_env!("BEAM_PORT")),

Diff for: lib/hexdocs/application.ex

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ defmodule Hexdocs.Application do
55

66
def start(_type, _args) do
77
setup_tmp_dir()
8+
:logger.add_handler(:sentry_handler, Sentry.LoggerHandler, %{})
89

910
port = String.to_integer(Application.get_env(:hexdocs, :port))
1011
cowboy_options = [port: port]

Diff for: lib/hexdocs/plug.ex

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
defmodule Hexdocs.Plug do
22
use Plug.Builder
33
use Plug.ErrorHandler
4-
use Hexdocs.Plug.Rollbax
54
require Logger
65

76
@key_html_fresh_time 60
87
@key_asset_fresh_time 120
98
@key_lifetime 60 * 60 * 24 * 29
109

10+
use Sentry.PlugCapture
11+
1112
if Mix.env() == :dev do
1213
use Plug.Debugger, otp_app: :my_app
1314
end
@@ -28,6 +29,8 @@ defmodule Hexdocs.Plug do
2829
plug(Logster.Plugs.Logger, excludes: [:params])
2930
end
3031

32+
plug(Sentry.PlugContext)
33+
3134
plug(Plug.Head)
3235

3336
if Mix.env() == :prod do

Diff for: lib/hexdocs/plug/rollbax.ex

-42
This file was deleted.

Diff for: mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ defmodule Hexdocs.MixProject do
3131
{:jason, "~> 1.1"},
3232
{:logster, "~> 1.0"},
3333
{:plug_cowboy, "~> 2.0"},
34-
{:rollbax, "~> 0.11.0"},
34+
{:sentry, "~> 10.0"},
3535
{:ssl_verify_fun, "~> 1.1", manager: :rebar3, override: true},
3636
{:sweet_xml, "~> 0.7.0"},
3737
{:hex_core, "~> 0.9.0", only: [:dev, :test]},

Diff for: mix.lock

+16-20
Large diffs are not rendered by default.

Diff for: test/hexdocs/plug_test.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ defmodule Hexdocs.PlugTest do
1919
end
2020

2121
test "handle no path" do
22-
conn = conn(:get, "http://plugtest.localhost:5002") |> call()
22+
conn = conn(:get, "http://plugtest.localhost:5002/") |> call()
2323
assert conn.status == 302
2424

2525
assert get_resp_header(conn, "location") ==
26-
["http://localhost:5000/login?hexdocs=plugtest&return="]
26+
["http://localhost:5000/login?hexdocs=plugtest&return=/"]
2727
end
2828

2929
test "update session and redirect when key is set" do

0 commit comments

Comments
 (0)