From da95772a9b2f9a46b305ec41802eb978ec9a5215 Mon Sep 17 00:00:00 2001 From: Bohdan Akimenko Date: Wed, 27 Nov 2024 21:45:37 +0200 Subject: [PATCH] Fields of GBError were set private again. Nullability of second parameter of GBTrackingCallback was taken away --- .../kotlin/com/sdk/growthbook/GrowthBookSDK.kt | 2 +- .../growthbook/evaluators/GBFeatureEvaluator.kt | 4 +++- .../kotlin/com/sdk/growthbook/utils/Constants.kt | 16 +++------------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/GrowthBookSDK.kt b/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/GrowthBookSDK.kt index dbe4aa0b..f2becd14 100644 --- a/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/GrowthBookSDK.kt +++ b/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/GrowthBookSDK.kt @@ -24,7 +24,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonElement -typealias GBTrackingCallback = (GBExperiment, GBExperimentResult?) -> Unit +typealias GBTrackingCallback = (GBExperiment, GBExperimentResult) -> Unit typealias GBFeatureUsageCallback = (featureKey: String, gbFeatureResult: GBFeatureResult) -> Unit /** diff --git a/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/evaluators/GBFeatureEvaluator.kt b/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/evaluators/GBFeatureEvaluator.kt index 03f0f60b..ac41d5f0 100644 --- a/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/evaluators/GBFeatureEvaluator.kt +++ b/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/evaluators/GBFeatureEvaluator.kt @@ -232,7 +232,9 @@ internal class GBFeatureEvaluator { result = track.result.experimentResult ) ) { - context.trackingCallback(track.experiment, track.result.experimentResult) + track.result.experimentResult?.let { + context.trackingCallback(track.experiment, it) + } } } } diff --git a/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/utils/Constants.kt b/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/utils/Constants.kt index a6ffbca4..060dff4b 100644 --- a/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/utils/Constants.kt +++ b/GrowthBook/src/commonMain/kotlin/com/sdk/growthbook/utils/Constants.kt @@ -88,22 +88,12 @@ class GBError(error: Throwable?) { /** * Error Message for the caught error / exception */ - private lateinit var errorMessage: String + val errorMessage: String = error?.message ?: "" /** * Error Stacktrace for the caught error / exception */ - private lateinit var stackTrace: String - - /** - * Constructor for initializing - */ - init { - if (error != null) { - errorMessage = error.message ?: "" - stackTrace = error.stackTraceToString() - } - } + val stackTrace: String? = error?.stackTraceToString() } /** @@ -319,7 +309,7 @@ object RangeSerializer { * Wrapper for deserialized model with optional field */ sealed class OptionalProperty { - object NotPresent : OptionalProperty() + data object NotPresent : OptionalProperty() data class Present(val value: T) : OptionalProperty() }