feat(backend): added new fields to mobile start request
This commit is contained in:
parent
80f0005362
commit
8c84fd6550
2 changed files with 16 additions and 6 deletions
|
|
@ -28,7 +28,7 @@ func (e *Router) startSessionHandlerIOS(w http.ResponseWriter, r *http.Request)
|
||||||
body := http.MaxBytesReader(w, r.Body, e.cfg.JsonSizeLimit)
|
body := http.MaxBytesReader(w, r.Body, e.cfg.JsonSizeLimit)
|
||||||
defer body.Close()
|
defer body.Close()
|
||||||
|
|
||||||
req := &StartIOSSessionRequest{}
|
req := &StartMobileSessionRequest{}
|
||||||
if err := json.NewDecoder(body).Decode(req); err != nil {
|
if err := json.NewDecoder(body).Decode(req); err != nil {
|
||||||
e.ResponseWithError(r.Context(), w, http.StatusBadRequest, err, startTime, r.URL.Path, 0)
|
e.ResponseWithError(r.Context(), w, http.StatusBadRequest, err, startTime, r.URL.Path, 0)
|
||||||
return
|
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)))
|
r = r.WithContext(context.WithValue(r.Context(), "sessionID", fmt.Sprintf("%d", sessionID)))
|
||||||
|
|
||||||
geoInfo := e.ExtractGeoData(r)
|
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 !req.DoNotRecord {
|
||||||
if err := e.services.Sessions.Add(&sessions.Session{
|
if err := e.services.Sessions.Add(&sessions.Session{
|
||||||
SessionID: sessionID,
|
SessionID: sessionID,
|
||||||
Platform: "ios",
|
Platform: platform,
|
||||||
Timestamp: req.Timestamp,
|
Timestamp: req.Timestamp,
|
||||||
Timezone: req.Timezone,
|
Timezone: req.Timezone,
|
||||||
ProjectID: p.ProjectID,
|
ProjectID: p.ProjectID,
|
||||||
TrackerVersion: req.TrackerVersion,
|
TrackerVersion: req.TrackerVersion,
|
||||||
RevID: req.RevID,
|
RevID: req.RevID,
|
||||||
UserUUID: userUUID,
|
UserUUID: userUUID,
|
||||||
UserOS: "IOS",
|
UserOS: os,
|
||||||
UserOSVersion: req.UserOSVersion,
|
UserOSVersion: req.UserOSVersion,
|
||||||
UserDevice: ios.MapIOSDevice(req.UserDevice),
|
UserDevice: ios.MapIOSDevice(req.UserDevice),
|
||||||
UserDeviceType: ios.GetIOSDeviceType(req.UserDevice),
|
UserDeviceType: ios.GetIOSDeviceType(req.UserDevice),
|
||||||
|
|
@ -125,6 +131,7 @@ func (e *Router) startSessionHandlerIOS(w http.ResponseWriter, r *http.Request)
|
||||||
UserCity: geoInfo.City,
|
UserCity: geoInfo.City,
|
||||||
UserDeviceMemorySize: req.DeviceMemory,
|
UserDeviceMemorySize: req.DeviceMemory,
|
||||||
UserDeviceHeapSize: req.DeviceMemory,
|
UserDeviceHeapSize: req.DeviceMemory,
|
||||||
|
UserBrowser: screen,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
e.log.Warn(r.Context(), "failed to add mobile session to DB: %s", err)
|
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),
|
Token: e.services.Tokenizer.Compose(*tokenData),
|
||||||
UserUUID: userUUID,
|
UserUUID: userUUID,
|
||||||
SessionID: strconv.FormatUint(tokenData.ID, 10),
|
SessionID: strconv.FormatUint(tokenData.ID, 10),
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ type NotStartedRequest struct {
|
||||||
DoNotTrack bool `json:"DoNotTrack"`
|
DoNotTrack bool `json:"DoNotTrack"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type StartIOSSessionRequest struct {
|
type StartMobileSessionRequest struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
ProjectKey *string `json:"projectKey"`
|
ProjectKey *string `json:"projectKey"`
|
||||||
TrackerVersion string `json:"trackerVersion"`
|
TrackerVersion string `json:"trackerVersion"`
|
||||||
|
|
@ -59,9 +59,12 @@ type StartIOSSessionRequest struct {
|
||||||
DeviceMemory uint64 `json:"deviceMemory"`
|
DeviceMemory uint64 `json:"deviceMemory"`
|
||||||
DoNotRecord bool `json:"doNotRecord"` // start record session or not
|
DoNotRecord bool `json:"doNotRecord"` // start record session or not
|
||||||
Condition string `json:"condition"` // condition for start record session
|
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"`
|
Token string `json:"token"`
|
||||||
ImagesHashList []string `json:"imagesHashList"`
|
ImagesHashList []string `json:"imagesHashList"`
|
||||||
UserUUID string `json:"userUUID"`
|
UserUUID string `json:"userUUID"`
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue