@@ -77,6 +77,37 @@ func (client *OptimizelyClient) Track(
77
77
// user_id: ID for user
78
78
// attributes: optional list representing visitor attributes and values
79
79
func (client * OptimizelyClient ) Activate (experiment_key string , user_id string , attributes []AttributeEntity ) {
80
+ var valid_experiment = false
81
+ var experiment_id = ""
82
+ for i := 0 ; i < len (client .project_config .Experiments ); i ++ {
83
+ if client .project_config .Experiments [i ].Key == experiment_key {
84
+ if ExperimentIsRunning (client .project_config .Experiments [i ]) {
85
+ valid_experiment = true
86
+ experiment_id = client .project_config .Experiments [i ].Id
87
+ }
88
+ }
89
+ }
90
+
91
+ if ! valid_experiment {
92
+ return
93
+ }
94
+
95
+ end_user_id := fmt .Sprintf (END_USER_ID_TEMPLATE , user_id )
96
+ //variation_id := client.Bucket(experiment_key, user_id)
97
+
98
+ parameters := url.Values {}
99
+ parameters .Add (ACCOUNT_ID , client .account_id )
100
+ parameters .Add (PROJECT_ID , client .project_config .ProjectId )
101
+ parameters .Add (GOAL_NAME , "TODO" )
102
+ parameters .Add (GOAL_ID , experiment_id )
103
+ parameters .Add (END_USER_ID , end_user_id )
104
+
105
+ // Set attribute params if any
106
+ if len (attributes ) > 0 {
107
+ BuildAttributeParams (client .project_config , attributes , parameters )
108
+ }
109
+
110
+ // TODO dispatch event
80
111
81
112
}
82
113
0 commit comments