Add analytics events for google login
This commit is contained in:
parent
159bc453ec
commit
ea507552b0
2 changed files with 17 additions and 4 deletions
|
@ -501,7 +501,7 @@ 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")
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "qr"})
|
||||
var resp LoginResponse
|
||||
switch {
|
||||
case errors.Is(item.err, ErrLoginTimeout):
|
||||
|
@ -513,7 +513,7 @@ Loop:
|
|||
jsonResponse(w, http.StatusOK, resp)
|
||||
case item.success:
|
||||
log.Debug().Msg("Got pair success in QR channel")
|
||||
Analytics.Track(user.MXID, "$login_success")
|
||||
Analytics.Track(user.MXID, "$login_success", map[string]any{"mode": "qr"})
|
||||
jsonResponse(w, http.StatusOK, LoginResponse{Status: "success"})
|
||||
default:
|
||||
log.Error().Any("item_data", item).Msg("Unknown item in QR channel")
|
||||
|
|
17
user.go
17
user.go
|
@ -416,7 +416,7 @@ func (user *User) Login(maxAttempts int) (<-chan qrChannelItem, error) {
|
|||
user.loginInProgress.Store(false)
|
||||
return nil, fmt.Errorf("failed to connect to Google Messages: %w", err)
|
||||
}
|
||||
Analytics.Track(user.MXID, "$login_start")
|
||||
Analytics.Track(user.MXID, "$login_start", map[string]any{"mode": "qr"})
|
||||
ch := make(chan qrChannelItem, maxAttempts+2)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
user.cancelLogin = cancel
|
||||
|
@ -555,12 +555,25 @@ func (user *User) LoginGoogle(ctx context.Context, cookies map[string]string, em
|
|||
authData := libgm.NewAuthData()
|
||||
authData.Cookies = cookies
|
||||
user.createClient(authData)
|
||||
Analytics.Track(user.MXID, "$login_start")
|
||||
Analytics.Track(user.MXID, "$login_start", map[string]any{"mode": "google"})
|
||||
err := user.Client.DoGaiaPairing(ctx, emojiCallback)
|
||||
if err != nil {
|
||||
user.unlockedDeleteConnection()
|
||||
switch {
|
||||
case errors.Is(err, libgm.ErrNoDevicesFound):
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "google", "error": "no devices"})
|
||||
case errors.Is(err, libgm.ErrIncorrectEmoji):
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "google", "error": "incorrect emoji"})
|
||||
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"})
|
||||
default:
|
||||
Analytics.Track(user.MXID, "$login_failure", map[string]any{"mode": "google", "error": "unknown"})
|
||||
}
|
||||
return err
|
||||
}
|
||||
Analytics.Track(user.MXID, "$login_success", map[string]any{"mode": "google"})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue