Skip to content

Commit

Permalink
Add a JSON wrapper for Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
joshk committed Dec 20, 2024
1 parent 4c38283 commit 22b097e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ config :sentry,
cron: [enabled: true]
]
],
json_library: JSON
json_library: NervesHub.SentryJsonWrapper

config :opentelemetry, :resource, service: %{name: nerves_hub_app}

Expand Down
15 changes: 15 additions & 0 deletions lib/nerves_hub/sentry_json_wrapper.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
defmodule NervesHub.SentryJsonWrapper do
# Sentry tries to validate the JSON library configured, but the builtin
# JSON library doesn't define `encode`, only `encode!`.
# This little wrapper fixes that, until Sentry is updated to support `encode!`, or
# `JSON` supports `encode`.
# https://github.com/getsentry/sentry-elixir/blob/master/lib/sentry/config.ex#L696-L714

def encode(data) do
JSON.encode!(data)
end

def decode(data) do
JSON.decode!(data)
end
end

0 comments on commit 22b097e

Please sign in to comment.