mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-10 22:29:00 +08:00
fix: set userId as distinctId if failed to fetch IP
This commit is contained in:
parent
938f42bd4f
commit
10faa6f42b
@ -22,6 +22,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const api_key = "4Gmoa4ixJAUHx2BpJxsjwA1bEfnwEeRz"
|
const api_key = "4Gmoa4ixJAUHx2BpJxsjwA1bEfnwEeRz"
|
||||||
|
const IP_NOT_FOUND_PLACEHOLDER = "NA"
|
||||||
|
|
||||||
var telemetry *Telemetry
|
var telemetry *Telemetry
|
||||||
var once sync.Once
|
var once sync.Once
|
||||||
@ -59,7 +60,7 @@ func createTelemetry() {
|
|||||||
// Get preferred outbound ip of this machine
|
// Get preferred outbound ip of this machine
|
||||||
func getOutboundIP() string {
|
func getOutboundIP() string {
|
||||||
|
|
||||||
ip := []byte("NA")
|
ip := []byte(IP_NOT_FOUND_PLACEHOLDER)
|
||||||
resp, err := http.Get("https://api.ipify.org?format=text")
|
resp, err := http.Get("https://api.ipify.org?format=text")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -116,7 +117,7 @@ func (a *Telemetry) SendEvent(event string, data map[string]interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userId := a.ipAddress
|
userId := a.ipAddress
|
||||||
if a.isTelemetryAnonymous() {
|
if a.isTelemetryAnonymous() || userId == IP_NOT_FOUND_PLACEHOLDER {
|
||||||
userId = a.GetDistinctId()
|
userId = a.GetDistinctId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user