chore: reduce events

This commit is contained in:
Ankit Nayan 2023-02-11 23:15:07 +05:30
parent 93b6749920
commit a906f94b8a
2 changed files with 22 additions and 1 deletions

View File

@ -11,3 +11,18 @@ func IgnoredPaths() map[string]struct{} {
return ignoredPaths
}
func ignoreEvents(event string, attributes map[string]interface{}) bool {
if event == TELEMETRY_EVENT_ACTIVE_USER || event == TELEMETRY_EVENT_ACTIVE_USER_PH {
for attr_key, attr_val := range attributes {
if attr_key == "any" && attr_val.(int8) == 0 {
return true
}
}
}
return false
}

View File

@ -46,13 +46,14 @@ const IP_NOT_FOUND_PLACEHOLDER = "NA"
const DEFAULT_NUMBER_OF_SERVICES = 6
const HEART_BEAT_DURATION = 6 * time.Hour
const ACTIVE_USER_DURATION = 30 * time.Minute
// const HEART_BEAT_DURATION = 30 * time.Second
// const ACTIVE_USER_DURATION = 30 * time.Second
const RATE_LIMIT_CHECK_DURATION = 1 * time.Minute
const RATE_LIMIT_VALUE = 2
const RATE_LIMIT_VALUE = 1
// const RATE_LIMIT_CHECK_DURATION = 20 * time.Second
// const RATE_LIMIT_VALUE = 5
@ -301,6 +302,11 @@ func (a *Telemetry) SendEvent(event string, data map[string]interface{}, opts ..
return
}
// drop events with properties matching
if ignoreEvents(event, data) {
return
}
if rateLimitFlag {
if a.rateLimits[event] < RATE_LIMIT_VALUE {
a.rateLimits[event] += 1