diff --git a/backend/internal/http/router/handlers-mobile.go b/backend/internal/http/router/handlers-mobile.go index 6ebf2467f..beb61078d 100644 --- a/backend/internal/http/router/handlers-mobile.go +++ b/backend/internal/http/router/handlers-mobile.go @@ -28,7 +28,7 @@ func (e *Router) startSessionHandlerIOS(w http.ResponseWriter, r *http.Request) body := http.MaxBytesReader(w, r.Body, e.cfg.JsonSizeLimit) defer body.Close() - req := &StartIOSSessionRequest{} + req := &StartMobileSessionRequest{} if err := json.NewDecoder(body).Decode(req); err != nil { e.ResponseWithError(r.Context(), w, http.StatusBadRequest, err, startTime, r.URL.Path, 0) return @@ -105,18 +105,24 @@ 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) + platform, os, screen := "ios", "IOS", "" + if req.Platform != "" && req.Platform != "ios" { + platform = req.Platform + os = "Android" + screen = fmt.Sprintf("%d:%d", req.Width, req.Height) + } if !req.DoNotRecord { if err := e.services.Sessions.Add(&sessions.Session{ SessionID: sessionID, - Platform: "ios", + Platform: platform, Timestamp: req.Timestamp, Timezone: req.Timezone, ProjectID: p.ProjectID, TrackerVersion: req.TrackerVersion, RevID: req.RevID, UserUUID: userUUID, - UserOS: "IOS", + UserOS: os, UserOSVersion: req.UserOSVersion, UserDevice: ios.MapIOSDevice(req.UserDevice), UserDeviceType: ios.GetIOSDeviceType(req.UserDevice), @@ -125,6 +131,7 @@ func (e *Router) startSessionHandlerIOS(w http.ResponseWriter, r *http.Request) UserCity: geoInfo.City, UserDeviceMemorySize: req.DeviceMemory, UserDeviceHeapSize: req.DeviceMemory, + UserBrowser: screen, }); err != nil { e.log.Warn(r.Context(), "failed to add mobile session to DB: %s", err) } @@ -148,7 +155,7 @@ func (e *Router) startSessionHandlerIOS(w http.ResponseWriter, r *http.Request) } } - e.ResponseWithJSON(r.Context(), w, &StartIOSSessionResponse{ + e.ResponseWithJSON(r.Context(), w, &StartMobileSessionResponse{ Token: e.services.Tokenizer.Compose(*tokenData), UserUUID: userUUID, SessionID: strconv.FormatUint(tokenData.ID, 10), diff --git a/backend/internal/http/router/model.go b/backend/internal/http/router/model.go index e7f77c819..9d42778a2 100644 --- a/backend/internal/http/router/model.go +++ b/backend/internal/http/router/model.go @@ -46,7 +46,7 @@ type NotStartedRequest struct { DoNotTrack bool `json:"DoNotTrack"` } -type StartIOSSessionRequest struct { +type StartMobileSessionRequest struct { Token string `json:"token"` ProjectKey *string `json:"projectKey"` TrackerVersion string `json:"trackerVersion"` @@ -59,9 +59,12 @@ type StartIOSSessionRequest struct { DeviceMemory uint64 `json:"deviceMemory"` DoNotRecord bool `json:"doNotRecord"` // start record session or not Condition string `json:"condition"` // condition for start record session + Platform string `json:"platform"` + Width int `json:"width"` + Height int `json:"height"` } -type StartIOSSessionResponse struct { +type StartMobileSessionResponse struct { Token string `json:"token"` ImagesHashList []string `json:"imagesHashList"` UserUUID string `json:"userUUID"`