Hey Hi All! Someone who has done whole DB setup wi...
# ask-questions
f
Hey Hi All! Someone who has done whole DB setup with postgres , kindly help me! I am stuck for 2 days here!
f
Hi Star
if we break the problems down in to a few pieces
Were you able to get the SDK to correctly bucket users?
f
As in passing the exact attributed to the flag in my SDK?
f
like the code you were playing with earlier
were you able to get the feature to turn on and off with the flag?
f
yes
thats working
f
okay cool
so where are you stuck now?
f
1. I have created a A/B experiment for that feature flad. What I expect if my feature flag is on. I should see a metric / graph in my experimentation
Thats not happening
2. I see we have to connect to a database and I am using postgres for that. I have created viewed_experiments with 4 columns.
Nothing is happening on that table!
Acrually I need to complete two complex POC. I can only do that if I am unblocked else we might not go for this product
Copy code
{
  "status": 200,
  "features": {
    "test-feature": {
      "defaultValue": true,
      "rules": [
        {
          "condition": {
            "loggedIn": true
          },
          "variations": [
            true,
            false
          ],
          "coverage": 1,
          "weights": [
            0.5,
            0.5
          ],
          "key": "test-feature-tracking",
          "hashAttribute": "id"
        }
      ]
    }
  },
  "dateUpdated": "2023-03-15T08:43:57.399Z"
}
Screenshot 2023-03-16 at 7.41.36 AM.png
Screenshot 2023-03-16 at 7.42.34 AM.png
f
okay - what do you have for your trackingCallback?
f
Copy code
context := growthbook.NewContext().
		WithFeatures(features).WithTrackingCallback(func(experiment *growthbook.Experiment, result *growthbook.ExperimentResult) {
		log.Println("Viewed Experiment")
		log.Println("Experiment Id", experiment.Key)
		log.Println("Variation Id", result.VariationID)
	})
f
okay
so GrowthBook doesn’t do the event tracking for you
so you’d need to have some way to fire that event to whatever event tracking you’re using
do you have an event tracker now?
f
I am not aware of that
Like how event tracker works?
f
Screen Shot 2023-03-15 at 7.20.10 PM.png
you can use any event tracking you like - RudderStack, Google Analytics, Segment, Jitsu, Snowplow, etc
how do you track events on your product currently?
f
We dont have explicit event tracking mechanism for the product
I was hoping to integrate with postgres some how
f
yes, Rudderstack, Jitsu, or Segment would let you do that
f
so basically what I understand is between postgres and growtbook I need to keep jitsu for event tracking ?
DO you have some sample code etc around that?
f
there isn’t much code to add
just something like jitsu.track(experiment.key, result.VariationID)
You want to use an event tracker as doing that data pipelining is non-trivial and you want to have them batched when writing to your database
f
I am sorry I cannot understand that part.
f
you can typically break data into two parts, application data (like users, states, etc), and analytics data (event tracking, etc) - for application data, having the right data is critical, so you will wait for that data to load. For analytics data, it’s not critical, so you want to have it not disrupt your user’s experience.
So eventually consistency is okay for analytics data
thats where event trackers come into play
f
ok I hope it could have been done with kafka etc. or something integrated with Growthbook
I have one more question. So Growthbook can only be connected through events. Why do we have database connection anyways then?
I was hoping that we can create alternative rules in feature flags based on users in the database. Or we can enable a feature flag for only certain users in that database. So for that, we need to provide some kind of DB connection.
Screenshot 2023-03-16 at 8.13.15 AM.png
f
you can do that, but you have to push that db info down to the SDK level
to make the evaluation very fast, waiting for a DB request would be too slow for most users.
that data source page is for pulling exposure information and generating reports of experiments
f
so correct me if I am wrong. What I understand is 1) TO get userbase info we need to call user from our own database in my golang code, based on that i need to add attributes in the context and make a call to Growthbook. After that I need to update my Database if the experiment ran from my golang code only. The job of Grwothbook there is just to read the updated data and show metrics out of it
f
yes, pretty close
f
is write operation from growthbook to database is possible ?
is the growth book acts as a lister service only?
f
We do all the parts except tracking
f
got it so it does evaluation and acts as a listener service