-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
83 additions
and
12 deletions.
There are no files selected for viewing
36 changes: 25 additions & 11 deletions
36
...dMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
package io.sentry.kotlin.multiplatform.extensions | ||
|
||
import io.sentry.android.core.SentryAndroidOptions | ||
import io.sentry.kotlin.multiplatform.JvmSentryReplayQuality | ||
import io.sentry.kotlin.multiplatform.SentryOptions | ||
import io.sentry.kotlin.multiplatform.SentryReplayOptions | ||
import kotlin.collections.forEach as kForEach | ||
|
||
internal fun SentryOptions.toAndroidSentryOptionsCallback(): (SentryAndroidOptions) -> Unit = { | ||
internal fun SentryOptions.toAndroidSentryOptionsCallback(): (SentryAndroidOptions) -> Unit = { androidOptions -> | ||
val kmpOptions = this | ||
|
||
// Apply base options available to all JVM targets | ||
it.applyJvmBaseOptions(this) | ||
androidOptions.applyJvmBaseOptions(kmpOptions) | ||
|
||
// Apply Android specific options | ||
it.isAttachScreenshot = this.attachScreenshot | ||
it.isAttachViewHierarchy = this.attachViewHierarchy | ||
it.isAnrEnabled = this.isAnrEnabled | ||
it.anrTimeoutIntervalMillis = this.anrTimeoutIntervalMillis | ||
androidOptions.isAttachScreenshot = kmpOptions.attachScreenshot | ||
androidOptions.isAttachViewHierarchy = kmpOptions.attachViewHierarchy | ||
androidOptions.isAnrEnabled = kmpOptions.isAnrEnabled | ||
androidOptions.anrTimeoutIntervalMillis = kmpOptions.anrTimeoutIntervalMillis | ||
|
||
// Replay options | ||
it.experimental.sessionReplay.redactAllText = this.experimental.sessionReplay.redactAllText | ||
it.experimental.sessionReplay.redactAllImages = this.experimental.sessionReplay.redactAllImages | ||
it.experimental.sessionReplay.sessionSampleRate = this.experimental.sessionReplay.sessionSampleRate?.toDouble() | ||
it.experimental.sessionReplay.errorSampleRate = this.experimental.sessionReplay.onErrorSampleRate?.toDouble() | ||
androidOptions.experimental.sessionReplay.redactAllText = kmpOptions.experimental.sessionReplay.redactAllText | ||
androidOptions.experimental.sessionReplay.redactAllImages = kmpOptions.experimental.sessionReplay.redactAllImages | ||
androidOptions.experimental.sessionReplay.sessionSampleRate = kmpOptions.experimental.sessionReplay.sessionSampleRate | ||
androidOptions.experimental.sessionReplay.errorSampleRate = kmpOptions.experimental.sessionReplay.onErrorSampleRate | ||
androidOptions.experimental.sessionReplay.quality = kmpOptions.experimental.sessionReplay.quality.toAndroidSentryQuality() | ||
|
||
// kForEach solves an issue with linter where it thinks forEach is the Java version | ||
// see here: https://stackoverflow.com/questions/44751469/kotlin-extension-functions-suddenly-require-api-level-24/68897591#68897591 | ||
this.sdk?.packages?.kForEach { sdkPackage -> | ||
it.sdkVersion?.addPackage(sdkPackage.name, sdkPackage.version) | ||
androidOptions.sdkVersion?.addPackage(sdkPackage.name, sdkPackage.version) | ||
} | ||
} | ||
|
||
internal fun SentryReplayOptions.Quality.toAndroidSentryQuality(): JvmSentryReplayQuality { | ||
val kmpQuality = this | ||
return when (kmpQuality) { | ||
SentryReplayOptions.Quality.LOW -> JvmSentryReplayQuality.LOW | ||
SentryReplayOptions.Quality.MEDIUM -> JvmSentryReplayQuality.MEDIUM | ||
SentryReplayOptions.Quality.HIGH -> JvmSentryReplayQuality.HIGH | ||
Check warning on line 40 in sentry-kotlin-multiplatform/src/androidMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.android.kt Codecov / codecov/patchsentry-kotlin-multiplatform/src/androidMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.android.kt#L40
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters