format(backend): format some go files
This commit is contained in:
parent
ce2cd38db1
commit
777648dedd
16 changed files with 127 additions and 145 deletions
36
backend/pkg/db/cache/messages_ios.go
vendored
36
backend/pkg/db/cache/messages_ios.go
vendored
|
|
@ -1,41 +1,40 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
import (
|
||||
"errors"
|
||||
. "openreplay/backend/pkg/messages"
|
||||
. "openreplay/backend/pkg/db/types"
|
||||
. "openreplay/backend/pkg/messages"
|
||||
)
|
||||
|
||||
func (c *PGCache) InsertIOSSessionStart(sessionID uint64, s *IOSSessionStart) error {
|
||||
if c.sessions[ sessionID ] != nil {
|
||||
if c.sessions[sessionID] != nil {
|
||||
return errors.New("This session already in cache!")
|
||||
}
|
||||
c.sessions[ sessionID ] = &Session{
|
||||
SessionID: sessionID,
|
||||
Platform: "ios",
|
||||
Timestamp: s.Timestamp,
|
||||
ProjectID: uint32(s.ProjectID),
|
||||
c.sessions[sessionID] = &Session{
|
||||
SessionID: sessionID,
|
||||
Platform: "ios",
|
||||
Timestamp: s.Timestamp,
|
||||
ProjectID: uint32(s.ProjectID),
|
||||
TrackerVersion: s.TrackerVersion,
|
||||
RevID: s.RevID,
|
||||
UserUUID: s.UserUUID,
|
||||
UserOS: s.UserOS,
|
||||
UserOSVersion: s.UserOSVersion,
|
||||
UserDevice: s.UserDevice,
|
||||
UserCountry: s.UserCountry,
|
||||
RevID: s.RevID,
|
||||
UserUUID: s.UserUUID,
|
||||
UserOS: s.UserOS,
|
||||
UserOSVersion: s.UserOSVersion,
|
||||
UserDevice: s.UserDevice,
|
||||
UserCountry: s.UserCountry,
|
||||
UserDeviceType: s.UserDeviceType,
|
||||
}
|
||||
if err := c.Conn.InsertSessionStart(sessionID, c.sessions[ sessionID ]); err != nil {
|
||||
c.sessions[ sessionID ] = nil
|
||||
if err := c.Conn.InsertSessionStart(sessionID, c.sessions[sessionID]); err != nil {
|
||||
c.sessions[sessionID] = nil
|
||||
return err
|
||||
}
|
||||
return nil;
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *PGCache) InsertIOSSessionEnd(sessionID uint64, e *IOSSessionEnd) error {
|
||||
return c.insertSessionEnd(sessionID, e.Timestamp)
|
||||
}
|
||||
|
||||
|
||||
func (c *PGCache) InsertIOSScreenEnter(sessionID uint64, screenEnter *IOSScreenEnter) error {
|
||||
if err := c.Conn.InsertIOSScreenEnter(sessionID, screenEnter); err != nil {
|
||||
return err
|
||||
|
|
@ -95,4 +94,3 @@ func (c *PGCache) InsertIOSIssueEvent(sessionID uint64, issueEvent *IOSIssueEven
|
|||
// }
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
19
backend/pkg/db/cache/pg_cache.go
vendored
19
backend/pkg/db/cache/pg_cache.go
vendored
|
|
@ -1,8 +1,8 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
"time"
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"openreplay/backend/pkg/db/postgres"
|
||||
. "openreplay/backend/pkg/db/types"
|
||||
|
|
@ -10,32 +10,29 @@ import (
|
|||
|
||||
type ProjectMeta struct {
|
||||
*Project
|
||||
expirationTime time.Time
|
||||
expirationTime time.Time
|
||||
}
|
||||
|
||||
// !TODO: remove old sessions by timeout to avoid memleaks
|
||||
|
||||
/*
|
||||
/*
|
||||
* Cache layer around the stateless PG adapter
|
||||
**/
|
||||
type PGCache struct {
|
||||
*postgres.Conn
|
||||
sessions map[uint64]*Session
|
||||
projects map[uint32]*ProjectMeta
|
||||
projectsByKeys sync.Map // map[string]*ProjectMeta
|
||||
sessions map[uint64]*Session
|
||||
projects map[uint32]*ProjectMeta
|
||||
projectsByKeys sync.Map // map[string]*ProjectMeta
|
||||
projectExpirationTimeout time.Duration
|
||||
}
|
||||
|
||||
// TODO: create conn automatically
|
||||
func NewPGCache(pgConn *postgres.Conn, projectExpirationTimeoutMs int64) *PGCache {
|
||||
return &PGCache{
|
||||
Conn: pgConn,
|
||||
Conn: pgConn,
|
||||
sessions: make(map[uint64]*Session),
|
||||
projects: make(map[uint32]*ProjectMeta),
|
||||
//projectsByKeys: make(map[string]*ProjectMeta),
|
||||
projectExpirationTimeout: time.Duration(1000 * projectExpirationTimeoutMs),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
15
backend/pkg/db/cache/project.go
vendored
15
backend/pkg/db/cache/project.go
vendored
|
|
@ -1,8 +1,8 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
"time"
|
||||
import (
|
||||
. "openreplay/backend/pkg/db/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (c *PGCache) GetProjectByKey(projectKey string) (*Project, error) {
|
||||
|
|
@ -24,19 +24,16 @@ func (c *PGCache) GetProjectByKey(projectKey string) (*Project, error) {
|
|||
return p, nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (c *PGCache) GetProject(projectID uint32) (*Project, error) {
|
||||
if c.projects[ projectID ] != nil &&
|
||||
time.Now().Before(c.projects[ projectID ].expirationTime) {
|
||||
return c.projects[ projectID ].Project, nil
|
||||
if c.projects[projectID] != nil &&
|
||||
time.Now().Before(c.projects[projectID].expirationTime) {
|
||||
return c.projects[projectID].Project, nil
|
||||
}
|
||||
p, err := c.Conn.GetProject(projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.projects[ projectID ] = &ProjectMeta{ p, time.Now().Add(c.projectExpirationTimeout) }
|
||||
c.projects[projectID] = &ProjectMeta{p, time.Now().Add(c.projectExpirationTimeout)}
|
||||
//c.projectsByKeys.Store(p.ProjectKey, c.projects[ projectID ])
|
||||
return p, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
8
backend/pkg/db/cache/session.go
vendored
8
backend/pkg/db/cache/session.go
vendored
|
|
@ -1,13 +1,13 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
import (
|
||||
"github.com/jackc/pgx/v4"
|
||||
|
||||
. "openreplay/backend/pkg/db/types"
|
||||
)
|
||||
|
||||
func (c *PGCache) GetSession(sessionID uint64) (*Session, error) {
|
||||
if s, inCache := c.sessions[ sessionID ]; inCache {
|
||||
if s, inCache := c.sessions[sessionID]; inCache {
|
||||
// TODO: review. Might cause bugs in case of multiple instances
|
||||
if s == nil {
|
||||
return nil, pgx.ErrNoRows
|
||||
|
|
@ -16,12 +16,12 @@ func (c *PGCache) GetSession(sessionID uint64) (*Session, error) {
|
|||
}
|
||||
s, err := c.Conn.GetSession(sessionID)
|
||||
if err == pgx.ErrNoRows {
|
||||
c.sessions[ sessionID ] = nil
|
||||
c.sessions[sessionID] = nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.sessions[ sessionID ] = s
|
||||
c.sessions[sessionID] = s
|
||||
return s, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ package postgres
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/jackc/pgx/v4"
|
||||
"github.com/jackc/pgconn"
|
||||
"github.com/jackc/pgerrcode"
|
||||
"github.com/jackc/pgx/v4"
|
||||
)
|
||||
|
||||
func IsPkeyViolation(err error) bool {
|
||||
var pgErr *pgconn.PgError
|
||||
return errors.As(err, &pgErr) && pgErr.Code == pgerrcode.UniqueViolation
|
||||
return errors.As(err, &pgErr) && pgErr.Code == pgerrcode.UniqueViolation
|
||||
}
|
||||
|
||||
func IsNoRowsErr(err error) bool {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ func getIssueScore(issueEvent *messages.IssueEvent) int {
|
|||
switch issueEvent.Type {
|
||||
case "crash", "dead_click", "memory", "cpu":
|
||||
return 1000
|
||||
case "bad_request", "excessive_scrolling", "click_rage", "missing_resource" :
|
||||
case "bad_request", "excessive_scrolling", "click_rage", "missing_resource":
|
||||
return 500
|
||||
case "slow_resource", "slow_page_load":
|
||||
return 100
|
||||
|
|
@ -32,4 +32,4 @@ func calcResponseTime(pe *messages.PageEvent) uint64 {
|
|||
return pe.ResponseEnd - pe.ResponseStart
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/jackc/pgx/v4"
|
||||
|
||||
|
||||
)
|
||||
|
||||
type Listener struct {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"openreplay/backend/pkg/messages"
|
||||
"openreplay/backend/pkg/hashid"
|
||||
"openreplay/backend/pkg/messages"
|
||||
"openreplay/backend/pkg/url"
|
||||
)
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ func (conn *Conn) InsertIOSUserAnonymousID(sessionID uint64, userAnonymousID *me
|
|||
func (conn *Conn) InsertIOSNetworkCall(sessionID uint64, e *messages.IOSNetworkCall) error {
|
||||
err := conn.InsertRequest(sessionID, e.Timestamp, e.Index, e.URL, e.Duration, e.Success)
|
||||
if err == nil {
|
||||
conn.insertAutocompleteValue(sessionID, "REQUEST_IOS", url.DiscardURLQuery(e.URL))
|
||||
conn.insertAutocompleteValue(sessionID, "REQUEST_IOS", url.DiscardURLQuery(e.URL))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ func (conn *Conn) InsertIOSScreenEnter(sessionID uint64, screenEnter *messages.I
|
|||
if err = tx.commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
conn.insertAutocompleteValue(sessionID, "VIEW_IOS", screenEnter.ViewName)
|
||||
conn.insertAutocompleteValue(sessionID, "VIEW_IOS", screenEnter.ViewName)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ func (conn *Conn) InsertIOSClickEvent(sessionID uint64, clickEvent *messages.IOS
|
|||
session_id, timestamp, seq_index, label
|
||||
) VALUES (
|
||||
$1, $2, $3, $4
|
||||
)`,
|
||||
)`,
|
||||
sessionID, clickEvent.Timestamp, clickEvent.Index, clickEvent.Label,
|
||||
); err != nil {
|
||||
return err
|
||||
|
|
@ -153,7 +153,7 @@ func (conn *Conn) InsertIOSCrash(sessionID uint64, projectID uint32, crash *mess
|
|||
project_id, $2, $3, $4, $5
|
||||
FROM sessions
|
||||
WHERE session_id = $1
|
||||
)ON CONFLICT DO NOTHING`,
|
||||
)ON CONFLICT DO NOTHING`,
|
||||
sessionID, crashID, crash.Name, crash.Reason, crash.Stacktrace,
|
||||
); err != nil {
|
||||
return err
|
||||
|
|
@ -163,7 +163,7 @@ func (conn *Conn) InsertIOSCrash(sessionID uint64, projectID uint32, crash *mess
|
|||
session_id, timestamp, seq_index, crash_id
|
||||
) VALUES (
|
||||
$1, $2, $3, $4
|
||||
)`,
|
||||
)`,
|
||||
sessionID, crash.Timestamp, crash.Index, crashID,
|
||||
); err != nil {
|
||||
return err
|
||||
|
|
@ -177,5 +177,3 @@ func (conn *Conn) InsertIOSCrash(sessionID uint64, projectID uint32, crash *mess
|
|||
}
|
||||
return tx.commit()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,8 @@ func getSqIdx(messageID uint64) uint {
|
|||
return uint(messageID % math.MaxInt32)
|
||||
}
|
||||
|
||||
|
||||
func (conn *Conn) InsertWebCustomEvent(sessionID uint64, e *CustomEvent) error {
|
||||
err := conn.InsertCustomEvent(sessionID, e.Timestamp,
|
||||
err := conn.InsertCustomEvent(sessionID, e.Timestamp,
|
||||
e.MessageID,
|
||||
e.Name, e.Payload)
|
||||
if err == nil {
|
||||
|
|
@ -44,12 +43,12 @@ func (conn *Conn) InsertWebResourceEvent(sessionID uint64, e *ResourceEvent) err
|
|||
if e.Type != "fetch" {
|
||||
return nil
|
||||
}
|
||||
err := conn.InsertRequest(sessionID, e.Timestamp,
|
||||
err := conn.InsertRequest(sessionID, e.Timestamp,
|
||||
e.MessageID,
|
||||
e.URL, e.Duration, e.Success,
|
||||
)
|
||||
if err == nil {
|
||||
conn.insertAutocompleteValue(sessionID, "REQUEST", url.DiscardURLQuery(e.URL))
|
||||
conn.insertAutocompleteValue(sessionID, "REQUEST", url.DiscardURLQuery(e.URL))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
@ -62,7 +61,7 @@ func (conn *Conn) InsertWebPageEvent(sessionID uint64, e *PageEvent) error {
|
|||
}
|
||||
tx, err := conn.begin()
|
||||
if err != nil {
|
||||
return err
|
||||
return err
|
||||
}
|
||||
defer tx.rollback()
|
||||
if err := tx.exec(`
|
||||
|
|
@ -79,7 +78,7 @@ func (conn *Conn) InsertWebPageEvent(sessionID uint64, e *PageEvent) error {
|
|||
)
|
||||
`,
|
||||
sessionID, e.MessageID, e.Timestamp, e.Referrer, url.DiscardURLQuery(e.Referrer), host, path, url.DiscardURLQuery(path),
|
||||
e.DomContentLoadedEventEnd, e.LoadEventEnd, e.ResponseEnd, e.FirstPaint, e.FirstContentfulPaint,
|
||||
e.DomContentLoadedEventEnd, e.LoadEventEnd, e.ResponseEnd, e.FirstPaint, e.FirstContentfulPaint,
|
||||
e.SpeedIndex, e.VisuallyComplete, e.TimeToInteractive,
|
||||
calcResponseTime(e), calcDomBuildingTime(e),
|
||||
); err != nil {
|
||||
|
|
@ -133,7 +132,6 @@ func (conn *Conn) InsertWebClickEvent(sessionID uint64, e *ClickEvent) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
|
||||
func (conn *Conn) InsertWebInputEvent(sessionID uint64, e *InputEvent) error {
|
||||
tx, err := conn.begin()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ type TenantNotification struct {
|
|||
Title string `db:"title" json:"title"`
|
||||
Description string `db:"description" json:"description"`
|
||||
ButtonText string `db:"button_text" json:"buttonText"`
|
||||
ButtonUrl string `db:"button_url" json:"buttonUrl"`
|
||||
ButtonUrl string `db:"button_url" json:"buttonUrl"`
|
||||
ImageUrl *string `db:"image_url" json:"imageUrl"`
|
||||
Options map[string]interface{} `db:"options" json:"options"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
)
|
||||
|
||||
func (conn *Conn) GetProjectByKey(projectKey string) (*Project, error) {
|
||||
p := &Project{ ProjectKey: projectKey }
|
||||
p := &Project{ProjectKey: projectKey}
|
||||
if err := conn.queryRow(`
|
||||
SELECT max_session_duration, sample_rate, project_id
|
||||
FROM projects
|
||||
|
|
@ -20,7 +20,7 @@ func (conn *Conn) GetProjectByKey(projectKey string) (*Project, error) {
|
|||
|
||||
// TODO: logical separation of metadata
|
||||
func (conn *Conn) GetProject(projectID uint32) (*Project, error) {
|
||||
p := &Project{ ProjectID: projectID }
|
||||
p := &Project{ProjectID: projectID}
|
||||
if err := conn.queryRow(`
|
||||
SELECT project_key, max_session_duration,
|
||||
metadata_1, metadata_2, metadata_3, metadata_4, metadata_5,
|
||||
|
|
@ -29,10 +29,10 @@ func (conn *Conn) GetProject(projectID uint32) (*Project, error) {
|
|||
WHERE project_id=$1 AND active = true
|
||||
`,
|
||||
projectID,
|
||||
).Scan(&p.ProjectKey,&p.MaxSessionDuration,
|
||||
&p.Metadata1, &p.Metadata2, &p.Metadata3, &p.Metadata4, &p.Metadata5,
|
||||
&p.Metadata6, &p.Metadata7, &p.Metadata8, &p.Metadata9, &p.Metadata10); err != nil {
|
||||
).Scan(&p.ProjectKey, &p.MaxSessionDuration,
|
||||
&p.Metadata1, &p.Metadata2, &p.Metadata3, &p.Metadata4, &p.Metadata5,
|
||||
&p.Metadata6, &p.Metadata7, &p.Metadata8, &p.Metadata9, &p.Metadata10); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
package postgres
|
||||
|
||||
type UnstartedSession struct {
|
||||
ProjectKey string
|
||||
TrackerVersion string
|
||||
DoNotTrack bool
|
||||
Platform string
|
||||
UserAgent string
|
||||
UserOS string
|
||||
UserOSVersion string
|
||||
UserBrowser string
|
||||
ProjectKey string
|
||||
TrackerVersion string
|
||||
DoNotTrack bool
|
||||
Platform string
|
||||
UserAgent string
|
||||
UserOS string
|
||||
UserOSVersion string
|
||||
UserBrowser string
|
||||
UserBrowserVersion string
|
||||
UserDevice string
|
||||
UserDeviceType string
|
||||
UserCountry string
|
||||
UserDevice string
|
||||
UserDeviceType string
|
||||
UserCountry string
|
||||
}
|
||||
|
||||
func (conn *Conn) InsertUnstartedSession(s UnstartedSession) error {
|
||||
|
|
@ -34,12 +34,12 @@ func (conn *Conn) InsertUnstartedSession(s UnstartedSession) error {
|
|||
$10, $11,
|
||||
$12
|
||||
)`,
|
||||
s.ProjectKey,
|
||||
s.ProjectKey,
|
||||
s.TrackerVersion, s.DoNotTrack,
|
||||
s.Platform, s.UserAgent,
|
||||
s.UserOS, s.UserOSVersion,
|
||||
s.UserBrowser, s.UserBrowserVersion,
|
||||
s.UserDevice, s.UserDeviceType,
|
||||
s.UserDevice, s.UserDeviceType,
|
||||
s.UserCountry,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,20 +6,19 @@ type Project struct {
|
|||
ProjectID uint32
|
||||
ProjectKey string
|
||||
MaxSessionDuration int64
|
||||
SampleRate byte
|
||||
Metadata1 *string
|
||||
Metadata2 *string
|
||||
Metadata3 *string
|
||||
Metadata4 *string
|
||||
Metadata5 *string
|
||||
Metadata6 *string
|
||||
Metadata7 *string
|
||||
Metadata8 *string
|
||||
Metadata9 *string
|
||||
SampleRate byte
|
||||
Metadata1 *string
|
||||
Metadata2 *string
|
||||
Metadata3 *string
|
||||
Metadata4 *string
|
||||
Metadata5 *string
|
||||
Metadata6 *string
|
||||
Metadata7 *string
|
||||
Metadata8 *string
|
||||
Metadata9 *string
|
||||
Metadata10 *string
|
||||
}
|
||||
|
||||
|
||||
func (p *Project) GetMetadataNo(key string) uint {
|
||||
if p == nil {
|
||||
log.Printf("GetMetadataNo: Project is nil")
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ type Session struct {
|
|||
UserDevice string
|
||||
UserCountry string
|
||||
|
||||
Duration *uint64
|
||||
PagesCount int
|
||||
EventsCount int
|
||||
ErrorsCount int
|
||||
Duration *uint64
|
||||
PagesCount int
|
||||
EventsCount int
|
||||
ErrorsCount int
|
||||
|
||||
UserID *string // pointer??
|
||||
UserAnonymousID *string
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ func insertMessage(sessionID uint64, msg Message) error {
|
|||
return pg.InsertMetadata(sessionID, m)
|
||||
case *IssueEvent:
|
||||
return pg.InsertIssueEvent(sessionID, m)
|
||||
//TODO: message adapter (transformer) (at the level of pkg/message) for types:
|
||||
//TODO: message adapter (transformer) (at the level of pkg/message) for types:
|
||||
// case *IOSMetadata, *IOSIssueEvent and others
|
||||
|
||||
// Web
|
||||
|
|
@ -34,10 +34,10 @@ func insertMessage(sessionID uint64, msg Message) error {
|
|||
return pg.InsertWebResourceEvent(sessionID, m)
|
||||
case *PageEvent:
|
||||
return pg.InsertWebPageEvent(sessionID, m)
|
||||
case *ErrorEvent:
|
||||
case *ErrorEvent:
|
||||
return pg.InsertWebErrorEvent(sessionID, m)
|
||||
|
||||
// IOS
|
||||
// IOS
|
||||
case *IOSSessionStart:
|
||||
return pg.InsertIOSSessionStart(sessionID, m)
|
||||
case *IOSSessionEnd:
|
||||
|
|
@ -57,8 +57,8 @@ func insertMessage(sessionID uint64, msg Message) error {
|
|||
return pg.InsertIOSNetworkCall(sessionID, m)
|
||||
case *IOSScreenEnter:
|
||||
return pg.InsertIOSScreenEnter(sessionID, m)
|
||||
case *IOSCrash:
|
||||
case *IOSCrash:
|
||||
return pg.InsertIOSCrash(sessionID, m)
|
||||
}
|
||||
return nil // "Not implemented"
|
||||
}
|
||||
return nil // "Not implemented"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,33 +41,32 @@ func getResourceType(initiator string, URL string) string {
|
|||
}
|
||||
|
||||
type builder struct {
|
||||
readyMsgs []Message
|
||||
timestamp uint64
|
||||
lastProcessedTimestamp int64
|
||||
peBuilder *pageEventBuilder
|
||||
ptaBuilder *performanceTrackAggrBuilder
|
||||
ieBuilder *inputEventBuilder
|
||||
ciFinder *cpuIssueFinder
|
||||
miFinder *memoryIssueFinder
|
||||
ddDetector *domDropDetector
|
||||
crDetector *clickRageDetector
|
||||
dcDetector *deadClickDetector
|
||||
integrationsWaiting bool
|
||||
|
||||
readyMsgs []Message
|
||||
timestamp uint64
|
||||
lastProcessedTimestamp int64
|
||||
peBuilder *pageEventBuilder
|
||||
ptaBuilder *performanceTrackAggrBuilder
|
||||
ieBuilder *inputEventBuilder
|
||||
ciFinder *cpuIssueFinder
|
||||
miFinder *memoryIssueFinder
|
||||
ddDetector *domDropDetector
|
||||
crDetector *clickRageDetector
|
||||
dcDetector *deadClickDetector
|
||||
integrationsWaiting bool
|
||||
|
||||
sid uint64
|
||||
}
|
||||
|
||||
func NewBuilder() *builder {
|
||||
return &builder{
|
||||
peBuilder: &pageEventBuilder{},
|
||||
ptaBuilder: &performanceTrackAggrBuilder{},
|
||||
ieBuilder: NewInputEventBuilder(),
|
||||
ciFinder: &cpuIssueFinder{},
|
||||
miFinder: &memoryIssueFinder{},
|
||||
ddDetector: &domDropDetector{},
|
||||
crDetector: &clickRageDetector{},
|
||||
dcDetector: &deadClickDetector{},
|
||||
peBuilder: &pageEventBuilder{},
|
||||
ptaBuilder: &performanceTrackAggrBuilder{},
|
||||
ieBuilder: NewInputEventBuilder(),
|
||||
ciFinder: &cpuIssueFinder{},
|
||||
miFinder: &memoryIssueFinder{},
|
||||
ddDetector: &domDropDetector{},
|
||||
crDetector: &clickRageDetector{},
|
||||
dcDetector: &deadClickDetector{},
|
||||
integrationsWaiting: true,
|
||||
}
|
||||
}
|
||||
|
|
@ -115,15 +114,14 @@ func (b *builder) handleMessage(message Message, messageID uint64) {
|
|||
b.timestamp = timestamp
|
||||
}
|
||||
|
||||
b.lastProcessedTimestamp = time.Now().UnixNano()/1e6
|
||||
|
||||
b.lastProcessedTimestamp = time.Now().UnixNano() / 1e6
|
||||
|
||||
// Might happen before the first timestamp.
|
||||
switch msg := message.(type) {
|
||||
case *SessionStart,
|
||||
*Metadata,
|
||||
*UserID,
|
||||
*UserAnonymousID:
|
||||
*Metadata,
|
||||
*UserID,
|
||||
*UserAnonymousID:
|
||||
b.appendReadyMessage(msg)
|
||||
case *RawErrorEvent:
|
||||
b.appendReadyMessage(&ErrorEvent{
|
||||
|
|
@ -220,14 +218,14 @@ func (b *builder) handleMessage(message Message, messageID uint64) {
|
|||
Type: tp,
|
||||
Success: success,
|
||||
})
|
||||
if !success && tp == "fetch" {
|
||||
b.appendReadyMessage(&IssueEvent{
|
||||
Type: "bad_request",
|
||||
MessageID: messageID,
|
||||
Timestamp: msg.Timestamp,
|
||||
if !success && tp == "fetch" {
|
||||
b.appendReadyMessage(&IssueEvent{
|
||||
Type: "bad_request",
|
||||
MessageID: messageID,
|
||||
Timestamp: msg.Timestamp,
|
||||
ContextString: msg.URL,
|
||||
Context: "",
|
||||
Payload: "",
|
||||
Context: "",
|
||||
Payload: "",
|
||||
})
|
||||
}
|
||||
case *RawCustomEvent:
|
||||
|
|
@ -239,11 +237,11 @@ func (b *builder) handleMessage(message Message, messageID uint64) {
|
|||
})
|
||||
case *CustomIssue:
|
||||
b.appendReadyMessage(&IssueEvent{
|
||||
Type: "custom",
|
||||
Timestamp: b.timestamp,
|
||||
MessageID: messageID,
|
||||
Type: "custom",
|
||||
Timestamp: b.timestamp,
|
||||
MessageID: messageID,
|
||||
ContextString: msg.Name,
|
||||
Payload: msg.Payload,
|
||||
Payload: msg.Payload,
|
||||
})
|
||||
case *Fetch:
|
||||
b.appendReadyMessage(&ResourceEvent{
|
||||
|
|
@ -283,11 +281,10 @@ func (b *builder) handleMessage(message Message, messageID uint64) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func (b *builder) checkTimeouts(ts int64) bool {
|
||||
if b.timestamp == 0 {
|
||||
if b.timestamp == 0 {
|
||||
return false // There was no timestamp events yet
|
||||
}
|
||||
}
|
||||
|
||||
if b.peBuilder.HasInstance() && int64(b.peBuilder.GetTimestamp())+intervals.EVENTS_PAGE_EVENT_TIMEOUT < ts {
|
||||
b.buildPageEvent()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue