Hello! I implemented the SDK without issues, featu...
# sdk-flutter
f
Hello! I implemented the SDK without issues, feature flags are working properly, they update once it is changed in the dashboard, so all good there. The problem I am having is with the AB experiments, they simply are not showing up. I tested and debugged with 3 different feature flags, the experiments field/attribute in the feature flags never comes with data. Any ideas on what could be happening?
f
What are you using for your data tracking?
did you set up the tracking callback?
f
It's not returning the Experiments, so it never triggers the callback.
f
in the endpoint JSON?
f
In the GBFeatureResult, example:
Copy code
growthBookSDK.feature('test')
the attributes
experiment
or
experimentResult
always comes as null.
f
can you verify that the experiment is there in the JSON?
as a rule?
f
Yes i tested with 3 and none returned, the value didn't change either
only changes if I change the feature flag directly in the dashboard
f
are you setting attributes?
f
Yes, but I am not filtering the AB test per attributes, I was just testing if AB test worked, targeted all users
f
it needs some attribute to do the assignment deterministically - so it needs to be defined in both the GrowthBook UI and then that attribute must be set in the SDK implementation
f
So we can't test against all users?
this has to have always an attribute targeting?
f
yes
targeting is different from the randomization unit
It will be marked as "*Assignment Attribute" or "Split"*
f
Ok, seems like the attributes we are passing are not showing up in the dashboard. We are using the
.setAttributes(attributes)
, doesn't error, but doesn't show the attributes.
Will test using any attribute that already shows there
f
setAttributes usually overwrites (though haven't checked flutter)
f
Just tested using an existing attribute called deviceType
.setAttributes(<String, dynamic>{'deviceType':'mobile'});
and targeting the ab test to this attribute, still not showing:
We can look better into this tomorrow, just wanted to give all the info possible, I'm heading out now, but thanks for the quick replies!
f
okay
would be helpful to paste JSON of the feature states (from the SDK endpoint)
f
On flutter it is all done within the SDK, I can try to debug the SDK code to get it, but not sure if possible.
f
I mean, if you go to GrowthBook
the SDK endpoint that your app is ingesting
there will be a link to the full endpoint
which you can just open in a browser
it is encrypted
f
ah
less helpful 🙂
🤣 1
f
No worries, lets continue tomorrow, I can maybe turn off the encryption for testing purposes and facilitate setting everything up
Disabled the encryption, still working for feature flags, but still not working for experiments. In the json it shows up, seems like the SDK doesn't connect it to the feature flag The JSON:
Copy code
{
  "status": 200,
  "features": {
    "login_enteryouremail": {
      "defaultValue": false,
      "rules": [
        {
          "coverage": 1,
          "hashAttribute": "id",
          "seed": "2883c3e1-a0d1-4e5a-a127-9534deb44e27",
          "hashVersion": 2,
          "variations": [
            false,
            true
          ],
          "weights": [
            0.5,
            0.5
          ],
          "key": "login_email_title_test_4",
          "meta": [
            {
              "key": "0",
              "name": "Control"
            },
            {
              "key": "1",
              "name": "Variation 1"
            }
          ],
          "phase": "0",
          "name": "login_email_title_test_4"
        }
      ]
    },
    "payments.avs": {
      "defaultValue": "N"
    },
    "test_december": {
      "defaultValue": "default_value",
      "rules": [
        {
          "condition": {
            "deviceType": "mobile"
          },
          "coverage": 1,
          "hashAttribute": "id",
          "bucketVersion": 1,
          "seed": "0e88a490-7afb-43c8-a0e8-6be72cded181",
          "hashVersion": 2,
          "variations": [
            "Control_value",
            "variation1_value"
          ],
          "weights": [
            0.5,
            0.5
          ],
          "key": "ab-test-validation-december",
          "meta": [
            {
              "key": "0",
              "name": "Control"
            },
            {
              "key": "1",
              "name": "Variation 1"
            }
          ],
          "phase": "0",
          "name": "AB test Validation December"
        }
      ]
    }
  },
  "dateUpdated": "2024-12-10T18:01:36.926Z"
}
@fresh-football-47124 whenever you are available to help out 🙂
Maybe @calm-dog-24239 can help?
c
Hi, @flaky-vase-27115. Yes, sure we can help you with that.
We will check that and get back to you after weekends on Monday.
thankyou 2
m
hello! any updates here?
f
I see you're setting a condition on that experiment
actually - what is the feature name you're debugging?
"test_december" has the condition of "deviceType" = "mobile"
are you setting deviceType to "mobile" as an attribute?
f
Yes I am, I had no conditions but then you told me to add one, I added, but still doesn't work.
I don't think the Flutter SDK is parsing the experiments properly for the features
f
@calm-dog-24239 are you able to take a look now that we have the payload? Can we reproduce it?
c
Hi @fresh-football-47124. Yes, sure. We will do that. I will write tomorrow as soon as we will reproduce that.
Hi, @flaky-vase-27115. As we understand that it is the same issue to Github. We assume that you are passing only the deviceType attribute and not the id attribute to retrieve the experiment and experiment result from the feature result. We noticed that you have a hashed attribute - id from the backend, and you should use it in the evaluation process because it is involved in hashing functions and determines which user attribute should be used to assign variations.
f
Hello, I was not able to understand this response, can you rephrase it? If you look at the thread I was using the hashed version, cyphered, but then I disabled it to send the json to you, but it wasn't working even before that. What do you mean by id attribute to retrieve the experiment? The feature is being returned, so that doesn't make much sense to me that the Experiment wouldn't be able to be parsed for those reasons, I tested without any filtering by device type already and it didn't work either. If you can send me an example code that works that would be helpful.
This is how I am setting up, and the feature flags work:
Copy code
await GBSDKBuilderApp(
  hostURL: '<https://cdn.growthbook.io/>',
  apiKey: GROWTHBOOK_API_KEY,
  encryptionKey: GROWTHBOOK_DECRYPT_KEY,
  growthBookTrackingCallBack: (GBExperiment gbExperiment, GBExperimentResult gbExperimentResult) {
    // TODO: Use your real analytics tracking system
    log('Viewed Experiment');
    log('Experiment Id: ${gbExperiment.key}');
    log('Variation Id: ${gbExperimentResult.variationID}');
    log('Variation Value: ${gbExperimentResult.value}');
  },
).initialize()
f
where are you setting the attributes?
f
Before calling for the feature.
I don't see anywhere in the code examples where I should pass this id attribute
Is it the user id attribute?
f
"hashAttribute":"id"
the SDK is expecting to find an attribute called "id"
are you calling it something else?
f
I am not sending anything like this, since I wasn't aware this was necessary
I don't see this in the documentation
Will test now
Copy code
.setAttributes({
      'hashAttribute': 'id',
      'deviceType': 'mobile',
    });
Is this what I should be doing?
c
No, it needs to be like this. final userAttr = {“id”: 1, “deviceType”: “mobile”};
And then pass it to setAttributes function
f
It worked!
🙌 1
c
Awesome
f
So the user needs to have an id, in case we need to use it before signup we have to generate a random ID for it I guess, is there a way to link an ID with an existing one?
f
for the record - all experiments are assigned by hashing together the experiment key/name and some attribute of the user, which is defined when you set up the experiment.
you can use any id, but if it changes, the assignment may change
f
I see, it might make more sense for us to use the email as the id instead of the ID we use internally then, so we can make sure the flags are always the same for the user.
f
up to you, but it should be invariant for the user
but can be anything
and doesn't have to be the same thing you use on the reporting side for analysis
f
It's because before signup we don't have an ID for the user, only after signup, or login
f
right
usually most tracking systems will have some kind of anonymous id
that will be the same on either side of a register/signup flow
or you can set your own
f
Yes, but it changes per session
We'll test what best fits our needs, thanks for the support!
🙌 1
m
thank you very much @fresh-football-47124 @calm-dog-24239 - appreciate the your help. cc @orange-cartoon-87538 @ripe-rocket-19996 FYI
🙌 2