@highfivve/ad-tag 5.8.12 → 5.8.14

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.
@@ -9,7 +9,7 @@ export class AdReload {
9
9
  this.description = 'Moli implementation of an ad reload module.';
10
10
  this.moduleType = 'ad-reload';
11
11
  this.moduleConfig = null;
12
- this.refreshIntervalMs = 20000;
12
+ this.defaultRefreshIntervalMs = 20000;
13
13
  this.reloadKeyValue = 'native-ad-reload';
14
14
  this.initialized = false;
15
15
  this.initialize = (context, config, slotsToMonitor, reloadAdSlotCallback) => {
@@ -26,7 +26,7 @@ export class AdReload {
26
26
  this.initialized = true;
27
27
  };
28
28
  this.setupAdVisibilityService = (config, window, logger) => {
29
- this.adVisibilityService = new AdVisibilityService(new UserActivityService(window, config.userActivityLevelControl, logger), config.refreshIntervalMs ?? this.refreshIntervalMs, config.refreshIntervalMsOverrides ?? {}, false, !!config.disableAdVisibilityChecks, config.viewabilityOverrides ?? {}, window, logger);
29
+ this.adVisibilityService = new AdVisibilityService(new UserActivityService(window, config.userActivityLevelControl, logger), config.refreshIntervalMs ?? this.defaultRefreshIntervalMs, config.refreshIntervalMsOverrides ?? {}, false, !!config.disableAdVisibilityChecks, config.viewabilityOverrides ?? {}, window, logger);
30
30
  };
31
31
  this.setupSlotRenderListener = (config, slotsToMonitor, reloadAdSlotCallback, window, logger) => window.googletag.pubads().addEventListener('slotRenderEnded', renderEndedEvent => {
32
32
  const { slot: googleTagSlot, campaignId, advertiserId, companyIds, yieldGroupIds, isEmpty: slotIsEmpty } = renderEndedEvent;
@@ -1,6 +1,7 @@
1
1
  import { tcfapi } from 'ad-tag/types/tcfapi';
2
2
  import { mkInitStep, mkConfigureStepOncePerRequestAdsCycle } from 'ad-tag/ads/adPipeline';
3
3
  import { AssetLoadMethod } from 'ad-tag/util/assetLoaderService';
4
+ import { extractTopPrivateDomainFromHostname } from 'ad-tag/util/extractTopPrivateDomainFromHostname';
4
5
  const requiredPurposeIds = [
5
6
  tcfapi.responses.TCPurpose.STORE_INFORMATION_ON_DEVICE,
6
7
  tcfapi.responses.TCPurpose.SELECT_BASIC_ADS,
@@ -29,6 +30,22 @@ export const createUtiq = () => {
29
30
  ? { ...utiqWindow.Utiq, config: { ...utiqWindow.Utiq.config, ...config.options } }
30
31
  : { queue: [], config: config.options };
31
32
  utiqWindow.Utiq.queue = utiqWindow.Utiq.queue || [];
33
+ const emetriqSid = config.userIdConfig?.emetriq?.sid;
34
+ if (emetriqSid) {
35
+ utiqWindow.Utiq.queue.push(() => {
36
+ if (utiqWindow.Utiq?.API) {
37
+ utiqWindow.Utiq.API.addEventListener('onIdsAvailable', ({ mtid, category }) => {
38
+ if (!mtid || category !== 'mobile') {
39
+ context.logger__.info('Utiq', 'MTID missing or category is not mobile, fallback to standard code');
40
+ return;
41
+ }
42
+ context.logger__.debug('Utiq', 'MTID found and category is mobile, setting Emetriq params');
43
+ utiqWindow._enqAdpParam || (utiqWindow._enqAdpParam = {});
44
+ utiqWindow._enqAdpParam[`id_utiq_${emetriqSid}`] = mtid;
45
+ });
46
+ }
47
+ });
48
+ }
32
49
  if (context.tcData__.gdprApplies &&
33
50
  requiredPurposeIds.some(purposeId => context.tcData__.gdprApplies && !context.tcData__.purpose.consents[purposeId])) {
34
51
  return Promise.resolve();
@@ -38,11 +55,16 @@ export const createUtiq = () => {
38
55
  context.logger__.info('Utiq', `not enough ad requests to load Utiq. ${minAdRequests} required.`);
39
56
  return Promise.resolve();
40
57
  }
58
+ const assetUrl = config.assetUrl ?? extractTopPrivateDomainFromHostname(context.window__.location.hostname);
59
+ if (!assetUrl) {
60
+ context.logger__.error('Utiq', 'Cannot load Utiq: no assetUrl provided in config and unable to extract domain from hostname');
61
+ return Promise.resolve();
62
+ }
41
63
  return context.assetLoaderService__
42
64
  .loadScript({
43
65
  name: 'utiq',
44
66
  loadMethod: AssetLoadMethod.TAG,
45
- assetUrl: config.assetUrl
67
+ assetUrl
46
68
  })
47
69
  .then(() => {
48
70
  scriptLoaded = true;
@@ -1,3 +1,3 @@
1
1
  export const packageJson = {
2
- version: '5.8.12'
2
+ version: '5.8.14'
3
3
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highfivve/ad-tag",
3
- "version": "5.8.12",
3
+ "version": "5.8.14",
4
4
  "license": "Apache-2.0",
5
5
  "description": "An ad tag implementation called moli",
6
6
  "main": "./lib/index.js",