Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sentry to 4.0.0 #437

Merged
merged 2 commits into from
Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 11 additions & 11 deletions sentry/src/main/scala/com/avast/sst/sentry/SentryModule.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {
Expand Down