1.2 KiB · text History bcd6ae2
# Sends an error, a message and a cron check-in with the real sentry-elixir
# (from SENTRY_ELIXIR_PATH, the reference checkout) to SENTRY_DSN, waiting
# for each answer (`result: :sync`), and prints what the SDK got back. Run
# by VigilWeb.SdkConformanceTest; the install is cached by Mix after the
# first run. The DSN comes from the environment, not Mix.install's config,
# so a new DSN doesn't mean a new install.
Mix.install([
  {:sentry, path: System.fetch_env!("SENTRY_ELIXIR_PATH")},
  {:jason, "~> 1.4"},
  {:finch, "~> 0.21"}
])

Application.put_env(:sentry, :dsn, System.fetch_env!("SENTRY_DSN"))
Application.put_env(:sentry, :environment_name, "test")
Application.put_env(:sentry, :release, "vigil-test@1.0")

report = fn label, result -> IO.puts("#{label}: #{inspect(result)}") end

exception =
  try do
    raise ArgumentError, "boom from elixir"
  rescue
    e -> e
  end

report.("exception", Sentry.capture_exception(exception, result: :sync))
report.("message", Sentry.capture_message("hello from elixir", result: :sync))

report.(
  "check_in",
  Sentry.capture_check_in(
    status: :ok,
    monitor_slug: "vigil-nightly",
    monitor_config: [schedule: [type: :crontab, value: "0 3 * * *"]]
  )
)