From 70230c931f44d93877f3767ce6ac2972c93534f7 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 20 Feb 2024 02:46:44 +0100 Subject: [PATCH 1/8] add options --- ....kt => SentryOptionsExtensions.android.kt} | 2 + .../SentryOptionsExtensions.apple.kt | 2 + .../kotlin/multiplatform/SentryOptions.kt | 48 +++++++++++++++++++ 3 files changed, 52 insertions(+) rename sentry-kotlin-multiplatform/src/androidMain/kotlin/io/sentry/kotlin/multiplatform/extensions/{SentryAndroidOptionsExtensions.kt => SentryOptionsExtensions.android.kt} (92%) diff --git a/sentry-kotlin-multiplatform/src/androidMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryAndroidOptionsExtensions.kt b/sentry-kotlin-multiplatform/src/androidMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.android.kt similarity index 92% rename from sentry-kotlin-multiplatform/src/androidMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryAndroidOptionsExtensions.kt rename to sentry-kotlin-multiplatform/src/androidMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.android.kt index 3837a666..3688bc3b 100644 --- a/sentry-kotlin-multiplatform/src/androidMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryAndroidOptionsExtensions.kt +++ b/sentry-kotlin-multiplatform/src/androidMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.android.kt @@ -12,6 +12,8 @@ internal fun SentryOptions.toAndroidSentryOptionsCallback(): (SentryAndroidOptio // Apply Android specific options it.isAttachScreenshot = this.attachScreenshot it.isAttachViewHierarchy = this.attachViewHierarchy + it.isAnrEnabled = this.isAnrEnabled + it.anrTimeoutIntervalMillis = this.anrTimeoutIntervalMillis it.sdkVersion?.name = this.sdk?.name ?: BuildKonfig.SENTRY_KMP_ANDROID_SDK_NAME it.sdkVersion?.version = this.sdk?.version ?: BuildKonfig.VERSION_NAME diff --git a/sentry-kotlin-multiplatform/src/appleMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.apple.kt b/sentry-kotlin-multiplatform/src/appleMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.apple.kt index 34063c1a..f5e5237f 100644 --- a/sentry-kotlin-multiplatform/src/appleMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.apple.kt +++ b/sentry-kotlin-multiplatform/src/appleMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.apple.kt @@ -33,6 +33,8 @@ internal fun CocoaSentryOptions.applyCocoaBaseOptions(options: SentryOptions) { enableAutoSessionTracking = options.enableAutoSessionTracking maxAttachmentSize = options.maxAttachmentSize.convert() maxBreadcrumbs = options.maxBreadcrumbs.convert() + enableAppHangTracking = options.enableAppHangTracking + appHangTimeoutInterval = options.appHangTimeoutIntervalMillis.convert() options.sampleRate?.let { sampleRate = NSNumber(double = it) } diff --git a/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt b/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt index b8cbb8eb..59b24a5c 100644 --- a/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt +++ b/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt @@ -120,4 +120,52 @@ public open class SentryOptions { * transactions will be sent. Transactions are picked randomly. Default is null (disabled) */ public var tracesSampleRate: Double? = null + + /** + * Controls the tracking of App Hangs capturing moments when the application becomes unresponsive for a set duration. + * + * **Default**: Enabled. + * + * **Platform Availability**: Cocoa. + * + * For more information, refer to the Cocoa documentation on App Hangs: + * [Cocoa App Hangs](https://docs.sentry.io/platforms/apple/configuration/app-hangs/) + */ + public var enableAppHangTracking: Boolean = true + + /** + * Defines the timeout interval in milliseconds for detecting App Hangs. + * + * **Default**: 2000 milliseconds (2 seconds). + * + * **Platform Availability**: Cocoa. + * + * For configuration details and best practices, see: + * [Cocoa App Hangs](https://docs.sentry.io/platforms/apple/configuration/app-hangs/) + */ + public var appHangTimeoutIntervalMillis: Long = 2000 + + /** + * Enables or disables ANR (Application Not Responding) tracking. + * + * **Default**: Enabled. + * + * **Platform Availability**: Android. + * + * Detailed documentation on ANR tracking can be found here: + * [Android ANR](https://docs.sentry.io/platforms/android/configuration/app-not-respond/) + */ + public var isAnrEnabled: Boolean = true + + /** + * Sets the timeout interval in milliseconds for considering an application as not responding (ANR). + * + * **Default**: 5000 milliseconds (5 seconds). + * + * **Platform Availability**: Android. + * + * For more information on configuring ANR detection, visit: + * [Android ANR](https://docs.sentry.io/platforms/android/configuration/app-not-respond/) + */ + public var anrTimeoutIntervalMillis: Long = 5000 } From 71733444259236ab6e6b2e6335b2a35ba3425c28 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 20 Feb 2024 02:48:46 +0100 Subject: [PATCH 2/8] Add test --- .../kotlin/multiplatform/SentryOptions.kt | 6 ++-- .../kotlin/multiplatform/SentryOptionsTest.kt | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt b/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt index 59b24a5c..c395abeb 100644 --- a/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt +++ b/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt @@ -3,9 +3,9 @@ package io.sentry.kotlin.multiplatform import io.sentry.kotlin.multiplatform.protocol.Breadcrumb import io.sentry.kotlin.multiplatform.protocol.SdkVersion -private const val DEFAULT_MAX_BREADCRUMBS = 100 -private const val DEFAULT_MAX_ATTACHMENT_SIZE = 20 * 1024 * 1024L -private const val DEFAULT_SESSION_INTERVAL_MILLIS = 30000L +internal const val DEFAULT_MAX_BREADCRUMBS = 100 +internal const val DEFAULT_MAX_ATTACHMENT_SIZE = 20 * 1024 * 1024L +internal const val DEFAULT_SESSION_INTERVAL_MILLIS = 30000L /** Sentry options that can be used to configure the SDK. */ public open class SentryOptions { diff --git a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt index 29f95bab..2bfae759 100644 --- a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt +++ b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt @@ -4,6 +4,9 @@ import io.sentry.kotlin.multiplatform.protocol.Breadcrumb import io.sentry.kotlin.multiplatform.utils.fakeDsn import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNull +import kotlin.test.assertTrue class SentryOptionsTest : BaseSentryTest() { @Test @@ -93,4 +96,35 @@ class SentryOptionsTest : BaseSentryTest() { assertEquals(null, modifiedBreadcrumb) } + + @Test + fun `GIVEN SentryOptions THEN default values are set`() { + val options = SentryOptions() + + assertNull(options.dsn, "DSN should be null by default.") + assertTrue(options.attachStackTrace, "attachStackTrace should be true by default.") + assertTrue(options.attachThreads, "attachThreads should be true by default.") + assertNull(options.release, "Release should be null by default.") + assertFalse(options.debug, "Debug should be false by default.") + assertNull(options.environment, "Environment should be null by default.") + assertNull(options.dist, "Dist should be null by default.") + assertTrue(options.enableAutoSessionTracking, "enableAutoSessionTracking should be true by default.") + assertEquals(DEFAULT_SESSION_INTERVAL_MILLIS, options.sessionTrackingIntervalMillis, "sessionTrackingIntervalMillis should match the default value.") + assertFalse(options.attachScreenshot, "attachScreenshot should be false by default.") + assertNull(options.beforeBreadcrumb, "beforeBreadcrumb should be null by default.") + assertNull(options.beforeSend, "beforeSend should be null by default.") + assertNull(options.sdk, "SDK version should be null by default.") + assertEquals(DEFAULT_MAX_BREADCRUMBS, options.maxBreadcrumbs, "maxBreadcrumbs should match the default value.") + assertEquals(DEFAULT_MAX_ATTACHMENT_SIZE, options.maxAttachmentSize, "maxAttachmentSize should match the default value.") + assertFalse(options.attachViewHierarchy, "attachViewHierarchy should be false by default.") + assertTrue(options.enableCaptureFailedRequests, "enableCaptureFailedRequests should be true by default.") + assertEquals(listOf(HttpStatusCodeRange()), options.failedRequestStatusCodes, "failedRequestStatusCodes should contain the default range.") + assertEquals(listOf(".*"), options.failedRequestTargets, "failedRequestTargets should contain the default regex for all targets.") + assertNull(options.sampleRate, "sampleRate should be null by default.") + assertNull(options.tracesSampleRate, "tracesSampleRate should be null by default.") + assertTrue(options.enableAppHangTracking, "enableAppHangTracking should be true by default.") + assertEquals(2000L, options.appHangTimeoutIntervalMillis, "appHangTimeoutIntervalMillis should be 2000 milliseconds by default.") + assertTrue(options.isAnrEnabled, "anrEnabled should be true by default.") + assertEquals(5000L, options.anrTimeoutIntervalMillis, "anrTimeoutIntervalMillis should be 5000 milliseconds by default.") + } } From b346f6f47b9cde21e6456bfd513820a019902027 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 20 Feb 2024 03:24:32 +0100 Subject: [PATCH 3/8] add test --- sentry-kotlin-multiplatform/build.gradle.kts | 8 ++ .../sentry_kotlin_multiplatform.podspec | 2 +- .../multiplatform/PlatformOptions.android.kt | 77 +++++++++++++++++++ .../SentryOptionsExtensions.apple.kt | 2 +- .../kotlin/multiplatform/PlatformOptions.kt | 22 ++++++ .../kotlin/multiplatform/SentryOptionsTest.kt | 44 +++++++++++ .../PlatformOptions.tvwatchmacos.kt | 56 ++++++++++++++ .../multiplatform/PlatformOptions.ios.kt | 75 ++++++++++++++++++ .../multiplatform/PlatformOptions.jvm.kt | 53 +++++++++++++ 9 files changed, 337 insertions(+), 2 deletions(-) create mode 100644 sentry-kotlin-multiplatform/src/androidUnitTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.android.kt create mode 100644 sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.kt create mode 100644 sentry-kotlin-multiplatform/src/commonTvWatchMacOsTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.tvwatchmacos.kt create mode 100644 sentry-kotlin-multiplatform/src/iosTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.ios.kt create mode 100644 sentry-kotlin-multiplatform/src/jvmTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.jvm.kt diff --git a/sentry-kotlin-multiplatform/build.gradle.kts b/sentry-kotlin-multiplatform/build.gradle.kts index e939e81f..44b00254 100644 --- a/sentry-kotlin-multiplatform/build.gradle.kts +++ b/sentry-kotlin-multiplatform/build.gradle.kts @@ -122,6 +122,14 @@ kotlin { macosMain.get().dependsOn(commonTvWatchMacOsMain) watchosMain.get().dependsOn(commonTvWatchMacOsMain) + val commonTvWatchMacOsTest by creating { + dependsOn(appleTest.get()) + } + + tvosTest.get().dependsOn(commonTvWatchMacOsTest) + macosTest.get().dependsOn(commonTvWatchMacOsTest) + watchosTest.get().dependsOn(commonTvWatchMacOsTest) + cocoapods { summary = "Official Sentry SDK Kotlin Multiplatform" homepage = "https://github.com/getsentry/sentry-kotlin-multiplatform" diff --git a/sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec b/sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec index d54b654e..fd365097 100644 --- a/sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec +++ b/sentry-kotlin-multiplatform/sentry_kotlin_multiplatform.podspec @@ -50,4 +50,4 @@ Pod::Spec.new do |spec| } ] -end +end \ No newline at end of file diff --git a/sentry-kotlin-multiplatform/src/androidUnitTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.android.kt b/sentry-kotlin-multiplatform/src/androidUnitTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.android.kt new file mode 100644 index 00000000..fffc5635 --- /dev/null +++ b/sentry-kotlin-multiplatform/src/androidUnitTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.android.kt @@ -0,0 +1,77 @@ +package io.sentry.kotlin.multiplatform + +import io.sentry.android.core.SentryAndroidOptions +import io.sentry.kotlin.multiplatform.extensions.toAndroidSentryOptionsCallback +import kotlin.test.assertEquals + +actual interface PlatformOptions : CommonPlatformOptions { + val isAnrEnabled: Boolean + val anrTimeoutIntervalMillis: Long + val attachScreenshot: Boolean + val attachViewHierarchy: Boolean +} + +class SentryAndroidOptionsWrapper(private val androidOptions: SentryAndroidOptions) : + PlatformOptions { + override val dsn: String? + get() = androidOptions.dsn + + override val attachStackTrace: Boolean + get() = androidOptions.isAttachStacktrace + + override val release: String? + get() = androidOptions.release + + override val debug: Boolean + get() = androidOptions.isDebug + + override val environment: String? + get() = androidOptions.environment + + override val dist: String? + get() = androidOptions.dist + + override val enableAutoSessionTracking: Boolean + get() = androidOptions.isEnableAutoSessionTracking + + override val sessionTrackingIntervalMillis: Long + get() = androidOptions.sessionTrackingIntervalMillis + + override val maxBreadcrumbs: Int + get() = androidOptions.maxBreadcrumbs + + override val maxAttachmentSize: Long + get() = androidOptions.maxAttachmentSize + + override val sampleRate: Double? + get() = androidOptions.sampleRate + + override val tracesSampleRate: Double? + get() = androidOptions.tracesSampleRate + + override val isAnrEnabled: Boolean + get() = androidOptions.isAnrEnabled + + override val anrTimeoutIntervalMillis: Long + get() = androidOptions.anrTimeoutIntervalMillis + + override val attachScreenshot: Boolean + get() = androidOptions.isAttachScreenshot + + override val attachViewHierarchy: Boolean + get() = androidOptions.isAttachViewHierarchy + + override fun applyFromOptions(options: SentryOptions) { + options.toAndroidSentryOptionsCallback().invoke(androidOptions) + } +} + +actual fun createPlatformOptions(): PlatformOptions = + SentryAndroidOptionsWrapper(SentryAndroidOptions()) + +actual fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) { + assertEquals(attachScreenshot, options.attachScreenshot) + assertEquals(attachViewHierarchy, options.attachViewHierarchy) + assertEquals(isAnrEnabled, options.isAnrEnabled) + assertEquals(anrTimeoutIntervalMillis, options.anrTimeoutIntervalMillis) +} \ No newline at end of file diff --git a/sentry-kotlin-multiplatform/src/appleMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.apple.kt b/sentry-kotlin-multiplatform/src/appleMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.apple.kt index f5e5237f..419c429b 100644 --- a/sentry-kotlin-multiplatform/src/appleMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.apple.kt +++ b/sentry-kotlin-multiplatform/src/appleMain/kotlin/io/sentry/kotlin/multiplatform/extensions/SentryOptionsExtensions.apple.kt @@ -34,7 +34,7 @@ internal fun CocoaSentryOptions.applyCocoaBaseOptions(options: SentryOptions) { maxAttachmentSize = options.maxAttachmentSize.convert() maxBreadcrumbs = options.maxBreadcrumbs.convert() enableAppHangTracking = options.enableAppHangTracking - appHangTimeoutInterval = options.appHangTimeoutIntervalMillis.convert() + appHangTimeoutInterval = options.appHangTimeoutIntervalMillis.toDouble() options.sampleRate?.let { sampleRate = NSNumber(double = it) } diff --git a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.kt b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.kt new file mode 100644 index 00000000..dd0663c7 --- /dev/null +++ b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.kt @@ -0,0 +1,22 @@ +package io.sentry.kotlin.multiplatform + +interface CommonPlatformOptions { + val dsn: String? + val attachStackTrace: Boolean + val release: String? + val debug: Boolean + val environment: String? + val dist: String? + val enableAutoSessionTracking: Boolean + val sessionTrackingIntervalMillis: Long + val maxBreadcrumbs: Int + val maxAttachmentSize: Long + val sampleRate: Double? + val tracesSampleRate: Double? + + fun applyFromOptions(options: SentryOptions) +} + +expect interface PlatformOptions : CommonPlatformOptions + +expect fun createPlatformOptions(): PlatformOptions \ No newline at end of file diff --git a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt index 2bfae759..1b61ccf0 100644 --- a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt +++ b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt @@ -127,4 +127,48 @@ class SentryOptionsTest : BaseSentryTest() { assertTrue(options.isAnrEnabled, "anrEnabled should be true by default.") assertEquals(5000L, options.anrTimeoutIntervalMillis, "anrTimeoutIntervalMillis should be 5000 milliseconds by default.") } + + @Test + fun `GIVEN SentryOptions WHEN applyFromOptions THEN applies values to native options`() { + val options = SentryOptions().apply { + dsn = fakeDsn + attachStackTrace = false + release = "release" + debug = true + environment = "environment" + dist = "dist" + enableAutoSessionTracking = false + sessionTrackingIntervalMillis = 1000L + maxBreadcrumbs = 10 + maxAttachmentSize = 100L + sampleRate = 0.5 + tracesSampleRate = 0.5 + attachScreenshot = true + attachViewHierarchy = true + enableAppHangTracking = false + appHangTimeoutIntervalMillis = 1000L + isAnrEnabled = false + anrTimeoutIntervalMillis = 1000L + } + + val platformOptions = createPlatformOptions() + platformOptions.applyFromOptions(options) + + assertEquals(fakeDsn, platformOptions.dsn) + assertFalse(platformOptions.attachStackTrace) + assertEquals("release", platformOptions.release) + assertTrue(platformOptions.debug) + assertEquals("environment", platformOptions.environment) + assertEquals("dist", platformOptions.dist) + assertFalse(platformOptions.enableAutoSessionTracking) + assertEquals(1000L, platformOptions.sessionTrackingIntervalMillis) + assertEquals(10, platformOptions.maxBreadcrumbs) + assertEquals(100L, platformOptions.maxAttachmentSize) + assertEquals(0.5, platformOptions.sampleRate) + assertEquals(0.5, platformOptions.tracesSampleRate) + + platformOptions.assertPlatformSpecificOptions(options) + } } + +expect fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) \ No newline at end of file diff --git a/sentry-kotlin-multiplatform/src/commonTvWatchMacOsTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.tvwatchmacos.kt b/sentry-kotlin-multiplatform/src/commonTvWatchMacOsTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.tvwatchmacos.kt new file mode 100644 index 00000000..68e210cf --- /dev/null +++ b/sentry-kotlin-multiplatform/src/commonTvWatchMacOsTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.tvwatchmacos.kt @@ -0,0 +1,56 @@ +package io.sentry.kotlin.multiplatform + +import io.sentry.kotlin.multiplatform.extensions.toCocoaOptionsConfiguration +import kotlinx.cinterop.convert + +actual interface PlatformOptions : CommonPlatformOptions + +class SentryTvWatchMacOsOptionsWrapper(private val cocoaOptions: CocoaSentryOptions) : + PlatformOptions { + override val dsn: String? + get() = cocoaOptions.dsn + + override val attachStackTrace: Boolean + get() = cocoaOptions.attachStacktrace + + override val release: String? + get() = cocoaOptions.releaseName + + override val debug: Boolean + get() = cocoaOptions.debug + + override val environment: String + get() = cocoaOptions.environment + + override val dist: String? + get() = cocoaOptions.dist + + override val enableAutoSessionTracking: Boolean + get() = cocoaOptions.enableAutoSessionTracking + + override val sessionTrackingIntervalMillis: Long + get() = cocoaOptions.sessionTrackingIntervalMillis.convert() + + override val maxBreadcrumbs: Int + get() = cocoaOptions.maxBreadcrumbs.convert() + + override val maxAttachmentSize: Long + get() = cocoaOptions.maxAttachmentSize.convert() + + override val sampleRate: Double? + get() = cocoaOptions.sampleRate?.doubleValue + + override val tracesSampleRate: Double? + get() = cocoaOptions.tracesSampleRate?.doubleValue + + override fun applyFromOptions(options: SentryOptions) { + options.toCocoaOptionsConfiguration().invoke(cocoaOptions) + } +} + +actual fun createPlatformOptions(): PlatformOptions = + SentryTvWatchMacOsOptionsWrapper(CocoaSentryOptions()) + +actual fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) { + // no-op +} \ No newline at end of file diff --git a/sentry-kotlin-multiplatform/src/iosTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.ios.kt b/sentry-kotlin-multiplatform/src/iosTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.ios.kt new file mode 100644 index 00000000..7bd92b2e --- /dev/null +++ b/sentry-kotlin-multiplatform/src/iosTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.ios.kt @@ -0,0 +1,75 @@ +package io.sentry.kotlin.multiplatform + +import io.sentry.kotlin.multiplatform.extensions.toIosOptionsConfiguration +import kotlinx.cinterop.convert +import kotlin.test.assertEquals + +actual interface PlatformOptions : CommonPlatformOptions { + val attachScreenshot: Boolean + val attachViewHierarchy: Boolean + val enableAppHangTracking: Boolean + val appHangTimeoutIntervalMillis: Long +} + +class SentryIosOptionsWrapper(private val cocoaOptions: CocoaSentryOptions) : PlatformOptions { + override val attachScreenshot: Boolean + get() = cocoaOptions.attachScreenshot + + override val attachViewHierarchy: Boolean + get() = cocoaOptions.attachViewHierarchy + + override val enableAppHangTracking: Boolean + get() = cocoaOptions.enableAppHangTracking + + override val appHangTimeoutIntervalMillis: Long + get() = cocoaOptions.appHangTimeoutInterval.toLong() + + override val dsn: String? + get() = cocoaOptions.dsn + + override val attachStackTrace: Boolean + get() = cocoaOptions.attachStacktrace + + override val release: String? + get() = cocoaOptions.releaseName + + override val debug: Boolean + get() = cocoaOptions.debug + + override val environment: String + get() = cocoaOptions.environment + + override val dist: String? + get() = cocoaOptions.dist + + override val enableAutoSessionTracking: Boolean + get() = cocoaOptions.enableAutoSessionTracking + + override val sessionTrackingIntervalMillis: Long + get() = cocoaOptions.sessionTrackingIntervalMillis.convert() + + override val maxBreadcrumbs: Int + get() = cocoaOptions.maxBreadcrumbs.convert() + + override val maxAttachmentSize: Long + get() = cocoaOptions.maxAttachmentSize.convert() + + override val sampleRate: Double? + get() = cocoaOptions.sampleRate?.doubleValue + + override val tracesSampleRate: Double? + get() = cocoaOptions.tracesSampleRate?.doubleValue + + override fun applyFromOptions(options: SentryOptions) { + options.toIosOptionsConfiguration().invoke(cocoaOptions) + } +} + +actual fun createPlatformOptions(): PlatformOptions = SentryIosOptionsWrapper(CocoaSentryOptions()) + +actual fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) { + assertEquals(attachScreenshot, options.attachScreenshot) + assertEquals(attachViewHierarchy, options.attachViewHierarchy) + assertEquals(enableAppHangTracking, options.enableAppHangTracking) + assertEquals(appHangTimeoutIntervalMillis, options.appHangTimeoutIntervalMillis) +} \ No newline at end of file diff --git a/sentry-kotlin-multiplatform/src/jvmTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.jvm.kt b/sentry-kotlin-multiplatform/src/jvmTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.jvm.kt new file mode 100644 index 00000000..4cf93ad6 --- /dev/null +++ b/sentry-kotlin-multiplatform/src/jvmTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.jvm.kt @@ -0,0 +1,53 @@ +package io.sentry.kotlin.multiplatform + +import io.sentry.kotlin.multiplatform.extensions.toJvmSentryOptionsCallback + +actual interface PlatformOptions : CommonPlatformOptions + +class SentryJvmOptionsWrapper(private val jvmOptions: JvmSentryOptions) : PlatformOptions { + override val dsn: String? + get() = jvmOptions.dsn + + override val attachStackTrace: Boolean + get() = jvmOptions.isAttachStacktrace + + override val release: String? + get() = jvmOptions.release + + override val debug: Boolean + get() = jvmOptions.isDebug + + override val environment: String? + get() = jvmOptions.environment + + override val dist: String? + get() = jvmOptions.dist + + override val enableAutoSessionTracking: Boolean + get() = jvmOptions.isEnableAutoSessionTracking + + override val sessionTrackingIntervalMillis: Long + get() = jvmOptions.sessionTrackingIntervalMillis + + override val maxBreadcrumbs: Int + get() = jvmOptions.maxBreadcrumbs + + override val maxAttachmentSize: Long + get() = jvmOptions.maxAttachmentSize + + override val sampleRate: Double? + get() = jvmOptions.sampleRate + + override val tracesSampleRate: Double? + get() = jvmOptions.tracesSampleRate + + override fun applyFromOptions(options: SentryOptions) { + options.toJvmSentryOptionsCallback().invoke(jvmOptions) + } +} + +actual fun createPlatformOptions(): PlatformOptions = SentryJvmOptionsWrapper(JvmSentryOptions()) + +actual fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) { + // no-op +} \ No newline at end of file From 3c7c0fecc0c84966879961606609d134d76f756b Mon Sep 17 00:00:00 2001 From: Sentry Github Bot Date: Tue, 20 Feb 2024 02:25:49 +0000 Subject: [PATCH 4/8] Format code --- .../io/sentry/kotlin/multiplatform/PlatformOptions.android.kt | 2 +- .../kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.kt | 4 ++-- .../io/sentry/kotlin/multiplatform/SentryOptionsTest.kt | 2 +- .../kotlin/multiplatform/PlatformOptions.tvwatchmacos.kt | 2 +- .../io/sentry/kotlin/multiplatform/PlatformOptions.ios.kt | 2 +- .../io/sentry/kotlin/multiplatform/PlatformOptions.jvm.kt | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sentry-kotlin-multiplatform/src/androidUnitTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.android.kt b/sentry-kotlin-multiplatform/src/androidUnitTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.android.kt index fffc5635..1ba45516 100644 --- a/sentry-kotlin-multiplatform/src/androidUnitTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.android.kt +++ b/sentry-kotlin-multiplatform/src/androidUnitTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.android.kt @@ -74,4 +74,4 @@ actual fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) assertEquals(attachViewHierarchy, options.attachViewHierarchy) assertEquals(isAnrEnabled, options.isAnrEnabled) assertEquals(anrTimeoutIntervalMillis, options.anrTimeoutIntervalMillis) -} \ No newline at end of file +} diff --git a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.kt b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.kt index dd0663c7..3e2ab65e 100644 --- a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.kt +++ b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.kt @@ -13,10 +13,10 @@ interface CommonPlatformOptions { val maxAttachmentSize: Long val sampleRate: Double? val tracesSampleRate: Double? - + fun applyFromOptions(options: SentryOptions) } expect interface PlatformOptions : CommonPlatformOptions -expect fun createPlatformOptions(): PlatformOptions \ No newline at end of file +expect fun createPlatformOptions(): PlatformOptions diff --git a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt index 1b61ccf0..d12a5200 100644 --- a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt +++ b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt @@ -171,4 +171,4 @@ class SentryOptionsTest : BaseSentryTest() { } } -expect fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) \ No newline at end of file +expect fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) diff --git a/sentry-kotlin-multiplatform/src/commonTvWatchMacOsTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.tvwatchmacos.kt b/sentry-kotlin-multiplatform/src/commonTvWatchMacOsTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.tvwatchmacos.kt index 68e210cf..e584625d 100644 --- a/sentry-kotlin-multiplatform/src/commonTvWatchMacOsTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.tvwatchmacos.kt +++ b/sentry-kotlin-multiplatform/src/commonTvWatchMacOsTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.tvwatchmacos.kt @@ -53,4 +53,4 @@ actual fun createPlatformOptions(): PlatformOptions = actual fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) { // no-op -} \ No newline at end of file +} diff --git a/sentry-kotlin-multiplatform/src/iosTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.ios.kt b/sentry-kotlin-multiplatform/src/iosTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.ios.kt index 7bd92b2e..98e1c797 100644 --- a/sentry-kotlin-multiplatform/src/iosTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.ios.kt +++ b/sentry-kotlin-multiplatform/src/iosTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.ios.kt @@ -72,4 +72,4 @@ actual fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) assertEquals(attachViewHierarchy, options.attachViewHierarchy) assertEquals(enableAppHangTracking, options.enableAppHangTracking) assertEquals(appHangTimeoutIntervalMillis, options.appHangTimeoutIntervalMillis) -} \ No newline at end of file +} diff --git a/sentry-kotlin-multiplatform/src/jvmTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.jvm.kt b/sentry-kotlin-multiplatform/src/jvmTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.jvm.kt index 4cf93ad6..e93be2ff 100644 --- a/sentry-kotlin-multiplatform/src/jvmTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.jvm.kt +++ b/sentry-kotlin-multiplatform/src/jvmTest/kotlin/io/sentry/kotlin/multiplatform/PlatformOptions.jvm.kt @@ -50,4 +50,4 @@ actual fun createPlatformOptions(): PlatformOptions = SentryJvmOptionsWrapper(Jv actual fun PlatformOptions.assertPlatformSpecificOptions(options: SentryOptions) { // no-op -} \ No newline at end of file +} From 158747de0add801aeaf59ee954d834638a92857a Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 20 Feb 2024 03:27:12 +0100 Subject: [PATCH 5/8] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 240e7196..72859652 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Unreleased +### Features + +- Add App Hang Tracking / ANR options ([#187](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/187)) + - Use `isAnrEnabled` and `anrTimeoutIntervalMillis` to configure ANR tracking for Android + - Use `enableAppHangTracking` and `appHangTimeoutIntervalMillis` to configure App Hang tracking for iOS + ### Dependencies - Bump Cocoa SDK from v8.17.2 to v8.20.0 ([#180](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/180), [#182](https://github.com/getsentry/sentry-kotlin-multiplatform/pull/182)) From b2c2a28f835b4c49800c03e41e9553902fed4344 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 20 Feb 2024 03:31:42 +0100 Subject: [PATCH 6/8] Update tests --- .../kotlin/multiplatform/SentryOptionsTest.kt | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt index d12a5200..3be34660 100644 --- a/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt +++ b/sentry-kotlin-multiplatform/src/commonTest/kotlin/io/sentry/kotlin/multiplatform/SentryOptionsTest.kt @@ -101,31 +101,31 @@ class SentryOptionsTest : BaseSentryTest() { fun `GIVEN SentryOptions THEN default values are set`() { val options = SentryOptions() - assertNull(options.dsn, "DSN should be null by default.") - assertTrue(options.attachStackTrace, "attachStackTrace should be true by default.") - assertTrue(options.attachThreads, "attachThreads should be true by default.") - assertNull(options.release, "Release should be null by default.") - assertFalse(options.debug, "Debug should be false by default.") - assertNull(options.environment, "Environment should be null by default.") - assertNull(options.dist, "Dist should be null by default.") - assertTrue(options.enableAutoSessionTracking, "enableAutoSessionTracking should be true by default.") - assertEquals(DEFAULT_SESSION_INTERVAL_MILLIS, options.sessionTrackingIntervalMillis, "sessionTrackingIntervalMillis should match the default value.") - assertFalse(options.attachScreenshot, "attachScreenshot should be false by default.") - assertNull(options.beforeBreadcrumb, "beforeBreadcrumb should be null by default.") - assertNull(options.beforeSend, "beforeSend should be null by default.") - assertNull(options.sdk, "SDK version should be null by default.") - assertEquals(DEFAULT_MAX_BREADCRUMBS, options.maxBreadcrumbs, "maxBreadcrumbs should match the default value.") - assertEquals(DEFAULT_MAX_ATTACHMENT_SIZE, options.maxAttachmentSize, "maxAttachmentSize should match the default value.") - assertFalse(options.attachViewHierarchy, "attachViewHierarchy should be false by default.") - assertTrue(options.enableCaptureFailedRequests, "enableCaptureFailedRequests should be true by default.") - assertEquals(listOf(HttpStatusCodeRange()), options.failedRequestStatusCodes, "failedRequestStatusCodes should contain the default range.") - assertEquals(listOf(".*"), options.failedRequestTargets, "failedRequestTargets should contain the default regex for all targets.") - assertNull(options.sampleRate, "sampleRate should be null by default.") - assertNull(options.tracesSampleRate, "tracesSampleRate should be null by default.") - assertTrue(options.enableAppHangTracking, "enableAppHangTracking should be true by default.") - assertEquals(2000L, options.appHangTimeoutIntervalMillis, "appHangTimeoutIntervalMillis should be 2000 milliseconds by default.") - assertTrue(options.isAnrEnabled, "anrEnabled should be true by default.") - assertEquals(5000L, options.anrTimeoutIntervalMillis, "anrTimeoutIntervalMillis should be 5000 milliseconds by default.") + assertNull(options.dsn) + assertTrue(options.attachStackTrace) + assertTrue(options.attachThreads) + assertNull(options.release) + assertFalse(options.debug) + assertNull(options.environment) + assertNull(options.dist) + assertTrue(options.enableAutoSessionTracking) + assertEquals(DEFAULT_SESSION_INTERVAL_MILLIS, options.sessionTrackingIntervalMillis) + assertFalse(options.attachScreenshot) + assertNull(options.beforeBreadcrumb) + assertNull(options.beforeSend) + assertNull(options.sdk) + assertEquals(DEFAULT_MAX_BREADCRUMBS, options.maxBreadcrumbs) + assertEquals(DEFAULT_MAX_ATTACHMENT_SIZE, options.maxAttachmentSize) + assertFalse(options.attachViewHierarchy) + assertTrue(options.enableCaptureFailedRequests) + assertEquals(listOf(HttpStatusCodeRange()), options.failedRequestStatusCodes) + assertEquals(listOf(".*"), options.failedRequestTargets) + assertNull(options.sampleRate) + assertNull(options.tracesSampleRate) + assertTrue(options.enableAppHangTracking) + assertEquals(2000L, options.appHangTimeoutIntervalMillis) + assertTrue(options.isAnrEnabled) + assertEquals(5000L, options.anrTimeoutIntervalMillis) } @Test From 30be8bee2700b9bf7ae2a05215b169f24edff64d Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 20 Feb 2024 13:37:01 +0100 Subject: [PATCH 7/8] add api --- .../api/android/sentry-kotlin-multiplatform.api | 8 ++++++++ .../api/jvm/sentry-kotlin-multiplatform.api | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/sentry-kotlin-multiplatform/api/android/sentry-kotlin-multiplatform.api b/sentry-kotlin-multiplatform/api/android/sentry-kotlin-multiplatform.api index 89233344..ef8d4351 100644 --- a/sentry-kotlin-multiplatform/api/android/sentry-kotlin-multiplatform.api +++ b/sentry-kotlin-multiplatform/api/android/sentry-kotlin-multiplatform.api @@ -157,6 +157,8 @@ public final class io/sentry/kotlin/multiplatform/SentryLevel : java/lang/Enum { public class io/sentry/kotlin/multiplatform/SentryOptions { public fun ()V + public final fun getAnrTimeoutIntervalMillis ()J + public final fun getAppHangTimeoutIntervalMillis ()J public final fun getAttachScreenshot ()Z public final fun getAttachStackTrace ()Z public final fun getAttachThreads ()Z @@ -166,6 +168,7 @@ public class io/sentry/kotlin/multiplatform/SentryOptions { public final fun getDebug ()Z public final fun getDist ()Ljava/lang/String; public final fun getDsn ()Ljava/lang/String; + public final fun getEnableAppHangTracking ()Z public final fun getEnableAutoSessionTracking ()Z public final fun getEnableCaptureFailedRequests ()Z public final fun getEnvironment ()Ljava/lang/String; @@ -178,6 +181,10 @@ public class io/sentry/kotlin/multiplatform/SentryOptions { public final fun getSdk ()Lio/sentry/kotlin/multiplatform/protocol/SdkVersion; public final fun getSessionTrackingIntervalMillis ()J public final fun getTracesSampleRate ()Ljava/lang/Double; + public final fun isAnrEnabled ()Z + public final fun setAnrEnabled (Z)V + public final fun setAnrTimeoutIntervalMillis (J)V + public final fun setAppHangTimeoutIntervalMillis (J)V public final fun setAttachScreenshot (Z)V public final fun setAttachStackTrace (Z)V public final fun setAttachThreads (Z)V @@ -187,6 +194,7 @@ public class io/sentry/kotlin/multiplatform/SentryOptions { public final fun setDebug (Z)V public final fun setDist (Ljava/lang/String;)V public final fun setDsn (Ljava/lang/String;)V + public final fun setEnableAppHangTracking (Z)V public final fun setEnableAutoSessionTracking (Z)V public final fun setEnableCaptureFailedRequests (Z)V public final fun setEnvironment (Ljava/lang/String;)V diff --git a/sentry-kotlin-multiplatform/api/jvm/sentry-kotlin-multiplatform.api b/sentry-kotlin-multiplatform/api/jvm/sentry-kotlin-multiplatform.api index e1f8a5cc..cd762cbe 100644 --- a/sentry-kotlin-multiplatform/api/jvm/sentry-kotlin-multiplatform.api +++ b/sentry-kotlin-multiplatform/api/jvm/sentry-kotlin-multiplatform.api @@ -154,6 +154,8 @@ public final class io/sentry/kotlin/multiplatform/SentryLevel : java/lang/Enum { public class io/sentry/kotlin/multiplatform/SentryOptions { public fun ()V + public final fun getAnrTimeoutIntervalMillis ()J + public final fun getAppHangTimeoutIntervalMillis ()J public final fun getAttachScreenshot ()Z public final fun getAttachStackTrace ()Z public final fun getAttachThreads ()Z @@ -163,6 +165,7 @@ public class io/sentry/kotlin/multiplatform/SentryOptions { public final fun getDebug ()Z public final fun getDist ()Ljava/lang/String; public final fun getDsn ()Ljava/lang/String; + public final fun getEnableAppHangTracking ()Z public final fun getEnableAutoSessionTracking ()Z public final fun getEnableCaptureFailedRequests ()Z public final fun getEnvironment ()Ljava/lang/String; @@ -175,6 +178,10 @@ public class io/sentry/kotlin/multiplatform/SentryOptions { public final fun getSdk ()Lio/sentry/kotlin/multiplatform/protocol/SdkVersion; public final fun getSessionTrackingIntervalMillis ()J public final fun getTracesSampleRate ()Ljava/lang/Double; + public final fun isAnrEnabled ()Z + public final fun setAnrEnabled (Z)V + public final fun setAnrTimeoutIntervalMillis (J)V + public final fun setAppHangTimeoutIntervalMillis (J)V public final fun setAttachScreenshot (Z)V public final fun setAttachStackTrace (Z)V public final fun setAttachThreads (Z)V @@ -184,6 +191,7 @@ public class io/sentry/kotlin/multiplatform/SentryOptions { public final fun setDebug (Z)V public final fun setDist (Ljava/lang/String;)V public final fun setDsn (Ljava/lang/String;)V + public final fun setEnableAppHangTracking (Z)V public final fun setEnableAutoSessionTracking (Z)V public final fun setEnableCaptureFailedRequests (Z)V public final fun setEnvironment (Ljava/lang/String;)V From 9b7cd20ab78930532994d0c8760cc241859dc3b9 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Tue, 20 Feb 2024 13:42:37 +0100 Subject: [PATCH 8/8] Fix detekt --- .../io/sentry/kotlin/multiplatform/SentryOptions.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt b/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt index c395abeb..9abb506b 100644 --- a/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt +++ b/sentry-kotlin-multiplatform/src/commonMain/kotlin/io/sentry/kotlin/multiplatform/SentryOptions.kt @@ -6,6 +6,8 @@ import io.sentry.kotlin.multiplatform.protocol.SdkVersion internal const val DEFAULT_MAX_BREADCRUMBS = 100 internal const val DEFAULT_MAX_ATTACHMENT_SIZE = 20 * 1024 * 1024L internal const val DEFAULT_SESSION_INTERVAL_MILLIS = 30000L +internal const val DEFAULT_APPHANG_TIMEOUT_INTERVAL_MILLIS = 2000L +internal const val DEFAULT_ANR_TIMEOUT_INTERVAL_MILLIS = 5000L /** Sentry options that can be used to configure the SDK. */ public open class SentryOptions { @@ -122,7 +124,8 @@ public open class SentryOptions { public var tracesSampleRate: Double? = null /** - * Controls the tracking of App Hangs capturing moments when the application becomes unresponsive for a set duration. + * Controls the tracking of App Hangs capturing moments when the application + * becomes unresponsive for a set duration. * * **Default**: Enabled. * @@ -143,7 +146,7 @@ public open class SentryOptions { * For configuration details and best practices, see: * [Cocoa App Hangs](https://docs.sentry.io/platforms/apple/configuration/app-hangs/) */ - public var appHangTimeoutIntervalMillis: Long = 2000 + public var appHangTimeoutIntervalMillis: Long = DEFAULT_APPHANG_TIMEOUT_INTERVAL_MILLIS /** * Enables or disables ANR (Application Not Responding) tracking. @@ -167,5 +170,5 @@ public open class SentryOptions { * For more information on configuring ANR detection, visit: * [Android ANR](https://docs.sentry.io/platforms/android/configuration/app-not-respond/) */ - public var anrTimeoutIntervalMillis: Long = 5000 + public var anrTimeoutIntervalMillis: Long = DEFAULT_ANR_TIMEOUT_INTERVAL_MILLIS }