Check status code when tracking segment events

This commit is contained in:
Tulir Asokan 2022-05-16 15:24:26 +03:00
parent 46ba3981c1
commit 4264c50558

View file

@ -19,6 +19,7 @@ package main
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"net/http" "net/http"
log "maunium.net/go/maulogger/v2" log "maunium.net/go/maulogger/v2"
@ -55,7 +56,10 @@ func (sc *SegmentClient) trackSync(userID id.UserID, event string, properties ma
if err != nil { if err != nil {
return err return err
} }
defer resp.Body.Close() _ = resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("unexpected status code %d", resp.StatusCode)
}
return nil return nil
} }