Added crash filtering
Added version field to individual crash
This commit is contained in:
@@ -61,6 +61,7 @@ Users are stored per backend and not per app.
|
||||
{
|
||||
count: 1, // We do not store duplicates. If a duplicate does occur
|
||||
platform: "android",
|
||||
appVersion: "v1.0.0", // Application version
|
||||
error: "error",
|
||||
stack: "stacktrace"
|
||||
}
|
||||
@@ -279,6 +280,7 @@ Request Body:
|
||||
{
|
||||
id: "UUID", // This is an ignored value, but it is highly recommended to include it to prevent reporting the same crash multiple times.
|
||||
platform: "android",
|
||||
appVersion: "v1.0.0",
|
||||
error: "error",
|
||||
stack: "stacktrace"
|
||||
}
|
||||
|
||||
@@ -9,6 +9,12 @@ type App interface {
|
||||
CrashTable() CrashTable
|
||||
}
|
||||
|
||||
// Allows for an App to filter crashes before they get added to the DB, such as making sure the crash is from the correct version.
|
||||
type CrashFilterApp interface {
|
||||
App
|
||||
AddCrash(IndividualCrash) bool
|
||||
}
|
||||
|
||||
type ExtendedApp interface {
|
||||
// Extension is called for any calls to /{appID}/
|
||||
// Alternatively, use Backend.HandleFunc for more customizability
|
||||
|
||||
@@ -14,10 +14,11 @@ type ArchivedCrash struct {
|
||||
}
|
||||
|
||||
type IndividualCrash struct {
|
||||
Platform string `json:"platform" bson:"platform"`
|
||||
Error string `json:"error" bson:"error"`
|
||||
Stack string `json:"stack" bson:"stack"`
|
||||
Count int `json:"count" bson:"count"`
|
||||
Platform string `json:"platform" bson:"platform"`
|
||||
AppVersion string `json:"appVersion" bson:"appVersion"`
|
||||
Error string `json:"error" bson:"error"`
|
||||
Stack string `json:"stack" bson:"stack"`
|
||||
Count int `json:"count" bson:"count"`
|
||||
}
|
||||
|
||||
type CrashReport struct {
|
||||
@@ -43,10 +44,15 @@ func (b *Backend) reportCrash(w http.ResponseWriter, r *http.Request) {
|
||||
defer r.Body.Close()
|
||||
var crash IndividualCrash
|
||||
err = json.NewDecoder(r.Body).Decode(&crash)
|
||||
if err != nil || crash.Platform == "" || crash.Error == "" || crash.Stack == "" {
|
||||
if err != nil || crash.Platform == "" || crash.AppVersion == "" || crash.Error == "" || crash.Stack == "" {
|
||||
ReturnError(w, http.StatusBadRequest, "invalidBody", "Bad request")
|
||||
return
|
||||
}
|
||||
if filter, ok := ap.(CrashFilterApp); ok {
|
||||
if !filter.AddCrash(crash) {
|
||||
return
|
||||
}
|
||||
}
|
||||
tab := ap.CrashTable()
|
||||
if tab == nil {
|
||||
log.Printf("key %v has crash permission, but app does not have a crash table", hdr.Key.AppID)
|
||||
@@ -60,8 +66,8 @@ func (b *Backend) reportCrash(w http.ResponseWriter, r *http.Request) {
|
||||
ReturnError(w, http.StatusInternalServerError, "internal", "Server error")
|
||||
return
|
||||
}
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
}
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
}
|
||||
|
||||
func (b *Backend) deleteCrash(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package db
|
||||
|
||||
/*
|
||||
TODO
|
||||
Currently there isn't a clean way to implement this (as far as I can tell).
|
||||
Currently there isn't a easy and clean way to implement this (as far as I can tell).
|
||||
valkey-go relies on an internal library for it's command builder, which makes it impossible to
|
||||
use properly for generics without manually writing out the Index command. I could probably do this, but
|
||||
it's a pain.
|
||||
|
||||
@@ -33,7 +33,6 @@ func NewBlogApp(b *backend.Backend, db *mongo.Database, mux *http.ServeMux) *Blo
|
||||
mux.HandleFunc("GET /author/{authorID}", out.reqAuthorInfo)
|
||||
mux.HandleFunc("POST /author", out.addAuthorInfo)
|
||||
mux.HandleFunc("POST /author/{authorID}", out.updateAuthorInfo)
|
||||
//TODO
|
||||
return out
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user