Skip to content

Commit 5a67d89

Browse files
jsnellbakerjaiminpanchal27
authored andcommitted
fix hb_cache_id for adpod bids (prebid#3617)
1 parent a84f33e commit 5a67d89

File tree

3 files changed

+94
-3
lines changed

3 files changed

+94
-3
lines changed

modules/adpod.js

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ function attachPriceIndustryDurationKeyToBid(bid, brandCategoryExclusion) {
132132
}
133133
bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR] = pcd;
134134
bid.adserverTargeting[TARGETING_KEY_CACHE_ID] = initialCacheKey;
135+
bid.videoCacheKey = initialCacheKey;
135136
bid.customCacheKey = `${pcd}_${initialCacheKey}`;
136137
}
137138

test/spec/auctionmanager_spec.js

+82-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ describe('auctionmanager.js', function () {
139139
expected[ CONSTANTS.TARGETING_KEYS.SIZE ] = bid.getSize();
140140
expected[ CONSTANTS.TARGETING_KEYS.SOURCE ] = bid.source;
141141
expected[ CONSTANTS.TARGETING_KEYS.FORMAT ] = bid.mediaType;
142-
142+
if (bid.mediaType === 'video') {
143+
expected[ CONSTANTS.TARGETING_KEYS.UUID ] = bid.videoCacheKey;
144+
expected[ CONSTANTS.TARGETING_KEYS.CACHE_ID ] = bid.videoCacheKey;
145+
}
143146
if (!keys) {
144147
return expected;
145148
}
@@ -157,8 +160,20 @@ describe('auctionmanager.js', function () {
157160
});
158161

159162
it('No bidder level configuration defined - default', function () {
160-
var expected = getDefaultExpected(bid);
161-
var response = getKeyValueTargetingPairs(bid.bidderCode, bid, CONSTANTS.GRANULARITY_OPTIONS.MEDIUM);
163+
$$PREBID_GLOBAL$$.bidderSettings = {};
164+
let expected = getDefaultExpected(bid);
165+
let response = getKeyValueTargetingPairs(bid.bidderCode, bid);
166+
assert.deepEqual(response, expected);
167+
});
168+
169+
it('No bidder level configuration defined - default for video', function () {
170+
$$PREBID_GLOBAL$$.bidderSettings = {};
171+
let videoBid = utils.deepClone(bid);
172+
videoBid.mediaType = 'video';
173+
videoBid.videoCacheKey = 'abc123def';
174+
175+
let expected = getDefaultExpected(videoBid);
176+
let response = getKeyValueTargetingPairs(videoBid.bidderCode, videoBid);
162177
assert.deepEqual(response, expected);
163178
});
164179

@@ -213,6 +228,70 @@ describe('auctionmanager.js', function () {
213228
assert.deepEqual(response, expected);
214229
});
215230

231+
it('Custom configuration for all bidders with video bid', function () {
232+
let videoBid = utils.deepClone(bid);
233+
videoBid.mediaType = 'video';
234+
videoBid.videoCacheKey = 'abc123def';
235+
236+
$$PREBID_GLOBAL$$.bidderSettings =
237+
{
238+
standard: {
239+
adserverTargeting: [
240+
{
241+
key: CONSTANTS.TARGETING_KEYS.BIDDER,
242+
val: function (bidResponse) {
243+
return bidResponse.bidderCode;
244+
}
245+
}, {
246+
key: CONSTANTS.TARGETING_KEYS.AD_ID,
247+
val: function (bidResponse) {
248+
return bidResponse.adId;
249+
}
250+
}, {
251+
key: CONSTANTS.TARGETING_KEYS.PRICE_BUCKET,
252+
val: function (bidResponse) {
253+
return bidResponse.pbMg;
254+
}
255+
}, {
256+
key: CONSTANTS.TARGETING_KEYS.SIZE,
257+
val: function (bidResponse) {
258+
return bidResponse.size;
259+
}
260+
},
261+
{
262+
key: CONSTANTS.TARGETING_KEYS.SOURCE,
263+
val: function (bidResponse) {
264+
return bidResponse.source;
265+
}
266+
},
267+
{
268+
key: CONSTANTS.TARGETING_KEYS.FORMAT,
269+
val: function (bidResponse) {
270+
return bidResponse.mediaType;
271+
}
272+
},
273+
{
274+
key: CONSTANTS.TARGETING_KEYS.UUID,
275+
val: function (bidResponse) {
276+
return bidResponse.videoCacheKey;
277+
}
278+
},
279+
{
280+
key: CONSTANTS.TARGETING_KEYS.CACHE_ID,
281+
val: function (bidResponse) {
282+
return bidResponse.videoCacheKey;
283+
}
284+
}
285+
]
286+
287+
}
288+
};
289+
290+
let expected = getDefaultExpected(videoBid);
291+
let response = getKeyValueTargetingPairs(videoBid.bidderCode, videoBid);
292+
assert.deepEqual(response, expected);
293+
});
294+
216295
it('Custom configuration for one bidder', function () {
217296
$$PREBID_GLOBAL$$.bidderSettings =
218297
{

test/spec/modules/adpod_spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,13 @@ describe('adpod.js', function () {
150150
expect(auctionBids[0].customCacheKey).to.exist.and.to.match(/^5\.00_test_15s_.*/);
151151
expect(auctionBids[0].adserverTargeting.hb_pb_cat_dur).to.equal('5.00_test_15s');
152152
expect(auctionBids[0].adserverTargeting.hb_cache_id).to.exist;
153+
expect(auctionBids[0].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id)
153154
expect(auctionBids[1].adId).to.equal(bidResponse2.adId);
154155
expect(auctionBids[1].customCacheKey).to.exist.and.to.match(/^12\.00_value_15s_.*/);
155156
expect(auctionBids[1].adserverTargeting.hb_pb_cat_dur).to.equal('12.00_value_15s');
156157
expect(auctionBids[1].adserverTargeting.hb_cache_id).to.exist;
157158
expect(auctionBids[1].adserverTargeting.hb_cache_id).to.equal(auctionBids[0].adserverTargeting.hb_cache_id);
159+
expect(auctionBids[1].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id);
158160
});
159161

160162
it('should send prebid cache call once bid queue is full', function () {
@@ -220,10 +222,12 @@ describe('adpod.js', function () {
220222
expect(auctionBids[0].customCacheKey).to.exist.and.to.match(/^10\.00_airline_30s_.*/);
221223
expect(auctionBids[0].adserverTargeting.hb_pb_cat_dur).to.equal('10.00_airline_30s');
222224
expect(auctionBids[0].adserverTargeting.hb_cache_id).to.exist;
225+
expect(auctionBids[0].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id)
223226
expect(auctionBids[1].adId).to.equal('adId234');
224227
expect(auctionBids[1].customCacheKey).to.exist.and.to.match(/^15\.00_airline_30s_.*/);
225228
expect(auctionBids[1].adserverTargeting.hb_pb_cat_dur).to.equal('15.00_airline_30s');
226229
expect(auctionBids[1].adserverTargeting.hb_cache_id).to.exist;
230+
expect(auctionBids[1].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id)
227231
});
228232

229233
it('should send prebid cache call after set period of time (even if queue is not full)', function () {
@@ -276,6 +280,7 @@ describe('adpod.js', function () {
276280
expect(auctionBids[0].customCacheKey).to.exist.and.to.match(/^15\.00_airline_30s_.*/);
277281
expect(auctionBids[0].adserverTargeting.hb_pb_cat_dur).to.equal('15.00_airline_30s');
278282
expect(auctionBids[0].adserverTargeting.hb_cache_id).to.exist;
283+
expect(auctionBids[0].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id)
279284
});
280285

281286
it('should execute multiple prebid cache calls when number of bids exceeds queue size', function () {
@@ -360,14 +365,17 @@ describe('adpod.js', function () {
360365
expect(auctionBids[0].customCacheKey).to.exist.and.to.match(/^15\.00_airline_15s_.*/);
361366
expect(auctionBids[0].adserverTargeting.hb_pb_cat_dur).to.equal('15.00_airline_15s');
362367
expect(auctionBids[0].adserverTargeting.hb_cache_id).to.exist;
368+
expect(auctionBids[0].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id)
363369
expect(auctionBids[1].adId).to.equal('multi_ad2');
364370
expect(auctionBids[1].customCacheKey).to.exist.and.to.match(/^15\.00_news_15s_.*/);
365371
expect(auctionBids[1].adserverTargeting.hb_pb_cat_dur).to.equal('15.00_news_15s');
366372
expect(auctionBids[1].adserverTargeting.hb_cache_id).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id);
373+
expect(auctionBids[1].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id)
367374
expect(auctionBids[2].adId).to.equal('multi_ad3');
368375
expect(auctionBids[2].customCacheKey).to.exist.and.to.match(/^10\.00_sports_15s_.*/);
369376
expect(auctionBids[2].adserverTargeting.hb_pb_cat_dur).to.equal('10.00_sports_15s');
370377
expect(auctionBids[2].adserverTargeting.hb_cache_id).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id);
378+
expect(auctionBids[2].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id)
371379
});
372380

373381
it('should cache the bids with a shortened custom key when adpod.brandCategoryExclusion is false', function() {
@@ -436,10 +444,12 @@ describe('adpod.js', function () {
436444
expect(auctionBids[0].customCacheKey).to.exist.and.to.match(/^10\.00_15s_.*/);
437445
expect(auctionBids[0].adserverTargeting.hb_pb_cat_dur).to.equal('10.00_15s');
438446
expect(auctionBids[0].adserverTargeting.hb_cache_id).to.exist;
447+
expect(auctionBids[0].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id)
439448
expect(auctionBids[1].adId).to.equal('nocat_ad2');
440449
expect(auctionBids[1].customCacheKey).to.exist.and.to.match(/^15\.00_15s_.*/);
441450
expect(auctionBids[1].adserverTargeting.hb_pb_cat_dur).to.equal('15.00_15s');
442451
expect(auctionBids[1].adserverTargeting.hb_cache_id).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id);
452+
expect(auctionBids[1].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id)
443453
});
444454

445455
it('should not add bid to auction when config adpod.brandCategoryExclusion is true but bid is missing adServerCatId', function() {
@@ -564,6 +574,7 @@ describe('adpod.js', function () {
564574
expect(auctionBids[0].customCacheKey).to.exist.and.to.match(/^5\.00_tech_45s_.*/);
565575
expect(auctionBids[0].adserverTargeting.hb_pb_cat_dur).to.equal('5.00_tech_45s');
566576
expect(auctionBids[0].adserverTargeting.hb_cache_id).to.exist;
577+
expect(auctionBids[0].videoCacheKey).to.exist.and.to.equal(auctionBids[0].adserverTargeting.hb_cache_id)
567578
});
568579

569580
it('should not add bids to auction if PBC returns an error', function() {

0 commit comments

Comments
 (0)