diff --git a/backend/pkg/db/postgres/messages_web.go b/backend/pkg/db/postgres/messages_web.go index 39f56492a..75b427dc1 100644 --- a/backend/pkg/db/postgres/messages_web.go +++ b/backend/pkg/db/postgres/messages_web.go @@ -175,11 +175,14 @@ func (conn *Conn) InsertWebErrorEvent(sessionID uint64, projectID uint32, e *Err errorID := hashid.WebErrorID(projectID, e) log.Println(">>errorID") log.Println(errorID) + log.Println(">>payload") + log.Println(e.Payload) + if err = tx.exec(` INSERT INTO errors (error_id, project_id, source, name, message, payload) VALUES - ($1, $2, $3, $4, $5, $6) + ($1, $2, $3, $4, $5, $6::jsonb) ON CONFLICT DO NOTHING`, errorID, projectID, e.Source, e.Name, e.Message, e.Payload, ); err != nil { diff --git a/backend/services/integrations/integration/elasticsearch.go b/backend/services/integrations/integration/elasticsearch.go index 734ab7288..970a8c518 100644 --- a/backend/services/integrations/integration/elasticsearch.go +++ b/backend/services/integrations/integration/elasticsearch.go @@ -130,7 +130,7 @@ func (es *elasticsearch) Request(c *client) error { log.Println("No hits found") break } - log.Printf("received %d hits",len(hits)) + log.Printf("received %d hits", len(hits)) for _, hit := range hits { // Parse the attributes/fields of the document @@ -173,6 +173,11 @@ func (es *elasticsearch) Request(c *client) error { log.Printf("Error converting token to uint46: %s\n", err) sessionID = 0 } + payload, err := json.Marshal(source) + if err != nil { + log.Printf("Error converting source to json: %v\n", source) + continue + } c.evChan <- &SessionErrorEvent{ //SessionID: sessionID, SessionID: sessionID, @@ -181,7 +186,7 @@ func (es *elasticsearch) Request(c *client) error { Source: "elasticsearch", Timestamp: timestamp, Name: fmt.Sprintf("%v", docID), - Payload: fmt.Sprintf("%v", source), + Payload: string(payload), }, } }