mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 07:29:05 +08:00
chore: added group analytics
This commit is contained in:
parent
d170515d4d
commit
4875652ecb
@ -5,6 +5,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ type Telemetry struct {
|
|||||||
isAnonymous bool
|
isAnonymous bool
|
||||||
distinctId string
|
distinctId string
|
||||||
reader interfaces.Reader
|
reader interfaces.Reader
|
||||||
|
companyDomain string
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTelemetry() {
|
func createTelemetry() {
|
||||||
@ -106,6 +108,7 @@ func (a *Telemetry) IdentifyUser(user *model.User) {
|
|||||||
if !a.isTelemetryEnabled() || a.isTelemetryAnonymous() {
|
if !a.isTelemetryEnabled() || a.isTelemetryAnonymous() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
a.setCompanyDomain(user.Email)
|
||||||
|
|
||||||
a.operator.Enqueue(analytics.Identify{
|
a.operator.Enqueue(analytics.Identify{
|
||||||
UserId: a.ipAddress,
|
UserId: a.ipAddress,
|
||||||
@ -113,6 +116,21 @@ func (a *Telemetry) IdentifyUser(user *model.User) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Telemetry) setCompanyDomain(email string) {
|
||||||
|
|
||||||
|
email_split := strings.Split(email, "@")
|
||||||
|
if len(email_split) != 2 {
|
||||||
|
a.companyDomain = email
|
||||||
|
}
|
||||||
|
a.companyDomain = email_split[1]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Telemetry) getCompanyDomain() string {
|
||||||
|
return a.companyDomain
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Telemetry) checkEvents(event string) bool {
|
func (a *Telemetry) checkEvents(event string) bool {
|
||||||
sendEvent := true
|
sendEvent := true
|
||||||
if event == TELEMETRY_EVENT_USER && a.isTelemetryAnonymous() {
|
if event == TELEMETRY_EVENT_USER && a.isTelemetryAnonymous() {
|
||||||
@ -136,6 +154,7 @@ func (a *Telemetry) SendEvent(event string, data map[string]interface{}) {
|
|||||||
properties := analytics.NewProperties()
|
properties := analytics.NewProperties()
|
||||||
properties.Set("version", version.GetVersion())
|
properties.Set("version", version.GetVersion())
|
||||||
properties.Set("deploymentType", getDeploymentType())
|
properties.Set("deploymentType", getDeploymentType())
|
||||||
|
properties.Set("companyDomain", a.getCompanyDomain())
|
||||||
|
|
||||||
for k, v := range data {
|
for k, v := range data {
|
||||||
properties.Set(k, v)
|
properties.Set(k, v)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user