@highfivve/ad-tag 5.8.32 → 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)
|
|
@@ -7,6 +7,7 @@ export const createStickyHeaderAd = () => {
|
|
|
7
7
|
const buttonSelector = '[data-ref="header-ad-close-button"]';
|
|
8
8
|
const navbarHiddenClassName = 'h5v-header-ad--navbarHidden';
|
|
9
9
|
let observer = null;
|
|
10
|
+
let observeTargetTimeoutId = null;
|
|
10
11
|
let stickyHeaderAdConfig = null;
|
|
11
12
|
const configure__ = (moduleConfig) => {
|
|
12
13
|
if (moduleConfig?.stickyHeaderAd?.enabled) {
|
|
@@ -20,6 +21,10 @@ export const createStickyHeaderAd = () => {
|
|
|
20
21
|
return config
|
|
21
22
|
? [
|
|
22
23
|
mkConfigureStepOncePerRequestAdsCycle('sticky-header-ads:cleanup', () => {
|
|
24
|
+
if (observeTargetTimeoutId !== null) {
|
|
25
|
+
clearTimeout(observeTargetTimeoutId);
|
|
26
|
+
observeTargetTimeoutId = null;
|
|
27
|
+
}
|
|
23
28
|
if (observer) {
|
|
24
29
|
observer.disconnect();
|
|
25
30
|
observer = null;
|
|
@@ -61,7 +66,12 @@ export const createStickyHeaderAd = () => {
|
|
|
61
66
|
if (target) {
|
|
62
67
|
const adRenderResultPromise = adRenderResult(ctx, headerSlot.moliSlot, config.disallowedAdvertiserIds, minVisibleDuration);
|
|
63
68
|
observer = new IntersectionObserver(intersectionObserverFadeOutCallback(container, target, adRenderResultPromise, navbar, navbarHiddenClass, config.fadeOutClassName), options);
|
|
64
|
-
|
|
69
|
+
observeTargetTimeoutId = ctx.window__.setTimeout(() => {
|
|
70
|
+
if (observer) {
|
|
71
|
+
observer.observe(target);
|
|
72
|
+
}
|
|
73
|
+
observeTargetTimeoutId = null;
|
|
74
|
+
}, minVisibleDuration);
|
|
65
75
|
if (navbar) {
|
|
66
76
|
observer.observe(navbar);
|
|
67
77
|
}
|
|
@@ -18,6 +18,20 @@ const requiredPurposeIds = [
|
|
|
18
18
|
export const createUtiq = () => {
|
|
19
19
|
let utiqConfig = null;
|
|
20
20
|
let scriptLoaded = false;
|
|
21
|
+
const hasRequiredPurposeConsent = (context) => {
|
|
22
|
+
const tcData = context.tcData__;
|
|
23
|
+
if (!tcData.gdprApplies) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return !requiredPurposeIds.some(purposeId => !tcData.purpose.consents[purposeId]);
|
|
27
|
+
};
|
|
28
|
+
const hasRequiredVendorConsent = (context, vendorId) => {
|
|
29
|
+
const tcData = context.tcData__;
|
|
30
|
+
if (!vendorId || !tcData.gdprApplies) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return tcData.vendor.consents[vendorId];
|
|
34
|
+
};
|
|
21
35
|
const loadUtiq = (config, context) => {
|
|
22
36
|
if (context.env__ === 'test') {
|
|
23
37
|
return Promise.resolve();
|
|
@@ -25,6 +39,13 @@ export const createUtiq = () => {
|
|
|
25
39
|
if (scriptLoaded) {
|
|
26
40
|
return Promise.resolve();
|
|
27
41
|
}
|
|
42
|
+
if (!hasRequiredVendorConsent(context, config.vendorId)) {
|
|
43
|
+
context.logger__.debug('Utiq', 'Skipping Utiq load because vendor consent is missing', config.vendorId);
|
|
44
|
+
return Promise.resolve();
|
|
45
|
+
}
|
|
46
|
+
if (!hasRequiredPurposeConsent(context)) {
|
|
47
|
+
return Promise.resolve();
|
|
48
|
+
}
|
|
28
49
|
const utiqWindow = context.window__;
|
|
29
50
|
utiqWindow.Utiq = utiqWindow.Utiq
|
|
30
51
|
? { ...utiqWindow.Utiq, config: { ...utiqWindow.Utiq.config, ...config.options } }
|
|
@@ -46,10 +67,6 @@ export const createUtiq = () => {
|
|
|
46
67
|
}
|
|
47
68
|
});
|
|
48
69
|
}
|
|
49
|
-
if (context.tcData__.gdprApplies &&
|
|
50
|
-
requiredPurposeIds.some(purposeId => context.tcData__.gdprApplies && !context.tcData__.purpose.consents[purposeId])) {
|
|
51
|
-
return Promise.resolve();
|
|
52
|
-
}
|
|
53
70
|
const minAdRequests = config.delay?.enabled && config.delay.minAdRequests ? config.delay.minAdRequests : 0;
|
|
54
71
|
if (!context.auction__.hasMinimumRequestAds(minAdRequests)) {
|
|
55
72
|
context.logger__.info('Utiq', `not enough ad requests to load Utiq. ${minAdRequests} required.`);
|
package/lib/gen/packageJson.js
CHANGED