@highfivve/ad-tag 5.8.17 → 5.8.18

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.
@@ -11,140 +11,141 @@ export const filterHighestNonSkinBid = (bidResponses, blockedAdSlotDomIds) => {
11
11
  .sort((bid1, bid2) => bid2.cpm - bid1.cpm)
12
12
  .slice(0, 1)));
13
13
  };
14
- export class Skin {
15
- constructor() {
16
- this.name = 'skin';
17
- this.description = 'Block other ad slots if a wallpaper has won the auction';
18
- this.moduleType = 'prebid';
19
- this.skinModuleConfig = null;
20
- this.bidsBackHandler = [];
21
- this.getConfigEffect = (config, bidResponses, log) => {
22
- const skinBidResponse = bidResponses[config.skinAdSlotDomId];
23
- const isSkinBid = (bid) => {
24
- const oneFilterApplied = config.formatFilter.some(filter => {
25
- switch (filter.bidder) {
26
- case '*':
27
- return true;
28
- case 'gumgum':
29
- return (bid.bidder === prebidjs.GumGum &&
30
- (filter.auid === undefined ||
31
- (typeof bid.ad !== 'string' && bid.ad.auid === filter.auid)));
32
- default:
33
- return bid.bidder === filter.bidder;
34
- }
35
- });
36
- return bid.cpm > 0 && oneFilterApplied;
37
- };
38
- const nonSkinBids = filterHighestNonSkinBid(bidResponses, config.blockedAdSlotDomIds);
39
- const combinedNonSkinCpm = nonSkinBids.reduce((prev, current) => prev + current.cpm, 0);
40
- const skinBids = skinBidResponse
14
+ export const createSkin = () => {
15
+ const name = 'skin';
16
+ let skinModuleConfig = null;
17
+ let bidsBackHandler = [];
18
+ const config__ = () => skinModuleConfig;
19
+ const getConfigEffect = (config, bidResponses, log) => {
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
+ const nonSkinBids = filterHighestNonSkinBid(bidResponses, config.blockedAdSlotDomIds);
37
+ const combinedNonSkinCpm = nonSkinBids.reduce((prev, current) => prev + current.cpm, 0);
38
+ const skinBids = skinBidResponse
39
+ ?
40
+ skinBidResponse.bids.filter(isSkinBid).sort((bid1, bid2) => bid2.cpm - bid1.cpm)
41
+ : [];
42
+ const skinConfigEffect = skinBids.length > 0
43
+ ? skinBids[0].cpm > combinedNonSkinCpm
41
44
  ?
42
- skinBidResponse.bids.filter(isSkinBid).sort((bid1, bid2) => bid2.cpm - bid1.cpm)
43
- : [];
44
- const skinConfigEffect = skinBids.length > 0
45
- ? skinBids[0].cpm > combinedNonSkinCpm
46
- ?
47
- "BlockOtherSlots"
48
- :
49
- "BlockSkinSlot"
45
+ "BlockOtherSlots"
50
46
  :
51
- "NoBlocking";
52
- log.debug(this.name, 'nonSkinBids', nonSkinBids);
53
- log.debug(this.name, 'skinBids', skinBids);
54
- if (config.enableCpmComparison) {
55
- return skinConfigEffect;
47
+ "BlockSkinSlot"
48
+ :
49
+ "NoBlocking";
50
+ log.debug(name, 'nonSkinBids', nonSkinBids);
51
+ log.debug(name, 'skinBids', skinBids);
52
+ if (config.enableCpmComparison) {
53
+ return skinConfigEffect;
54
+ }
55
+ return skinBids.length > 0 ? "BlockOtherSlots" : "NoBlocking";
56
+ };
57
+ const selectConfig = (skinModuleConfig, bidResponses, log) => skinModuleConfig.configs
58
+ .map(config => ({
59
+ skinConfig: config,
60
+ configEffect: getConfigEffect(config, bidResponses, log)
61
+ }))
62
+ .find(({ configEffect }) => configEffect !== "NoBlocking");
63
+ const destroyAdSlot = (slotDefinitions, gWindow) => (adSlotDomId) => {
64
+ const adSlots = slotDefinitions
65
+ .map(slot => slot.adSlot)
66
+ .filter((slot) => slot.getSlotElementId() === adSlotDomId);
67
+ gWindow.googletag.destroySlots(adSlots);
68
+ };
69
+ const hideAdSlot = (_window, log) => (domId) => {
70
+ const element = _window.document.getElementById(domId);
71
+ try {
72
+ if (element) {
73
+ log.debug('SkinModule', `Set display:none for ${domId}`);
74
+ element.style.setProperty('display', 'none');
56
75
  }
57
- return skinBids.length > 0 ? "BlockOtherSlots" : "NoBlocking";
58
- };
59
- this.selectConfig = (skinModuleConfig, bidResponses, log) => skinModuleConfig.configs
60
- .map(config => ({
61
- skinConfig: config,
62
- configEffect: this.getConfigEffect(config, bidResponses, log)
63
- }))
64
- .find(({ configEffect }) => configEffect !== "NoBlocking");
65
- this.destroyAdSlot = (slotDefinitions, gWindow) => (adSlotDomId) => {
66
- const adSlots = slotDefinitions
67
- .map(slot => slot.adSlot)
68
- .filter((slot) => slot.getSlotElementId() === adSlotDomId);
69
- gWindow.googletag.destroySlots(adSlots);
70
- };
71
- this.runSkinConfigs = (skinModuleConfig) => (ctx, bidResponses, slotDefinitions) => {
72
- const skinConfigWithEffect = this.selectConfig(skinModuleConfig, bidResponses, ctx.logger__);
73
- if (skinConfigWithEffect) {
74
- const { skinConfig, configEffect } = skinConfigWithEffect;
75
- if (configEffect === "BlockOtherSlots") {
76
- ctx.logger__.debug('SkinModule', 'Skin configuration applied', skinConfig);
77
- skinConfig.blockedAdSlotDomIds.forEach(this.destroyAdSlot(slotDefinitions, ctx.window__));
78
- if (skinConfig.hideBlockedSlots) {
79
- skinConfig.blockedAdSlotDomIds.forEach(this.hideAdSlot(ctx.window__, ctx.logger__));
80
- }
81
- if (skinConfig.hideSkinAdSlot) {
82
- this.hideAdSlot(ctx.window__, ctx.logger__)(skinConfig.skinAdSlotDomId);
83
- }
84
- if (skinConfig.hideBlockedSlotsSelector) {
85
- ctx.window__.document
86
- .querySelectorAll(skinConfig.hideBlockedSlotsSelector)
87
- .forEach(node => {
88
- ctx.logger__.debug('SkinModule', `Set display:none for container with selector ${skinConfig.hideBlockedSlotsSelector}`);
89
- node.style.setProperty('display', 'none');
90
- });
91
- }
92
- if (skinConfig.targeting) {
93
- try {
94
- ctx.window__.googletag
95
- .pubads()
96
- .setTargeting(skinConfig.targeting.key, skinConfig.targeting.value ?? '1');
97
- }
98
- catch (e) {
99
- ctx.logger__.error('SkinModule', e);
100
- }
101
- }
76
+ }
77
+ catch (e) {
78
+ log.error('SkinModule', `Couldn't set the the wallpaper div ${domId} to display:none;`, e);
79
+ }
80
+ };
81
+ const runSkinConfigs = (skinModuleConfig) => (ctx, bidResponses, slotDefinitions) => {
82
+ const skinConfigWithEffect = selectConfig(skinModuleConfig, bidResponses, ctx.logger__);
83
+ if (skinConfigWithEffect) {
84
+ const { skinConfig, configEffect } = skinConfigWithEffect;
85
+ if (configEffect === "BlockOtherSlots") {
86
+ ctx.logger__.debug('SkinModule', 'Skin configuration applied', skinConfig);
87
+ skinConfig.blockedAdSlotDomIds.forEach(destroyAdSlot(slotDefinitions, ctx.window__));
88
+ if (skinConfig.hideBlockedSlots) {
89
+ skinConfig.blockedAdSlotDomIds.forEach(hideAdSlot(ctx.window__, ctx.logger__));
102
90
  }
103
- else if (skinConfig.enableCpmComparison) {
104
- ctx.logger__.debug('SkinModule', 'Skin configuration ignored because cpm was low', skinConfig);
105
- this.destroyAdSlot(slotDefinitions, ctx.window__)(skinConfig.skinAdSlotDomId);
91
+ if (skinConfig.hideSkinAdSlot) {
92
+ hideAdSlot(ctx.window__, ctx.logger__)(skinConfig.skinAdSlotDomId);
106
93
  }
107
- }
108
- else {
109
- skinModuleConfig.configs
110
- .filter(skinConfig => skinConfig.destroySkinSlot)
111
- .map(skinConfig => skinConfig.skinAdSlotDomId)
112
- .filter(uniquePrimitiveFilter)
113
- .forEach(this.destroyAdSlot(slotDefinitions, ctx.window__));
114
- }
115
- };
116
- this.hideAdSlot = (_window, log) => (domId) => {
117
- const element = _window.document.getElementById(domId);
118
- try {
119
- if (element) {
120
- log.debug('SkinModule', `Set display:none for ${domId}`);
121
- element.style.setProperty('display', 'none');
94
+ if (skinConfig.hideBlockedSlotsSelector) {
95
+ ctx.window__.document
96
+ .querySelectorAll(skinConfig.hideBlockedSlotsSelector)
97
+ .forEach(node => {
98
+ ctx.logger__.debug('SkinModule', `Set display:none for container with selector ${skinConfig.hideBlockedSlotsSelector}`);
99
+ node.style.setProperty('display', 'none');
100
+ });
101
+ }
102
+ if (skinConfig.targeting) {
103
+ try {
104
+ ctx.window__.googletag
105
+ .pubads()
106
+ .setTargeting(skinConfig.targeting.key, skinConfig.targeting.value ?? '1');
107
+ }
108
+ catch (e) {
109
+ ctx.logger__.error('SkinModule', e);
110
+ }
122
111
  }
123
112
  }
124
- catch (e) {
125
- log.error('SkinModule', `Couldn't set the the wallpaper div ${domId} to display:none;`, e);
113
+ else if (skinConfig.enableCpmComparison) {
114
+ ctx.logger__.debug('SkinModule', 'Skin configuration ignored because cpm was low', skinConfig);
115
+ destroyAdSlot(slotDefinitions, ctx.window__)(skinConfig.skinAdSlotDomId);
126
116
  }
127
- };
128
- }
129
- config__() {
130
- return this.skinModuleConfig;
131
- }
132
- configure__(moduleConfig) {
117
+ }
118
+ else {
119
+ skinModuleConfig.configs
120
+ .filter(skinConfig => skinConfig.destroySkinSlot)
121
+ .map(skinConfig => skinConfig.skinAdSlotDomId)
122
+ .filter(uniquePrimitiveFilter)
123
+ .forEach(destroyAdSlot(slotDefinitions, ctx.window__));
124
+ }
125
+ };
126
+ const configure__ = (moduleConfig) => {
133
127
  if (moduleConfig?.skin && moduleConfig.skin.enabled) {
134
- this.skinModuleConfig = moduleConfig.skin;
135
- this.bidsBackHandler.push(this.runSkinConfigs(moduleConfig.skin));
128
+ skinModuleConfig = moduleConfig.skin;
129
+ bidsBackHandler.push(runSkinConfigs(moduleConfig.skin));
136
130
  }
137
- }
138
- initSteps__() {
139
- return [];
140
- }
141
- configureSteps__() {
142
- return [];
143
- }
144
- prepareRequestAdsSteps__() {
145
- return [];
146
- }
147
- prebidBidsBackHandler__() {
148
- return this.bidsBackHandler;
149
- }
150
- }
131
+ };
132
+ const initSteps__ = () => [];
133
+ const configureSteps__ = () => [];
134
+ const prepareRequestAdsSteps__ = () => [];
135
+ const prebidBidsBackHandler__ = () => bidsBackHandler;
136
+ return {
137
+ name,
138
+ description: 'Block other ad slots if a wallpaper has won the auction',
139
+ moduleType: 'prebid',
140
+ config__,
141
+ configure__,
142
+ initSteps__,
143
+ configureSteps__,
144
+ prepareRequestAdsSteps__,
145
+ prebidBidsBackHandler__,
146
+ getConfigEffect,
147
+ selectConfig,
148
+ destroyAdSlot,
149
+ runSkinConfigs
150
+ };
151
+ };
@@ -1,43 +1,20 @@
1
1
  import { mkInitStep } from 'ad-tag/ads/adPipeline';
2
2
  import { AssetLoadMethod } from 'ad-tag/util/assetLoaderService';
3
- export class IdentityLink {
4
- constructor() {
5
- this.name = 'identitylink';
6
- this.description = "Provides LiveRamp's ATS (authenticated traffic solution) functionality to Moli.";
7
- this.moduleType = 'identity';
8
- this.gvlid = '97';
9
- this.identityLinkConfig = null;
10
- }
11
- config__() {
12
- return this.identityLinkConfig;
13
- }
14
- configure__(moduleConfig) {
3
+ export const createIdentityLink = () => {
4
+ const name = 'identitylink';
5
+ const gvlid = '97';
6
+ let identityLinkConfig = null;
7
+ const config__ = () => identityLinkConfig;
8
+ const configure__ = (moduleConfig) => {
15
9
  if (moduleConfig?.identitylink && moduleConfig.identitylink.enabled) {
16
- this.identityLinkConfig = moduleConfig.identitylink;
10
+ identityLinkConfig = moduleConfig.identitylink;
17
11
  }
18
- }
19
- initSteps__() {
20
- const config = this.identityLinkConfig;
21
- return config
22
- ? [
23
- mkInitStep(this.name, ctx => {
24
- this.loadAts(ctx, config);
25
- return Promise.resolve();
26
- })
27
- ]
28
- : [];
29
- }
30
- configureSteps__() {
31
- return [];
32
- }
33
- prepareRequestAdsSteps__() {
34
- return [];
35
- }
36
- loadAts(context, moduleConfig) {
12
+ };
13
+ const loadAts = (context, moduleConfig) => {
37
14
  if (context.env__ === 'test') {
38
15
  return Promise.resolve();
39
16
  }
40
- if (context.tcData__.gdprApplies && !context.tcData__.vendor.consents[this.gvlid]) {
17
+ if (context.tcData__.gdprApplies && !context.tcData__.vendor.consents[gvlid]) {
41
18
  return Promise.resolve();
42
19
  }
43
20
  const window = context.window__;
@@ -62,10 +39,34 @@ export class IdentityLink {
62
39
  });
63
40
  return context.assetLoaderService__
64
41
  .loadScript({
65
- name: this.name,
42
+ name,
66
43
  loadMethod: AssetLoadMethod.TAG,
67
44
  assetUrl: `https://launchpad-wrapper.privacymanager.io/${moduleConfig.launchPadId}/launchpad-liveramp.js`
68
45
  })
69
46
  .catch(error => context.logger__.error('failed to load emetriq', error));
70
- }
71
- }
47
+ };
48
+ const initSteps__ = () => {
49
+ const config = identityLinkConfig;
50
+ return config
51
+ ? [
52
+ mkInitStep(name, ctx => {
53
+ loadAts(ctx, config);
54
+ return Promise.resolve();
55
+ })
56
+ ]
57
+ : [];
58
+ };
59
+ const configureSteps__ = () => [];
60
+ const prepareRequestAdsSteps__ = () => [];
61
+ return {
62
+ name,
63
+ description: "Provides LiveRamp's ATS (authenticated traffic solution) functionality to Moli.",
64
+ moduleType: 'identity',
65
+ config__,
66
+ configure__,
67
+ initSteps__,
68
+ configureSteps__,
69
+ prepareRequestAdsSteps__,
70
+ loadAts
71
+ };
72
+ };
@@ -2,35 +2,21 @@ import { mkConfigureStep } from 'ad-tag/ads/adPipeline';
2
2
  import { uniquePrimitiveFilter } from 'ad-tag/util/arrayUtils';
3
3
  import { mergeDeep } from 'ad-tag/util/objectUtils';
4
4
  import { extractTopPrivateDomainFromHostname } from 'ad-tag/util/extractTopPrivateDomainFromHostname';
5
- export class PrebidFirstPartyDataModule {
6
- constructor() {
7
- this.description = 'Module for passing first party data to prebid auctions';
8
- this.moduleType = 'prebid';
9
- this.name = 'prebid-first-party-data';
10
- this.moduleConfig = null;
11
- this._configureSteps = [];
12
- }
13
- config__() {
14
- return this.moduleConfig;
15
- }
16
- configure__(moduleConfig) {
17
- if (moduleConfig?.prebidFirstPartyData?.enabled) {
18
- const config = moduleConfig.prebidFirstPartyData;
19
- this._configureSteps = [
20
- mkConfigureStep('prebid-fpd-module-configure', context => PrebidFirstPartyDataModule.setPrebidFpdConfig(context, config, context.logger__))
21
- ];
5
+ export const createPrebidFirstPartyDataModule = () => {
6
+ const name = 'prebid-first-party-data';
7
+ let moduleConfig = null;
8
+ let configureStepsArr = [];
9
+ const config__ = () => moduleConfig;
10
+ const extractKeyValueArray = (key, keyValues) => {
11
+ const value = keyValues[key];
12
+ if (value) {
13
+ return typeof value === 'string' ? [value] : value;
14
+ }
15
+ else {
16
+ return [];
22
17
  }
23
- }
24
- initSteps__() {
25
- return [];
26
- }
27
- configureSteps__() {
28
- return this._configureSteps;
29
- }
30
- prepareRequestAdsSteps__() {
31
- return [];
32
- }
33
- static setPrebidFpdConfig(context, config, log) {
18
+ };
19
+ const setPrebidFpdConfig = (context, config, log) => {
34
20
  if (context.config__.prebid) {
35
21
  const keyValues = context.config__.targeting?.keyValues || {};
36
22
  const gptTargeting = config.gptTargetingMappings;
@@ -45,16 +31,16 @@ export class PrebidFirstPartyDataModule {
45
31
  ...ortb2FromKeyValues.site
46
32
  };
47
33
  if (gptTargeting.cat) {
48
- const keyValueData = PrebidFirstPartyDataModule.extractKeyValueArray(gptTargeting.cat, keyValues);
34
+ const keyValueData = extractKeyValueArray(gptTargeting.cat, keyValues);
49
35
  site.cat?.push(...keyValueData);
50
36
  site.pagecat?.push(...keyValueData);
51
37
  site.sectioncat?.push(...keyValueData);
52
38
  }
53
39
  if (gptTargeting.sectionCat) {
54
- site.sectioncat = PrebidFirstPartyDataModule.extractKeyValueArray(gptTargeting.sectionCat, keyValues);
40
+ site.sectioncat = extractKeyValueArray(gptTargeting.sectionCat, keyValues);
55
41
  }
56
42
  if (gptTargeting.pageCat) {
57
- site.pagecat = PrebidFirstPartyDataModule.extractKeyValueArray(gptTargeting.pageCat, keyValues);
43
+ site.pagecat = extractKeyValueArray(gptTargeting.pageCat, keyValues);
58
44
  }
59
45
  if (site.cat) {
60
46
  site.cat = site.cat.filter(uniquePrimitiveFilter);
@@ -75,7 +61,7 @@ export class PrebidFirstPartyDataModule {
75
61
  data: site.content?.data?.filter(data => data.name !== provider) ?? []
76
62
  };
77
63
  if (gptTargeting.iabV2 && provider) {
78
- const iabV2Ids = PrebidFirstPartyDataModule.extractKeyValueArray(gptTargeting.iabV2, keyValues);
64
+ const iabV2Ids = extractKeyValueArray(gptTargeting.iabV2, keyValues);
79
65
  const publisherContentData = {
80
66
  name: provider,
81
67
  ext: {
@@ -86,7 +72,7 @@ export class PrebidFirstPartyDataModule {
86
72
  site.content.data?.push(publisherContentData);
87
73
  }
88
74
  if (gptTargeting.iabV3 && provider) {
89
- const iabV3Ids = PrebidFirstPartyDataModule.extractKeyValueArray(gptTargeting.iabV3, keyValues);
75
+ const iabV3Ids = extractKeyValueArray(gptTargeting.iabV3, keyValues);
90
76
  const publisherContentData = {
91
77
  name: provider,
92
78
  ext: {
@@ -102,14 +88,26 @@ export class PrebidFirstPartyDataModule {
102
88
  });
103
89
  }
104
90
  return Promise.resolve();
105
- }
106
- static extractKeyValueArray(key, keyValues) {
107
- const value = keyValues[key];
108
- if (value) {
109
- return typeof value === 'string' ? [value] : value;
110
- }
111
- else {
112
- return [];
91
+ };
92
+ const configure__ = (mConfig) => {
93
+ if (mConfig?.prebidFirstPartyData?.enabled) {
94
+ const config = mConfig.prebidFirstPartyData;
95
+ configureStepsArr = [
96
+ mkConfigureStep('prebid-fpd-module-configure', context => setPrebidFpdConfig(context, config, context.logger__))
97
+ ];
113
98
  }
114
- }
115
- }
99
+ };
100
+ const initSteps__ = () => [];
101
+ const configureSteps__ = () => configureStepsArr;
102
+ const prepareRequestAdsSteps__ = () => [];
103
+ return {
104
+ name,
105
+ description: 'Module for passing first party data to prebid auctions',
106
+ moduleType: 'prebid',
107
+ config__,
108
+ configure__,
109
+ initSteps__,
110
+ configureSteps__,
111
+ prepareRequestAdsSteps__
112
+ };
113
+ };
@@ -1,22 +1,16 @@
1
1
  import { AssetLoadMethod } from 'ad-tag/util/assetLoaderService';
2
2
  import { mkConfigureStep, mkInitStep } from '../../adPipeline';
3
- export class Pubstack {
4
- constructor() {
5
- this.name = 'pubstack';
6
- this.description = 'prebid analytics integration';
7
- this.moduleType = 'reporting';
8
- this.pubstackConfig = null;
9
- }
10
- config__() {
11
- return this.pubstackConfig;
12
- }
13
- configure__(moduleConfig) {
3
+ export const createPubstack = () => {
4
+ const name = 'pubstack';
5
+ let pubstackConfig = null;
6
+ const config__ = () => pubstackConfig;
7
+ const configure__ = (moduleConfig) => {
14
8
  if (moduleConfig?.pubstack && moduleConfig.pubstack.enabled) {
15
- this.pubstackConfig = moduleConfig.pubstack;
9
+ pubstackConfig = moduleConfig.pubstack;
16
10
  }
17
- }
18
- initSteps__() {
19
- const config = this.pubstackConfig;
11
+ };
12
+ const initSteps__ = () => {
13
+ const config = pubstackConfig;
20
14
  return config
21
15
  ? [
22
16
  mkInitStep('pubstack-init', ctx => {
@@ -25,7 +19,7 @@ export class Pubstack {
25
19
  }
26
20
  ctx.assetLoaderService__
27
21
  .loadScript({
28
- name: 'pubstack',
22
+ name,
29
23
  loadMethod: AssetLoadMethod.TAG,
30
24
  assetUrl: `https://boot.pbstck.com/v1/tag/${config.tagId}`
31
25
  })
@@ -34,9 +28,9 @@ export class Pubstack {
34
28
  })
35
29
  ]
36
30
  : [];
37
- }
38
- configureSteps__() {
39
- const config = this.pubstackConfig;
31
+ };
32
+ const configureSteps__ = () => {
33
+ const config = pubstackConfig;
40
34
  return config
41
35
  ? [
42
36
  mkConfigureStep('pubstack-configure', ctx => {
@@ -52,8 +46,16 @@ export class Pubstack {
52
46
  })
53
47
  ]
54
48
  : [];
55
- }
56
- prepareRequestAdsSteps__() {
57
- return [];
58
- }
59
- }
49
+ };
50
+ const prepareRequestAdsSteps__ = () => [];
51
+ return {
52
+ name,
53
+ description: 'prebid analytics integration',
54
+ moduleType: 'reporting',
55
+ config__,
56
+ configure__,
57
+ initSteps__,
58
+ configureSteps__,
59
+ prepareRequestAdsSteps__
60
+ };
61
+ };
@@ -1,28 +1,22 @@
1
1
  import { LOW_PRIORITY, mkPrepareRequestAdsStep } from 'ad-tag/ads/adPipeline';
2
2
  import { setupFooterAdListener } from './desktopFloorAd';
3
3
  import { initMobileAdSticky } from './mobileSticky';
4
- export class StickyFooterAd {
5
- constructor() {
6
- this.name = 'sticky-footer-ads';
7
- this.description = 'sticky footer ad creatives';
8
- this.moduleType = 'creatives';
9
- this.stickyFooterAdConfig = null;
10
- }
11
- config__() {
12
- return this.stickyFooterAdConfig;
13
- }
14
- configure__(moduleConfig) {
4
+ export const createStickyFooterAd = () => {
5
+ const name = 'sticky-footer-ads';
6
+ let stickyFooterAdConfig = null;
7
+ const config__ = () => stickyFooterAdConfig;
8
+ const configure__ = (moduleConfig) => {
15
9
  if (moduleConfig?.stickyFooterAd?.enabled) {
16
- this.stickyFooterAdConfig = moduleConfig.stickyFooterAd;
10
+ stickyFooterAdConfig = moduleConfig.stickyFooterAd;
17
11
  }
18
- }
19
- prepareRequestAdsSteps__() {
20
- const config = this.stickyFooterAdConfig;
12
+ };
13
+ const prepareRequestAdsSteps__ = () => {
14
+ const config = stickyFooterAdConfig;
21
15
  return config
22
16
  ? [
23
- mkPrepareRequestAdsStep(this.name, LOW_PRIORITY, (ctx, slots) => {
17
+ mkPrepareRequestAdsStep(name, LOW_PRIORITY, (ctx, slots) => {
24
18
  if (config.mobileStickyDomId &&
25
- slots.some(slot => slot.moliSlot.domId === this.stickyFooterAdConfig?.mobileStickyDomId)) {
19
+ slots.some(slot => slot.moliSlot.domId === config.mobileStickyDomId)) {
26
20
  initMobileAdSticky(ctx.window__, ctx.env__, ctx.logger__, config.mobileStickyDomId, config.disallowedAdvertiserIds, config.initiallyHidden ?? false);
27
21
  }
28
22
  if (config.desktopFloorAdDomId &&
@@ -33,11 +27,17 @@ export class StickyFooterAd {
33
27
  })
34
28
  ]
35
29
  : [];
36
- }
37
- configureSteps__() {
38
- return [];
39
- }
40
- initSteps__() {
41
- return [];
42
- }
43
- }
30
+ };
31
+ const configureSteps__ = () => [];
32
+ const initSteps__ = () => [];
33
+ return {
34
+ name,
35
+ description: 'sticky footer ad creatives',
36
+ moduleType: 'creatives',
37
+ config__,
38
+ configure__,
39
+ prepareRequestAdsSteps__,
40
+ configureSteps__,
41
+ initSteps__
42
+ };
43
+ };