feat(custom): parse custom event's payload and use the predefined timestamp as a correct ts for our messages
This commit is contained in:
parent
889fde91a9
commit
c9b29c5c3d
1 changed files with 9 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ package datasaver
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"openreplay/backend/pkg/db/postgres"
|
||||
"openreplay/backend/pkg/db/types"
|
||||
|
|
@ -63,6 +64,14 @@ func (s *saverImpl) handleWebMessage(sessCtx context.Context, session *sessions.
|
|||
s.pg.InsertAutocompleteValue(session.SessionID, session.ProjectID, "USERANONYMOUSID", m.ID)
|
||||
return nil
|
||||
case *messages.CustomEvent:
|
||||
// Try to parse custom event payload to JSON and extract or_payload field
|
||||
type CustomEventPayload struct {
|
||||
CustomTimestamp uint64 `json:"or_timestamp"`
|
||||
}
|
||||
customPayload := &CustomEventPayload{}
|
||||
if err := json.Unmarshal([]byte(m.Payload), customPayload); err == nil {
|
||||
m.Timestamp = customPayload.CustomTimestamp
|
||||
}
|
||||
if err := s.pg.InsertWebCustomEvent(session, m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue