diff --git a/backend/Dockerfile b/backend/Dockerfile index 9f5db5de7..b17fe07c6 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -106,7 +106,9 @@ ENV TZ=UTC \ RECORD_CANVAS=true \ JWT_SECRET="SECRET" \ JWT_SPOT_SECRET="SECRET" \ - BUCKET_NAME="spots" + BUCKET_NAME="spots" \ + IS_FEATURE_FLAG_ENABLED=false \ + IS_USABILITY_TEST_ENABLED=false RUN if [ "$SERVICE_NAME" = "http" ]; then \ diff --git a/backend/internal/config/http/config.go b/backend/internal/config/http/config.go index 36b3b6ecc..720b6f1f7 100644 --- a/backend/internal/config/http/config.go +++ b/backend/internal/config/http/config.go @@ -37,6 +37,8 @@ type Config struct { CanvasFps int `env:"CANVAS_FPS,default=1"` MobileQuality string `env:"MOBILE_QUALITY,default=low"` // (low, standard, high) MobileFps int `env:"MOBILE_FPS,default=1"` + IsFeatureFlagEnabled bool `env:"IS_FEATURE_FLAG_ENABLED,default=false"` + IsUsabilityTestEnabled bool `env:"IS_USABILITY_TEST_ENABLED,default=false"` WorkerID uint16 } diff --git a/backend/internal/http/router/handlers-mobile.go b/backend/internal/http/router/handlers-mobile.go index c51509e65..b9b5366dd 100644 --- a/backend/internal/http/router/handlers-mobile.go +++ b/backend/internal/http/router/handlers-mobile.go @@ -164,6 +164,7 @@ func (e *Router) startMobileSessionHandler(w http.ResponseWriter, r *http.Reques ImageQuality: e.cfg.MobileQuality, FrameRate: e.cfg.MobileFps, ProjectID: strconv.FormatUint(uint64(p.ProjectID), 10), + Features: e.features, }, startTime, r.URL.Path, 0) } diff --git a/backend/internal/http/router/handlers-web.go b/backend/internal/http/router/handlers-web.go index 454218e51..e5518053e 100644 --- a/backend/internal/http/router/handlers-web.go +++ b/backend/internal/http/router/handlers-web.go @@ -281,6 +281,7 @@ func (e *Router) startSessionHandlerWeb(w http.ResponseWriter, r *http.Request) CanvasEnabled: e.cfg.RecordCanvas, CanvasImageQuality: e.cfg.CanvasQuality, CanvasFrameRate: e.cfg.CanvasFps, + Features: e.features, } modifyResponse(req, startResponse) diff --git a/backend/internal/http/router/model.go b/backend/internal/http/router/model.go index cf154f363..6649b26cc 100644 --- a/backend/internal/http/router/model.go +++ b/backend/internal/http/router/model.go @@ -26,12 +26,13 @@ type StartMobileSessionRequest struct { } type StartMobileSessionResponse struct { - Token string `json:"token"` - ImagesHashList []string `json:"imagesHashList"` - UserUUID string `json:"userUUID"` - BeaconSizeLimit int64 `json:"beaconSizeLimit"` - SessionID string `json:"sessionID"` - ImageQuality string `json:"quality"` - FrameRate int `json:"fps"` - ProjectID string `json:"projectID"` + Token string `json:"token"` + ImagesHashList []string `json:"imagesHashList"` + UserUUID string `json:"userUUID"` + BeaconSizeLimit int64 `json:"beaconSizeLimit"` + SessionID string `json:"sessionID"` + ImageQuality string `json:"quality"` + FrameRate int `json:"fps"` + ProjectID string `json:"projectID"` + Features map[string]bool `json:"features"` } diff --git a/backend/internal/http/router/router.go b/backend/internal/http/router/router.go index 71954431f..6bc158c44 100644 --- a/backend/internal/http/router/router.go +++ b/backend/internal/http/router/router.go @@ -30,6 +30,7 @@ type Router struct { services *http2.ServicesBuilder beaconSizeCache map[uint64]*BeaconSize // Cache for session's beaconSize compressionThreshold int64 + features map[string]bool } func NewRouter(cfg *http3.Config, log logger.Logger, services *http2.ServicesBuilder) (*Router, error) { @@ -48,6 +49,10 @@ func NewRouter(cfg *http3.Config, log logger.Logger, services *http2.ServicesBui services: services, beaconSizeCache: make(map[uint64]*BeaconSize), compressionThreshold: cfg.CompressionThreshold, + features: map[string]bool{ + "feature-flags": cfg.IsFeatureFlagEnabled, + "usability-test": cfg.IsUsabilityTestEnabled, + }, } e.init() go e.clearBeaconSizes() diff --git a/backend/internal/http/router/web-start.go b/backend/internal/http/router/web-start.go index 97977b925..3b21936c7 100644 --- a/backend/internal/http/router/web-start.go +++ b/backend/internal/http/router/web-start.go @@ -22,24 +22,25 @@ type StartSessionRequest struct { } type StartSessionResponse struct { - Timestamp int64 `json:"timestamp"` - StartTimestamp int64 `json:"startTimestamp"` - Delay int64 `json:"delay"` - Token string `json:"token"` - UserUUID string `json:"userUUID"` - UserOS string `json:"userOS"` - UserDevice string `json:"userDevice"` - UserBrowser string `json:"userBrowser"` - UserCountry string `json:"userCountry"` - UserState string `json:"userState"` - UserCity string `json:"userCity"` - SessionID string `json:"sessionID"` - ProjectID string `json:"projectID"` - BeaconSizeLimit int64 `json:"beaconSizeLimit"` - CompressionThreshold int64 `json:"compressionThreshold"` - CanvasEnabled bool `json:"canvasEnabled"` // false default - CanvasImageQuality string `json:"canvasQuality"` // low | medium | high - CanvasFrameRate int `json:"canvasFPS"` // 2 default + Timestamp int64 `json:"timestamp"` + StartTimestamp int64 `json:"startTimestamp"` + Delay int64 `json:"delay"` + Token string `json:"token"` + UserUUID string `json:"userUUID"` + UserOS string `json:"userOS"` + UserDevice string `json:"userDevice"` + UserBrowser string `json:"userBrowser"` + UserCountry string `json:"userCountry"` + UserState string `json:"userState"` + UserCity string `json:"userCity"` + SessionID string `json:"sessionID"` + ProjectID string `json:"projectID"` + BeaconSizeLimit int64 `json:"beaconSizeLimit"` + CompressionThreshold int64 `json:"compressionThreshold"` + CanvasEnabled bool `json:"canvasEnabled"` // false default + CanvasImageQuality string `json:"canvasQuality"` // low | medium | high + CanvasFrameRate int `json:"canvasFPS"` // 2 default + Features map[string]bool `json:"features"` } func recordSession(req *StartSessionRequest) bool {