(global, data)
| 11 | * @param {!Object} data |
| 12 | */ |
| 13 | export function yieldbot(global, data) { |
| 14 | validateData(data, ['psn', 'ybSlot', 'slot']); |
| 15 | |
| 16 | global.ybotq = global.ybotq || []; |
| 17 | |
| 18 | loadScript(global, 'https://cdn.yldbt.com/js/yieldbot.intent.amp.js', () => { |
| 19 | global.ybotq.push(() => { |
| 20 | try { |
| 21 | const multiSizeDataStr = data.multiSize || null; |
| 22 | const primaryWidth = parseInt(data.overrideWidth || data.width, 10); |
| 23 | const primaryHeight = parseInt(data.overrideHeight || data.height, 10); |
| 24 | let dimensions; |
| 25 | |
| 26 | if (multiSizeDataStr) { |
| 27 | dimensions = getMultiSizeDimensions( |
| 28 | multiSizeDataStr, |
| 29 | primaryWidth, |
| 30 | primaryHeight, |
| 31 | false |
| 32 | ); |
| 33 | dimensions.unshift([primaryWidth, primaryHeight]); |
| 34 | } else { |
| 35 | dimensions = [[primaryWidth, primaryHeight]]; |
| 36 | } |
| 37 | |
| 38 | global.yieldbot.psn(data.psn); |
| 39 | global.yieldbot.enableAsync(); |
| 40 | if (window.context.isMaster) { |
| 41 | global.yieldbot.defineSlot(data.ybSlot, {sizes: dimensions}); |
| 42 | global.yieldbot.go(); |
| 43 | } else { |
| 44 | const slots = {}; |
| 45 | slots[data.ybSlot] = dimensions; |
| 46 | global.yieldbot.nextPageview(slots); |
| 47 | } |
| 48 | } catch (e) { |
| 49 | rethrowAsync(e); |
| 50 | } |
| 51 | }); |
| 52 | |
| 53 | global.ybotq.push(() => { |
| 54 | try { |
| 55 | const targeting = global.yieldbot.getSlotCriteria(data['ybSlot']); |
| 56 | data['targeting'] = data['targeting'] || {}; |
| 57 | for (const key in targeting) { |
| 58 | data.targeting[key] = targeting[key]; |
| 59 | } |
| 60 | } catch (e) { |
| 61 | rethrowAsync(e); |
| 62 | } |
| 63 | user().warn( |
| 64 | 'AMP-AD', |
| 65 | 'type="yieldbot" will no longer ' + |
| 66 | 'be supported starting on March 29, 2018.' + |
| 67 | ' Please use your amp-ad-network and RTC to configure a' + |
| 68 | ' Yieldbot callout vendor. Refer to' + |
| 69 | ' https://github.com/ampproject/amphtml/blob/main/' + |
| 70 | 'extensions/amp-a4a/rtc-publisher-implementation-guide.md' + |
nothing calls this directly
no test coverage detected