mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-11 23:29:01 +08:00
chore: move posthog to segment (#5330)
This commit is contained in:
parent
41f91db622
commit
51032f6caa
@ -389,7 +389,7 @@ trap bye EXIT
|
||||
|
||||
URL="https://api.segment.io/v1/track"
|
||||
HEADER_1="Content-Type: application/json"
|
||||
HEADER_2="Authorization: Basic NEdtb2E0aXhKQVVIeDJCcEp4c2p3QTFiRWZud0VlUno6"
|
||||
HEADER_2="Authorization: Basic OWtScko3b1BDR1BFSkxGNlFqTVBMdDVibGpGaFJRQnI="
|
||||
|
||||
send_event() {
|
||||
error=""
|
||||
|
1
go.mod
1
go.mod
@ -37,7 +37,6 @@ require (
|
||||
github.com/opentracing/opentracing-go v1.2.0
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/posthog/posthog-go v0.0.0-20220817142604-0b0bbf0f9c0f
|
||||
github.com/prometheus/common v0.54.0
|
||||
github.com/prometheus/prometheus v2.5.0+incompatible
|
||||
github.com/rs/cors v1.11.0
|
||||
|
6
go.sum
6
go.sum
@ -137,7 +137,6 @@ github.com/coreos/go-oidc/v3 v3.10.0 h1:tDnXHnLyiTVyT/2zLDGj09pFPkhND8Gl8lnTRhoE
|
||||
github.com/coreos/go-oidc/v3 v3.10.0/go.mod h1:5j11xcw0D3+SGxn6Z/WFADsgcWVMyNAlSQupk0KK3ac=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -625,8 +624,6 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
|
||||
github.com/posthog/posthog-go v0.0.0-20220817142604-0b0bbf0f9c0f h1:h0p1aZ9F5d6IXOygysob3g4B07b+HuVUQC0VJKD8wA4=
|
||||
github.com/posthog/posthog-go v0.0.0-20220817142604-0b0bbf0f9c0f/go.mod h1:oa2sAs9tGai3VldabTV0eWejt/O4/OOD7azP8GaikqU=
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c h1:NRoLoZvkBTKvR5gQLgA3e0hqjkY9u1wm+iOL45VN/qI=
|
||||
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
@ -673,7 +670,6 @@ github.com/russellhaering/gosaml2 v0.9.0 h1:CNMnH42z/GirrKjdmNrSS6bAAs47F9bPdl4P
|
||||
github.com/russellhaering/gosaml2 v0.9.0/go.mod h1:byViER/1YPUa0Puj9ROZblpoq2jsE7h/CJmitzX0geU=
|
||||
github.com/russellhaering/goxmldsig v1.2.0 h1:Y6GTTc9Un5hCxSzVz4UIWQ/zuVwDvzJk80guqzwx6Vg=
|
||||
github.com/russellhaering/goxmldsig v1.2.0/go.mod h1:gM4MDENBQf7M+V824SGfyIUVFWydB7n0KkEubVJl+Tw=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
@ -697,7 +693,6 @@ github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
||||
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
|
||||
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
|
||||
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo=
|
||||
@ -747,7 +742,6 @@ github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFA
|
||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
||||
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
||||
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=
|
||||
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
|
||||
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ=
|
||||
|
@ -10,7 +10,7 @@ func EnabledPaths() map[string]struct{} {
|
||||
|
||||
func ignoreEvents(event string, attributes map[string]interface{}) bool {
|
||||
|
||||
if event == TELEMETRY_EVENT_ACTIVE_USER || event == TELEMETRY_EVENT_ACTIVE_USER_PH {
|
||||
if event == TELEMETRY_EVENT_ACTIVE_USER {
|
||||
for attr_key, attr_val := range attributes {
|
||||
|
||||
if attr_key == "any" && attr_val.(int8) == 0 {
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
ph "github.com/posthog/posthog-go"
|
||||
"gopkg.in/segmentio/analytics-go.v3"
|
||||
|
||||
"go.signoz.io/signoz/pkg/query-service/constants"
|
||||
@ -26,7 +25,6 @@ const (
|
||||
TELEMETRY_EVENT_USER = "User"
|
||||
TELEMETRY_EVENT_INPRODUCT_FEEDBACK = "InProduct Feedback Submitted"
|
||||
TELEMETRY_EVENT_NUMBER_OF_SERVICES = "Number of Services"
|
||||
TELEMETRY_EVENT_NUMBER_OF_SERVICES_PH = "Number of Services V2"
|
||||
TELEMETRY_EVENT_HEART_BEAT = "Heart Beat"
|
||||
TELEMETRY_EVENT_ORG_SETTINGS = "Org Settings"
|
||||
DEFAULT_SAMPLING = 0.1
|
||||
@ -44,7 +42,6 @@ const (
|
||||
TELEMETRY_EVENT_QUERY_RANGE_API = "Query Range API"
|
||||
TELEMETRY_EVENT_DASHBOARDS_ALERTS = "Dashboards/Alerts Info"
|
||||
TELEMETRY_EVENT_ACTIVE_USER = "Active User"
|
||||
TELEMETRY_EVENT_ACTIVE_USER_PH = "Active User V2"
|
||||
TELEMETRY_EVENT_USER_INVITATION_SENT = "User Invitation Sent"
|
||||
TELEMETRY_EVENT_USER_INVITATION_ACCEPTED = "User Invitation Accepted"
|
||||
TELEMETRY_EVENT_SUCCESSFUL_DASHBOARD_PANEL_QUERY = "Successful Dashboard Panel Query"
|
||||
@ -69,8 +66,21 @@ var SAAS_EVENTS_LIST = map[string]struct{}{
|
||||
TELEMETRY_EVENT_TRACE_DETAIL_API: {},
|
||||
}
|
||||
|
||||
const api_key = "4Gmoa4ixJAUHx2BpJxsjwA1bEfnwEeRz"
|
||||
const ph_api_key = "H-htDCae7CR3RV57gUzmol6IAKtm5IMCvbcm_fwnL-w"
|
||||
var OSS_EVENTS_LIST = map[string]struct{}{
|
||||
TELEMETRY_EVENT_NUMBER_OF_SERVICES: {},
|
||||
TELEMETRY_EVENT_HEART_BEAT: {},
|
||||
TELEMETRY_EVENT_LANGUAGE: {},
|
||||
TELEMETRY_EVENT_ENVIRONMENT: {},
|
||||
TELEMETRY_EVENT_DASHBOARDS_ALERTS: {},
|
||||
TELEMETRY_EVENT_ACTIVE_USER: {},
|
||||
TELEMETRY_EVENT_PATH: {},
|
||||
TELEMETRY_EVENT_ORG_SETTINGS: {},
|
||||
TELEMETRY_LICENSE_CHECK_FAILED: {},
|
||||
TELEMETRY_LICENSE_UPDATED: {},
|
||||
TELEMETRY_LICENSE_ACT_FAILED: {},
|
||||
}
|
||||
|
||||
const api_key = "9kRrJ7oPCGPEJLF6QjMPLt5bljFhRQBr"
|
||||
|
||||
const IP_NOT_FOUND_PLACEHOLDER = "NA"
|
||||
const DEFAULT_NUMBER_OF_SERVICES = 6
|
||||
@ -110,13 +120,13 @@ func (telemetry *Telemetry) CheckSigNozSignals(postData *v3.QueryRangeParamsV3)
|
||||
|
||||
if postData.CompositeQuery.QueryType == v3.QueryTypeBuilder {
|
||||
for _, query := range postData.CompositeQuery.BuilderQueries {
|
||||
if query.DataSource == v3.DataSourceLogs && len(query.Filters.Items) > 0 {
|
||||
if query.DataSource == v3.DataSourceLogs && query.Filters != nil && len(query.Filters.Items) > 0 {
|
||||
signozLogsUsed = true
|
||||
} else if query.DataSource == v3.DataSourceMetrics &&
|
||||
!strings.Contains(query.AggregateAttribute.Key, "signoz_") &&
|
||||
len(query.AggregateAttribute.Key) > 0 {
|
||||
signozMetricsUsed = true
|
||||
} else if query.DataSource == v3.DataSourceTraces && len(query.Filters.Items) > 0 {
|
||||
} else if query.DataSource == v3.DataSourceTraces && query.Filters != nil && len(query.Filters.Items) > 0 {
|
||||
signozTracesUsed = true
|
||||
}
|
||||
}
|
||||
@ -159,9 +169,8 @@ func (telemetry *Telemetry) AddActiveLogsUser() {
|
||||
}
|
||||
|
||||
type Telemetry struct {
|
||||
operator analytics.Client
|
||||
ossOperator analytics.Client
|
||||
saasOperator analytics.Client
|
||||
phOperator ph.Client
|
||||
ipAddress string
|
||||
userEmail string
|
||||
isEnabled bool
|
||||
@ -188,11 +197,10 @@ func createTelemetry() {
|
||||
}
|
||||
|
||||
telemetry = &Telemetry{
|
||||
operator: analytics.New(api_key),
|
||||
phOperator: ph.New(ph_api_key),
|
||||
ipAddress: getOutboundIP(),
|
||||
rateLimits: make(map[string]int8),
|
||||
activeUser: make(map[string]int8),
|
||||
ossOperator: analytics.New(api_key),
|
||||
ipAddress: getOutboundIP(),
|
||||
rateLimits: make(map[string]int8),
|
||||
activeUser: make(map[string]int8),
|
||||
}
|
||||
telemetry.minRandInt = 0
|
||||
telemetry.maxRandInt = int(1 / DEFAULT_SAMPLING)
|
||||
@ -392,18 +400,16 @@ func (a *Telemetry) IdentifyUser(user *model.User) {
|
||||
})
|
||||
}
|
||||
|
||||
a.operator.Enqueue(analytics.Identify{
|
||||
a.ossOperator.Enqueue(analytics.Identify{
|
||||
UserId: a.ipAddress,
|
||||
Traits: analytics.NewTraits().SetName(user.Name).SetEmail(user.Email).Set("ip", a.ipAddress),
|
||||
})
|
||||
// Updating a groups properties
|
||||
a.phOperator.Enqueue(ph.GroupIdentify{
|
||||
Type: "companyDomain",
|
||||
Key: a.getCompanyDomain(),
|
||||
Properties: ph.NewProperties().
|
||||
Set("companyDomain", a.getCompanyDomain()),
|
||||
a.ossOperator.Enqueue(analytics.Group{
|
||||
UserId: a.ipAddress,
|
||||
GroupId: a.getCompanyDomain(),
|
||||
Traits: analytics.NewTraits().Set("company_domain", a.getCompanyDomain()),
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func (a *Telemetry) SetCountUsers(countUsers int8) {
|
||||
@ -520,33 +526,19 @@ func (a *Telemetry) SendEvent(event string, data map[string]interface{}, userEma
|
||||
})
|
||||
}
|
||||
|
||||
a.operator.Enqueue(analytics.Track{
|
||||
Event: event,
|
||||
UserId: userId,
|
||||
Properties: properties,
|
||||
})
|
||||
_, isOSSEvent := OSS_EVENTS_LIST[event]
|
||||
|
||||
if event == TELEMETRY_EVENT_NUMBER_OF_SERVICES {
|
||||
|
||||
a.phOperator.Enqueue(ph.Capture{
|
||||
DistinctId: userId,
|
||||
Event: TELEMETRY_EVENT_NUMBER_OF_SERVICES_PH,
|
||||
Properties: ph.Properties(properties),
|
||||
Groups: ph.NewGroups().
|
||||
Set("companyDomain", a.getCompanyDomain()),
|
||||
if a.ossOperator != nil && isOSSEvent {
|
||||
a.ossOperator.Enqueue(analytics.Track{
|
||||
Event: event,
|
||||
UserId: userId,
|
||||
Properties: properties,
|
||||
Context: &analytics.Context{
|
||||
Extra: map[string]interface{}{
|
||||
"groupId": a.getCompanyDomain(),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
}
|
||||
if event == TELEMETRY_EVENT_ACTIVE_USER {
|
||||
|
||||
a.phOperator.Enqueue(ph.Capture{
|
||||
DistinctId: userId,
|
||||
Event: TELEMETRY_EVENT_ACTIVE_USER_PH,
|
||||
Properties: ph.Properties(properties),
|
||||
Groups: ph.NewGroups().
|
||||
Set("companyDomain", a.getCompanyDomain()),
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user