https://www.growthbook.io/ logo
c

cool-apple-97384

09/22/2022, 4:47 AM
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

fresh-football-47124

09/22/2022, 4:48 AM
Hi Chandra - which SDK?
c

cool-apple-97384

09/22/2022, 4:49 AM
I use Flutter SDK @fresh-football-47124, thanks for the response
f

fresh-football-47124

09/22/2022, 4:55 AM
(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

cool-apple-97384

09/22/2022, 4:58 AM
I see, the hostURL is API url not url self hosted?
f

fresh-football-47124

09/22/2022, 4:58 AM
if you’re self hosting, it will be a different url
c

cool-apple-97384

09/22/2022, 4:59 AM
Yes, we have dashboard url and api url. So I need to add API or dashboard?
f

fresh-football-47124

09/22/2022, 4:59 AM
You can get the url from the implementation instructions
go to features, then click on “show setup steps” then click on “view instructions”
c

cool-apple-97384

09/22/2022, 5:01 AM
Hi @fresh-football-47124 can you refers a document how to update the attributes?
f

fresh-football-47124

09/22/2022, 5:04 AM
Hrmm, looking at the code
@glamorous-florist-39551 do you know?
g

glamorous-florist-39551

09/22/2022, 5:36 AM
@gifted-cat-24658 Can you help @cool-apple-97384?
g

gifted-cat-24658

09/22/2022, 6:13 AM
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

cool-apple-97384

09/22/2022, 6:16 AM
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

gifted-cat-24658

09/22/2022, 6:20 AM
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

cool-apple-97384

09/22/2022, 6:25 AM
Any solution to update attributes @gifted-cat-24658?
g

gifted-cat-24658

09/22/2022, 6:29 AM
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

cool-apple-97384

09/22/2022, 6:30 AM
So, my code above is the solution?
g

gifted-cat-24658

09/22/2022, 6:31 AM
Yes !!
You can go ahead and create pr for this.
c

cool-apple-97384

09/22/2022, 6:33 AM
Ok thanks team for the solution. @gifted-cat-24658 @glamorous-florist-39551 @fresh-football-47124
👍 2