diff --git a/config/runtime.exs b/config/runtime.exs index 27edf6cea6..b085b3b5b1 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -107,13 +107,6 @@ config :lightning, System.get_env("INIT_PROJECT_FOR_NEW_USER", "false") |> String.to_atom() -# If you've booted up with a SENTRY_DSN environment variable, use Sentry! -config :sentry, - filter: Lightning.SentryEventFilter, - environment_name: config_env(), - included_environments: - if(System.get_env("SENTRY_DSN"), do: [config_env()], else: []) - # To actually send emails you need to configure the mailer to use a real # adapter. You may configure the swoosh api client of your choice. We # automatically configure Mailgun if an API key has been provided. See @@ -248,3 +241,27 @@ if config_env() == :test do config :lightning, Lightning.Repo, pool_size: :erlang.system_info(:schedulers_online) + 4 end + +release = + case Application.get_env(:lightning, :image_info) do + [image_tag: image_tag, branch: _branch, commit: commit] -> + if Enum.member?(["edge", "latest"], image_tag), + do: commit, + else: image_tag + + _other -> + "mix-v#{elem(:application.get_key(:lightning, :vsn), 1)}" + end + +config :sentry, + filter: Lightning.SentryEventFilter, + environment_name: config_env(), + tags: %{ + host: Application.get_env(:lightning, LightningWeb.Endpoint)[:url][:host] + }, + # If you've booted up with a SENTRY_DSN environment variable, use Sentry! + included_environments: + if(System.get_env("SENTRY_DSN"), do: [config_env()], else: []), + release: release, + enable_source_code_context: true, + root_source_code_path: File.cwd!() diff --git a/lib/lightning_web/live/components/common.ex b/lib/lightning_web/live/components/common.ex index efd8306ed5..291c10974f 100644 --- a/lib/lightning_web/live/components/common.ex +++ b/lib/lightning_web/live/components/common.ex @@ -25,10 +25,16 @@ defmodule LightningWeb.Components.Common do "Docker image tag found: '#{image}' tagged release build from #{commit}", :release} - # If running in docker and tag doesn't match :vsn, display :vsn and warning. + # If running in docker and tag doesn't match :vsn, display image tag. + image != nil and image != vsn and image != "edge" -> + {image, + "Detected image tag that does not match application version #{vsn}; image tag '#{image}' built from #{commit}", + :warn} + + # If running in docker and tag doesn't match :vsn, display commit. image != nil and image != vsn -> {commit, - "Warning: detected image tag that does not match application version #{vsn}; image tag '#{image}' built from #{commit}", + "Detected image tag that does not match application version #{vsn}; image tag '#{image}' built from #{commit}", :warn} true -> diff --git a/test/lightning_web/live/components/common_test.exs b/test/lightning_web/live/components/common_test.exs index fbe9cda3dc..623ef03891 100644 --- a/test/lightning_web/live/components/common_test.exs +++ b/test/lightning_web/live/components/common_test.exs @@ -82,7 +82,7 @@ defmodule LightningWeb.Components.CommonTest do "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" assert html =~ - "Warning: detected image tag that does not match application version" + "Detected image tag that does not match application version" assert html =~ "v#{elem(:application.get_key(:lightning, :vsn), 1)}" end