feat(backend): added session's screen width/height to PG
This commit is contained in:
parent
b5d0770052
commit
486a7115d7
5 changed files with 12 additions and 6 deletions
|
|
@ -105,13 +105,11 @@ func (e *Router) startSessionHandlerIOS(w http.ResponseWriter, r *http.Request)
|
|||
r = r.WithContext(context.WithValue(r.Context(), "sessionID", fmt.Sprintf("%d", sessionID)))
|
||||
|
||||
geoInfo := e.ExtractGeoData(r)
|
||||
deviceType, platform, os, screen := ios.GetIOSDeviceType(req.UserDevice), "ios", "IOS", ""
|
||||
deviceType, platform, os := ios.GetIOSDeviceType(req.UserDevice), "ios", "IOS"
|
||||
if req.Platform != "" && req.Platform != "ios" {
|
||||
deviceType = req.UserDeviceType
|
||||
platform = req.Platform
|
||||
os = "Android"
|
||||
screen = fmt.Sprintf("%d:%d", req.Width, req.Height)
|
||||
e.log.Info(r.Context(), "mobile screen size: %s", screen)
|
||||
}
|
||||
|
||||
if !req.DoNotRecord {
|
||||
|
|
@ -133,6 +131,8 @@ func (e *Router) startSessionHandlerIOS(w http.ResponseWriter, r *http.Request)
|
|||
UserCity: geoInfo.City,
|
||||
UserDeviceMemorySize: req.DeviceMemory,
|
||||
UserDeviceHeapSize: req.DeviceMemory,
|
||||
ScreenWidth: req.Width,
|
||||
ScreenHeight: req.Height,
|
||||
}); err != nil {
|
||||
e.log.Warn(r.Context(), "failed to add mobile session to DB: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,6 +245,8 @@ func (e *Router) startSessionHandlerWeb(w http.ResponseWriter, r *http.Request)
|
|||
UserDeviceMemorySize: sessionStart.UserDeviceMemorySize,
|
||||
UserDeviceHeapSize: sessionStart.UserDeviceHeapSize,
|
||||
UserID: &sessionStart.UserID,
|
||||
ScreenWidth: req.Width,
|
||||
ScreenHeight: req.Height,
|
||||
}); err != nil {
|
||||
e.log.Warn(r.Context(), "can't insert sessionStart to DB: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ type StartSessionRequest struct {
|
|||
BufferDiff uint64 `json:"bufferDiff"` // buffer diff in ms for start record session
|
||||
IsOffline bool `json:"isOffline"` // to indicate that we have to use user's start timestamp
|
||||
Condition string `json:"condition"` // condition for start record session
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
}
|
||||
|
||||
type StartSessionResponse struct {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ type Session struct {
|
|||
UserDeviceHeapSize uint64
|
||||
SaveRequestPayload bool
|
||||
EncryptionKey string
|
||||
ScreenWidth int
|
||||
ScreenHeight int
|
||||
}
|
||||
|
||||
func (s *Session) SetMetadata(keyNo uint, value string) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func (s *storageImpl) Add(sess *Session) error {
|
|||
tracker_version, issue_score,
|
||||
platform,
|
||||
user_browser, user_browser_version, user_device_memory_size, user_device_heap_size,
|
||||
user_id, user_state, user_city, timezone
|
||||
user_id, user_state, user_city, timezone, screen_width, screen_height
|
||||
) VALUES (
|
||||
$1, $2, $3,
|
||||
$4, $5, $6, $7,
|
||||
|
|
@ -50,7 +50,7 @@ func (s *storageImpl) Add(sess *Session) error {
|
|||
$11, $12,
|
||||
$13,
|
||||
NULLIF($14, ''), NULLIF($15, ''), NULLIF($16, 0), NULLIF($17, 0::bigint),
|
||||
NULLIF(LEFT($18, 8000), ''), NULLIF($19, ''), NULLIF($20, ''), $21
|
||||
NULLIF(LEFT($18, 8000), ''), NULLIF($19, ''), NULLIF($20, ''), $21, $22, $23
|
||||
)`,
|
||||
sess.SessionID, sess.ProjectID, sess.Timestamp,
|
||||
sess.UserUUID, sess.UserDevice, sess.UserDeviceType, sess.UserCountry,
|
||||
|
|
@ -59,7 +59,7 @@ func (s *storageImpl) Add(sess *Session) error {
|
|||
sess.TrackerVersion, sess.Timestamp/1000,
|
||||
sess.Platform,
|
||||
sess.UserBrowser, sess.UserBrowserVersion, sess.UserDeviceMemorySize, sess.UserDeviceHeapSize,
|
||||
sess.UserID, sess.UserState, sess.UserCity, sess.Timezone,
|
||||
sess.UserID, sess.UserState, sess.UserCity, sess.Timezone, sess.ScreenWidth, sess.ScreenHeight,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue