diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 69154512d..96d76155b 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -32,7 +32,7 @@ object Dependencies { val scalafixScaluzzi = "com.github.vovapolu" %% "scaluzzi" % "0.1.17" val scalafixOrganizeImports = "com.github.liancheng" %% "organize-imports" % "0.4.4" val scalaTest = "org.scalatest" %% "scalatest" % "3.2.3" - val sentry = "io.sentry" % "sentry" % "3.2.1" + val sentry = "io.sentry" % "sentry" % "4.0.0" val silencer = "com.github.ghik" % "silencer-plugin" % Versions.silencer cross CrossVersion.full val silencerLib = "com.github.ghik" % "silencer-lib" % Versions.silencer % Provided cross CrossVersion.full val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.30" diff --git a/sentry/src/main/scala/com/avast/sst/sentry/SentryModule.scala b/sentry/src/main/scala/com/avast/sst/sentry/SentryModule.scala index 9fa6c112d..1e9bd473c 100644 --- a/sentry/src/main/scala/com/avast/sst/sentry/SentryModule.scala +++ b/sentry/src/main/scala/com/avast/sst/sentry/SentryModule.scala @@ -1,28 +1,28 @@ package com.avast.sst.sentry import cats.effect.{Resource, Sync} -import io.sentry.{SentryClient, SentryOptions} +import io.sentry.{Sentry, SentryOptions} import scala.reflect.ClassTag object SentryModule { /** Makes [[io.sentry.SentryClient]] initialized with the given config. */ - def make[F[_]: Sync](config: SentryConfig): Resource[F, SentryClient] = { + def make[F[_]: Sync](config: SentryConfig): Resource[F, Unit] = { Resource.make { Sync[F].delay { val dsnCustomizations = s"${config.stacktraceAppPackages.mkString("stacktrace.app.packages=", ",", "")}" val finalDsn = if (dsnCustomizations.nonEmpty) s"${config.dsn}?$dsnCustomizations" else config.dsn - val options = new SentryOptions() - options.setDsn(finalDsn) - config.release.foreach(options.setRelease) - config.environment.foreach(options.setEnvironment) - config.distribution.foreach(options.setDist) - config.serverName.foreach(options.setServerName) - new SentryClient(options, null) + Sentry.init((options: SentryOptions) => { + options.setDsn(finalDsn) + config.release.foreach(options.setRelease) + config.environment.foreach(options.setEnvironment) + config.distribution.foreach(options.setDist) + config.serverName.foreach(options.setServerName) + }) } - }(sentry => Sync[F].delay(sentry.close())) + }(_ => Sync[F].delay(Sentry.close())) } /** Makes [[io.sentry.SentryClient]] initialized with the given config and overrides the `release` property @@ -31,7 +31,7 @@ object SentryModule { * This format is recommended by Sentry ([[https://docs.sentry.io/workflow/releases]]) * because releases are global and must be differentiated. */ - def makeWithReleaseFromPackage[F[_]: Sync, Main: ClassTag](config: SentryConfig): Resource[F, SentryClient] = { + def makeWithReleaseFromPackage[F[_]: Sync, Main: ClassTag](config: SentryConfig): Resource[F, Unit] = { for { customizedConfig <- Resource.liftF { Sync[F].delay {