Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove CreateFirestoreSystemMessagesCollectionIfNotExist +remove go r… #1115

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 42 additions & 44 deletions analytics/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,55 +119,53 @@ func Close() {
}

func SendEvent(tenantName, username string, params map[string]interface{}, eventName string) {
go func() {
distinctId := deploymentId
if configuration.DEV_ENV != "" {
distinctId = "dev"
}
distinctId := deploymentId
if configuration.DEV_ENV != "" {
distinctId = "dev"
}

if eventName != "error" {
tenantName = strings.ReplaceAll(tenantName, "-", "_") // for parsing purposes
if tenantName != "" && username != "" {
distinctId = distinctId + "-" + tenantName + "-" + username
}
if eventName != "error" {
tenantName = strings.ReplaceAll(tenantName, "-", "_") // for parsing purposes
if tenantName != "" && username != "" {
distinctId = distinctId + "-" + tenantName + "-" + username
}
}

var eventMsg []byte
var event *EventBody
var err error

creationTime := time.Now().Unix()
timestamp := strconv.FormatInt(creationTime, 10)
if eventName == "error" {
event = &EventBody{
DistinctId: distinctId,
Event: "error",
Properties: params,
TimeStamp: timestamp,
MemphisVersion: memphisVersion,
}
} else {
event = &EventBody{
DistinctId: distinctId,
Event: eventName,
Properties: params,
TimeStamp: timestamp,
MemphisVersion: memphisVersion,
}
var eventMsg []byte
var event *EventBody
var err error

creationTime := time.Now().Unix()
timestamp := strconv.FormatInt(creationTime, 10)
if eventName == "error" {
event = &EventBody{
DistinctId: distinctId,
Event: "error",
Properties: params,
TimeStamp: timestamp,
MemphisVersion: memphisVersion,
}

eventMsg, err = json.Marshal(event)
if err != nil {
return
} else {
event = &EventBody{
DistinctId: distinctId,
Event: eventName,
Properties: params,
TimeStamp: timestamp,
MemphisVersion: memphisVersion,
}
if memphisConnection != nil {
err := memphisConnection.Produce("users-traces", "producer_users_traces", eventMsg, []memphis.ProducerOpt{memphis.ProducerGenUniqueSuffix()}, []memphis.ProduceOpt{})
if err != nil { // retry
memphisConnection, err = memphis.Connect(HOST, USERNAME, memphis.Password(PASSWORD), memphis.AccountId(ACCOUNT_ID), memphis.MaxReconnect(500), memphis.ReconnectInterval(1*time.Second))
if err == nil {
memphisConnection.Produce("users-traces", "producer_users_traces", eventMsg, []memphis.ProducerOpt{memphis.ProducerGenUniqueSuffix()}, []memphis.ProduceOpt{})
}
}

eventMsg, err = json.Marshal(event)
if err != nil {
return
}
if memphisConnection != nil {
err := memphisConnection.Produce("users-traces", "producer_users_traces", eventMsg, []memphis.ProducerOpt{memphis.ProducerGenUniqueSuffix()}, []memphis.ProduceOpt{})
if err != nil { // retry
memphisConnection, err = memphis.Connect(HOST, USERNAME, memphis.Password(PASSWORD), memphis.AccountId(ACCOUNT_ID), memphis.MaxReconnect(500), memphis.ReconnectInterval(1*time.Second))
if err == nil {
memphisConnection.Produce("users-traces", "producer_users_traces", eventMsg, []memphis.ProducerOpt{memphis.ProducerGenUniqueSuffix()}, []memphis.ProduceOpt{})
}
}
}()
}
}
5 changes: 0 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ func runMemphis(s *server.Server) {
s.Errorf("Failed initializing firestore: " + err.Error())
}

err = s.CreateFirestoreSystemMessagesCollectionIfNotExist()
if err != nil {
s.Errorf("Failed create firestore system messages collection: " + err.Error())
}

s.InitializeMemphisHandlers()

err = server.InitializeIntegrations()
Expand Down
4 changes: 0 additions & 4 deletions server/memphis_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -1913,10 +1913,6 @@ func updateSystemLiveness() {
analytics.SendEvent("", "", analyticsParams, "system-is-up")
}

func (s *Server) CreateFirestoreSystemMessagesCollectionIfNotExist() error {
return nil
}

func (umh UserMgmtHandler) GetRelevantSystemMessages() ([]SystemMessage, error) {
return []SystemMessage{}, nil
}