@highfivve/ad-tag 5.8.33 → 5.8.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,6 +16,32 @@ export const createSkin = () => {
|
|
|
16
16
|
let skinModuleConfig = null;
|
|
17
17
|
let bidsBackHandler = [];
|
|
18
18
|
const config__ = () => skinModuleConfig;
|
|
19
|
+
const getSkinBids = (config, bidResponses) => {
|
|
20
|
+
const skinBidResponse = bidResponses[config.skinAdSlotDomId];
|
|
21
|
+
const isSkinBid = (bid) => {
|
|
22
|
+
const oneFilterApplied = config.formatFilter.some(filter => {
|
|
23
|
+
switch (filter.bidder) {
|
|
24
|
+
case '*':
|
|
25
|
+
return true;
|
|
26
|
+
case 'gumgum':
|
|
27
|
+
return (bid.bidder === prebidjs.GumGum &&
|
|
28
|
+
(filter.auid === undefined ||
|
|
29
|
+
(typeof bid.ad !== 'string' && bid.ad.auid === filter.auid)));
|
|
30
|
+
default:
|
|
31
|
+
return bid.bidder === filter.bidder;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return bid.cpm > 0 && oneFilterApplied;
|
|
35
|
+
};
|
|
36
|
+
return skinBidResponse
|
|
37
|
+
?
|
|
38
|
+
skinBidResponse.bids.filter(isSkinBid).sort((bid1, bid2) => bid2.cpm - bid1.cpm)
|
|
39
|
+
: [];
|
|
40
|
+
};
|
|
41
|
+
const getHighestSkinBidCpm = (config, bidResponses) => {
|
|
42
|
+
const skinBids = getSkinBids(config, bidResponses);
|
|
43
|
+
return skinBids.length > 0 ? skinBids[0].cpm : null;
|
|
44
|
+
};
|
|
19
45
|
const getConfigEffect = (config, bidResponses, log) => {
|
|
20
46
|
const skinBidResponse = bidResponses[config.skinAdSlotDomId];
|
|
21
47
|
const isSkinBid = (bid) => {
|
|
@@ -54,12 +80,29 @@ export const createSkin = () => {
|
|
|
54
80
|
}
|
|
55
81
|
return skinBids.length > 0 ? "BlockOtherSlots" : "NoBlocking";
|
|
56
82
|
};
|
|
57
|
-
const selectConfig = (skinModuleConfig, bidResponses, log) =>
|
|
58
|
-
.map(config => ({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
83
|
+
const selectConfig = (skinModuleConfig, bidResponses, log) => {
|
|
84
|
+
const configEvaluations = skinModuleConfig.configs.map(config => ({
|
|
85
|
+
skinConfig: config,
|
|
86
|
+
configEffect: getConfigEffect(config, bidResponses, log),
|
|
87
|
+
highestSkinCpm: getHighestSkinBidCpm(config, bidResponses)
|
|
88
|
+
}));
|
|
89
|
+
const matchingConfigs = configEvaluations.filter(({ configEffect }) => configEffect !== "NoBlocking");
|
|
90
|
+
const compareWithOtherSkinsConfigs = matchingConfigs.filter(({ skinConfig }) => skinConfig.compareWithOtherSkins);
|
|
91
|
+
if (compareWithOtherSkinsConfigs.length > 1) {
|
|
92
|
+
return compareWithOtherSkinsConfigs.reduce((selectedConfig, currentConfig) => {
|
|
93
|
+
if (selectedConfig.highestSkinCpm === null ||
|
|
94
|
+
(currentConfig.highestSkinCpm !== null &&
|
|
95
|
+
currentConfig.highestSkinCpm > selectedConfig.highestSkinCpm)) {
|
|
96
|
+
return currentConfig;
|
|
97
|
+
}
|
|
98
|
+
return selectedConfig;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const fallbackConfig = matchingConfigs[0];
|
|
102
|
+
return fallbackConfig
|
|
103
|
+
? { skinConfig: fallbackConfig.skinConfig, configEffect: fallbackConfig.configEffect }
|
|
104
|
+
: undefined;
|
|
105
|
+
};
|
|
63
106
|
const destroyAdSlot = (slotDefinitions, gWindow) => (adSlotDomId) => {
|
|
64
107
|
const adSlots = slotDefinitions
|
|
65
108
|
.map(slot => slot.adSlot)
|
package/lib/gen/packageJson.js
CHANGED