Skip to content

Commit

Permalink
add evaluation details to GetGate (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenny-statsig authored May 7, 2024
1 parent 6e62cb9 commit 59bf132
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ type getConfigInput struct {
func (c *Client) checkGateImpl(user User, name string, options checkGateOptions) FeatureGate {
return c.errorBoundary.captureCheckGate(func() FeatureGate {
if !c.verifyUser(user) {
return *NewGate(name, false, "", "")
return *NewGate(name, false, "", "", nil)
}
user = normalizeUser(user, *c.options)
res := c.evaluator.evalGate(user, name)
Expand All @@ -330,7 +330,7 @@ func (c *Client) checkGateImpl(user User, name string, options checkGateOptions)
c.options.EvaluationCallbacks.GateEvaluationCallback(name, res.Value, exposure)
}
}
return *NewGate(name, res.Value, res.RuleID, res.GroupName)
return *NewGate(name, res.Value, res.RuleID, res.GroupName, res.EvaluationDetails)
})
}

Expand Down
20 changes: 11 additions & 9 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ type configBase struct {
}

type FeatureGate struct {
Name string `json:"name"`
Value bool `json:"value"`
RuleID string `json:"rule_id"`
GroupName string `json:"group_name"`
Name string `json:"name"`
Value bool `json:"value"`
RuleID string `json:"rule_id"`
GroupName string `json:"group_name"`
EvaluationDetails *evaluationDetails `json:"evaluation_details"`
}

// A json blob configured in the Statsig Console
Expand All @@ -54,12 +55,13 @@ type Layer struct {
AllocatedExperimentName string `json:"allocated_experiment_name"`
}

func NewGate(name string, value bool, ruleID string, groupName string) *FeatureGate {
func NewGate(name string, value bool, ruleID string, groupName string, evaluationDetails *evaluationDetails) *FeatureGate {
return &FeatureGate{
Name: name,
Value: value,
RuleID: ruleID,
GroupName: groupName,
Name: name,
Value: value,
RuleID: ruleID,
GroupName: groupName,
EvaluationDetails: evaluationDetails,
}
}

Expand Down

0 comments on commit 59bf132

Please sign in to comment.