From 5cd6597c5a83c5295e04b70896e7f4d779b8f952 Mon Sep 17 00:00:00 2001 From: Hiroshi Tanaka Date: Thu, 4 Nov 2021 15:52:31 +0900 Subject: [PATCH 1/5] Fix browsiImpression callback. --- modules/fluctAnalyticsAdapter.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/modules/fluctAnalyticsAdapter.js b/modules/fluctAnalyticsAdapter.js index 8798c1e64f7..59f5019c5a2 100644 --- a/modules/fluctAnalyticsAdapter.js +++ b/modules/fluctAnalyticsAdapter.js @@ -235,21 +235,28 @@ export const getAdUnitCodeBeforeReplication = (slots, adUnitCode) => { return find(Object.keys(slots), slot => !isBrowsiDivId(slots[slot]) && slots[slot] === path) ?? adUnitCode } +/** + * 各adUnitCodeに対応したadUnitPathを取得する + * @returns {Object.} + * @sample + * ``` + * { + * 'div-gpt-ad-1629864618640-0': '/62532913/p_fluctmagazine_320x50_surface_15377', + * 'browsi_ad_0_ai_1_rc_0': '/62532913/p_fluctmagazine_320x50_surface_15377' + * } + * ``` + */ +const getAdUnitMap = () => googletag.pubads().getSlots().reduce((prev, slot) => Object.assign(prev, { [slot.getSlotElementId()]: slot.getAdUnitPath() }), {}) + /** * @param {AdUnit} adUnit * @returns {AdUnit} */ const modifyBrowsiAdUnit = (adUnit) => { if (!isBrowsiDivId(adUnit.code)) return adUnit - // e.g. - // { - // 'div-gpt-ad-1629864618640-0': '/62532913/p_fluctmagazine_320x50_surface_15377', - // 'browsi_ad_0_ai_1_rc_0': '/62532913/p_fluctmagazine_320x50_surface_15377' - // } - const slots = googletag.pubads().getSlots().reduce((prev, slot) => Object.assign(prev, { [slot.getSlotElementId()]: slot.getAdUnitPath() }), {}) return { ...adUnit, - adUnitCode: getAdUnitCodeBeforeReplication(slots, adUnit.code), + adUnitCode: getAdUnitCodeBeforeReplication(getAdUnitMap(), adUnit.code), analytics: adUnit.analytics ?? find(pbjs.adUnits, _adUnit => _adUnit.code === adUnit.code).analytics, bids: undefined, originalAdUnitCode: adUnit.code, @@ -333,7 +340,13 @@ const sendMessage = (auctionId) => { }; window.addEventListener('browsiImpression', (data) => { - const auction = find(Object.values(cache.auctions), auction => auction.adUnitCodes.includes(data.detail.adUnit.code)) + const adUnitCode = Object.entries(getAdUnitMap()) + .reduce((prev, [code, path]) => { + return data.detail.adUnit === path && isBrowsiDivId(code) + ? code + : prev + }, '') + const auction = find(Object.values(cache.auctions), auction => auction.adUnitCodes.includes(adUnitCode)) sendMessage(auction.auctionId) }) From 0cda44d19475dbf59395bd2f35031f01d302a6c8 Mon Sep 17 00:00:00 2001 From: Hiroshi Tanaka Date: Thu, 4 Nov 2021 19:01:59 +0900 Subject: [PATCH 2/5] Fix bids[].adUnitCode --- modules/fluctAnalyticsAdapter.js | 27 +++++++------------ .../modules/fluctAnalyticsAdapter_spec.js | 5 ++++ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/modules/fluctAnalyticsAdapter.js b/modules/fluctAnalyticsAdapter.js index 59f5019c5a2..08ef61e1769 100644 --- a/modules/fluctAnalyticsAdapter.js +++ b/modules/fluctAnalyticsAdapter.js @@ -220,7 +220,7 @@ let fluctAnalyticsAdapter = Object.assign( /** * GPT slotから共通のpathを持つ、browsi_ad_ではないのadUnitCodeを返す - * @param {Object} slots + * @param {Object.} slots * @param {string} adUnitCode * @returns {string} */ @@ -248,21 +248,6 @@ export const getAdUnitCodeBeforeReplication = (slots, adUnitCode) => { */ const getAdUnitMap = () => googletag.pubads().getSlots().reduce((prev, slot) => Object.assign(prev, { [slot.getSlotElementId()]: slot.getAdUnitPath() }), {}) -/** - * @param {AdUnit} adUnit - * @returns {AdUnit} - */ -const modifyBrowsiAdUnit = (adUnit) => { - if (!isBrowsiDivId(adUnit.code)) return adUnit - return { - ...adUnit, - adUnitCode: getAdUnitCodeBeforeReplication(getAdUnitMap(), adUnit.code), - analytics: adUnit.analytics ?? find(pbjs.adUnits, _adUnit => _adUnit.code === adUnit.code).analytics, - bids: undefined, - originalAdUnitCode: adUnit.code, - } -} - /** * @param {string|undefined} adUnitCode * @returns {string|undefined} @@ -289,7 +274,11 @@ const modifyBrowsiAuctionId = (auctionId, adUnits) => { */ const sendMessage = (auctionId) => { let { adUnits, auctionEnd, auctionStatus, bids } = cache.auctions[auctionId] - adUnits = adUnits.map(adUnit => modifyBrowsiAdUnit(adUnit)) + adUnits = adUnits.map(adUnit => ({ + ...adUnit, + analytics: adUnit.analytics ?? find(pbjs.adUnits, _adUnit => _adUnit.code === adUnit.code).analytics, + bids: undefined, + })) /** * @param {string} adUnitCode @@ -301,6 +290,8 @@ const sendMessage = (auctionId) => { return find(analytics ?? [], obj => obj.bidder === bidder)?.dwid ?? null } + const slots = getAdUnitMap() + let payload = { auctionId: modifyBrowsiAuctionId(auctionId, adUnits), adUnits, @@ -315,7 +306,7 @@ const sendMessage = (auctionId) => { status, adId, adUrl, - adUnitCode, + adUnitCode: getAdUnitCodeBeforeReplication(slots, adUnitCode), bidder, netRevenue, cpm, diff --git a/test/spec/modules/fluctAnalyticsAdapter_spec.js b/test/spec/modules/fluctAnalyticsAdapter_spec.js index cb13dc39b6d..51cba434fdd 100644 --- a/test/spec/modules/fluctAnalyticsAdapter_spec.js +++ b/test/spec/modules/fluctAnalyticsAdapter_spec.js @@ -34,6 +34,11 @@ describe('正規表現にマッチしている', () => { const adUnitCode = getAdUnitCodeBeforeReplication(slots, 'browsi_ad_0_ai_1_rc_0') expect(adUnitCode).to.equal('div-gpt-ad-1629864618640-0') }) + + it('browsi枠ではない枠codeは変化しない', () => { + const adUnitCode = getAdUnitCodeBeforeReplication(slots, 'div-gpt-ad-1629864618640-0') + expect(adUnitCode).to.equal('div-gpt-ad-1629864618640-0') + }) }) describe('fluct analytics adapter', () => { From a84ab50e0f0d0b0e83ccedee33918b3e2376af56 Mon Sep 17 00:00:00 2001 From: Hiroshi Tanaka Date: Fri, 5 Nov 2021 12:47:14 +0900 Subject: [PATCH 3/5] Fix adUnit[].analytics --- modules/fluctAnalyticsAdapter.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/fluctAnalyticsAdapter.js b/modules/fluctAnalyticsAdapter.js index 08ef61e1769..4e63aba5fef 100644 --- a/modules/fluctAnalyticsAdapter.js +++ b/modules/fluctAnalyticsAdapter.js @@ -274,10 +274,12 @@ const modifyBrowsiAuctionId = (auctionId, adUnits) => { */ const sendMessage = (auctionId) => { let { adUnits, auctionEnd, auctionStatus, bids } = cache.auctions[auctionId] + const slots = getAdUnitMap() + adUnits = adUnits.map(adUnit => ({ ...adUnit, - analytics: adUnit.analytics ?? find(pbjs.adUnits, _adUnit => _adUnit.code === adUnit.code).analytics, - bids: undefined, + analytics: adUnit.analytics ?? find(pbjs.adUnits, _adUnit => _adUnit.code === getAdUnitCodeBeforeReplication(slots, adUnit.code)).analytics, + bids: undefined })) /** @@ -290,8 +292,6 @@ const sendMessage = (auctionId) => { return find(analytics ?? [], obj => obj.bidder === bidder)?.dwid ?? null } - const slots = getAdUnitMap() - let payload = { auctionId: modifyBrowsiAuctionId(auctionId, adUnits), adUnits, From 178779b067211b4866456727836b34758eb618b0 Mon Sep 17 00:00:00 2001 From: Hiroshi Tanaka Date: Fri, 5 Nov 2021 17:38:20 +0900 Subject: [PATCH 4/5] Add testcase. --- modules/fluctAnalyticsAdapter.js | 18 +- .../modules/fluctAnalyticsAdapter_spec.js | 442 +++++++++++++++++- 2 files changed, 436 insertions(+), 24 deletions(-) diff --git a/modules/fluctAnalyticsAdapter.js b/modules/fluctAnalyticsAdapter.js index 4e63aba5fef..9d79d923dda 100644 --- a/modules/fluctAnalyticsAdapter.js +++ b/modules/fluctAnalyticsAdapter.js @@ -1,6 +1,7 @@ import { ajax } from '../src/ajax.js'; import adapter from '../src/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; +import { config } from '../src/config.js' import CONSTANTS from '../src/constants.json'; import * as utils from '../src/utils.js'; import find from 'core-js-pure/features/array/find.js'; @@ -113,14 +114,17 @@ const cache = { gpt: {}, }; +/** + * @returns {string|undefined} + */ +const getSiteKey = () => find(config.getConfig('realTimeData.dataProviders') ?? [], provider => provider.name === 'browsi')?.params.siteKey + /** * @param {string} auctionId * @returns {boolean} */ -const isBrowsiAuction = (auctionId) => { - const siteKey = find(pbjs.getConfig().realTimeData?.dataProviders ?? [], provider => provider.name === 'browsi')?.params.siteKey - return Boolean(auctionId.match(new RegExp(`^${siteKey}`, 'g'))) -} +const isBrowsiAuction = (auctionId) => Boolean(auctionId.match(new RegExp(`^${getSiteKey()}`, 'g'))) + /** * @param {string} divId * @returns {boolean} @@ -208,7 +212,7 @@ let fluctAnalyticsAdapter = Object.assign( if (!isBrowsiAuction(auctionId)) { cache.timeouts[auctionId] = setTimeout(() => { sendMessage(auctionId); - }, pbjs.getConfig().bidderTimeout || 3000); + }, config.getConfig('bidderTimeout') ?? 3000); } break; } @@ -260,11 +264,9 @@ export const getBrowsiRefreshCount = (adUnitCode) => adUnitCode?.match(/browsi_. * @returns {string} */ const modifyBrowsiAuctionId = (auctionId, adUnits) => { - /** @type {string|undefined} */ - const siteKey = find(pbjs.getConfig().realTimeData?.dataProviders ?? [], provider => provider.name === 'browsi')?.params.siteKey /** @type {string|undefined} */ const reloadCount = getBrowsiRefreshCount(find(adUnits, adUnit => isBrowsiDivId(adUnit.code))?.code) - return auctionId.match(new RegExp(`^${siteKey}`, 'g')) && reloadCount + return auctionId.match(new RegExp(`^${getSiteKey()}`, 'g')) && reloadCount ? `${auctionId}_${reloadCount}` : auctionId } diff --git a/test/spec/modules/fluctAnalyticsAdapter_spec.js b/test/spec/modules/fluctAnalyticsAdapter_spec.js index 51cba434fdd..7026e471aac 100644 --- a/test/spec/modules/fluctAnalyticsAdapter_spec.js +++ b/test/spec/modules/fluctAnalyticsAdapter_spec.js @@ -13,6 +13,7 @@ import { setConfig, addBidResponseHook, } from 'modules/currency.js'; +// import * as rtdModule from 'modules/rtdModule/index.js'; describe('正規表現にマッチしている', () => { const slots = { @@ -41,23 +42,432 @@ describe('正規表現にマッチしている', () => { }) }) +const { + EVENTS: { + AUCTION_INIT, + AUCTION_END, + BID_WON, + } +} = CONSTANTS; + +const MOCK = { + AUCTION_INIT: { + 'auctionId': 'eeca6754-525b-4c4c-a697-b06b1fc6c352', + 'timestamp': 1635837149209, + 'auctionStatus': 'inProgress', + 'adUnits': [ + { + 'code': 'div-gpt-ad-1587114265584-0', + 'bids': [ + { + 'bidder': 'criteo', + 'params': { + 'networkId': '11021' + }, + 'ortb2Imp': { + 'ext': { + 'data': { + 'adserver': { + 'name': 'gam', + 'adslot': '/11598608/sk_sp_article_footeroverlay' + }, + 'pbadslot': '/11598608/sk_sp_article_footeroverlay' + } + } + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 320, + 100 + ], + [ + 320, + 50 + ] + ], + 'name': 'sk_sp_article_footeroverlay' + } + }, + 'adUnitCode': 'div-gpt-ad-1587114265584-0', + 'transactionId': '411f223f-299e-484f-8ffd-4ce75db58112', + 'sizes': [ + [ + 320, + 100 + ], + [ + 320, + 50 + ] + ], + 'bidId': '22697ff3e5bf7ee', + 'bidderRequestId': '19ef6cc0e7a746c', + 'auctionId': 'eeca6754-525b-4c4c-a697-b06b1fc6c352', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }, + ], + 'auctionStart': 1635837149209, + 'timeout': 1500, + 'refererInfo': { + 'referer': 'https://www.soccer-king.jp/news/world/esp/20211013/1578369.html?cx_top=topix&pbjs_debug=true', + 'reachedTop': true, + 'isAmp': false, + 'numIframes': 0, + 'stack': [ + 'https://www.soccer-king.jp/news/world/esp/20211013/1578369.html?cx_top=topix&pbjs_debug=true' + ], + 'canonicalUrl': 'https://www.soccer-king.jp/news/world/esp/20211013/1578369.html' + }, + 'start': 1635837149282 + } + ], + 'noBids': [], + 'bidsReceived': [ + { + 'bidderCode': 'criteo', + 'width': 320, + 'height': 100, + 'statusMessage': 'Bid available', + 'adId': '5c28bc93-b1a0-481b-ae59-0641f316ad1a', + 'requestId': '22697ff3e5bf7ee', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 5.386152744293213, + 'currency': 'JPY', + 'netRevenue': true, + 'ttl': 60, + 'creativeId': '11017985', + 'dealId': '', + 'ad': 'HTML_CODE', + 'originalCpm': 5.386152744293213, + 'originalCurrency': 'JPY', + 'meta': {}, + 'auctionId': 'eeca6754-525b-4c4c-a697-b06b1fc6c352', + 'responseTimestamp': 1635837149448, + 'requestTimestamp': 1635837149232, + 'bidder': 'criteo', + 'adUnitCode': 'div-gpt-ad-1587114265584-0', + 'timeToRespond': 216, + 'pbLg': '5.00', + 'pbMg': '5.30', + 'pbHg': '5.38', + 'pbAg': '5.30', + 'pbDg': '5.35', + 'pbCg': '4.00', + 'size': '320x100', + 'adserverTargeting': { + 'fbs_bidder': 'criteo', + 'fbs_adid': '5c28bc93-b1a0-481b-ae59-0641f316ad1a', + 'fbs_pb': '4.00', + 'fbs_size': '320x100', + 'fbs_source': 'client', + 'fbs_format': 'banner', + 'fbs_adomain': '' + }, + 'status': 'rendered', + 'params': [ + { + 'networkId': '11021' + } + ] + }, + ], + 'winningBids': [], + 'timeout': 1500 + }, + AUCTION_END: { + 'auctionId': 'eeca6754-525b-4c4c-a697-b06b1fc6c352', + 'timestamp': 1635837149209, + 'auctionEnd': 1635837149840, + 'auctionStatus': 'completed', + 'adUnits': [ + { + 'code': 'div-gpt-ad-1587114265584-0', + 'bids': [ + { + 'bidder': 'criteo', + 'params': { + 'networkId': '11021' + } + } + ], + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 320, + 100 + ], + [ + 320, + 50 + ] + ], + 'name': 'sk_sp_article_footeroverlay' + } + }, + 'analytics': [ + { + 'bidder': 'appnexus', + 'dwid': 'ecnavi_jp_22749357_soccer_king_hb_sp_network' + }, + { + 'bidder': 'criteo', + 'dwid': '1609486' + }, + { + 'bidder': 'ix', + 'dwid': '721766' + }, + { + 'bidder': 'logicad', + 'dwid': 'JMk4_QAoN' + }, + { + 'bidder': 'pubmatic', + 'dwid': '4065991' + } + ], + 'ext': { + 'device': 'SP' + }, + 'sizes': [ + [ + 320, + 100 + ], + [ + 320, + 50 + ] + ], + 'transactionId': '411f223f-299e-484f-8ffd-4ce75db58112', + 'ortb2Imp': { + 'ext': { + 'data': { + 'adserver': { + 'name': 'gam', + 'adslot': '/11598608/sk_sp_article_footeroverlay' + }, + 'pbadslot': '/11598608/sk_sp_article_footeroverlay' + } + } + }, + 'adserverTargeting': { + 'browsiViewability': [ + '1.00' + ] + } + } + ], + 'adUnitCodes': [ + 'div-gpt-ad-1587114265584-0' + ], + 'bidderRequests': [ + { + 'bidderCode': 'criteo', + 'auctionId': 'eeca6754-525b-4c4c-a697-b06b1fc6c352', + 'bidderRequestId': '19ef6cc0e7a746c', + 'bids': [ + { + 'bidder': 'criteo', + 'params': { + 'networkId': '11021' + }, + 'ortb2Imp': { + 'ext': { + 'data': { + 'adserver': { + 'name': 'gam', + 'adslot': '/11598608/sk_sp_article_footeroverlay' + }, + 'pbadslot': '/11598608/sk_sp_article_footeroverlay' + } + } + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 320, + 100 + ], + [ + 320, + 50 + ] + ], + 'name': 'sk_sp_article_footeroverlay' + } + }, + 'adUnitCode': 'div-gpt-ad-1587114265584-0', + 'transactionId': '411f223f-299e-484f-8ffd-4ce75db58112', + 'sizes': [ + [ + 320, + 100 + ], + [ + 320, + 50 + ] + ], + 'bidId': '22697ff3e5bf7ee', + 'bidderRequestId': '19ef6cc0e7a746c', + 'auctionId': 'eeca6754-525b-4c4c-a697-b06b1fc6c352', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1635837149209, + 'timeout': 1500, + 'refererInfo': { + 'referer': 'https://www.soccer-king.jp/news/world/esp/20211013/1578369.html?cx_top=topix&pbjs_debug=true', + 'reachedTop': true, + 'isAmp': false, + 'numIframes': 0, + 'stack': [ + 'https://www.soccer-king.jp/news/world/esp/20211013/1578369.html?cx_top=topix&pbjs_debug=true' + ], + 'canonicalUrl': 'https://www.soccer-king.jp/news/world/esp/20211013/1578369.html' + }, + 'start': 1635837149232 + } + ], + 'noBids': [], + 'bidsReceived': [ + { + 'bidderCode': 'criteo', + 'width': 320, + 'height': 100, + 'statusMessage': 'Bid available', + 'adId': '5c28bc93-b1a0-481b-ae59-0641f316ad1a', + 'requestId': '22697ff3e5bf7ee', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 5.386152744293213, + 'currency': 'JPY', + 'netRevenue': true, + 'ttl': 60, + 'creativeId': '11017985', + 'dealId': '', + 'ad': 'HTML_CODE', + 'originalCpm': 5.386152744293213, + 'originalCurrency': 'JPY', + 'meta': {}, + 'auctionId': 'eeca6754-525b-4c4c-a697-b06b1fc6c352', + 'responseTimestamp': 1635837149448, + 'requestTimestamp': 1635837149232, + 'bidder': 'criteo', + 'adUnitCode': 'div-gpt-ad-1587114265584-0', + 'timeToRespond': 216, + 'pbLg': '5.00', + 'pbMg': '5.30', + 'pbHg': '5.38', + 'pbAg': '5.30', + 'pbDg': '5.35', + 'pbCg': '4.00', + 'size': '320x100', + 'adserverTargeting': { + 'fbs_bidder': 'criteo', + 'fbs_adid': '5c28bc93-b1a0-481b-ae59-0641f316ad1a', + 'fbs_pb': '4.00', + 'fbs_size': '320x100', + 'fbs_source': 'client', + 'fbs_format': 'banner', + 'fbs_adomain': '' + }, + 'status': 'rendered', + 'params': [ + { + 'networkId': '11021' + } + ] + } + ], + 'winningBids': [], + 'timeout': 1500 + }, + BID_WON: { + 'bidderCode': 'criteo', + 'width': 320, + 'height': 100, + 'statusMessage': 'Bid available', + 'adId': '5c28bc93-b1a0-481b-ae59-0641f316ad1a', + 'requestId': '22697ff3e5bf7ee', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 5.386152744293213, + 'currency': 'JPY', + 'netRevenue': true, + 'ttl': 60, + 'creativeId': '11017985', + 'dealId': '', + 'ad': 'HTML_CODE', + 'originalCpm': 5.386152744293213, + 'originalCurrency': 'JPY', + 'meta': {}, + 'auctionId': 'eeca6754-525b-4c4c-a697-b06b1fc6c352', + 'responseTimestamp': 1635837149448, + 'requestTimestamp': 1635837149232, + 'bidder': 'criteo', + 'adUnitCode': 'div-gpt-ad-1587114265584-0', + 'timeToRespond': 216, + 'pbLg': '5.00', + 'pbMg': '5.30', + 'pbHg': '5.38', + 'pbAg': '5.30', + 'pbDg': '5.35', + 'pbCg': '4.00', + 'size': '320x100', + 'adserverTargeting': { + 'fbs_bidder': 'criteo', + 'fbs_adid': '5c28bc93-b1a0-481b-ae59-0641f316ad1a', + 'fbs_pb': '4.00', + 'fbs_size': '320x100', + 'fbs_source': 'client', + 'fbs_format': 'banner', + 'fbs_adomain': '' + }, + 'status': 'rendered', + 'params': [ + { + 'networkId': '11021' + } + ] + }, +} + describe('fluct analytics adapter', () => { - let sandbox; + let sandbox beforeEach(() => { - mockGpt.disable(); - sandbox = sinon.sandbox.create(); - config.setConfig({ - }) - }); + sandbox = sinon.sandbox.create() + sandbox.stub(events, 'getEvents').returns([]) + config.resetConfig() + mockGpt.reset() + mockGpt.makeSlot({ code: '/11598608/sk_sp_article_InArticle', divId: 'div-gpt-ad-1587114265584-0' }) + mockGpt.makeSlot({ code: '/11598608/sk_sp_article_InArticle', divId: 'browsi_ad_0_ai_1_rc_0' }) + fluctAnalyticsAdapter.enableAnalytics({ provider: 'fluct' }) + }) afterEach(() => { - sandbox.restore(); - config.resetConfig(); - mockGpt.enable(); - }); - - it('enableAnalyticsの引数内にoptionsを必要としない', () => { - fluctAnalyticsAdapter.enableAnalytics({}); - expect(fluctAnalyticsAdapter.initOptions).to.equal(undefined); - }); -}); + config.resetConfig() + mockGpt.reset() + sandbox.restore() + fluctAnalyticsAdapter.disableAnalytics() + }) + + it('EVENT: `AUCTION_END` 時に値を送信できる', () => { + events.emit(AUCTION_INIT, MOCK.AUCTION_INIT) + events.emit(AUCTION_END, MOCK.AUCTION_END) + expect(server.requests.length).to.equal(1) + expect(JSON.parse(server.requests[0].requestBody).auctionId).to.equal(MOCK.AUCTION_END.auctionId) + }) +}) From 6ca577a0ce0aaa7717448e59876a3cf8290f6ff2 Mon Sep 17 00:00:00 2001 From: Hiroshi Tanaka Date: Fri, 5 Nov 2021 18:18:59 +0900 Subject: [PATCH 5/5] Remove window.pbjsFluct use. --- modules/fluctAnalyticsAdapter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/fluctAnalyticsAdapter.js b/modules/fluctAnalyticsAdapter.js index 9d79d923dda..f6398567d4c 100644 --- a/modules/fluctAnalyticsAdapter.js +++ b/modules/fluctAnalyticsAdapter.js @@ -6,7 +6,6 @@ import CONSTANTS from '../src/constants.json'; import * as utils from '../src/utils.js'; import find from 'core-js-pure/features/array/find.js'; -const pbjs = window.pbjsFluct || window.pbjs const url = 'https://an.adingo.jp' /** @@ -280,7 +279,7 @@ const sendMessage = (auctionId) => { adUnits = adUnits.map(adUnit => ({ ...adUnit, - analytics: adUnit.analytics ?? find(pbjs.adUnits, _adUnit => _adUnit.code === getAdUnitCodeBeforeReplication(slots, adUnit.code)).analytics, + analytics: adUnit.analytics ?? find(Object.values(cache.auctions).flatMap(auction => auction.adUnits), _adUnit => _adUnit.code === getAdUnitCodeBeforeReplication(slots, adUnit.code)).analytics, bids: undefined }))