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

Release #148

Merged
merged 29 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
74874ef
Add support for compiling to Kotlin/JS targets
farmerbb Oct 29, 2024
c25e2cf
Revert AGP to 7.4.2 and JDK to 11
farmerbb Oct 31, 2024
1715822
Add ability to disable logging to stdout
farmerbb Oct 31, 2024
82fb2e9
Enable compilation targeting JRE 1.8
ToxicBakery Nov 5, 2024
a974b31
SDK version was updated
Bohdan-Kim Nov 6, 2024
c3554af
Restore package attribute to manifest
farmerbb Nov 6, 2024
3c8df46
Add ability to disable logging to stdout
farmerbb Oct 31, 2024
985a450
Merge pull request #146 from Angel-Studios/for-upstream-1
vazarkevych Nov 7, 2024
5b9ef5c
Merge pull request #2 from growthbook/release/1.1.63
farmerbb Nov 7, 2024
d0d6ed3
Merge remote-tracking branch 'origin/for-upstream-2-alt' into for-ups…
farmerbb Nov 7, 2024
d65675b
Fix test compilation
farmerbb Nov 7, 2024
b262d29
Merge pull request #147 from Angel-Studios/for-upstream-2
vazarkevych Nov 7, 2024
4aed004
Issue #142
Bohdan-Kim Nov 9, 2024
ce3a500
WIP
Bohdan-Kim Nov 11, 2024
f743234
add ability to deserialize optional field like force in GBFeatureRule
Bohdan-Kim Nov 12, 2024
5583bb4
add ability to evaluate manual force features
Bohdan-Kim Nov 12, 2024
5638cb3
Merge pull request #149 from growthbook/issues/142
vazarkevych Nov 20, 2024
0a1806e
Merge pull request #150 from growthbook/issues/145
vazarkevych Nov 20, 2024
8168c5d
Merge branch 'release/1.1.63' into force-property-issue
Bohdan-Kim Nov 20, 2024
2cf4428
Merge pull request #151 from growthbook/force-property-issue
vazarkevych Nov 20, 2024
9b93c15
Merge branch 'release/1.1.63' into fix-forced-feature-eval
Bohdan-Kim Nov 20, 2024
526e13c
Merge pull request #152 from growthbook/fix-forced-feature-eval
vazarkevych Nov 20, 2024
2840cd9
:Core module version was updated
Bohdan-Kim Nov 20, 2024
8592368
Add unit test for sse url creation
upendrap Nov 21, 2024
9f44283
Fix path for sse url
upendrap Nov 21, 2024
35738f3
Merge pull request #153 from upendrap/fix-sse-path
vazarkevych Nov 21, 2024
14162ba
Fixing failing publish command
Bohdan-Kim Nov 22, 2024
3e2d6d2
signing signatory is the same for each artifact
Bohdan-Kim Nov 22, 2024
a8f844c
Fixing AbstractMethodError
Bohdan-Kim Nov 22, 2024
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 .github/workflows/main-without-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Gradle clean
run: ./gradlew clean --info
- name: Build with Gradle
run: ./gradlew :DefaultNetworkDispatcher:build :GrowthBook:build --info
run: ./gradlew kotlinUpgradeYarnLock :DefaultNetworkDispatcher:build :GrowthBook:build --info
# - name: release
# uses: actions/create-release@v1
# id: create_release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Gradle clean
run: ./gradlew clean --info
- name: Build with Gradle
run: ./gradlew -Pversion=$LIB_VERSION :GrowthBook:build --info
run: ./gradlew -Pversion=$LIB_VERSION kotlinUpgradeYarnLock :GrowthBook:build --info
- name: release
uses: actions/create-release@v1
id: create_release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-core-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
run: ./gradlew -Pversion=$CORE_MODULE_VERSION :Core:build --info
- name: Publish to maven central
run: |
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$CORE_MODULE_VERSION :Core:publish
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$CORE_MODULE_VERSION kotlinUpgradeYarnLock :Core:publish
2 changes: 1 addition & 1 deletion .github/workflows/publish-ktor-dispatcher-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
run: ./gradlew -Pversion=$DISPATCHER_VERSION :NetworkDispatcherKtor:build --info
- name: Publish to maven central
run: |
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$DISPATCHER_VERSION :NetworkDispatcherKtor:publish
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$DISPATCHER_VERSION kotlinUpgradeYarnLock :NetworkDispatcherKtor:publish
2 changes: 1 addition & 1 deletion .github/workflows/publish-okhttp-dispatcher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
run: ./gradlew -Pversion=$DISPATCHER_VERSION :NetworkDispatcherOkHttp:build --info
- name: Publish to maven central
run: |
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$DISPATCHER_VERSION :NetworkDispatcherOkHttp:publish
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$DISPATCHER_VERSION kotlinUpgradeYarnLock :NetworkDispatcherOkHttp:publish
2 changes: 1 addition & 1 deletion .github/workflows/upload-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Gradle clean
run: ./gradlew clean --info
- name: Build with Gradle
run: ./gradlew -Pversion=${{ env.LIB_VERSION }} build --info
run: ./gradlew -Pversion=${{ env.LIB_VERSION }} kotlinUpgradeYarnLock build --info
- name: release
uses: actions/create-release@v1
id: create_release
Expand Down
34 changes: 24 additions & 10 deletions Core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn

plugins {
kotlin("multiplatform")
id("com.android.library")
kotlin("plugin.serialization")
id("maven-publish")
id("signing")
id("org.jetbrains.dokka") version "1.8.10"
}

group = "io.growthbook.sdk"
version = "1.0.2"
version = "1.0.3"

kotlin {
android {
androidTarget {
publishLibraryVariants("release")
}

js {
yarn.lockFileDirectory = file("kotlin-js-store")
browser {
commonWebpackConfig {
output = KotlinWebpackOutput(
library = project.name,
libraryTarget = KotlinWebpackOutput.Target.UMD,
globalObject = KotlinWebpackOutput.Target.WINDOW
)
}
}
}

jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
Expand All @@ -28,7 +42,7 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
}
}
}
Expand All @@ -48,6 +62,10 @@ android {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

val dokkaOutputDir = "$buildDir/dokka"
Expand Down Expand Up @@ -128,9 +146,5 @@ publishing {
* Signing JAR using GPG Keys
*/
signing {
useInMemoryPgpKeys(
System.getenv("GPG_PRIVATE_KEY"),
System.getenv("GPG_PRIVATE_PASSWORD")
)
sign(publishing.publications)
}
}
8 changes: 8 additions & 0 deletions Core/src/jsMain/kotlin/com/sdk/growthbook/Dispatcher.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.sdk.growthbook

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers

// 1
actual val PlatformDependentIODispatcher: CoroutineDispatcher =
Dispatchers.Unconfined
36 changes: 25 additions & 11 deletions GrowthBook/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn

plugins {
kotlin("multiplatform")
id("com.android.library")
kotlin("plugin.serialization")
id("maven-publish")
id("signing")
id("org.jetbrains.dokka") version "1.8.10"
id("org.jetbrains.dokka") version "1.9.10"
}

group = "io.growthbook.sdk"
version = "1.1.62"
version = "1.1.63"

kotlin {

val ktorVersion = "2.1.2"
val serializationVersion = "1.3.3"
val kryptoVersion = "2.7.0"

android {
androidTarget {
publishLibraryVariants("release")
}

js {
yarn.lockFileDirectory = file("kotlin-js-store")
browser {
commonWebpackConfig {
output = KotlinWebpackOutput(
library = project.name,
libraryTarget = KotlinWebpackOutput.Target.UMD,
globalObject = KotlinWebpackOutput.Target.WINDOW
)
}
}
}

jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
Expand All @@ -38,7 +52,7 @@ kotlin {
implementation("com.ionspin.kotlin:bignum:0.3.3")
implementation("com.soywiz.korlibs.krypto:krypto:$kryptoVersion")

api("io.growthbook.sdk:Core:1.0.2")
api(project(":Core"))
api(
"org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion"
)
Expand All @@ -60,7 +74,7 @@ kotlin {
implementation("com.soywiz.korlibs.krypto:krypto-android:$kryptoVersion")
}
}
val androidTest by getting {
val androidUnitTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13.2")
Expand Down Expand Up @@ -111,6 +125,10 @@ android {
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

val dokkaOutputDir = "$buildDir/dokka"
Expand Down Expand Up @@ -191,9 +209,5 @@ publishing {
* Signing JAR using GPG Keys
*/
signing {
useInMemoryPgpKeys(
System.getenv("GPG_PRIVATE_KEY"),
System.getenv("GPG_PRIVATE_PASSWORD")
)
sign(publishing.publications)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.sdk.growthbook.utils.GBCacheRefreshHandler
* EncryptionKey - Encryption key if you intend to use data encryption
* Network Dispatcher - Network Dispatcher
* Remote eval - Whether to use Remote Evaluation
* enableLogging - Prints logging statements to stdout
*/
abstract class SDKBuilder(
val apiKey: String,
Expand All @@ -25,6 +26,7 @@ abstract class SDKBuilder(
val encryptionKey: String?,
val networkDispatcher: NetworkDispatcher,
val remoteEval: Boolean,
val enableLogging: Boolean,
) {
internal var qaMode: Boolean = false
internal var forcedVariations: Map<String, Int> = HashMap()
Expand Down Expand Up @@ -69,6 +71,7 @@ abstract class SDKBuilder(
* EncryptionKey - Encryption key if you intend to use data encryption
* Network Dispatcher - Network Dispatcher
* Remote eval - Whether to use Remote Evaluation
* enableLogging - Prints logging statements to stdout
*/
class GBSDKBuilder(
apiKey: String,
Expand All @@ -78,9 +81,10 @@ class GBSDKBuilder(
encryptionKey: String? = null,
trackingCallback: GBTrackingCallback,
remoteEval: Boolean = false,
enableLogging: Boolean = false,
) : SDKBuilder(
apiKey, hostURL,
attributes, trackingCallback, encryptionKey, networkDispatcher, remoteEval
attributes, trackingCallback, encryptionKey, networkDispatcher, remoteEval, enableLogging
) {

private var refreshHandler: GBCacheRefreshHandler? = null
Expand Down Expand Up @@ -145,13 +149,14 @@ class GBSDKBuilder(
onFeatureUsage = featureUsageCallback,
encryptionKey = encryptionKey,
remoteEval = remoteEval,
enableLogging = enableLogging,
stickyBucketService = stickyBucketService,
)

return GrowthBookSDK(
gbContext,
refreshHandler,
networkDispatcher
networkDispatcher,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import com.sdk.growthbook.model.GBFeatureResult
import com.sdk.growthbook.utils.toHashMap
import kotlinx.coroutines.flow.Flow
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonElement

typealias GBTrackingCallback = (GBExperiment, GBExperimentResult) -> Unit
typealias GBExperimentRunCallback = (GBExperiment, GBExperimentResult) -> Unit
typealias GBTrackingCallback = (GBExperiment, GBExperimentResult?) -> Unit
typealias GBFeatureUsageCallback = (featureKey: String, gbFeatureResult: GBFeatureResult) -> Unit

/**
Expand All @@ -35,11 +35,10 @@ typealias GBFeatureUsageCallback = (featureKey: String, gbFeatureResult: GBFeatu
class GrowthBookSDK() : FeaturesFlowDelegate {

private var refreshHandler: GBCacheRefreshHandler? = null
private var subscriptions: MutableList<GBExperimentRunCallback> = mutableListOf()
private lateinit var networkDispatcher: NetworkDispatcher
private lateinit var featuresViewModel: FeaturesViewModel
private var attributeOverrides: Map<String, Any> = emptyMap()
private var forcedFeatures: Map<String, Any> = emptyMap()
private var forcedFeatures: Map<String, JsonElement> = emptyMap()
private var savedGroups: Map<String, Any>? = emptyMap()

//@ThreadLocal
Expand All @@ -65,7 +64,10 @@ class GrowthBookSDK() : FeaturesFlowDelegate {
this.featuresViewModel =
FeaturesViewModel(
delegate = this,
dataSource = FeaturesDataSource(dispatcher = networkDispatcher),
dataSource = FeaturesDataSource(
dispatcher = networkDispatcher,
enableLogging = context.enableLogging,
),
encryptionKey = gbContext.encryptionKey,
)
if (features != null) {
Expand All @@ -78,14 +80,6 @@ class GrowthBookSDK() : FeaturesFlowDelegate {
refreshStickyBucketService()
}

fun subscribe(callback: GBExperimentRunCallback) {
this.subscriptions.add(callback)
}

fun clearSubscriptions() {
this.subscriptions.clear()
}

fun setSavedGroups(savedGroups: Map<String, Any>) {
gbContext.savedGroups = savedGroups
}
Expand Down Expand Up @@ -182,7 +176,8 @@ class GrowthBookSDK() : FeaturesFlowDelegate {
return GBFeatureEvaluator().evaluateFeature(
context = gbContext,
featureKey = id,
attributeOverrides = attributeOverrides
attributeOverrides = attributeOverrides,
forcedFeature = this.forcedFeatures
)
}

Expand All @@ -198,23 +193,17 @@ class GrowthBookSDK() : FeaturesFlowDelegate {
* The run method takes an Experiment object and returns an ExperimentResult
*/
fun run(experiment: GBExperiment): GBExperimentResult {
val result = GBExperimentEvaluator().evaluateExperiment(
return GBExperimentEvaluator().evaluateExperiment(
context = gbContext,
experiment = experiment,
attributeOverrides = attributeOverrides
)

this.subscriptions.forEach { subscription ->
subscription(experiment, result)
}

return result
}

/**
* The setForcedFeatures method setup the Map of user's (forced) features
*/
fun setForcedFeatures(forcedFeatures: Map<String, Any>) {
fun setForcedFeatures(forcedFeatures: Map<String, JsonElement>) {
this.forcedFeatures = forcedFeatures
}

Expand Down
Loading
Loading