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

@financial-times/o-ads

Package Overview
Dependencies
Maintainers
18
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 14.1.0 to 14.2.0

dist/js/utils/url.js

133

dist/js/ad-servers/gpt.js

@@ -14,2 +14,4 @@ "use strict";

var _url = require("../utils/url");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -22,7 +24,7 @@

/**
* @fileOverview
* ad server modules for o-ads implementing Google publisher tags ad requests.
*
* @author Robin Marr, robin.marr@ft.com
*/
* @fileOverview
* ad server modules for o-ads implementing Google publisher tags ad requests.
*
* @author Robin Marr, robin.marr@ft.com
*/
var DEFAULT_COLLAPSE_MODE = 'never';

@@ -37,4 +39,4 @@ var breakpoints = false;

/*
* Initialise Google publisher tags functionality
*/
* Initialise Google publisher tags functionality
*/

@@ -57,4 +59,4 @@ function init() {

/*
* initalise the googletag global namespace and add the google publish tags library to the page
*/
* initalise the googletag global namespace and add the google publish tags library to the page
*/

@@ -85,6 +87,6 @@

/*
* Configure the GPT library for the current page
* this method is pushed onto the googletag command queue and run
* when the library is available
*/
* Configure the GPT library for the current page
* this method is pushed onto the googletag command queue and run
* when the library is available
*/

@@ -99,4 +101,10 @@

setPageCollapseEmpty();
var url = (0, _url.stripUrlParams)({
href: window.location.href,
filters: {
root: _url.SEARCH_PARAMS
}
});
googletag.enableServices();
googletag.pubads().setTargeting('url', window.location.href);
googletag.pubads().setTargeting('url', url);
googletag.pubads().setRequestNonPersonalizedAds(nonPersonalized);

@@ -106,5 +114,5 @@ return true;

/*
* set the gpt rendering mode to either sync or async
* default is async
*/
* set the gpt rendering mode to either sync or async
* default is async
*/

@@ -124,7 +132,7 @@

/**
* Adds page targeting to GPT ad calls
* @name setPageTargeting
* @memberof GPT
* @lends GPT
*/
* Adds page targeting to GPT ad calls
* @name setPageTargeting
* @memberof GPT
* @lends GPT
*/

@@ -149,4 +157,4 @@

/**
* Removes page targeting for a specified key from GPT ad calls
*/
* Removes page targeting for a specified key from GPT ad calls
*/

@@ -172,7 +180,7 @@

/**
* Sets behaviour of empty slots can be 'after', 'before' or 'never'
* * 'after' collapse slots that return an empty ad
* * 'before' collapses all slots and only displays them when an ad is found
* * 'never' does not collapse any empty slot, the collapseEmptyDivs method is not called in that case
*/
* Sets behaviour of empty slots can be 'after', 'before' or 'never'
* * 'after' collapse slots that return an empty ad
* * 'before' collapses all slots and only displays them when an ad is found
* * 'never' does not collapse any empty slot, the collapseEmptyDivs method is not called in that case
*/

@@ -192,5 +200,5 @@

/**
* When companions are enabled we delay the rendering of ad slots until
* either a master is returned or all slots are returned without a master
*/
* When companions are enabled we delay the rendering of ad slots until
* either a master is returned or all slots are returned without a master
*/

@@ -211,4 +219,4 @@

/*
* Event handler for when a slot is ready for an ad to rendered
*/
* Event handler for when a slot is ready for an ad to rendered
*/

@@ -236,4 +244,4 @@

/*
* Render is called when a slot is not rendered when the ready event fires
*/
* Render is called when a slot is not rendered when the ready event fires
*/

@@ -250,4 +258,4 @@

/*
* refresh is called when a slot requests the ad be flipped
*/
* refresh is called when a slot requests the ad be flipped
*/

@@ -277,4 +285,4 @@

/*
* function passed to the gpt library that is run when an ad completes rendering
*/
* function passed to the gpt library that is run when an ad completes rendering
*/

@@ -330,4 +338,4 @@

/**
* define a GPT slot
*/
* define a GPT slot
*/
defineSlot: function defineSlot() {

@@ -391,4 +399,4 @@ window.googletag.cmd.push(() => {

/**
* Tell gpt to destroy the slot and its metadata
*/
* Tell gpt to destroy the slot and its metadata
*/
destroySlot: function destroySlot(gptSlot) {

@@ -404,4 +412,4 @@ if (window.googletag.pubadsReady && window.googletag.pubads) {

/*
* Tell gpt to request an ad
*/
* Tell gpt to request an ad
*/
display: function display() {

@@ -416,4 +424,4 @@ window.googletag.cmd.push(() => {

/**
* Set the DFP unit name for the slot.
*/
* Set the DFP unit name for the slot.
*/
setUnitName: function setUnitName() {

@@ -444,4 +452,4 @@ window.googletag.cmd.push(() => {

/**
* Add the slot to the pub ads service and add a companion service if configured
*/
* Add the slot to the pub ads service and add a companion service if configured
*/
addServices: function addServices(gptSlot) {

@@ -461,5 +469,5 @@ window.googletag.cmd.push(() => {

/**
* Sets the GPT collapse empty mode for a given slot
* values can be 'after', 'before', 'never'
*/
* Sets the GPT collapse empty mode for a given slot
* values can be 'after', 'before', 'never'
*/
setCollapseEmpty: function setCollapseEmpty() {

@@ -510,5 +518,5 @@ window.googletag.cmd.push(() => {

/**
* Sets page url to be sent to google
* prevents later url changes via javascript from breaking the ads
*/
* Sets page url to be sent to google
* prevents later url changes via javascript from breaking the ads
*/
setURL: function setURL(gptSlot) {

@@ -524,4 +532,4 @@ window.googletag.cmd.push(() => {

/**
* Adds key values from a given object to the slot targeting
*/
* Adds key values from a given object to the slot targeting
*/
setTargeting: function setTargeting(gptSlot) {

@@ -548,6 +556,6 @@ window.googletag.cmd.push(() => {

/**
* The correlator is a random number added to ad calls.
* It is used by the ad server to determine which impressions where served to the same page
* Updating is used to tell the ad server to treat subsequent ad calls as being on a new page
*/
* The correlator is a random number added to ad calls.
* It is used by the ad server to determine which impressions where served to the same page
* Updating is used to tell the ad server to treat subsequent ad calls as being on a new page
*/

@@ -602,2 +610,3 @@ function updateCorrelator() {

init,
setup,
updateCorrelator,

@@ -604,0 +613,0 @@ updatePageTargeting,

"use strict";
// generated by genversion
module.exports = '14.1.0';
module.exports = '14.2.0';

@@ -27,3 +27,3 @@ // For a detailed explanation regarding each configuration property, visit:

// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
coverageDirectory: 'coverage',

@@ -65,6 +65,3 @@ // An array of regexp pattern strings used to skip coverage collection

// An array of directory names to be searched recursively up from the requiring module's location
moduleDirectories: [
"node_modules",
"bower_components"
],
moduleDirectories: ['node_modules', 'bower_components'],

@@ -135,3 +132,3 @@ // An array of file extensions your modules use

// The test environment that will be used for testing
// testEnvironment: "node",
testEnvironment: 'jest-environment-jsdom-global',

@@ -151,10 +148,6 @@ // Options that will be passed to the testEnvironment

// The glob patterns Jest uses to detect test files
testMatch: [
"**/test/jest/**/*.[jt]s?(x)",
],
testMatch: ['**/test/jest/**/*.[jt]s?(x)'],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: [
"/node_modules/", "/jest/testUtils"
],
testPathIgnorePatterns: ['/node_modules/', '/jest/testUtils'],

@@ -178,5 +171,5 @@ // The regexp pattern or array of patterns that Jest uses to detect test files

// transform: null,
"transform": {
"^.+\\.jsx?$": "babel-jest"
},
transform: {
'^.+\\.jsx?$': 'babel-jest'
}

@@ -183,0 +176,0 @@ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation

@@ -28,3 +28,3 @@ {

"name": "@financial-times/o-ads",
"version": "14.1.0",
"version": "14.2.0",
"dependencies": {

@@ -38,2 +38,6 @@ "ftdomdelegate": "^4.0.0",

"component": "o-ads",
"repository": {
"type": "git",
"url": "git@github.com:Financial-Times/o-ads.git"
},
"scripts": {

@@ -43,3 +47,4 @@ "demo-server": "obt demo --runServer --port=3002",

"test": "npm run test-unit",
"test-unit": "karma start karma.conf.js --single-run && jest",
"test-coverage": "karma start karma.conf.js --single-run",
"test-unit": "jest",
"test-cy:run": "cypress run -r spec --record false",

@@ -71,2 +76,5 @@ "test-cy:open": "cypress open",

"@testing-library/jest-dom": "^4.1.0",
"@types/doubleclick-gpt": "2019041801.0.2",
"@types/jest": "25.1.3",
"@types/jsdom": "16.1.0",
"babel-jest": "^24.8.0",

@@ -89,2 +97,4 @@ "babel-plugin-rewire": "^1.2.0",

"jest": "^24.8.0",
"jest-environment-jsdom": "25.1.0",
"jest-environment-jsdom-global": "1.2.1",
"jest-puppeteer": "^4.3.0",

@@ -91,0 +101,0 @@ "karma": "^4.1.0",

@@ -118,2 +118,2 @@ # oAds [![CircleCI Status](https://circleci.com/gh/Financial-Times/o-ads.svg?style=shield&circle-token=36a37c6ca27a08408c2575c7834f5f6f5c5c9d21)](https://circleci.com/gh/Financial-Times/o-ads/tree/master)

- Breaking change: If you use the destroy method on a slots instance, this will now properly destroy the given slots rather than just clear them
- New feature: util event 'off' - remove an event listener
- New feature: util event 'off' - remove an event listener

@@ -42,5 +42,7 @@ module.exports = {

'bcbe1a6d-fa90-4db5-b4dc-424c69802310',
'6790def915d959f61f56fb7005cba2cc'
'6790def915d959f61f56fb7005cba2cc',
'37b1e62e-93ff-4991-aa83-c1ec974d4802',
'0667615f-499e-4fa6-8130-f3430450228d'
]
}
};

@@ -5,10 +5,12 @@ /*globals googletag: true */

/**
* @fileOverview
* ad server modules for o-ads implementing Google publisher tags ad requests.
*
* @author Robin Marr, robin.marr@ft.com
*/
* @fileOverview
* ad server modules for o-ads implementing Google publisher tags ad requests.
*
* @author Robin Marr, robin.marr@ft.com
*/
import config from '../config';
import utils from '../utils';
import targeting from '../targeting';
import { stripUrlParams, SEARCH_PARAMS } from '../utils/url';
const DEFAULT_COLLAPSE_MODE = 'never';

@@ -23,4 +25,4 @@ let breakpoints = false;

/*
* Initialise Google publisher tags functionality
*/
* Initialise Google publisher tags functionality
*/
function init() {

@@ -38,4 +40,4 @@ const gptConfig = config('gpt') || {};

/*
* initalise the googletag global namespace and add the google publish tags library to the page
*/
* initalise the googletag global namespace and add the google publish tags library to the page
*/
function loadGPT() {

@@ -52,5 +54,11 @@ if (!window.googletag) {

utils.attach('//securepubads.g.doubleclick.net/tag/js/gpt.js', true,
() => { utils.broadcast('serverScriptLoaded'); },
(err) => { utils.broadcast('adServerLoadError', err); }
utils.attach(
'//securepubads.g.doubleclick.net/tag/js/gpt.js',
true,
() => {
utils.broadcast('serverScriptLoaded');
},
err => {
utils.broadcast('adServerLoadError', err);
}
);

@@ -66,6 +74,6 @@ }

/*
* Configure the GPT library for the current page
* this method is pushed onto the googletag command queue and run
* when the library is available
*/
* Configure the GPT library for the current page
* this method is pushed onto the googletag command queue and run
* when the library is available
*/
function setup(gptConfig) {

@@ -78,5 +86,12 @@ const nonPersonalized = config('nonPersonalized') ? 1 : 0;

setPageCollapseEmpty();
const url = stripUrlParams({
href: window.location.href,
filters: { root: SEARCH_PARAMS }
});
googletag.enableServices();
googletag.pubads().setTargeting('url', window.location.href);
googletag.pubads().setTargeting('url', url);
googletag.pubads().setRequestNonPersonalizedAds(nonPersonalized);
return true;

@@ -86,5 +101,5 @@ }

/*
* set the gpt rendering mode to either sync or async
* default is async
*/
* set the gpt rendering mode to either sync or async
* default is async
*/

@@ -103,7 +118,7 @@ function setRenderingMode(gptConfig) {

/**
* Adds page targeting to GPT ad calls
* @name setPageTargeting
* @memberof GPT
* @lends GPT
*/
* Adds page targeting to GPT ad calls
* @name setPageTargeting
* @memberof GPT
* @lends GPT
*/
function setPageTargeting(targetingData) {

@@ -127,4 +142,4 @@ if (utils.isPlainObject(targetingData)) {

/**
* Removes page targeting for a specified key from GPT ad calls
*/
* Removes page targeting for a specified key from GPT ad calls
*/
function clearPageTargetingForKey(key) {

@@ -145,7 +160,7 @@ if (!window.googletag) {

/**
* Sets behaviour of empty slots can be 'after', 'before' or 'never'
* * 'after' collapse slots that return an empty ad
* * 'before' collapses all slots and only displays them when an ad is found
* * 'never' does not collapse any empty slot, the collapseEmptyDivs method is not called in that case
*/
* Sets behaviour of empty slots can be 'after', 'before' or 'never'
* * 'after' collapse slots that return an empty ad
* * 'before' collapses all slots and only displays them when an ad is found
* * 'never' does not collapse any empty slot, the collapseEmptyDivs method is not called in that case
*/
function setPageCollapseEmpty() {

@@ -164,5 +179,5 @@ const mode = config('collapseEmpty');

/**
* When companions are enabled we delay the rendering of ad slots until
* either a master is returned or all slots are returned without a master
*/
* When companions are enabled we delay the rendering of ad slots until
* either a master is returned or all slots are returned without a master
*/
function enableCompanions(gptConfig) {

@@ -182,4 +197,4 @@ if (gptConfig.companions) {

/*
* Event handler for when a slot is ready for an ad to rendered
*/
* Event handler for when a slot is ready for an ad to rendered
*/
function onReady(slotMethods, event) {

@@ -196,3 +211,4 @@ const slot = event.detail.slot;

googletag.cmd.push(() => {
slot.defineSlot()
slot
.defineSlot()
.addServices()

@@ -210,4 +226,4 @@ .setCollapseEmpty()

/*
* Render is called when a slot is not rendered when the ready event fires
*/
* Render is called when a slot is not rendered when the ready event fires
*/
function onRender(event) {

@@ -222,4 +238,4 @@ const slot = event.detail.slot;

/*
* refresh is called when a slot requests the ad be flipped
*/
* refresh is called when a slot requests the ad be flipped
*/
function onRefresh(event) {

@@ -246,4 +262,4 @@ window.googletag.cmd.push(() => {

/*
* function passed to the gpt library that is run when an ad completes rendering
*/
* function passed to the gpt library that is run when an ad completes rendering
*/
function onRenderEnded(event) {

@@ -296,4 +312,4 @@ const data = {

/**
* define a GPT slot
*/
* define a GPT slot
*/
defineSlot: function() {

@@ -311,4 +327,3 @@ window.googletag.cmd.push(() => {

}
}
else {
} else {
this.gpt.slot = googletag.defineOutOfPageSlot(this.gpt.unitName, this.gpt.id);

@@ -329,17 +344,21 @@ }

window.googletag.cmd.push(() => {
utils.on('breakpoint', (event) => {
const slot = event.detail.slot;
const screensize = event.detail.screensize;
utils.on(
'breakpoint',
event => {
const slot = event.detail.slot;
const screensize = event.detail.screensize;
updatePageTargeting({ res: screensize });
updatePageTargeting({ res: screensize });
if (slot.hasValidSize(screensize)) {
/* istanbul ignore else */
if (slot.gpt.iframe) {
slot.fire('refresh');
} else if (!this.defer) {
slot.display();
if (slot.hasValidSize(screensize)) {
/* istanbul ignore else */
if (slot.gpt.iframe) {
slot.fire('refresh');
} else if (!this.defer) {
slot.display();
}
}
}
}, this.container);
},
this.container
);

@@ -359,4 +378,4 @@ const mapping = googletag.sizeMapping();

/**
* Tell gpt to destroy the slot and its metadata
*/
* Tell gpt to destroy the slot and its metadata
*/
destroySlot: function(gptSlot) {

@@ -371,4 +390,4 @@ if (window.googletag.pubadsReady && window.googletag.pubads) {

/*
* Tell gpt to request an ad
*/
* Tell gpt to request an ad
*/
display: function() {

@@ -382,4 +401,4 @@ window.googletag.cmd.push(() => {

/**
* Set the DFP unit name for the slot.
*/
* Set the DFP unit name for the slot.
*/
setUnitName: function() {

@@ -408,4 +427,4 @@ window.googletag.cmd.push(() => {

/**
* Add the slot to the pub ads service and add a companion service if configured
*/
* Add the slot to the pub ads service and add a companion service if configured
*/
addServices: function(gptSlot) {

@@ -424,5 +443,5 @@ window.googletag.cmd.push(() => {

/**
* Sets the GPT collapse empty mode for a given slot
* values can be 'after', 'before', 'never'
*/
* Sets the GPT collapse empty mode for a given slot
* values can be 'after', 'before', 'never'
*/
setCollapseEmpty: function() {

@@ -443,3 +462,3 @@ window.googletag.cmd.push(() => {

},
submitGptImpression : function() {
submitGptImpression: function() {
/* istanbul ignore next */

@@ -456,7 +475,8 @@ function getImpressionURL(iframe) {

if (this.outOfPage && this.gpt.iframe) {
const impressionURL = getImpressionURL(this.gpt.iframe);
/* istanbul ignore next */
if(impressionURL){
utils.attach(impressionURL, true,
if (impressionURL) {
utils.attach(
impressionURL,
true,
() => {

@@ -471,4 +491,3 @@ utils.log.info('Impression Url requested');

}
}
else {
} else {
utils.log.warn('Attempting to call submitImpression on a non-oop slot');

@@ -478,5 +497,5 @@ }

/**
* Sets page url to be sent to google
* prevents later url changes via javascript from breaking the ads
*/
* Sets page url to be sent to google
* prevents later url changes via javascript from breaking the ads
*/
setURL: function(gptSlot) {

@@ -492,4 +511,4 @@ window.googletag.cmd.push(() => {

/**
* Adds key values from a given object to the slot targeting
*/
* Adds key values from a given object to the slot targeting
*/
setTargeting: function(gptSlot) {

@@ -506,3 +525,3 @@ window.googletag.cmd.push(() => {

return this;
},
}
};

@@ -517,8 +536,10 @@

/**
* The correlator is a random number added to ad calls.
* It is used by the ad server to determine which impressions where served to the same page
* Updating is used to tell the ad server to treat subsequent ad calls as being on a new page
*/
* The correlator is a random number added to ad calls.
* It is used by the ad server to determine which impressions where served to the same page
* Updating is used to tell the ad server to treat subsequent ad calls as being on a new page
*/
function updateCorrelator() {
utils.log.warn('[DEPRECATED]: Updatecorrelator is being phased out by google and removed from o-ads in future releases.');
utils.log.warn(
'[DEPRECATED]: Updatecorrelator is being phased out by google and removed from o-ads in future releases.'
);

@@ -539,4 +560,3 @@ googletag.cmd.push(() => {

setPageTargeting(params);
}
else {
} else {
utils.log.warn('Attempting to set page targeting before the GPT library has initialized');

@@ -546,3 +566,3 @@ }

//https://developers.google.com/doubleclick-gpt/common_implementation_mistakes#scenario-2:-checking-the-googletag-object-to-know-whether-gpt-is-ready
function hasGPTLoaded () {
function hasGPTLoaded() {
if (window.googletag && window.googletag.apiReady) {

@@ -558,3 +578,3 @@ return true;

const conf = config('gpt');
if(!conf){
if (!conf) {
return;

@@ -567,4 +587,6 @@ }

}
export default {
init,
setup,
updateCorrelator,

@@ -571,0 +593,0 @@ updatePageTargeting,

// generated by genversion
module.exports = '14.1.0';
module.exports = '14.2.0';
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