Skip to content

Commit

Permalink
OTT-806: Adding CTV API in Modules (#532)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikhil Vaidya
Co-authored-by: Ankit-Pinge
Co-authored-by: Dhruv Sonone
Co-authored-by: Pubmatic-Supriya-Patil
  • Loading branch information
pm-nikhil-vaidya authored Jul 2, 2024
1 parent b8011ea commit e39df49
Show file tree
Hide file tree
Showing 93 changed files with 14,797 additions and 523 deletions.
55 changes: 42 additions & 13 deletions analytics/pubmatic/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,16 @@ func GetLogAuctionObjectAsURL(ao analytics.AuctionObject, rCtx *models.RequestCt

// parent bidder could in one of the above and we need them by prebid's bidderCode and not seat(could be alias)
slots := make([]SlotRecord, 0)
for _, imp := range ao.RequestWrapper.Imp {
impCtx, ok := rCtx.ImpBidCtx[imp.ID]
if !ok {
continue
}
for impId, impCtx := range rCtx.ImpBidCtx {
reward := 0
if impCtx.IsRewardInventory != nil {
reward = int(*impCtx.IsRewardInventory)
}

// to keep existing response intact
partnerData := make([]PartnerRecord, 0)
if ipr[imp.ID] != nil {
partnerData = ipr[imp.ID]
if ipr[impId] != nil {
partnerData = ipr[impId]
}

slots = append(slots, SlotRecord{
Expand All @@ -119,7 +115,7 @@ func GetLogAuctionObjectAsURL(ao analytics.AuctionObject, rCtx *models.RequestCt
Adunit: impCtx.AdUnitName,
PartnerData: partnerData,
RewardedInventory: int(reward),
// AdPodSlot: getAdPodSlot(imp, responseMap.AdPodBidsExt),
AdPodSlot: getAdPodSlot(impCtx.AdpodConfig),
})
}

Expand Down Expand Up @@ -324,7 +320,12 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)
}

for _, bid := range bids {
impCtx, ok := rCtx.ImpBidCtx[bid.ImpID]
var sequence int
impId := bid.ImpID
if rCtx.IsCTVRequest {
impId, sequence = models.GetImpressionID(impId)
}
impCtx, ok := rCtx.ImpBidCtx[impId]
if !ok {
continue
}
Expand Down Expand Up @@ -378,7 +379,7 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)
kgpv = tracker.Tracker.PartnerInfo.KGPV
kgpsv = tracker.Tracker.LoggerData.KGPSV
if kgpv == "" || kgpsv == "" {
kgpv, kgpsv = models.GetKGPSV(*bid.Bid, bidderMeta, adFormat, impCtx.TagID, impCtx.Div, rCtx.Source)
kgpv, kgpsv = models.GetKGPSV(*bid.Bid, &bidExt, bidderMeta, adFormat, impCtx.TagID, impCtx.Div, rCtx.Source)
}

price := bid.Price
Expand All @@ -391,7 +392,7 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)
}

if seat == models.BidderPubMatic {
pmMkt[bid.ImpID] = pubmaticMarketplaceMeta{
pmMkt[impId] = pubmaticMarketplaceMeta{
PubmaticKGP: kgp,
PubmaticKGPV: kgpv,
PubmaticKGPSV: kgpsv,
Expand Down Expand Up @@ -456,7 +457,7 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)
}

// WinningBids contains map of imp.id against bid.id+::+uuid
if b, ok := rCtx.WinningBids[bid.ImpID]; ok && b.ID == bidIDForLookup {
if rCtx.WinningBids.IsWinningBid(impId, bidIDForLookup) {
pr.WinningBidStaus = 1
}

Expand Down Expand Up @@ -495,12 +496,23 @@ func getPartnerRecordsByImp(ao analytics.AuctionObject, rCtx *models.RequestCtx)
}
}

if len(bid.Cat) > 0 {
pr.Cat = append(pr.Cat, bid.Cat...)
}

// Adpod parameters
if impCtx.AdpodConfig != nil {
pr.AdPodSequenceNumber = &sequence
aprc := int(impCtx.BidIDToAPRC[bidIDForLookup])
pr.NoBidReason = &aprc
}

pr.PriceBucket = tracker.Tracker.PartnerInfo.PriceBucket
if !models.IsDefaultBid(bid.Bid) && pr.PriceBucket == "" && rCtx.PriceGranularity != nil {
pr.PriceBucket = exchange.GetPriceBucketOW(bid.Price, *rCtx.PriceGranularity)
}

ipr[bid.ImpID] = append(ipr[bid.ImpID], pr)
ipr[impId] = append(ipr[impId], pr)
}
}

Expand Down Expand Up @@ -535,3 +547,20 @@ func getDefaultPartnerRecordsByImp(rCtx *models.RequestCtx) map[string][]Partner
}
return ipr
}

func getAdPodSlot(adPodConfig *models.AdPod) *AdPodSlot {
if adPodConfig == nil {
return nil
}

adPodSlot := AdPodSlot{
MinAds: adPodConfig.MinAds,
MaxAds: adPodConfig.MaxAds,
MinDuration: adPodConfig.MinDuration,
MaxDuration: adPodConfig.MaxDuration,
AdvertiserExclusionPercent: *adPodConfig.AdvertiserExclusionPercent,
IABCategoryExclusionPercent: *adPodConfig.IABCategoryExclusionPercent,
}

return &adPodSlot
}
Loading

0 comments on commit e39df49

Please sign in to comment.