Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ci' into prebid_v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pubmatic-Supriya-Patil committed Nov 27, 2023
2 parents 5e40322 + d5e47df commit b6db403
Show file tree
Hide file tree
Showing 119 changed files with 16,310 additions and 1,811 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/validate-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: Validate Merge

on:
pull_request:
branches: [master]
branches:
- master
- main
- ci

jobs:
validate-merge:
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test: deps
ifeq "$(adapter)" ""
./validate.sh
else
go test github.com/prebid/prebid-server/adapters/$(adapter) -bench=.
go test github.com/prebid/prebid-server/v2/adapters/$(adapter) -bench=.
endif

# build-modules generates modules/builder.go file which provides a list of all available modules
Expand Down Expand Up @@ -43,12 +43,16 @@ mockgeninstall:
mockgendb:
mkdir -p modules/pubmatic/openwrap/database/mock modules/pubmatic/openwrap/database/mock_driver
mockgen database/sql/driver Driver,Connector,Conn,DriverContext > modules/pubmatic/openwrap/database/mock_driver/mock.go
mockgen github.com/PubMatic-OpenWrap/prebid-server/modules/pubmatic/openwrap/database Database > modules/pubmatic/openwrap/database/mock/mock.go
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/modules/pubmatic/openwrap/database Database > modules/pubmatic/openwrap/database/mock/mock.go

mockgencache:
mkdir -p modules/pubmatic/openwrap/cache/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/modules/pubmatic/openwrap/cache Cache > modules/pubmatic/openwrap/cache/mock/mock.go
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/modules/pubmatic/openwrap/cache Cache > modules/pubmatic/openwrap/cache/mock/mock.go

mockgenmetrics:
mkdir -p modules/pubmatic/openwrap/metrics/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/modules/pubmatic/openwrap/metrics MetricsEngine > modules/pubmatic/openwrap/metrics/mock/mock.go
mockgen github.com/PubMatic-OpenWrap/prebid-server/modules/v2/pubmatic/openwrap/metrics MetricsEngine > modules/pubmatic/openwrap/metrics/mock/mock.go

mockgenlogger:
mkdir -p analytics/pubmatic/mhttp/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/analytics/pubmatic/mhttp HttpCallInterface,MultiHttpContextInterface > analytics/pubmatic/mhttp/mock/mock.go
79 changes: 57 additions & 22 deletions adapters/vastbidder/bidder_macro.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -177,16 +176,35 @@ func (tag *BidderMacro) GetHeaders() http.Header {
return http.Header{}
}

// GetValueFromKV returns the value from KV map wrt key
func (tag *BidderMacro) GetValueFromKV(key string) string {
if tag.KV == nil {
return ""
}
key = strings.TrimPrefix(key, kvPrefix)
if value, found := tag.KV[key]; found {
return fmt.Sprintf("%v", value)
// GetValue returns the value for given key
// isKeyFound will check the key is present or not
func (tag *BidderMacro) GetValue(key string) (string, bool) {
macroKeys := strings.Split(key, ".")
isKeyFound := false

// This will check if key has prefix kv/kvm
// if prefix present it will always return isKeyFound as true as it will help to replace the key with empty string in VAST TAG
if (macroKeys[0] == MacroKV || macroKeys[0] == MacroKVM) && len(macroKeys) > 1 {
isKeyFound = true
if tag.KV == nil {
return "", isKeyFound
}
switch macroKeys[0] {
case MacroKV:
val := getValueFromMap(macroKeys[1:], tag.KV)
if dataMap, ok := val.(map[string]interface{}); ok {
return mapToQuery(dataMap), isKeyFound
}
return fmt.Sprintf("%v", val), isKeyFound
case MacroKVM:
val := getValueFromMap(macroKeys[1:], tag.KV)
if isMap(val) {
return getJSONString(val), isKeyFound
}
return fmt.Sprintf("%v", val), isKeyFound
}
}
return ""
return "", isKeyFound
}

/********************* Request *********************/
Expand Down Expand Up @@ -268,6 +286,33 @@ func (tag *BidderMacro) MacroPaymentIDChain(key string) string {
return ""
}

// MacroSchain contains definition for Schain Parameter
func (tag *BidderMacro) MacroSchain(key string) string {
if tag.Request.Source == nil {
return ""
}

if tag.Request.Source.SChain != nil {
return openrtb_ext.SerializeSupplyChain(tag.Request.Source.SChain)
}

if tag.Request.Source.Ext != nil {
schain, _, _, err := jsonparser.Get(tag.Request.Source.Ext, MacroSchain)

if err != nil {
return ""
}
var schainObj openrtb2.SupplyChain
err = json.Unmarshal(schain, &schainObj)

if err != nil {
return ""
}
return openrtb_ext.SerializeSupplyChain(&schainObj)
}
return ""
}

/********************* Regs *********************/

// MacroCoppa contains definition for Coppa Parameter
Expand Down Expand Up @@ -1209,25 +1254,15 @@ func (tag *BidderMacro) MacroKV(key string) string {
if tag.KV == nil {
return ""
}

values := url.Values{}
for key, val := range tag.KV {
values.Add(key, fmt.Sprintf("%v", val))
}
return values.Encode()

return mapToQuery(tag.KV)
}

// MacroKVM replace the kvm macro
func (tag *BidderMacro) MacroKVM(key string) string {
if tag.KV == nil {
return ""
}
jsonBytes, err := json.Marshal(tag.KV)
if err != nil {
return ""
}
return string(jsonBytes)
return getJSONString(tag.KV)
}

/********************* Request Headers *********************/
Expand Down
Loading

0 comments on commit b6db403

Please sign in to comment.