From 20d88a0f61d71e8d2dcebfbcbda9f0207308e3aa Mon Sep 17 00:00:00 2001 From: Dara Carolan Date: Mon, 14 Jun 2021 14:21:05 +0100 Subject: [PATCH] update registeredSlots with targeting values and refresh --- js/manager.js | 9 ++++++--- lib/manager.js | 11 ++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/js/manager.js b/js/manager.js index cecf69c..e84b6ff 100644 --- a/js/manager.js +++ b/js/manager.js @@ -104,6 +104,10 @@ const DFPManager = Object.assign(new EventEmitter().setMaxListeners(0), { setTargetingArguments(data) { Object.assign(globalTargetingArguments, data); + const availableKeys = Object.keys(registeredSlots); + availableKeys.forEach((slotId) => { + registeredSlots[slotId].targetingArguments = data; + }); if (managerAlreadyInitialized === true) { this.getGoogletag().then((googletag) => { googletag.cmd.push(() => { @@ -354,9 +358,8 @@ const DFPManager = Object.assign(new EventEmitter().setMaxListeners(0), { this.configureOptions(googletag); googletag.cmd.push(() => { const pubadsService = googletag.pubads(); - pubadsService.refresh( - slots.map(slotId => registeredSlots[slotId].gptSlot), - ); + const slotsToRefreshArray = slots.map(slotId => registeredSlots[slotId].slotId); + pubadsService.refresh(slotsToRefreshArray); }); }); }, diff --git a/lib/manager.js b/lib/manager.js index 974b273..44cf689 100644 --- a/lib/manager.js +++ b/lib/manager.js @@ -104,6 +104,10 @@ var DFPManager = Object.assign(new _events.EventEmitter().setMaxListeners(0), { }, setTargetingArguments: function setTargetingArguments(data) { Object.assign(globalTargetingArguments, data); + var availableKeys = Object.keys(registeredSlots); + availableKeys.forEach(function (slotId) { + registeredSlots[slotId].targetingArguments = data; + }); if (managerAlreadyInitialized === true) { this.getGoogletag().then(function (googletag) { @@ -398,9 +402,10 @@ var DFPManager = Object.assign(new _events.EventEmitter().setMaxListeners(0), { googletag.cmd.push(function () { var pubadsService = googletag.pubads(); - pubadsService.refresh(slots.map(function (slotId) { - return registeredSlots[slotId].gptSlot; - })); + var slotsToRefreshArray = slots.map(function (slotId) { + return registeredSlots[slotId].slotId; + }); + pubadsService.refresh(slotsToRefreshArray); }); }); },