Analytics bugfix (#1195)

This commit is contained in:
Soam Vasani
2019-06-02 10:10:44 +08:00
committed by Ta-Ching Chen
parent 1d266537b0
commit 6bab9dcbaa
+3 -3
View File
@@ -17,7 +17,7 @@ type (
url string url string
} }
AnalyticsData struct { AnalyticsData struct {
id string ID string `json:"ID"`
FunctionCallCount uint64 `json:"FunctionCallCount"` FunctionCallCount uint64 `json:"FunctionCallCount"`
} }
) )
@@ -49,14 +49,14 @@ func (a *Analytics) run() {
ticker := time.NewTicker(24 * time.Hour) ticker := time.NewTicker(24 * time.Hour)
for range ticker.C { for range ticker.C {
msg := a.gatherData() msg := a.gatherData()
msg.id = a.id msg.ID = a.id
msgbytes, err := json.Marshal(*msg) msgbytes, err := json.Marshal(*msg)
if err != nil { if err != nil {
continue continue
} }
resp, err := http.Post(a.url, "application/json", bytes.NewReader(msgbytes)) resp, _ := http.Post(a.url, "application/json", bytes.NewReader(msgbytes))
if resp != nil { if resp != nil {
// close response body to prevent resources leak // close response body to prevent resources leak
resp.Body.Close() resp.Body.Close()