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
|
var sent = false
|
||||||
|
|
||||||
safe.RLock(func() {
|
safe.RLock(func() {
|
||||||
if len(bridge.users) > 0 {
|
|
||||||
for _, user := range bridge.users {
|
for _, user := range bridge.users {
|
||||||
if err := user.SendTelemetry(context.Background(), data); err == nil {
|
if err := user.SendTelemetry(context.Background(), data); err == nil {
|
||||||
sent = true
|
sent = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, bridge.usersLock)
|
}, bridge.usersLock)
|
||||||
|
|
||||||
return sent
|
return sent
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
package telemetry
|
package telemetry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ProtonMail/proton-bridge/v3/internal/updater"
|
"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) {
|
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) {
|
func (heartbeat *Heartbeat) SetNbAccount(val int) {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ func TestHeartbeat_default_heartbeat(t *testing.T) {
|
|||||||
CacheLocation: "default",
|
CacheLocation: "default",
|
||||||
KeychainPref: "default",
|
KeychainPref: "default",
|
||||||
PrevVersion: "1.2.3",
|
PrevVersion: "1.2.3",
|
||||||
Rollout: 10,
|
Rollout: "10",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ type HeartbeatDimensions struct {
|
|||||||
CacheLocation string `json:"cache_location"`
|
CacheLocation string `json:"cache_location"`
|
||||||
KeychainPref string `json:"keychain_pref"`
|
KeychainPref string `json:"keychain_pref"`
|
||||||
PrevVersion string `json:"prev_version"`
|
PrevVersion string `json:"prev_version"`
|
||||||
Rollout int `json:"rollout"`
|
Rollout string `json:"rollout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HeartbeatData struct {
|
type HeartbeatData struct {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ Feature: Send Telemetry Heartbeat
|
|||||||
"cache_location": "default",
|
"cache_location": "default",
|
||||||
"keychain_pref": "default",
|
"keychain_pref": "default",
|
||||||
"prev_version": "0.0.0",
|
"prev_version": "0.0.0",
|
||||||
"rollout": 42
|
"rollout": "42"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@ -75,7 +75,7 @@ Feature: Send Telemetry Heartbeat
|
|||||||
"cache_location": "custom",
|
"cache_location": "custom",
|
||||||
"keychain_pref": "custom",
|
"keychain_pref": "custom",
|
||||||
"prev_version": "0.0.0",
|
"prev_version": "0.0.0",
|
||||||
"rollout": 42
|
"rollout": "42"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@ -113,7 +113,7 @@ Feature: Send Telemetry Heartbeat
|
|||||||
"cache_location": "default",
|
"cache_location": "default",
|
||||||
"keychain_pref": "default",
|
"keychain_pref": "default",
|
||||||
"prev_version": "0.0.0",
|
"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"
|
When the user logs in with username "[user:user1]" and password "password"
|
||||||
And user "[user:user1]" finishes syncing
|
And user "[user:user1]" finishes syncing
|
||||||
Then bridge needs to send heartbeat
|
Then bridge needs to send heartbeat
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user