From 63be078fdd6a370b52ce09023990eab0956139b0 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Sat, 6 May 2023 07:36:24 -0400 Subject: [PATCH 1/4] Delete index.html --- integrationExamples/mass/index.html | 132 ---------------------------- 1 file changed, 132 deletions(-) delete mode 100644 integrationExamples/mass/index.html diff --git a/integrationExamples/mass/index.html b/integrationExamples/mass/index.html deleted file mode 100644 index 3b034957d13..00000000000 --- a/integrationExamples/mass/index.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - -
-

Note: for this example to work, you need access to a bid simulation tool from your MASS enabled Exchange partner.

-
- -
-
- - From 61e72e15a38d90e270ca432532a7b5ba77d23376 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Sat, 6 May 2023 07:36:41 -0400 Subject: [PATCH 2/4] Delete mass_spec.js --- test/spec/modules/mass_spec.js | 139 --------------------------------- 1 file changed, 139 deletions(-) delete mode 100644 test/spec/modules/mass_spec.js diff --git a/test/spec/modules/mass_spec.js b/test/spec/modules/mass_spec.js deleted file mode 100644 index 3b5d89b0a8c..00000000000 --- a/test/spec/modules/mass_spec.js +++ /dev/null @@ -1,139 +0,0 @@ -import { expect } from 'chai'; -import { - init, - addBidResponseHook, - addListenerOnce, - isMassBid, - useDefaultMatch, - useDefaultRender, - updateRenderers, - listenerAdded, - isEnabled -} from 'modules/mass'; -import { logInfo } from 'src/utils.js'; - -// mock a MASS bid: -const mockedMassBids = [ - { - bidder: 'ix', - bidId: 'mass-bid-1', - requestId: 'mass-bid-1', - bidderRequestId: 'bidder-request-id-1', - dealId: 'MASS1234', - ad: 'mass://provider/product/etc...', - meta: {} - }, - { - bidder: 'ix', - bidId: 'mass-bid-2', - requestId: 'mass-bid-2', - bidderRequestId: 'bidder-request-id-1', - dealId: '1234', - ad: 'mass://provider/product/etc...', - meta: { - mass: true - } - }, -]; - -// mock non-MASS bids: -const mockedNonMassBids = [ - { - bidder: 'ix', - bidId: 'non-mass-bid-1', - requstId: 'non-mass-bid-1', - bidderRequestId: 'bidder-request-id-1', - dealId: 'MASS1234', - ad: '', - meta: { - mass: true - } - }, - { - bidder: 'ix', - bidId: 'non-mass-bid-2', - requestId: 'non-mass-bid-2', - bidderRequestId: 'bidder-request-id-1', - dealId: '1234', - ad: 'mass://provider/product/etc...', - meta: {} - }, -]; - -const noop = function() {}; - -describe('MASS Module', function() { - it('should be enabled by default', function() { - expect(isEnabled).to.equal(true); - }); - - it('can be disabled', function() { - init({enabled: false}); - expect(isEnabled).to.equal(false); - }); - - it('should only affect MASS bids', function() { - init({renderUrl: 'https://...'}); - mockedNonMassBids.forEach(function(mockedBid) { - const originalBid = Object.assign({}, mockedBid); - const bid = Object.assign({}, originalBid); - - addBidResponseHook(noop, 'ad-code-id', bid); - - expect(bid).to.deep.equal(originalBid); - }); - }); - - it('should only update the ad markup field', function() { - init({renderUrl: 'https://...'}); - mockedMassBids.forEach(function(mockedBid) { - const originalBid = Object.assign({}, mockedBid); - const bid = Object.assign({}, originalBid); - - addBidResponseHook(noop, 'ad-code-id', bid); - - expect(bid.ad).to.not.equal(originalBid.ad); - - delete bid.ad; - delete originalBid.ad; - - expect(bid).to.deep.equal(originalBid); - }); - }); - - it('should add a message listener', function() { - addListenerOnce(); - expect(listenerAdded).to.equal(true); - }); - - it('should support custom renderers', function() { - init({ - renderUrl: 'https://...', - custom: [ - { - dealIdPattern: /abc/, - render: function() {} - } - ] - }); - - const renderers = updateRenderers(); - - expect(renderers.length).to.equal(2); - }); - - it('should match bids by deal ID with the default matcher', function() { - const match = useDefaultMatch(/abc/); - - expect(match({dealId: 'abc'})).to.equal(true); - expect(match({dealId: 'xyz'})).to.equal(false); - }); - - it('should have a default renderer', function() { - const render = useDefaultRender('https://example.com/render.js', 'abc'); - render({}); - - expect(window.abc.loaded).to.equal(true); - expect(window.abc.queue.length).to.equal(1); - }); -}); From ecfdfb2ac323618f6962a22b80ded774016bd7ba Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Sat, 6 May 2023 07:36:58 -0400 Subject: [PATCH 3/4] Delete mass.md --- modules/mass.md | 137 ------------------------------------------------ 1 file changed, 137 deletions(-) delete mode 100644 modules/mass.md diff --git a/modules/mass.md b/modules/mass.md deleted file mode 100644 index fc0add6a18e..00000000000 --- a/modules/mass.md +++ /dev/null @@ -1,137 +0,0 @@ -## Overview - -This module enables the MASS protocol for Prebid. To use it, you'll need to -work with a MASS enabled provider. - -This module scans incoming bids for the presence of a "mass" flag being set to -true in the bid meta or a publisher specified DealID pattern and uses -external resources to decypher and process the MASS:// URI found within the ad markup. -This modules is designed to work with MASS enabled Exchanges and DSP's. - -This module only loads external JavaScript resources if the publisher ad server has -selected a MASS enabled bid as a winner. - -Find out more [here](https://massplatform.net). - -{: .alert.alert-warning :} -## Disclosure - -This module loads external JavaScript to render creatives - -## Custom Mode - -You can specify your own `dealIdPattern` and `renderUrl` by adding one or more entries into the `custom` configuration option (see [Configuration Parameters](#configuration-parameters) below). When specifying a custom renderer, quality assurance is your responsibility. - -## Integration - -Build the MASS module into the Prebid.js package with: - -``` -gulp build --modules=mass,... -``` - - -## Module Configuration - -```js -pbjs.que.push(function() { - pbjs.setConfig({ - mass: { - enabled: true, - renderUrl: 'https://cdn.massplatform.net/bootloader.js', - dealIdPattern: /^MASS/i, - custom: [ - { - dealIdPattern: /xyz/, - renderUrl: 'https://my.domain.com/render.js', - namespace: 'xyz' - } - ] - } - }); -}); -``` - -### Configuration Parameters - -|Name |Type |Description |Notes | -| :------------ | :------------ | :------------ |:------------ | -|enabled | Boolean |Enable/disable the module |Defaults to `true` | -|dealIdPattern | RegExp |The pattern used to identify MASS deal IDs |Defaults to `/^MASS/i` | -|renderUrl | String |The MASS render script to load |`https://cdn.massplatform.net/bootloader.js` | -|custom | Array |Add custom renderers | | -|custom[].dealIdPattern | RegExp |A pattern used to identify matching deal IDs |Either this parameter or `custom[].match` must be specified | -|custom[].renderUrl | String |The render script to load |Either this parameter or `custom[].render` must be specified | -|custom[].namespace | String |The namespace (i.e.: object) created on `window` to pass parameters to the render script |Required with `custom[].renderUrl` | -|custom[].match | Function(bid) |A custom function to identify matching bids |Either this parameter or `custom[].dealIdPattern` must be specified | -|custom[].render | Function(payload) |A custom function to render the matchig/winning bid |Either this parameter or `custom[].renderUrl` must be specified. The `payload` parameter contains: `payload.bid`, `payload.bidRequest`, `payload.adm` | - -### Example Configurations - -### Only (official) MASS support enabled - -```js -pbjs.que.push(function() { - pbjs.setConfig({ - mass: { - renderUrl: 'https://cdn.massplatform.net/bootloader.js' - } - }); -}); -``` - -### MASS support disabled, custom renderer enabled - -```js -pbjs.que.push(function() { - pbjs.setConfig({ - mass: { - custom: [ - { - dealIdPattern: /xyz/, - renderUrl: 'https://my.domain.com/render.js', - namespace: 'xyz' - } - ] - } - }); -}); -``` - -### Custom `match` and `render` - -```js -pbjs.que.push(function() { - pbjs.setConfig({ - mass: { - custom: [ - { - match: function(bid) { - // return true/false if matching/non-matching bid - }, - - render: function(payload) { - console.log(payload); - } - } - ] - } - }); -}); -``` - -## Integration Example - -To view the integration example: - -1) in your cli run: - -``` -gulp serve --modules=ixBidAdapter,mass -``` - -2) in your browser, navigate to: - -``` -http://localhost:9999/integrationExamples/mass/index.html -``` From aa0320b7195eccd82f50bbacdd065a319cc405e0 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Sat, 6 May 2023 07:37:14 -0400 Subject: [PATCH 4/4] Delete mass.js --- modules/mass.js | 184 ------------------------------------------------ 1 file changed, 184 deletions(-) delete mode 100644 modules/mass.js diff --git a/modules/mass.js b/modules/mass.js deleted file mode 100644 index 113fdce8d4f..00000000000 --- a/modules/mass.js +++ /dev/null @@ -1,184 +0,0 @@ -/** - * This module adds MASS support to Prebid.js. - */ - -import {config} from '../src/config.js'; -import {getHook} from '../src/hook.js'; -import {auctionManager} from '../src/auctionManager.js'; -import {timedBidResponseHook} from '../src/utils/perfMetrics.js'; - -const defaultCfg = { - dealIdPattern: /^MASS/i -}; -let cfg; - -export let listenerAdded = false; -export let isEnabled = false; - -const matchedBids = {}; -let renderers; - -config.getConfig('mass', config => init(config.mass)); - -/** - * Module init. - */ -export function init(userCfg) { - cfg = Object.assign({}, defaultCfg, window.massConfig && window.massConfig.mass, userCfg); - - if (cfg.enabled === false) { - if (isEnabled) { - getHook('addBidResponse').getHooks({hook: addBidResponseHook}).remove(); - isEnabled = false; - } - } else { - if (!isEnabled) { - getHook('addBidResponse').before(addBidResponseHook); - isEnabled = true; - } - } - - if (isEnabled) { - updateRenderers(); - } -} - -/** - * Update the list of renderers based on current config. - */ -export function updateRenderers() { - renderers = []; - - // official MASS renderer: - if (cfg.dealIdPattern && cfg.renderUrl) { - renderers.push({ - match: isMassBid, - render: useDefaultRender(cfg.renderUrl, 'mass') - }); - } - - // add any custom renderer defined in the config: - (cfg.custom || []).forEach(renderer => { - if (!renderer.match && renderer.dealIdPattern) { - renderer.match = useDefaultMatch(renderer.dealIdPattern); - } - - if (!renderer.render && renderer.renderUrl && renderer.namespace) { - renderer.render = useDefaultRender(renderer.renderUrl, renderer.namespace); - } - - if (renderer.match && renderer.render) { - renderers.push(renderer); - } - }); - - return renderers; -} - -/** - * Before hook for 'addBidResponse'. - */ -export const addBidResponseHook = timedBidResponseHook('mass', function addBidResponseHook(next, adUnitCode, bid, reject, {index = auctionManager.index} = {}) { - let renderer; - for (let i = 0; i < renderers.length; i++) { - if (renderers[i].match(bid)) { - renderer = renderers[i]; - break; - } - } - - if (renderer) { - const bidRequest = index.getBidRequest(bid); - - matchedBids[bid.requestId] = { - renderer, - payload: { - bidRequest, - bid, - adm: bid.ad - } - }; - - bid.ad = '