Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@financial-times/ads-display

Package Overview
Dependencies
Maintainers
9
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@financial-times/ads-display - npm Package Compare versions

Comparing version 5.0.0-beta.2 to 5.0.0-beta.3

172

dist/ads-display.js

@@ -16,3 +16,3 @@ import oAds from '@financial-times/ads-legacy-o-ads';

const isPlainObject = o => {
return typeof o == 'object' && o.constructor == Object;
return typeof o == "object" && o.constructor == Object;
};

@@ -38,3 +38,3 @@ /**

viewportSize = window.innerWidth,
fallbackValue = '0%'
fallbackValue = "0%"
}) => {

@@ -83,3 +83,3 @@ if (!breakpointMargins || !viewportSize) {

const hideImage = width < collapseBelow;
const targetOrigin = 'https://tpc.googlesyndication.com';
const targetOrigin = "https://tpc.googlesyndication.com";
const adFrameSelector = `iframe[src^="${targetOrigin}"][data-load-complete="true"]`;

@@ -93,3 +93,3 @@ /** @type {NodeListOf<HTMLIFrameElement>} */

iframe.contentWindow.postMessage({
type: 'resize',
type: "resize",
hideImage

@@ -102,4 +102,4 @@ }, targetOrigin);

document.body.addEventListener('oViewport.resize', onResize);
oViewport.listenTo('resize');
document.body.addEventListener("oViewport.resize", onResize);
oViewport.listenTo("resize");
}

@@ -115,3 +115,3 @@ const getRootID = oTracking.getRootID;

} catch (e) {
console.warn('Failed to initialise PersonaliseConsent', e);
console.warn("Failed to initialise PersonaliseConsent", e);
}

@@ -123,11 +123,11 @@ }

const DEFAULT_ADS_API_HOST = 'https://ads-api.ft.com/v2';
const DEFAULT_ADS_API_HOST = "https://ads-api.ft.com/v2";
function getEndpointFromPageType(pageType) {
if (pageType === 'article') {
return 'content';
if (pageType === "article") {
return "content";
}
if (pageType === 'stream') {
return 'concept';
if (pageType === "stream") {
return "concept";
}

@@ -146,3 +146,3 @@

if (!pageId || !endpoint.match(/^(content|concept)$/)) {
console.error('Invalid ads-api endpoint specified for retrieving page targeting data'); //eslint-disable-line no-console
console.error("Invalid ads-api endpoint specified for retrieving page targeting data"); //eslint-disable-line no-console

@@ -161,3 +161,3 @@ return;

} catch (e) {
console.warn('Failed to fetch data from Ads API Content|Concept endpoint');
console.warn("Failed to fetch data from Ads API Content|Concept endpoint");
}

@@ -177,7 +177,7 @@ }

useCorsProxy: true,
credentials: 'include'
credentials: "include"
});
return resp.json();
} catch (e) {
console.warn('Failed to fetch data from Ads API User endpoint');
console.warn("Failed to fetch data from Ads API User endpoint");
}

@@ -242,3 +242,3 @@ }

if (isPlainObject(user)) {
const hasLoggedIn = typeof user.loggedInStatus === 'boolean';
const hasLoggedIn = typeof user.loggedInStatus === "boolean";
const hasHuiGender = user.hui && user.hui.gender;

@@ -270,11 +270,11 @@ const hasHuiIndustry = user.hui && user.hui.indb2b;

...(hasIndustry && {
['05']: user.industry.code
["05"]: user.industry.code
}),
// weird number mapping. 05 = industry
...(hasResponsibility && {
['06']: user.responsibility.code
["06"]: user.responsibility.code
}),
// weird number mapping. 06 = responsibility
...(hasPosition && {
['07']: user.position.code
["07"]: user.position.code
}) // weird number mapping. 07 = position

@@ -306,15 +306,15 @@

...(article.admants && {
ad: article.admants.join(',')
ad: article.admants.join(",")
}),
...(article.categories && {
ca: article.categories.join(',')
ca: article.categories.join(",")
}),
...(article.topic && {
topic: article.topic.join(',')
topic: article.topic.join(",")
}),
...(article.brand && {
secbrand: article.brand.join(',')
secbrand: article.brand.join(",")
}),
...(hasSpecialReport && {
sr: article.specialReport.join(',')
sr: article.specialReport.join(",")
}),

@@ -344,3 +344,3 @@ ...(article.srUUID && {

if (key === 'smid' && typeof value !== 'undefined') {
if (key === "smid" && typeof value !== "undefined") {
return {

@@ -413,4 +413,4 @@ [key]: value

const adsApiResponses = settledResults.map(settledResult => {
if (settledResult.status === 'rejected') {
console.warn('Failed to fetch data from Ads API', settledResult.reason);
if (settledResult.status === "rejected") {
console.warn("Failed to fetch data from Ads API", settledResult.reason);
return;

@@ -421,3 +421,3 @@ }

});
perfMark('oAds.adsAPIComplete');
perfMark("oAds.adsAPIComplete");
return formatAdsApiData(adsApiResponses, page);

@@ -427,3 +427,3 @@ }

const getEmbeddedOptions = () => {
const adsConfigEl = document.getElementById('n-ads-options');
const adsConfigEl = document.getElementById("n-ads-options");
let data = {};

@@ -435,3 +435,3 @@

} catch (e) {
console.error('Error while getting ads-display embedded options', e); // eslint-disable-line no-console
console.error("Error while getting ads-display embedded options", e); // eslint-disable-line no-console
}

@@ -444,8 +444,8 @@ }

const addIframeMessageListener = () => {
window.addEventListener('message', event => {
window.addEventListener("message", event => {
const {
data = ''
data = ""
} = event; // We don't want to waste time trying to parse postMessage that we know aren't for us
if (typeof data !== 'string' || !data.match(/oAds/)) {
if (typeof data !== "string" || !data.match(/oAds/)) {
return;

@@ -465,9 +465,9 @@ }

if (type === 'oAdsEmbed.monitor') {
if (type === "oAdsEmbed.monitor") {
const payload = {
category: 'ads',
action: 'embed',
message: parsedMessage.message || ''
category: "ads",
action: "embed",
message: parsedMessage.message || ""
};
broadcast('oTracking.event', payload);
broadcast("oTracking.event", payload);
return;

@@ -477,3 +477,3 @@ } // Pass data to iframe when iframe signals readiness to receive it

if (type === 'oAdsEmbed.listens') {
if (type === "oAdsEmbed.listens") {
const iframe = event.source; // 'iframe' is a reference to the specific iframe that sent

@@ -487,3 +487,3 @@ // the oAdsEmbed.listens postMessage. We only send our response to it

const message = {
messageType: 'oAdsEmbed',
messageType: "oAdsEmbed",
body: {

@@ -493,3 +493,3 @@ smartmatchCreativeMatches: matches

};
iframe.postMessage(message, '*');
iframe.postMessage(message, "*");
}

@@ -534,23 +534,23 @@ }

sampleSize: METRICS_SAMPLE_SIZE,
spoorAction: 'page-initialised',
triggers: ['serverScriptLoaded'],
marks: ['consentBehavioral', 'consentProgrammatic', 'moatTimeout', 'initialising', 'IVTComplete', 'adsAPIComplete', 'initialised', 'serverScriptLoaded'],
navigation: ['domInteractive']
spoorAction: "page-initialised",
triggers: ["serverScriptLoaded"],
marks: ["consentBehavioral", "consentProgrammatic", "moatTimeout", "initialising", "IVTComplete", "adsAPIComplete", "initialised", "serverScriptLoaded"],
navigation: ["domInteractive"]
}, {
sampleSize: METRICS_SAMPLE_SIZE,
spoorAction: 'slot-requested',
triggers: ['slotGoRender'],
marks: ['slotReady', 'slotCanRender', 'slotGoRender'],
spoorAction: "slot-requested",
triggers: ["slotGoRender"],
marks: ["slotReady", "slotCanRender", "slotGoRender"],
multiple: true
}, {
sampleSize: METRICS_SAMPLE_SIZE,
spoorAction: 'slot-rendered',
triggers: ['slotRenderEnded'],
marks: ['slotRenderStart', 'slotExpand', 'slotRenderEnded'],
spoorAction: "slot-rendered",
triggers: ["slotRenderEnded"],
marks: ["slotRenderStart", "slotExpand", "slotRenderEnded"],
multiple: true
}, {
sampleSize: METRICS_SAMPLE_SIZE,
spoorAction: 'slot-collapsed',
triggers: ['slotCollapsed'],
marks: ['slotCollapsed'],
spoorAction: "slot-collapsed",
triggers: ["slotCollapsed"],
marks: ["slotCollapsed"],
multiple: true

@@ -589,3 +589,3 @@ }];

return broadcast('oTracking.event', payload);
return broadcast("oTracking.event", payload);
};

@@ -604,3 +604,3 @@

// eslint-disable-line no-unused-vars
console.log('reports', reports); // eslint-disable-line no-console
console.log("reports", reports); // eslint-disable-line no-console
}, {

@@ -611,7 +611,7 @@ buffered: true

observer.observe();
window.addEventListener('unload', event => {
window.addEventListener("unload", event => {
// eslint-disable-line no-unused-vars
// pull all pending reports from the queue
const reports = observer.takeRecords();
console.log('reports', reports); // eslint-disable-line no-console
console.log("reports", reports); // eslint-disable-line no-console
});

@@ -658,3 +658,3 @@ };

//if adsEnableTestCreatives flag is set, pass sandbox as true downstream, as that's checked to show test creatives
sandbox: options.sandbox || !!flags.get('adsEnableTestCreatives')
sandbox: options.sandbox || !!flags.get("adsEnableTestCreatives")
};

@@ -668,3 +668,3 @@

if (!options.appName) {
throw new Error('Error initialising display ads. `options.appName` is required');
throw new Error("Error initialising display ads. `options.appName` is required");
}

@@ -696,6 +696,6 @@

function initAdSlots(oAdsInstance) {
const containers = document.querySelectorAll('.o-ads, [data-o-ads-name]');
const containers = document.querySelectorAll(".o-ads, [data-o-ads-name]");
if (!containers.length) {
console.warn('No ad slot found on the page'); // eslint-disable-line no-console
console.warn("No ad slot found on the page"); // eslint-disable-line no-console

@@ -721,3 +721,3 @@ return;

} catch (e) {
console.error('There was an error when initialising o-ads', e); // eslint-disable-line no-console
console.error("There was an error when initialising o-ads", e); // eslint-disable-line no-console
}

@@ -735,21 +735,21 @@

if (sandbox) {
console.warn('o-ads running in sandbox mode. No live ads showing'); // eslint-disable-line no-console
console.warn("o-ads running in sandbox mode. No live ads showing"); // eslint-disable-line no-console
return 'test.5887.origami';
return "test.5887.origami";
}
if (location.hash.includes('adsandbox')) {
console.warn('o-ads running in sandbox mode. No live ads showing'); // eslint-disable-line no-console
if (location.hash.includes("adsandbox")) {
console.warn("o-ads running in sandbox mode. No live ads showing"); // eslint-disable-line no-console
return 'sandbox.next.ft';
return "sandbox.next.ft";
} // Setting up an ad unit that doesn't contain the moat wrapper to gauge its impact
if (location.hash.includes('moatwrappertest')) {
console.warn('o-ads running in sandbox mode. No live ads showing'); // eslint-disable-line no-console
if (location.hash.includes("moatwrappertest")) {
console.warn("o-ads running in sandbox mode. No live ads showing"); // eslint-disable-line no-console
return 'test.5887.moatperformance';
return "test.5887.moatperformance";
}
return 'ft.com';
return "ft.com";
}

@@ -763,3 +763,3 @@ /**

function getGptZone(adUnit) {
return Array.isArray(adUnit) ? adUnit.join('/') : 'unclassified';
return Array.isArray(adUnit) ? adUnit.join("/") : "unclassified";
}

@@ -782,8 +782,8 @@ /**

gpt: {
network: '5887',
network: "5887",
site: getGptSite(sandbox),
zone: getGptZone(adUnit),
// enable single request architecture https://support.google.com/admanager/answer/183282
rendering: flags.get('adsEnableSRA') ? 'sra' : null,
enableLazyLoad: flags.get('adsEnableGPTLazyLoad') ? calculateViewportMargin({
rendering: flags.get("adsEnableSRA") ? "sra" : null,
enableLazyLoad: flags.get("adsEnableGPTLazyLoad") ? calculateViewportMargin({
breakpointMargins: lazyLoadMargins || GPT_LAZY_LOAD_DEFAULT,

@@ -795,6 +795,6 @@ fallbackValue: GPT_LAZY_LOAD_BREAKPOINT_FALLBACK

PartnerContent: {
sizes: 'fluid'
sizes: "fluid"
},
PaidPost: {
sizes: 'fluid'
sizes: "fluid"
},

@@ -820,4 +820,4 @@ OneByOne: {

},
collapseEmpty: 'before',
lazyLoad: !flags.get('adsEnableGPTLazyLoad') && {
collapseEmpty: "before",
lazyLoad: !flags.get("adsEnableGPTLazyLoad") && {
viewportMargin: calculateViewportMargin({

@@ -853,3 +853,3 @@ breakpointMargins: lazyLoadMargins

pt: appName.toLowerCase().substr(0, 3),
nlayout: adsLayout || 'default',
nlayout: adsLayout || "default",
mvt: abTestState,

@@ -934,6 +934,6 @@ rootid: rootId,

const manageCookiesUrl = new URL(manageCookiesLink.href);
manageCookiesUrl.searchParams.set('redirect', pageUrl);
manageCookiesLink.setAttribute('href', manageCookiesUrl.toString());
manageCookiesUrl.searchParams.set("redirect", pageUrl);
manageCookiesLink.setAttribute("href", manageCookiesUrl.toString());
} catch (err) {
console.warn('Error setting redirect url for cookie consent link', String(err).trim());
console.warn("Error setting redirect url for cookie consent link", String(err).trim());
}

@@ -945,3 +945,3 @@ }

const manageCookiesLink = document.querySelector('[data-n-messaging-manage-cookies]');
const manageCookiesLink = document.querySelector("[data-n-messaging-manage-cookies]");
addRedirectToManageCookiesLink(window.location.href, manageCookiesLink);

@@ -948,0 +948,0 @@ const adsUtils = {

@@ -24,2 +24,12 @@ {

},
"peerDependencies": {
"@financial-times/ads-legacy-o-ads": "file:../ads-legacy-o-ads",
"@financial-times/ads-moat-integration": "file:../ads-moat-integration",
"@financial-times/ads-permutive": "file:../ads-permutive",
"@financial-times/ads-personalised-consent": "file:../ads-personalised-consent",
"@financial-times/n-tracking": ">=4",
"@financial-times/o-tracking": ">=4",
"@financial-times/o-viewport": ">=5",
"@financial-times/privacy-us-privacy": ">=1"
},
"scripts": {

@@ -32,3 +42,3 @@ "clean": "rm -rf ./dist",

},
"version": "5.0.0-beta.2"
"version": "5.0.0-beta.3"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc