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

Implement /sdk/v2/flags API call and LoadStoreCache for flag configurations #31

Merged
merged 63 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
d0bd9a9
rebase
Sep 14, 2023
18ab28d
variant changes
Sep 5, 2023
91f754b
initial ExperimentClient changes
Sep 5, 2023
8bac8d7
make loadstorecache functions public
Sep 5, 2023
2f14a22
use synchronize instead of mutex
Sep 6, 2023
d267158
clean up
Sep 6, 2023
164b23e
update with ExperimentClient and implement getFlagStorage
Sep 6, 2023
9a5e3d5
add StorageTest
Sep 7, 2023
b80196e
DefaultExperimentClient takes Storage instead of application
Sep 14, 2023
4ff3fa3
fix ExperimentClientTest
Sep 14, 2023
60fe73a
update Cache load function
Sep 14, 2023
9072a9b
Merge branch 'local-evaluation' into update-expclient-with-storage-an…
tyiuhc Sep 14, 2023
251fbb5
update to java 9
Sep 14, 2023
8a0de32
test using java 9
Sep 14, 2023
13e41ed
update build.yml
Sep 14, 2023
a9b760f
lower mockito version
Sep 14, 2023
b12af15
chore: remove unneeded imports
Sep 14, 2023
70a3038
make classes internal
Sep 14, 2023
7456554
clean up imports
Sep 14, 2023
e54024c
fix VariantTest and Variant.toJson()
Sep 15, 2023
6377faf
update cache with flags
Sep 15, 2023
6ea5aa1
make transformVariantFromStorage() internal
Sep 15, 2023
31998ac
add flagapi
Sep 15, 2023
260995d
rebase
Sep 14, 2023
65e4cd0
variant changes
Sep 5, 2023
5cc190b
initial ExperimentClient changes
Sep 5, 2023
bd7af66
make loadstorecache functions public
Sep 5, 2023
7a0533b
use synchronize instead of mutex
Sep 6, 2023
a83a4f8
update with ExperimentClient and implement getFlagStorage
Sep 6, 2023
0fe933e
add StorageTest
Sep 7, 2023
188398d
DefaultExperimentClient takes Storage instead of application
Sep 14, 2023
8a253ca
fix ExperimentClientTest
Sep 14, 2023
fb10f15
update Cache load function
Sep 14, 2023
8eb85bb
update to java 9
Sep 14, 2023
3bc21b7
test using java 9
Sep 14, 2023
ae38c1d
update build.yml
Sep 14, 2023
f7459c1
lower mockito version
Sep 14, 2023
18e6089
chore: remove unneeded imports
Sep 14, 2023
c1c358c
make classes internal
Sep 14, 2023
fd590de
clean up imports
Sep 14, 2023
9398fc8
fix VariantTest and Variant.toJson()
Sep 15, 2023
e1507e9
make transformVariantFromStorage() internal
Sep 15, 2023
8830a99
update cache with flags
Sep 15, 2023
c7af78b
remove unused imports
Sep 15, 2023
79498e8
fix excess imports
Sep 15, 2023
122e2c7
chore: rearrange cache code
Sep 15, 2023
b076566
fix toVariant function
Sep 15, 2023
3574921
variant updates
Sep 15, 2023
94b15c8
fix transformFlagFromStorage()
Sep 15, 2023
b076a02
test getFlags
Sep 15, 2023
1fed30d
add doFlags() to client
Sep 19, 2023
2fa7ecb
update Cache load() function, add files from evaluation-core, update …
Sep 20, 2023
681edc3
Merge branch 'local-evaluation' into update-expclient-with-storage-an…
tyiuhc Sep 20, 2023
8bb7444
update build.gradle and import remaining evaluation-core files
Sep 21, 2023
77d390b
update shareprefsstorage and cache logic
Sep 21, 2023
d4289b8
fix VariantTest
Sep 21, 2023
528dcaf
update String.toFlag
Sep 22, 2023
50685c6
update Flag/Variant utils
Sep 22, 2023
58be549
update String.toVariant payload handling
Sep 22, 2023
606c306
update evaluation package, LoadStoreCache
Sep 22, 2023
a4cc3fa
fix getFlags
Sep 22, 2023
ea962e4
remove flag!=null after decodeFromString
Sep 22, 2023
03aa7e4
simplify toFlags logic
Sep 25, 2023
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 build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'org.jetbrains.dokka'
apply plugin: 'org.jlleitschuh.gradle.ktlint'

buildscript {
ext.kotlin_version = '1.5.31'
ext.kotlin_version = '1.6.21'
ext.dokka_version = '1.4.32'

repositories {
Expand Down
4 changes: 3 additions & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ plugins {
id 'com.android.library'
id 'kotlin-android'
id 'org.jetbrains.dokka'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.0'
}

ext {
PUBLISH_NAME = 'Experiment Android SDK'
PUBLISH_DESCRIPTION = 'Amplitude Experiment client-side SDK for Android'
Expand Down Expand Up @@ -42,6 +42,8 @@ dependencies {
implementation 'com.amplitude:analytics-connector:1.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'com.amplitude:android-sdk:2.26.1'
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.3")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3")

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.json:json:20201115'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.amplitude.experiment.evaluation

import kotlinx.serialization.Serializable

@Serializable
data class EvaluationAllocation(
tyiuhc marked this conversation as resolved.
Show resolved Hide resolved
val range: List<Int>,
val distributions: List<EvaluationDistribution>,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.amplitude.experiment.evaluation

import kotlinx.serialization.Serializable

@Serializable
data class EvaluationBucket(
// How to select the prop from the context.
val selector: List<String>,

// A random string used to salt the bucketing value prior to hashing.
val salt: String,

// Determines which variant, if any, should be returned based on the
// result of the hash functions.
val allocations: List<EvaluationAllocation>,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.amplitude.experiment.evaluation

import kotlinx.serialization.Serializable

@Serializable
data class EvaluationCondition(
// How to select the property from the evaluation state.
val selector: List<String>,

// The operator.
val op: String,

// The values to compare to.
val values: Set<String>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.amplitude.experiment.evaluation

import kotlinx.serialization.Serializable

@Serializable
class EvaluationContext : MutableMap<String, Any?> by LinkedHashMap(), Selectable {

override fun select(selector: String): Any? = this[selector]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.amplitude.experiment.evaluation

import kotlinx.serialization.Serializable

@Serializable
data class EvaluationDistribution(
// The key of the variant to deliver if this range matches.
val variant: String,

// The distribution range [start, end), where the max value is 42949672.
// E.g. [0, 42949673] = [0%, 100%]
val range: List<Int>,
)
Loading