forked from Silverfish/proton-bridge
feat(GODT-2552): Fix review comment + use only string for Heartbeat Dimension.
This commit is contained in:
committed by
Romain Le Jeune
parent
d3fc9a50f6
commit
00adb8bc22
@ -59,14 +59,12 @@ func (bridge *Bridge) SendHeartbeat(heartbeat *telemetry.HeartbeatData) bool {
|
||||
var sent = false
|
||||
|
||||
safe.RLock(func() {
|
||||
if len(bridge.users) > 0 {
|
||||
for _, user := range bridge.users {
|
||||
if err := user.SendTelemetry(context.Background(), data); err == nil {
|
||||
sent = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}, bridge.usersLock)
|
||||
|
||||
return sent
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/v3/internal/updater"
|
||||
@ -41,7 +42,7 @@ func NewHeartbeat(manager HeartbeatManager, imapPort, smtpPort int, cacheDir, ke
|
||||
}
|
||||
|
||||
func (heartbeat *Heartbeat) SetRollout(val float64) {
|
||||
heartbeat.metrics.Dimensions.Rollout = int(val * 100)
|
||||
heartbeat.metrics.Dimensions.Rollout = strconv.Itoa(int(val * 100))
|
||||
}
|
||||
|
||||
func (heartbeat *Heartbeat) SetNbAccount(val int) {
|
||||
|
||||
@ -48,7 +48,7 @@ func TestHeartbeat_default_heartbeat(t *testing.T) {
|
||||
CacheLocation: "default",
|
||||
KeychainPref: "default",
|
||||
PrevVersion: "1.2.3",
|
||||
Rollout: 10,
|
||||
Rollout: "10",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ type HeartbeatDimensions struct {
|
||||
CacheLocation string `json:"cache_location"`
|
||||
KeychainPref string `json:"keychain_pref"`
|
||||
PrevVersion string `json:"prev_version"`
|
||||
Rollout int `json:"rollout"`
|
||||
Rollout string `json:"rollout"`
|
||||
}
|
||||
|
||||
type HeartbeatData struct {
|
||||
|
||||
@ -31,7 +31,7 @@ Feature: Send Telemetry Heartbeat
|
||||
"cache_location": "default",
|
||||
"keychain_pref": "default",
|
||||
"prev_version": "0.0.0",
|
||||
"rollout": 42
|
||||
"rollout": "42"
|
||||
}
|
||||
}
|
||||
"""
|
||||
@ -75,7 +75,7 @@ Feature: Send Telemetry Heartbeat
|
||||
"cache_location": "custom",
|
||||
"keychain_pref": "custom",
|
||||
"prev_version": "0.0.0",
|
||||
"rollout": 42
|
||||
"rollout": "42"
|
||||
}
|
||||
}
|
||||
"""
|
||||
@ -113,7 +113,7 @@ Feature: Send Telemetry Heartbeat
|
||||
"cache_location": "default",
|
||||
"keychain_pref": "default",
|
||||
"prev_version": "0.0.0",
|
||||
"rollout": 42
|
||||
"rollout": "42"
|
||||
}
|
||||
}
|
||||
"""
|
||||
@ -127,4 +127,3 @@ Feature: Send Telemetry Heartbeat
|
||||
When the user logs in with username "[user:user1]" and password "password"
|
||||
And user "[user:user1]" finishes syncing
|
||||
Then bridge needs to send heartbeat
|
||||
|
||||
|
||||
Reference in New Issue
Block a user