@@ -90,10 +90,10 @@ const cacheManager = {
90
90
const bidsCacheSection = this . cache [ auctionId ] . bids . adUnits ;
91
91
Object . assign ( bidsCacheSection [ adUnitCode ] [ bidderCode ] , newObject )
92
92
} ,
93
- getStatus ( auctionId , adUnitCode ) {
93
+ getAuctionStatus ( auctionId , adUnitCode ) {
94
94
return this . cache [ auctionId ] . status [ adUnitCode ] ;
95
95
} ,
96
- setStatus ( auctionId , adUnitCode , newValue ) {
96
+ setAuctionStatus ( auctionId , adUnitCode , newValue ) {
97
97
this . cache [ auctionId ] . status [ adUnitCode ] = newValue ;
98
98
} ,
99
99
setAdCache ( auctionId , adUnitCode , bidderCode , newObject ) {
@@ -105,6 +105,11 @@ const cacheManager = {
105
105
const bidsWonCacheSection = this . cache [ auctionId ] . bidsWon . adUnits ;
106
106
bidsWonCacheSection [ adUnitCode ] = bidsWonCacheSection [ adUnitCode ] || { } ;
107
107
bidsWonCacheSection [ adUnitCode ] [ bidderCode ] = newObject ;
108
+ } ,
109
+ isBidderTimeout ( auctionId , adUnitCode , bidderCode ) {
110
+ const bid = cacheManager . getBidsCache ( auctionId , adUnitCode , bidderCode ) ;
111
+ return this . getAuctionStatus ( auctionId , adUnitCode ) === AUCTION_STATUS . COMPLETED ||
112
+ bid . status === BIDDER_STATUS . TIMEOUT
108
113
}
109
114
} ;
110
115
@@ -180,7 +185,7 @@ export const appierAnalyticsAdapter = Object.assign(adapter({DEFAULT_SERVER, ana
180
185
bidderRequest . bids . forEach ( function ( bid ) {
181
186
const adUnitCode = parseAdUnitCode ( bid ) ;
182
187
cacheManager . initBidsCache ( auction . auctionId , adUnitCode , bidderCode ) ;
183
- cacheManager . setStatus ( auction . auctionId , adUnitCode , AUCTION_STATUS . IN_PROGRESS ) ;
188
+ cacheManager . setAuctionStatus ( auction . auctionId , adUnitCode , AUCTION_STATUS . IN_PROGRESS ) ;
184
189
} ) ;
185
190
} ) ;
186
191
} ,
@@ -198,27 +203,24 @@ export const appierAnalyticsAdapter = Object.assign(adapter({DEFAULT_SERVER, ana
198
203
const bidderCode = parseBidderCode ( bidMessage ) ;
199
204
bidMessage . bids . forEach ( function ( bid ) {
200
205
const adUnitCode = parseAdUnitCode ( bid ) ;
201
- const cachedBid = cacheManager . getBidsCache ( bid . auctionId , adUnitCode , bidderCode ) ;
202
206
cacheManager . updateBidsCache ( bid . auctionId , adUnitCode , bidderCode , {
203
- 'isTimeout' : cacheManager . getStatus ( bid . auctionId , adUnitCode ) === AUCTION_STATUS . COMPLETED ||
204
- cachedBid . status === BIDDER_STATUS . TIMEOUT
207
+ 'isTimeout' : cacheManager . isBidderTimeout ( bid . auctionId , adUnitCode , bidderCode )
205
208
} ) ;
206
209
} ) ;
207
210
} ,
208
211
handleBidResponseMessage ( bid ) {
209
212
const adUnitCode = parseAdUnitCode ( bid ) ;
210
213
const bidderCode = parseBidderCode ( bid ) ;
211
- const cachedBid = cacheManager . getBidsCache ( bid . auctionId , adUnitCode , bidderCode ) ;
214
+ const isBidderTimeout = cacheManager . isBidderTimeout ( bid . auctionId , adUnitCode , bidderCode ) ;
212
215
cacheManager . updateBidsCache ( bid . auctionId , adUnitCode , bidderCode , {
213
216
'time' : bid . timeToRespond ,
214
- 'status' : ( cachedBid . status === BIDDER_STATUS . TIMEOUT ) ? BIDDER_STATUS . TIMEOUT : BIDDER_STATUS . BID ,
217
+ 'status' : ( isBidderTimeout ) ? BIDDER_STATUS . TIMEOUT : BIDDER_STATUS . BID ,
215
218
'cpm' : bid . cpm ,
216
219
'currency' : bid . currency ,
217
220
'originalCpm' : bid . originalCpm || bid . cpm ,
218
221
'cpmUsd' : getCpmInUsd ( bid ) ,
219
222
'originalCurrency' : bid . originalCurrency || bid . currency ,
220
- 'isTimeout' : cacheManager . getStatus ( bid . auctionId , adUnitCode ) === AUCTION_STATUS . COMPLETED ||
221
- cachedBid . status === BIDDER_STATUS . TIMEOUT ,
223
+ 'isTimeout' : isBidderTimeout ,
222
224
'prebidWon' : false
223
225
} ) ;
224
226
} ,
@@ -257,15 +259,13 @@ export const appierAnalyticsAdapter = Object.assign(adapter({DEFAULT_SERVER, ana
257
259
// Update cached auction status
258
260
auction . adUnits . forEach ( function ( adUnit ) {
259
261
const adUnitCode = adUnit . code . toLowerCase ( ) ;
260
- cacheManager . setStatus ( auction . auctionId , adUnitCode , AUCTION_STATUS . COMPLETED ) ;
262
+ cacheManager . setAuctionStatus ( auction . auctionId , adUnitCode , AUCTION_STATUS . COMPLETED ) ;
261
263
} ) ;
262
264
// Update no-bids in bidCache
263
265
auction . noBids . forEach ( function ( noBid ) {
264
266
const adUnitCode = parseAdUnitCode ( noBid ) ;
265
267
const bidderCode = parseBidderCode ( noBid ) ;
266
- const cachedBid = cacheManager . getBidsCache ( auction . auctionId , adUnitCode , bidderCode ) ;
267
- if ( cachedBid . status === BIDDER_STATUS . TIMEOUT ||
268
- cacheManager . getStatus ( auction . auctionId , adUnitCode ) === AUCTION_STATUS . COMPLETED ) {
268
+ if ( cacheManager . isBidderTimeout ( auction . auctionId , adUnitCode , bidderCode ) ) {
269
269
cacheManager . updateBidsCache ( auction . auctionId , adUnitCode , bidderCode , {
270
270
'status' : BIDDER_STATUS . TIMEOUT ,
271
271
'isTimeout' : true
0 commit comments