Improve login failure analytics
This commit is contained in:
parent
2a3acbff1b
commit
bbfb5e7b5b
2 changed files with 5 additions and 2 deletions
|
@ -504,12 +504,13 @@ Loop:
|
|||
jsonResponse(w, http.StatusOK, LoginResponse{Status: "qr", Code: item.qr})
|
||||
case item.err != nil:
|
||||
log.Err(item.err).Msg("Got error in QR channel")
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "qr"})
|
||||
var resp LoginResponse
|
||||
switch {
|
||||
case errors.Is(item.err, ErrLoginTimeout):
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "qr", "error": "user timeout"})
|
||||
resp = LoginResponse{ErrCode: "timeout", Error: "Scanning QR code timed out"}
|
||||
default:
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "qr", "error": "unknown"})
|
||||
resp = LoginResponse{ErrCode: "unknown", Error: "Login failed"}
|
||||
}
|
||||
resp.Status = "fail"
|
||||
|
|
4
user.go
4
user.go
|
@ -568,7 +568,9 @@ func (user *User) LoginGoogle(ctx context.Context, cookies map[string]string, em
|
|||
case errors.Is(err, libgm.ErrPairingCancelled):
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "google", "error": "cancelled"})
|
||||
case errors.Is(err, libgm.ErrPairingTimeout):
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "google", "error": "timeout"})
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "google", "error": "user timeout"})
|
||||
case errors.Is(err, libgm.ErrPairingInitTimeout):
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "google", "error": "init timeout"})
|
||||
default:
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "google", "error": "unknown"})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue