From 3f47d465c6e6f4ea83045b32b2c9f56eccb943e5 Mon Sep 17 00:00:00 2001 From: affinity-admin <114151276+affinity-admin@users.noreply.github.com> Date: Fri, 25 Nov 2022 10:21:35 +0530 Subject: [PATCH] Adding support for ad vendor Affinity (#38534) * Added support for adtype Affinity On branch main Your branch is up to date with 'origin/main'. Changes to be committed: new file: 3p/vendors/affinity.js modified: ads/_config.js modified: ads/ads.extern.js new file: ads/vendors/affinity.js new file: ads/vendors/affinity.md modified: examples/amp-ad/ads.amp.html modified: extensions/amp-ad/amp-ad.md * Linted the code On branch affinity_adtype_master Changes to be committed: modified: 3p/vendors/affinity.js modified: ads/ads.extern.js modified: ads/vendors/affinity.js * Ran AMP Prettify On branch affinity_adtype_master Your branch is up to date with 'origin/affinity_adtype_master'. Changes to be committed: modified: ads/vendors/affinity.md Co-authored-by: github-01-affinity --- 3p/vendors/affinity.js | 12 ++++++++++++ ads/_config.js | 5 +++++ ads/ads.extern.js | 11 +++++++++++ ads/vendors/affinity.js | 28 ++++++++++++++++++++++++++++ ads/vendors/affinity.md | 24 ++++++++++++++++++++++++ examples/amp-ad/ads.amp.html | 5 +++++ extensions/amp-ad/amp-ad.md | 1 + 7 files changed, 86 insertions(+) create mode 100644 3p/vendors/affinity.js create mode 100644 ads/vendors/affinity.js create mode 100644 ads/vendors/affinity.md diff --git a/3p/vendors/affinity.js b/3p/vendors/affinity.js new file mode 100644 index 000000000000..5730b83da6a8 --- /dev/null +++ b/3p/vendors/affinity.js @@ -0,0 +1,12 @@ +// src/polyfills.js must be the first import. +import '#3p/polyfills'; + +import {register} from '#3p/3p'; +import {draw3p, init} from '#3p/integration-lib'; + +import {affinity} from '#ads/vendors/affinity'; + +init(window); +register('affinity', affinity); + +window.draw3p = draw3p; diff --git a/ads/_config.js b/ads/_config.js index 20cd191496f4..d6eb35a96dd3 100755 --- a/ads/_config.js +++ b/ads/_config.js @@ -286,6 +286,11 @@ const adConfig = jsonConfiguration({ renderStartImplemented: true, }, + 'affinity': { + prefetch: 'https://securepubads.g.doubleclick.net/tag/js/gpt.js', + preconnect: 'https://cdn4-hbs.affinitymatrix.com', + }, + 'aja': { prefetch: [ 'https://cdn.as.amanad.adtdp.com/sdk/asot-amp.js', diff --git a/ads/ads.extern.js b/ads/ads.extern.js index 7ba923a21475..3322e38357e5 100644 --- a/ads/ads.extern.js +++ b/ads/ads.extern.js @@ -319,6 +319,17 @@ window.andbeyond.initAmp = function ( extras ) {}; +// affinity.js +window.affinity = {}; +window.affinity.initAMP = function (global, data) {}; +data.width; +data.height; +data.adtype; +data.adslot; +data['multi-size']; +data.jsontargeting; +data.extras; + // adreactor.js data.zid; data.pid; diff --git a/ads/vendors/affinity.js b/ads/vendors/affinity.js new file mode 100644 index 000000000000..6f709731ba62 --- /dev/null +++ b/ads/vendors/affinity.js @@ -0,0 +1,28 @@ +import {loadScript, validateData} from '#3p/3p'; + +/** + * @param {!Window} global + * @param {!Object} data + */ +export function affinity(global, data) { + validateData( + data, + ['width', 'height', 'adtype', 'adslot'], + ['multi-size', 'jsontargeting', 'extras'] + ); + loadScript( + global, + 'https://securepubads.g.doubleclick.net/tag/js/gpt.js', + () => { + loadScript( + global, + 'https://cdn4-hbs.affinitymatrix.com/amp/v2022/amp.js', + () => { + (function () { + window.affinity.initAMP(global, data); + })(); + } + ); + } + ); +} diff --git a/ads/vendors/affinity.md b/ads/vendors/affinity.md new file mode 100644 index 000000000000..1c060a1e0c0c --- /dev/null +++ b/ads/vendors/affinity.md @@ -0,0 +1,24 @@ +# Affinity + +Adtype Affinity support for AMP + +## Example + +```html + + +``` + +## Configuration + +- `data-adtype`: (Mandatory) Type of the adformat +- `data-adslot`: (Mandatory) Name of of adslot +- `data-multi-size`: (Optional) Multi-size support +- `data-jsontargeting`: (Optional) Targeting related paramterers +- `data-extras`: (Optional) Extra data diff --git a/examples/amp-ad/ads.amp.html b/examples/amp-ad/ads.amp.html index b49161dba4ef..c5cdbb789eb4 100644 --- a/examples/amp-ad/ads.amp.html +++ b/examples/amp-ad/ads.amp.html @@ -212,6 +212,7 @@ + @@ -941,6 +942,10 @@

Affiliate-B

+

Affinity

+ + +

AJA

diff --git a/extensions/amp-ad/amp-ad.md b/extensions/amp-ad/amp-ad.md index 453d06e4f868..2f68cd46e8ad 100644 --- a/extensions/amp-ad/amp-ad.md +++ b/extensions/amp-ad/amp-ad.md @@ -299,6 +299,7 @@ See [amp-ad rules](validator-amp-ad.protoascii) in the AMP validator specificati - [AdvertServe](../../ads/vendors/advertserve.md) - [Adyoulike](../../ads/vendors/adyoulike.md) - [Affiliate-B](../../ads/vendors/affiliateb.md) +- [Affinity](../../ads/vendors/affinity.md) - [AJA](../../ads/vendors/aja.md) - [AMoAd](../../ads/vendors/amoad.md) - [Andbeyond](../../ads/vendors/andbeyond.md)