Compare commits

...

2 Commits

Author SHA1 Message Date
Shadowfacts 5ece9cd21c
Yet more Sentry 2021-09-22 19:54:45 -04:00
Shadowfacts 6916647737
Don't try to convert data URIs to data URIs 2021-09-22 19:46:07 -04:00
4 changed files with 37 additions and 10 deletions

View File

@ -23,6 +23,10 @@ defmodule Frenzy.Network do
@spec http_get(String.t()) :: Tesla.Env.result()
def http_get(url) do
if Frenzy.sentry_enabled?() do
Sentry.Context.add_breadcrumb(%{category: "http_get", message: url})
end
HTTP.get(url)
end
@ -77,6 +81,10 @@ defmodule Frenzy.Network do
@spec gemini_request(String.t() | URI.t()) :: {:ok, Gemini.Response.t()} | {:error, term()}
def gemini_request(uri) do
if Frenzy.sentry_enabled?() do
Sentry.Context.add_breadcrumb(%{category: "gemini_request", message: uri})
end
case Gemini.request(uri) do
{:ok, %Gemini.Response{status: code} = response} when code in @gemini_success_codes ->
{:ok, response}

View File

@ -152,6 +152,10 @@ defmodule Frenzy.Pipeline.ScrapeStage do
@content_type_allowlist ["image/jpeg", "image/png", "image/heic", "image/heif", "image/tiff"]
# convert images to data URIs so that they're stored by clients as part of the body
defp image_to_data_uri("data:" <> _ = src, _site_uri, _convert) do
src
end
defp image_to_data_uri(src, site_uri, true) do
absolute_url = URI.merge(site_uri, src) |> to_string()

View File

@ -47,6 +47,13 @@ defmodule Frenzy.Task.CreateItem do
feed.pipeline.stages
|> Enum.reduce({:ok, item_params}, fn
stage, {:ok, item_params} ->
if Frenzy.sentry_enabled?() do
Sentry.Context.add_breadcrumb(%{
category: "pipeline",
message: stage["module_name"]
})
end
apply(String.to_existing_atom("Elixir." <> stage["module_name"]), :apply, [
stage["options"],
item_params
@ -69,8 +76,12 @@ defmodule Frenzy.Task.CreateItem do
if Frenzy.sentry_enabled?() do
Sentry.capture_message(
"Error evaluating pipeline '#{feed.pipeline.name}': #{inspect(error)}",
extra: %{feed_id: feed.id, pipeline_id: feed.pipeline.id}
"Error evaluating pipeline: #{inspect(error)}",
extra: %{
feed_id: feed.id,
pipeline_id: feed.pipeline.id,
pipeline_name: feed.pipeline.name
}
)
end
@ -106,8 +117,12 @@ defmodule Frenzy.Task.CreateItem do
Logger.error(changeset.errors)
if Frenzy.sentry_enabled?() do
Sentry.capture_message("Error inserting item '#{item_params.guid}'",
extra: %{feed_id: feed.id, errors: changeset.errors}
Sentry.capture_message("Error inserting item: #{inspect(changeset.errors)}",
extra: %{
item_guid: item_params.guid,
feed_id: feed.id,
errors: changeset.errors
}
)
end
end

View File

@ -151,8 +151,8 @@ defmodule Frenzy.UpdateFeeds do
Logger.error("Couldn't load feed #{feed.feed_url}: #{inspect(reason)}")
if Frenzy.sentry_enabled?() do
Sentry.capture_message("Error loading HTTP feed '#{feed.feed_url}': #{inspect(reason)}",
extra: %{feed_id: feed.id}
Sentry.capture_message("Error loading HTTP feed: #{inspect(reason)}",
extra: %{feed_id: feed.id, feed_url: feed.feed_url}
)
end
end
@ -168,8 +168,8 @@ defmodule Frenzy.UpdateFeeds do
if Frenzy.sentry_enabled?() do
Sentry.capture_message(
"Error loading Gemini feed '#{feed.feed_url}': #{inspect(reason)}",
extra: %{feed_id: feed.id}
"Error loading Gemini feed: #{inspect(reason)}",
extra: %{feed_id: feed.id, feed_url: feed.feed_url}
)
end
end
@ -184,8 +184,8 @@ defmodule Frenzy.UpdateFeeds do
Logger.error("Unable to parse feed at '#{feed.feed_url}': #{inspect(reason)}")
if Frenzy.sentry_enabled?() do
Sentry.capture_message("Unable to parse feed '#{feed.feed_url}': #{inspect(reason)}",
extra: %{feed_id: feed.id}
Sentry.capture_message("Unable to parse feed: #{inspect(reason)}",
extra: %{feed_id: feed.id, feed_url: feed.feed_url}
)
end
end