Skip to content

Commit

Permalink
fix: assignment track defaults and details (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori authored Dec 21, 2023
1 parent f0d4504 commit b46239f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/experiment/local/assignment_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func toEvent(assignment *assignment) amplitude.Event {

// Loop to set event_properties
for resultsKey, result := range assignment.results {
version, _ := result.Metadata["version"].(int)
version, _ := result.Metadata["flagVersion"].(float64)
segmentName, _ := result.Metadata["segmentName"].(string)
event.EventProperties[fmt.Sprintf("%s.variant", resultsKey)] = result.Key
if version != 0 && len(segmentName) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/experiment/local/assignment_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ func TestToEvent(t *testing.T) {
Key: "on",
Metadata: map[string]interface{}{
"segmentName": "Segment",
"version": 13,
"flagVersion": float64(13),
},
},
"flag-key-2": {
Key: "control",
Metadata: map[string]interface{}{
"default": true,
"segmentName": "All Other Users",
"version": 12,
"flagVersion": float64(12),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/experiment/local/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Initialize(apiKey string, config *Config) *Client {
config = fillConfigDefaults(config)
log := logger.New(config.Debug)
var as *assignmentService
if config.AssignmentConfig != nil && config.AssignmentConfig.Config.IsValid() {
if config.AssignmentConfig != nil && config.AssignmentConfig.APIKey != "" {
amplitudeClient := amplitude.NewClient(config.AssignmentConfig.Config)
as = &assignmentService{
amplitude: &amplitudeClient,
Expand Down

0 comments on commit b46239f

Please sign in to comment.