Hi all... I'm new here. Anyone can help me about s...
# ask-questions
c
Hi all... I'm new here. Anyone can help me about several information when call SDK Instance. •
hostUrl
, it's dashboard url for self hosted growthbook? •
attributes
, it's user attributes or sdk attributes? If user attributes, we need to instance SDK after login to give experiments in specific user?
f
Hi Chandra - which SDK?
c
I use Flutter SDK @fresh-football-47124, thanks for the response
f
(sorry, was just checking the code)
api = context.hostURL! + Constant.featurePath + context.apiKey!;
so the hostURL will be the full url to the api end point that serves the json file of features. If you’re using the cloud it will be https://cdn.growthbook.io/.
(include the final slash)
attributes are the user attributes (like user id, country, etc). You can update the attributes at any time
(it will re-evaluate the flags)
c
I see, the hostURL is API url not url self hosted?
f
if you’re self hosting, it will be a different url
c
Yes, we have dashboard url and api url. So I need to add API or dashboard?
f
You can get the url from the implementation instructions
go to features, then click on “show setup steps” then click on “view instructions”
c
Hi @fresh-football-47124 can you refers a document how to update the attributes?
f
Hrmm, looking at the code
@glamorous-florist-39551 do you know?
g
@gifted-cat-24658 Can you help @cool-apple-97384?
g
Hey, @cool-apple-97384 you can use use GbContext update attributes for now.
Copy code
void updateAttr(Map<String, dynamic> attr) {
    _sdkInstance.context.attributes = attr;
}
In upcoming release we will provide direct functionality to update attributes from
GrowthBookSDK
. And her
_sdkInstance
is
GrowthBookSDK
.
c
Hi @gifted-cat-24658 thanks for your help, I try to call context first. But, I did'nt found
updateAttr
. I just got
attributes
Have you see context.dart?
When you want to change updateAttributes under sdkInstance, it's will breaking changes in next version?
It's will be same solution when we call
sdkInstance.context.attributes.update
or
sdkInstance.context.attributes.updateAll
?
g
Yes, it is going to be breaking change. You can migrate later. Till then you can point to the previous version of sdk.
I am planning to provide functionality to
add
(spread over) and
reset
.
c
Any solution to update attributes @gifted-cat-24658?
g
So i’ll suggest you to create a service around
GrowthBookSDK
and then you can use as following.
Copy code
void spreadAttr({Map<String, dynamic> attributes = const {}}) {
    for (var attrPair in attributes!.entries) {
      _sdkInstance.context.attributes!
          .putIfAbsent(attrPair.key, () => attrPair.value);
    }
  }
But in future releases you will able to do so from
GrowthBookSDK
.
c
So, my code above is the solution?
g
Yes !!
You can go ahead and create pr for this.
c
Ok thanks team for the solution. @gifted-cat-24658 @glamorous-florist-39551 @fresh-football-47124
👍 2