Skip to content

Commit

Permalink
Fix type of explicit parameters (#219)
Browse files Browse the repository at this point in the history
Explicit parameters are an array of strings everywhere else. Because Go stores it as a map, persisted assignments for layers cannot be shared across SDKs.

This is a breaking change for anyone using the old schema

https://app.graphite.dev/github/pr/statsig-io/kong/2487/Add-test-coverage-for-additional-fields-in-sticky-values
  • Loading branch information
kenny-statsig authored Aug 15, 2024
1 parent bd0fc41 commit 9f37bc1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
9 changes: 2 additions & 7 deletions evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type evalResult struct {
SecondaryExposures []SecondaryExposure `json:"secondary_exposures"`
UndelegatedSecondaryExposures []SecondaryExposure `json:"undelegated_secondary_exposures"`
ConfigDelegate string `json:"config_delegate"`
ExplicitParameters map[string]bool `json:"explicit_parameters"`
ExplicitParameters []string `json:"explicit_parameters"`
EvaluationDetails *EvaluationDetails `json:"evaluation_details,omitempty"`
IsExperimentGroup *bool `json:"is_experiment_group,omitempty"`
}
Expand Down Expand Up @@ -429,12 +429,7 @@ func (e *evaluator) evalDelegate(user User, rule configRule, exposures []Seconda
result.ConfigDelegate = rule.ConfigDelegate
result.SecondaryExposures = e.cleanExposures(append(exposures, result.SecondaryExposures...), context.Hash)
result.UndelegatedSecondaryExposures = exposures

explicitParams := map[string]bool{}
for _, s := range config.ExplicitParameters {
explicitParams[s] = true
}
result.ExplicitParameters = explicitParams
result.ExplicitParameters = config.ExplicitParameters
return result
}

Expand Down
7 changes: 6 additions & 1 deletion logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ func (l *logger) getLayerExposureWithEvaluationDetails(
context *logContext) *ExposureEvent {
allocatedExperiment := ""
exposures := evalResult.UndelegatedSecondaryExposures
isExplicit := evalResult.ExplicitParameters[parameterName]
isExplicit := false
for _, s := range evalResult.ExplicitParameters {
if s == parameterName {
isExplicit = true
}
}

if isExplicit {
allocatedExperiment = evalResult.ConfigDelegate
Expand Down
2 changes: 1 addition & 1 deletion user_persistent_storage_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type StickyValues struct {
SecondaryExposures []SecondaryExposure `json:"secondary_exposures"`
Time int64 `json:"time"`
ConfigDelegate string `json:"config_delegate,omitempty"`
ExplicitParameters map[string]bool `json:"explicit_parameters,omitempty"`
ExplicitParameters []string `json:"explicit_parameters,omitempty"`
UndelegatedSecondaryExposures []SecondaryExposure `json:"undelegated_secondary_exposures"`
}

Expand Down

0 comments on commit 9f37bc1

Please sign in to comment.