analytics/lib/plausible_web/views/email_view.ex
Adam Rutkowski ad12e1ef31
Show user feedback form on server errors (#2617)
* Move Endpoint errors setup to common config

* Implement naive Sentry link resolver

* Implement error report e-mail

* Delete static sentry script

* Implement user feedback form on server errors

* Re-arrange pipe

* Use Sentry.Config.dsn() where applicable

* Fix typo

* Use Map.replace/3
2023-01-25 15:15:41 +01:00

38 lines
823 B
Elixir

defmodule PlausibleWeb.EmailView do
use PlausibleWeb, :view
def plausible_url do
PlausibleWeb.Endpoint.url()
end
def base_domain() do
PlausibleWeb.Endpoint.host()
end
def greet_recipient(%{user: %{name: name}}) when is_binary(name) do
"Hey #{String.split(name) |> List.first()},"
end
def greet_recipient(_), do: "Hey,"
def date_format(date) do
Timex.format!(date, "{D} {Mshort} {YYYY}")
end
def sentry_link(trace_id, dsn \\ Sentry.Config.dsn()) do
search_query = URI.encode_query(%{query: trace_id})
path = "/organizations/sentry/issues/"
if is_binary(dsn) do
dsn
|> URI.parse()
|> Map.replace(:userinfo, nil)
|> Map.replace(:path, path)
|> Map.replace(:query, search_query)
|> URI.to_string()
else
""
end
end
end