mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-15 00:16:07 +08:00
chore: segment oss (#5910)
Co-authored-by: Prashant Shahi <prashant@signoz.io>
This commit is contained in:
parent
3c151e3adb
commit
573d369d4b
@ -25,6 +25,11 @@ var ConfigSignozIo = "https://config.signoz.io/api/v1"
|
|||||||
|
|
||||||
var DEFAULT_TELEMETRY_ANONYMOUS = false
|
var DEFAULT_TELEMETRY_ANONYMOUS = false
|
||||||
|
|
||||||
|
func IsOSSTelemetryEnabled() bool {
|
||||||
|
ossSegmentKey := GetOrDefaultEnv("OSS_TELEMETRY_ENABLED", "true")
|
||||||
|
return ossSegmentKey == "true"
|
||||||
|
}
|
||||||
|
|
||||||
const MaxAllowedPointsInTimeSeries = 300
|
const MaxAllowedPointsInTimeSeries = 300
|
||||||
|
|
||||||
func IsTelemetryEnabled() bool {
|
func IsTelemetryEnabled() bool {
|
||||||
|
@ -204,11 +204,19 @@ func createTelemetry() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
telemetry = &Telemetry{
|
if constants.IsOSSTelemetryEnabled() {
|
||||||
ossOperator: analytics.New(api_key),
|
telemetry = &Telemetry{
|
||||||
ipAddress: getOutboundIP(),
|
ossOperator: analytics.New(api_key),
|
||||||
rateLimits: make(map[string]int8),
|
ipAddress: getOutboundIP(),
|
||||||
activeUser: make(map[string]int8),
|
rateLimits: make(map[string]int8),
|
||||||
|
activeUser: make(map[string]int8),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
telemetry = &Telemetry{
|
||||||
|
ipAddress: getOutboundIP(),
|
||||||
|
rateLimits: make(map[string]int8),
|
||||||
|
activeUser: make(map[string]int8),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
telemetry.minRandInt = 0
|
telemetry.minRandInt = 0
|
||||||
telemetry.maxRandInt = int(1 / DEFAULT_SAMPLING)
|
telemetry.maxRandInt = int(1 / DEFAULT_SAMPLING)
|
||||||
@ -484,16 +492,18 @@ func (a *Telemetry) IdentifyUser(user *model.User) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
a.ossOperator.Enqueue(analytics.Identify{
|
if a.ossOperator != nil {
|
||||||
UserId: a.ipAddress,
|
a.ossOperator.Enqueue(analytics.Identify{
|
||||||
Traits: analytics.NewTraits().SetName(user.Name).SetEmail(user.Email).Set("ip", a.ipAddress),
|
UserId: a.ipAddress,
|
||||||
})
|
Traits: analytics.NewTraits().SetName(user.Name).SetEmail(user.Email).Set("ip", a.ipAddress),
|
||||||
// Updating a groups properties
|
})
|
||||||
a.ossOperator.Enqueue(analytics.Group{
|
// Updating a groups properties
|
||||||
UserId: a.ipAddress,
|
a.ossOperator.Enqueue(analytics.Group{
|
||||||
GroupId: a.getCompanyDomain(),
|
UserId: a.ipAddress,
|
||||||
Traits: analytics.NewTraits().Set("company_domain", a.getCompanyDomain()),
|
GroupId: a.getCompanyDomain(),
|
||||||
})
|
Traits: analytics.NewTraits().Set("company_domain", a.getCompanyDomain()),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Telemetry) SetUserEmail(email string) {
|
func (a *Telemetry) SetUserEmail(email string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user