Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UOE-9673: OpenWrap module minor improvements #579

Merged
merged 6 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions modules/pubmatic/openwrap/adunitconfig/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import (
"github.com/prebid/prebid-server/modules/pubmatic/openwrap/models/adunitconfig"
)

func ReplaceDeviceTypeFromAdUnitConfig(rCtx models.RequestCtx, device *openrtb2.Device) {
if device != nil || device.DeviceType != 0 {
func ReplaceDeviceTypeFromAdUnitConfig(rCtx models.RequestCtx, device **openrtb2.Device) {
pm-nilesh-chate marked this conversation as resolved.
Show resolved Hide resolved
if *device == nil {
pm-nilesh-chate marked this conversation as resolved.
Show resolved Hide resolved
*device = &openrtb2.Device{}
}

if (*device).DeviceType != 0 {
return
}

Expand All @@ -28,9 +32,5 @@ func ReplaceDeviceTypeFromAdUnitConfig(rCtx models.RequestCtx, device *openrtb2.
return
}

if device == nil {
device = &openrtb2.Device{}
}

device.DeviceType = adcom1.DeviceType(adUnitCfg.Device.DeviceType)
(*device).DeviceType = adcom1.DeviceType(adUnitCfg.Device.DeviceType)
}
2 changes: 1 addition & 1 deletion modules/pubmatic/openwrap/beforevalidationhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func (m *OpenWrap) applyProfileChanges(rctx models.RequestCtx, bidRequest *openr
}

adunitconfig.ReplaceAppObjectFromAdUnitConfig(rctx, bidRequest.App)
adunitconfig.ReplaceDeviceTypeFromAdUnitConfig(rctx, bidRequest.Device)
adunitconfig.ReplaceDeviceTypeFromAdUnitConfig(rctx, &bidRequest.Device)

bidRequest.Device.IP = rctx.IP
bidRequest.Device.Language = getValidLanguage(bidRequest.Device.Language)
Expand Down
28 changes: 23 additions & 5 deletions modules/pubmatic/openwrap/entrypointhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ import (
)

const (
OpenWrapAuction = "/pbs/openrtb2/auction"
OpenWrapV25 = "/openrtb/2.5"
OpenWrapV25Video = "/openrtb/2.5/video"
OpenWrapAmp = "/openrtb/amp"
OpenWrapAuction = "/pbs/openrtb2/auction"
OpenWrapV25 = "/openrtb/2.5"
OpenWrapV25Video = "/openrtb/2.5/video"
OpenWrapOpenRTBVideo = "/video/openrtb"
OpenWrapVAST = "/video/vast"
OpenWrapJSON = "/video/json"
OpenWrapAmp = "/amp"
)

func (m OpenWrap) handleEntrypointHook(
Expand All @@ -32,6 +35,7 @@ func (m OpenWrap) handleEntrypointHook(
return result, nil
}

var pubid int
var endpoint string
var err error
var requestExtWrapper models.RequestExtWrapper
Expand All @@ -51,8 +55,17 @@ func (m OpenWrap) handleEntrypointHook(
requestExtWrapper, err = v25.ConvertVideoToAuctionRequest(payload, &result)
endpoint = models.EndpointVideo
case OpenWrapAmp:
// requestExtWrapper, err = models.GetQueryParamRequestExtWrapper(payload.Body)
requestExtWrapper, pubid, err = models.GetQueryParamRequestExtWrapper(payload.Request)
endpoint = models.EndpointAMP
case OpenWrapOpenRTBVideo:
requestExtWrapper, err = models.GetRequestExtWrapper(payload.Body, "ext", "wrapper")
endpoint = models.EndpointVideo
case OpenWrapVAST:
pm-nilesh-chate marked this conversation as resolved.
Show resolved Hide resolved
requestExtWrapper, err = models.GetRequestExtWrapper(payload.Body, "ext", "wrapper")
endpoint = models.EndpointVAST
case OpenWrapJSON:
requestExtWrapper, err = models.GetRequestExtWrapper(payload.Body, "ext", "wrapper")
endpoint = models.EndpointJson
default:
// we should return from here
}
Expand Down Expand Up @@ -117,6 +130,11 @@ func (m OpenWrap) handleEntrypointHook(
rCtx.LoggerImpressionID = uuid.NewV4().String()
}

// temp, for AMP, etc
if pubid != 0 {
rCtx.PubID = pubid
}

result.ModuleContext = make(hookstage.ModuleContext)
result.ModuleContext["rctx"] = rCtx

Expand Down
19 changes: 19 additions & 0 deletions modules/pubmatic/openwrap/models/amp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package models

import (
"net/http"
"strconv"
)

func GetQueryParamRequestExtWrapper(request *http.Request) (RequestExtWrapper, int, error) {
extWrapper := RequestExtWrapper{
SSAuctionFlag: -1,
}

values := request.URL.Query()
pubid, _ := strconv.Atoi(values.Get(PUBID_KEY))
extWrapper.ProfileId, _ = strconv.Atoi(values.Get(PROFILEID_KEY))
extWrapper.VersionId, _ = strconv.Atoi(values.Get(VERSION_KEY))

return extWrapper, pubid, nil
}
1 change: 1 addition & 0 deletions modules/pubmatic/openwrap/models/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ const (
EndpointJson = "json"
EndpointORTB = "ortb"
EndpointVAST = "vast"
EndPointCTV = "ctv"
Openwrap = "openwrap"
ImpTypeBanner = "banner"
ImpTypeVideo = "video"
Expand Down
5 changes: 5 additions & 0 deletions modules/pubmatic/openwrap/openwrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
metrics "github.com/prebid/prebid-server/modules/pubmatic/openwrap/metrics"
metrics_cfg "github.com/prebid/prebid-server/modules/pubmatic/openwrap/metrics/config"
"github.com/prebid/prebid-server/modules/pubmatic/openwrap/models"
"github.com/prebid/prebid-server/modules/pubmatic/openwrap/tbf"
)

const (
Expand Down Expand Up @@ -66,8 +67,12 @@ func initOpenWrap(rawCfg json.RawMessage, moduleDeps moduledeps.ModuleDeps) (Ope

owCache := ow_gocache.New(cache, db, cfg.Cache, &metricEngine)

// Init FSC and related services
fullscreenclickability.Init(owCache, cfg.Cache.CacheDefaultExpiry)

// Init TBF (tracking-beacon-first) feature related services
tbf.Init(cfg.Cache.CacheDefaultExpiry, owCache)

return OpenWrap{
cfg: cfg,
cache: owCache,
Expand Down
38 changes: 38 additions & 0 deletions modules/pubmatic/openwrap/openwrap_sshb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package openwrap

import (
cache "github.com/prebid/prebid-server/modules/pubmatic/openwrap/cache"
"github.com/prebid/prebid-server/modules/pubmatic/openwrap/config"
metrics "github.com/prebid/prebid-server/modules/pubmatic/openwrap/metrics"
)

// GetConfig Temporary function to expose config to SSHB
func (ow OpenWrap) GetConfig() config.Config {
return ow.cfg

}

// GetCache Temporary function to expose cache to SSHB
func (ow OpenWrap) GetCache() cache.Cache {
return ow.cache
}

// GetMetricEngine Temporary function to expose mertics to SSHB
func (ow OpenWrap) GetMetricEngine() metrics.MetricsEngine {
return ow.metricEngine
}

// SetConfig Temporary function to expose config to SSHB
func (ow *OpenWrap) SetConfig(c config.Config) {
ow.cfg = c
}

// GetCache Temporary function to expose cache to SSHB
func (ow *OpenWrap) SetCache(c cache.Cache) {
ow.cache = c
}

// GetMetricEngine Temporary function to expose mertics to SSHB
func (ow *OpenWrap) SetMetricEngine(m metrics.MetricsEngine) {
ow.metricEngine = m
}