refactor(backend): use analytics topic for IntegrationEvent

This commit is contained in:
Alex Kaminskii 2022-06-24 16:37:51 +02:00
parent 4e439354c3
commit 236ac05c92
3 changed files with 13 additions and 14 deletions

View file

@ -84,8 +84,7 @@ func main() {
}
sessionID = sessData.ID
}
// TODO: send to ready-events topic. Otherwise it have to go through the events worker.
producer.Produce(cfg.TopicRawWeb, sessionID, messages.Encode(event.IntegrationEvent))
producer.Produce(cfg.TopicAnalytics, sessionID, messages.Encode(event.IntegrationEvent))
case err := <-manager.Errors:
log.Printf("Integration error: %v\n", err)
case i := <-manager.RequestDataUpdates:

View file

@ -10,8 +10,8 @@ type Config struct {
func New() *Config {
return &Config{
TopicRawWeb: env.String("TOPIC_RAW_WEB"),
PostgresURI: env.String("POSTGRES_STRING"),
TokenSecret: env.String("TOKEN_SECRET"),
TopicAnalytics: env.String("TOPIC_ANALYTICS"),
PostgresURI: env.String("POSTGRES_STRING"),
TokenSecret: env.String("TOKEN_SECRET"),
}
}

View file

@ -42,6 +42,15 @@ func (mi *Saver) InsertMessage(sessionID uint64, msg Message) error {
return mi.pg.InsertWebFetchEvent(sessionID, m)
case *GraphQLEvent:
return mi.pg.InsertWebGraphQLEvent(sessionID, m)
case *IntegrationEvent:
return mi.pg.InsertWebErrorEvent(sessionID, &ErrorEvent{
MessageID: m.Meta().Index,
Timestamp: m.Timestamp,
Source: m.Source,
Name: m.Name,
Message: m.Message,
Payload: m.Payload,
})
// IOS
case *IOSSessionStart:
@ -66,15 +75,6 @@ func (mi *Saver) InsertMessage(sessionID uint64, msg Message) error {
case *IOSCrash:
return mi.pg.InsertIOSCrash(sessionID, m)
case *IntegrationEvent:
return mi.pg.InsertWebErrorEvent(sessionID, &ErrorEvent{
MessageID: m.Meta().Index, // TODO: is it possible to catch panic here???
Timestamp: m.Timestamp,
Source: m.Source,
Name: m.Name,
Message: m.Message,
Payload: m.Payload,
})
}
return nil // "Not implemented"
}