-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
59 lines (49 loc) · 1.58 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"context"
"github.com/devcyclehq/go-server-sdk"
"log"
"os"
"time"
)
func main() {
environmentKey := os.Getenv("DVC_SERVER_KEY")
user := devcycle.UserData{UserId: "test"}
auth := context.WithValue(context.Background(), devcycle.ContextAPIKey, devcycle.APIKey{
Key: environmentKey,
})
dvcOptions := devcycle.DVCOptions{
EnableEdgeDB: false,
DisableLocalBucketing: false,
EventsFlushInterval: 0,
PollingInterval: 10 * time.Second,
RequestTimeout: 10 * time.Second,
DisableAutomaticEventLogging: false,
DisableCustomEventLogging: false,
}
lb, err := devcycle.InitializeLocalBucketing(environmentKey, &dvcOptions)
if err != nil {
log.Fatal(err)
}
client, _ := devcycle.NewDVCClient(environmentKey, &dvcOptions, lb)
features, _ := client.DevCycleApi.AllFeatures(auth, user)
for key, feature := range features {
log.Printf("Key:%s, feature:%s", key, feature)
}
variables, _ := client.DevCycleApi.AllVariables(auth, user)
for key, variable := range variables {
log.Printf("Key:%s, feature:%v", key, variable)
}
event := devcycle.DVCEvent{
Type_: "customEvent",
Target: "somevariable.key"}
vara, _ := client.DevCycleApi.Variable(auth, user, "elliot-test", "test")
if !vara.IsDefaulted {
log.Printf("vara not defaulted:%v", vara.IsDefaulted)
}
varaDefaulted, _ := client.DevCycleApi.Variable(auth, user, "elliot-asdasd", "test")
if varaDefaulted.IsDefaulted {
log.Printf("vara defaulted:%v", varaDefaulted.IsDefaulted)
}
_, _ = client.DevCycleApi.Track(auth, user, event)
}