@highfivve/ad-tag 5.7.0 → 5.7.2

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.
@@ -305,9 +305,8 @@ export const gptDefineSlots = () => (context, slots) => {
305
305
  if (adSlot) {
306
306
  if (moliSlot.gpt) {
307
307
  adSlot.setConfig(moliSlot.gpt);
308
- context.logger__.debug('GAM', `Add slot settings: [AdSlot] ${adSlot} [Settings] ${moliSlot.gpt}`);
308
+ context.logger__.debug('GAM', `Add slot settings: [AdSlot] ${adSlot.getSlotElementId()}`, moliSlot.gpt);
309
309
  }
310
- adSlot.setCollapseEmptyDiv(moliSlot.gpt?.collapseEmptyDiv !== false);
311
310
  adSlot.addService(context.window__.googletag.pubads());
312
311
  context.logger__.debug('GAM', `Register slot: [DomID] ${moliSlot.domId} [AdUnitPath] ${moliSlot.adUnitPath}`);
313
312
  return Promise.resolve({
@@ -0,0 +1,5 @@
1
+ export const isAdvertiserIncluded = (event, advertisersList) => {
2
+ const { advertiserId, companyIds } = event;
3
+ return ((!!advertiserId && advertisersList.includes(advertiserId)) ||
4
+ (!!companyIds && advertisersList.some(id => companyIds.includes(id))));
5
+ };
@@ -1,3 +1,4 @@
1
+ import { isAdvertiserIncluded } from 'ad-tag/ads/isAdvertiserIncluded';
1
2
  export class AdVisibilityService {
2
3
  constructor(userActivityService, refreshInterval, refreshIntervalOverrides, useIntersectionObserver, disableAdVisibilityChecks, viewabilityOverrides, window, logger) {
3
4
  this.userActivityService = userActivityService;
@@ -60,7 +61,7 @@ export class AdVisibilityService {
60
61
  this.setUpdateTimer(true);
61
62
  this.logger?.debug('AdVisibilityService', 'initialized');
62
63
  }
63
- trackSlot(slot, refreshCallback, advertiserId) {
64
+ trackSlot(slot, refreshCallback, advertiserId, companyIds) {
64
65
  const slotDomId = slot.getSlotElementId();
65
66
  const domElement = this.observedDomElementForSlot(slot);
66
67
  if (domElement) {
@@ -75,9 +76,8 @@ export class AdVisibilityService {
75
76
  (override?.variant === 'disabled' &&
76
77
  (override.disableAllAdVisibilityChecks ||
77
78
  !(override.disabledAdVisibilityCheckAdvertiserIds &&
78
- override.disabledAdVisibilityCheckAdvertiserIds.length > 0 &&
79
- advertiserId) ||
80
- override.disabledAdVisibilityCheckAdvertiserIds.includes(advertiserId)))
79
+ override.disabledAdVisibilityCheckAdvertiserIds.length > 0) ||
80
+ isAdvertiserIncluded({ advertiserId, companyIds }, override.disabledAdVisibilityCheckAdvertiserIds)))
81
81
  ? this.window.performance.now()
82
82
  : undefined,
83
83
  durationVisibleSum: 0,
@@ -2,6 +2,7 @@ import { AdVisibilityService } from './adVisibilityService';
2
2
  import { UserActivityService } from './userActivityService';
3
3
  import { mkConfigureStep } from '../../adPipeline';
4
4
  import { isNotNull } from 'ad-tag/util/arrayUtils';
5
+ import { isAdvertiserIncluded } from 'ad-tag/ads/isAdvertiserIncluded';
5
6
  export class AdReload {
6
7
  constructor() {
7
8
  this.name = 'moli-ad-reload';
@@ -33,8 +34,7 @@ export class AdReload {
33
34
  const slotIsMonitored = slotsToMonitor.indexOf(slotDomId) > -1;
34
35
  const orderIdNotExcluded = !campaignId || config.excludeOrderIds.indexOf(campaignId) === -1;
35
36
  const orderIdIncluded = !!campaignId && config.includeOrderIds.indexOf(campaignId) > -1;
36
- const advertiserIdIncluded = (!!advertiserId && config.includeAdvertiserIds.indexOf(advertiserId) > -1) ||
37
- (!!companyIds && config.includeAdvertiserIds.some(id => companyIds.includes(id)));
37
+ const advertiserIdIncluded = isAdvertiserIncluded(renderEndedEvent, config.includeAdvertiserIds);
38
38
  const yieldGroupIdIncluded = !!yieldGroupIds && config.includeYieldGroupIds.some(id => yieldGroupIds.indexOf(id) > -1);
39
39
  const trackingSlotAllowed = !slotIsEmpty &&
40
40
  slotIsMonitored &&
@@ -52,7 +52,7 @@ export class AdReload {
52
52
  }
53
53
  const slotAlreadyTracked = !!this.adVisibilityService?.isSlotTracked(slotDomId);
54
54
  if (trackingSlotAllowed) {
55
- this.adVisibilityService.trackSlot(googleTagSlot, reloadAdSlotCallback, advertiserId);
55
+ this.adVisibilityService.trackSlot(googleTagSlot, reloadAdSlotCallback, advertiserId, companyIds);
56
56
  }
57
57
  else if (slotAlreadyTracked) {
58
58
  this.adVisibilityService.removeSlotTracking(googleTagSlot);
@@ -1,5 +1,6 @@
1
1
  import { getBrowserStorageValue } from 'ad-tag/util/localStorage';
2
2
  import { isGamInterstitial } from 'ad-tag/ads/auctions/interstitialContext';
3
+ import { isAdvertiserIncluded } from 'ad-tag/ads/isAdvertiserIncluded';
3
4
  const interstitialContainerSelector = '[data-ref="h5v-interstitial"]';
4
5
  const interstitialCloseButtonSelector = '[data-ref="h5v-interstitial-close"]';
5
6
  const interstitialHidingClass = 'h5v-interstitial--hidden';
@@ -11,11 +12,7 @@ const interstitialRenderedEvent = (interstitialDomId, disallowedAdvertiserIds, w
11
12
  if (event.isEmpty) {
12
13
  resolve({ result: 'empty', slot: event.slot });
13
14
  }
14
- else if (event.advertiserId && disallowedAdvertiserIds.includes(event.advertiserId)) {
15
- resolve({ result: 'disallowed', slot: event.slot });
16
- }
17
- else if (event.companyIds &&
18
- disallowedAdvertiserIds.some(id => event.companyIds?.includes(id))) {
15
+ else if (isAdvertiserIncluded(event, disallowedAdvertiserIds)) {
19
16
  resolve({ result: 'disallowed', slot: event.slot });
20
17
  }
21
18
  else {
@@ -1,3 +1,4 @@
1
+ import { isAdvertiserIncluded } from 'ad-tag/ads/isAdvertiserIncluded';
1
2
  const closeButtonDataRef = 'footer-ad-close-button';
2
3
  const containerDataRefSelector = '[data-ref=h5-footer-ad-container]';
3
4
  const closeButtonDataRefSelector = `[data-ref=${closeButtonDataRef}]`;
@@ -21,8 +22,7 @@ const renderFooterAd = (window, floorAdDomId, disallowedAdvertiserIds, log) => (
21
22
  !footerAdElement ||
22
23
  slot.getSlotElementId() !== floorAdDomId ||
23
24
  event.isEmpty ||
24
- (!!event.advertiserId && disallowedAdvertiserIds.includes(event.advertiserId)) ||
25
- (!!event.companyIds && disallowedAdvertiserIds.some(id => event.companyIds?.includes(id))) ||
25
+ isAdvertiserIncluded(event, disallowedAdvertiserIds) ||
26
26
  window.matchMedia('(max-width: 767px)').matches) {
27
27
  log.debug('[footer-ad]', 'remove footer ad container');
28
28
  return;
@@ -1,3 +1,4 @@
1
+ import { isAdvertiserIncluded } from 'ad-tag/ads/isAdvertiserIncluded';
1
2
  const adStickyContainerDataRef = '[data-ref=sticky-ad]';
2
3
  const adStickyCloseButtonDataRef = '[data-ref=sticky-ad-close]';
3
4
  const adVisibleClass = 'h5-sticky-ad--visible';
@@ -20,11 +21,7 @@ const stickyRenderedEvent = (adSticky, mobileStickyDomId, disallowedAdvertiserId
20
21
  }
21
22
  resolve('empty');
22
23
  }
23
- else if (!!event.advertiserId && disallowedAdvertiserIds.includes(event.advertiserId)) {
24
- resolve('disallowed');
25
- }
26
- else if (!!event.companyIds &&
27
- disallowedAdvertiserIds.some(id => event.companyIds?.includes(id))) {
24
+ else if (isAdvertiserIncluded(event, disallowedAdvertiserIds)) {
28
25
  resolve('disallowed');
29
26
  }
30
27
  else {
@@ -1,3 +1,4 @@
1
+ import { isAdvertiserIncluded } from 'ad-tag/ads/isAdvertiserIncluded';
1
2
  const adStickyContainerDataRef = '[data-ref=h5v-sticky-ad]';
2
3
  const adStickyCloseButtonDataRef = '[data-ref=h5v-sticky-ad-close]';
3
4
  const adStickyCloseButtonContent = '.h5v-closeButtonContent';
@@ -12,11 +13,7 @@ const stickyRenderedEvent = (mobileStickyDomId, disallowedAdvertiserIds, window)
12
13
  if (event.isEmpty) {
13
14
  resolve('empty');
14
15
  }
15
- else if (event.advertiserId && disallowedAdvertiserIds.includes(event.advertiserId)) {
16
- resolve('disallowed');
17
- }
18
- else if (!!event.companyIds &&
19
- disallowedAdvertiserIds.some(id => event.companyIds?.includes(id))) {
16
+ else if (isAdvertiserIncluded(event, disallowedAdvertiserIds)) {
20
17
  resolve('disallowed');
21
18
  }
22
19
  else {
@@ -1,3 +1,4 @@
1
+ import { isAdvertiserIncluded } from 'ad-tag/ads/isAdvertiserIncluded';
1
2
  export const adRenderResult = (ctx, headerSlot, disallowedAdvertiserIds, minVisibleDuration) => new Promise(resolve => {
2
3
  if (ctx.env__ === 'test') {
3
4
  resolve('standard');
@@ -7,11 +8,7 @@ export const adRenderResult = (ctx, headerSlot, disallowedAdvertiserIds, minVisi
7
8
  if (event.slot.getSlotElementId() !== headerSlot.domId) {
8
9
  return;
9
10
  }
10
- if (event.advertiserId && disallowedAdvertiserIds.includes(event.advertiserId)) {
11
- resolve('disallowed');
12
- }
13
- else if (event.companyIds &&
14
- disallowedAdvertiserIds.some(id => event.companyIds?.includes(id))) {
11
+ if (isAdvertiserIncluded(event, disallowedAdvertiserIds)) {
15
12
  resolve('disallowed');
16
13
  }
17
14
  else if (event.isEmpty) {
@@ -1,3 +1,3 @@
1
1
  export const packageJson = {
2
- version: '5.7.0'
2
+ version: '5.7.2'
3
3
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highfivve/ad-tag",
3
- "version": "5.7.0",
3
+ "version": "5.7.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "An ad tag implementation called moli",
6
6
  "main": "./lib/index.js",