Hey guys, I am experimenting with GrowthBook for f...
# announcements
s
Hey guys, I am experimenting with GrowthBook for feature flag experiments on android, and I seem to have hit a roadblock. I have created a feature, set up an experiment that affects all users, split them by
id
, 50%-50%, and whatever I do, I only seem to be able to receive
defaultValue
, instead of the expected overrides (all the users are included in the experiment). Details in thread, do I miss something?
the way the feature is set up
used API key points to
staging
, just like the feature experiment
testing code
Copy code
val builder = GBSDKBuilderApp(
                    apiKey = API_KEY,
                    hostURL = HOST_URL,
                    attributes = mapOf("id" to userId),
                    trackingCallback = { _, _ -> } // TODO set later
                )
                builder.setRefreshHandler { isRefreshed ->
                    Log.d("growthbook", "refresh callback: $isRefreshed")
                    waiter?.resume(Unit)
                    waiter = null
                }
                val sdk = builder.initialize()

                val beforeCont = sdk.feature("test_feature")
                Log.d(
                    "growthbook",
                    "before cont: ${beforeCont.value}, ${beforeCont.source.name}",
                )

                suspendCoroutine<Unit> { continuation ->
                    Log.d("growthbook", "cont")
                    waiter = continuation
                }

                val afterCont = sdk.feature("test_feature")
                Log.d(
                    "growthbook",
                    "after cont: ${afterCont.value}, ${afterCont.source.name}",
                )
log output
Copy code
2022-09-13 15:49:15.916 D/growthbook: before cont: null, unknownFeature
2022-09-13 15:49:15.917 D/growthbook: cont
2022-09-13 15:49:16.372 D/growthbook: refresh callback: true
2022-09-13 15:49:16.373 D/growthbook: after cont: bar, defaultValue
little code help: this is running in a
coroutine
, and I am waiting until a refresh successfully completes, that is what the
Continuation
stuff is about, and the result is visible, since before, it returns
unknownFeature
, but after,
defaultValue
in the API call of
<https://cdn.growthbook.io/api/features/API_KEY>
, the feature is visible as well:
Copy code
"test_feature": {
"defaultValue": "bar",
"rules": [
{
"variations": [
"override",
"control"
],
"coverage": 1,
"weights": [
0.5,
0.5
],
"key": "test_feature",
"hashAttribute": "id"
}
]
}
what am I doing wrong? am I missing something? any help is appreciated 🙂
f
What is the value of the
id
attribute you are passing into the SDK attributes?
s
a number corresponding to the user, example: 123
a
Long
to be precise
f
Can you try passing that as a string instead and see if that helps?
s
hahaha, that was it
nice, thanks
it works with a string 🙂
f
The SDKs are supposed to cast any attribute values to strings before using, but there must be a bug in our Android SDK
s
yup, sounds like a bug, and I did not see any error log anywhere
b
@future-teacher-7046 Just wanted to follow up on this and see who owns Android SDK and do you have a plan for improving it over time? This bug was a minor bug but there could be more similar issues with SDK and was wondering what is the process of fixing them? Thanks a lot for you response!