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
1 changed files with 5 additions and 1 deletions

View File

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