Skip to content

Commit 18bd0b4

Browse files
author
tjj5036
committed
Starts generating goal name... after I figure out the format I'll update accordingly
1 parent 4613437 commit 18bd0b4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

optimizely/utils.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ package optimizely
33
import (
44
"fmt"
55
"net/url"
6+
"strings"
67
)
78

9+
const REVENUE_GOAL_KEY = "Total Revenue"
10+
811
// GetGoalIdFromProjectConfig returns the goal that matches the event key
912
// The wording here is a bit confusing
1013
func GetGoalIdFromProjectConfig(event_key string, project_config ProjectConfig) string {
@@ -101,3 +104,20 @@ func GetVariationKeyFromId(experiment_key string, variation_id string, experimen
101104
}
102105
return ""
103106
}
107+
108+
// Gets a list of all goal keys in the project except "Total Revenue"
109+
func GetGoalKeys(events []EventEntity) []string {
110+
var goal_keys = make([]string, 0)
111+
for i := 0; i < len(events); i++ {
112+
if events[i].Key != REVENUE_GOAL_KEY {
113+
goal_keys = append(goal_keys, events[i].Key)
114+
}
115+
}
116+
return goal_keys
117+
}
118+
119+
// Generates a Goal Name for `Activate`
120+
func GenerateGoalName(events []EventEntity) string {
121+
var goal_name = strings.Join(GetGoalKeys(events), ",")
122+
return goal_name
123+
}

0 commit comments

Comments
 (0)