cuddly-zebra-96178
11/20/2024, 7:31 AMinternal constructor(
context: GBContext,
refreshHandler: GBCacheRefreshHandler?,
networkDispatcher: NetworkDispatcher,
features: GBFeatures? = null,
savedGroups: Map<String, Any>? = null
) : this() {
gbContext = context
this.refreshHandler = refreshHandler
this.networkDispatcher = networkDispatcher
/**
* JAVA Consumers preset Features
* SDK will not call API to fetch Features List
*/
this.featuresViewModel =
FeaturesViewModel(
delegate = this,
dataSource = FeaturesDataSource(dispatcher = networkDispatcher),
encryptionKey = gbContext.encryptionKey,
)
if (features != null) {
gbContext.features = features
} else {
refreshCache()
}
this.attributeOverrides = gbContext.attributes
this.savedGroups = savedGroups
refreshStickyBucketService()
}
what is purpose of the flowing code?
this.attributeOverrides = gbContext.attributes
if calling growthBook.feature(key) then try evaluate variation of experiment by hashkey,
but, evaluating a hash may depend on attributeOverrides values.
in case, attributeOverrides has user_id, no matter how much i try changing user_id by setAttribute(), experiment variation is not changes.ancient-car-96302
11/20/2024, 8:58 AMcuddly-zebra-96178
11/20/2024, 9:06 AMcuddly-zebra-96178
11/20/2024, 9:07 AMthis.attributeOverrides = gbContext.attributes
cuddly-zebra-96178
11/20/2024, 9:12 AMval growthBook = GBSDKBuilder().initialize()
growthBook.setAttributeOverrides(emptyMap())
// when attribute changed
growthBook.setAttribute()
ancient-car-96302
11/20/2024, 9:13 AMcuddly-zebra-96178
11/20/2024, 9:17 AMancient-car-96302
11/20/2024, 9:24 AMcuddly-zebra-96178
11/20/2024, 9:41 AMgrowthBook = GBSDKBuilder(
apiKey = context.getString(R.string.key_growth_book),
hostURL = "<https://cdn.growthbook.io/>",
attributes = mapOf("userId", "lastLoginedUserId"),
).initialize()
attributes is set for last user,
getFeature(featureKey) returns A
then user logout, I need to change attributes.
so I called
growthBook.setAttribute(mapOf("userId" to ""))
then call getFeature(featureKey) returns A again,
expected value is B.ancient-car-96302
11/20/2024, 9:51 AMancient-car-96302
11/20/2024, 10:05 AMcuddly-zebra-96178
11/20/2024, 10:06 AMcuddly-zebra-96178
11/20/2024, 10:06 AMcuddly-zebra-96178
11/20/2024, 10:07 AMancient-car-96302
11/20/2024, 10:20 AMcalm-dog-24239
11/20/2024, 2:04 PMcuddly-zebra-96178
11/21/2024, 1:09 AMcuddly-zebra-96178
11/21/2024, 1:10 AMcalm-dog-24239
11/30/2024, 11:46 AM