@guardian/commercial-core 4.17.0 → 4.18.0

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.
@@ -0,0 +1 @@
1
+ export function a9Apstag(): void;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.a9Apstag = void 0;
4
+ /**
5
+ * Load Amazon A9 library as {@link https://ams.amazon.com/webpublisher/uam/docs/web-integration-documentation/integration-guide/javascript-guide/display.html described here}
6
+ */
7
+ const a9Apstag = () => {
8
+ (function (a9, a, p, s, t, A, g) {
9
+ if (a[a9])
10
+ return;
11
+ function q(c, r) {
12
+ a[a9]._Q.push([c, r]);
13
+ }
14
+ a[a9] = {
15
+ init() {
16
+ q('i', arguments);
17
+ },
18
+ fetchBids() {
19
+ q('f', arguments);
20
+ },
21
+ setDisplayBids() { },
22
+ targetingKeys() {
23
+ return [];
24
+ },
25
+ _Q: [],
26
+ };
27
+ A = p.createElement(s);
28
+ A.async = !0;
29
+ A.src = t;
30
+ g = p.getElementsByTagName(s)[0];
31
+ g.parentNode.insertBefore(A, g);
32
+ })('apstag', window, document, 'script', '//c.amazon-adsystem.com/aax2/apstag.js');
33
+ };
34
+ exports.a9Apstag = a9Apstag;
@@ -0,0 +1 @@
1
+ export function ipsosMoriStub(): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ipsosMoriStub = void 0;
4
+ /**
5
+ * Load the Ipsos Mori Stub
6
+ *
7
+ * See {@Link https://github.com/guardian/dotcom-rendering/blob/150fc2d81e6a66d9c3336185e874fc8cd0288546/dotcom-rendering/docs/architecture/3rd%20party%20technical%20review/002-ipsos-mori.md documentation here }
8
+ */
9
+ const ipsosMoriStub = () => {
10
+ window.dm = window.dm || { AjaxData: [] };
11
+ window.dm.AjaxEvent = (et, d, ssid, ad) => {
12
+ dm.AjaxData.push({ et, d, ssid, ad });
13
+ if (window.DotMetricsObj) {
14
+ DotMetricsObj.onAjaxDataUpdate();
15
+ }
16
+ };
17
+ };
18
+ exports.ipsosMoriStub = ipsosMoriStub;
@@ -0,0 +1 @@
1
+ export function launchpad(): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.launchpad = void 0;
4
+ /**
5
+ *  Loads the Launchpad js tracker (used by Redplanet) into the page,
6
+ *  and creates the global "launchpad" method
7
+ */
8
+ const launchpad = () => {
9
+ (function (p, l, o, w, i, n, g) {
10
+ if (!p[i]) {
11
+ p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || [];
12
+ p.GlobalSnowplowNamespace.push(i);
13
+ p[i] = function () {
14
+ (p[i].q = p[i].q || []).push(arguments);
15
+ };
16
+ p[i].q = p[i].q || [];
17
+ n = l.createElement(o);
18
+ g = l.getElementsByTagName(o)[0];
19
+ n.async = 1;
20
+ n.src = w;
21
+ g.parentNode.insertBefore(n, g);
22
+ }
23
+ }(window, document, "script", "https://lps.qantas.com/sp.js", "launchpad"));
24
+ };
25
+ exports.launchpad = launchpad;
@@ -0,0 +1 @@
1
+ export function pubmatic(bid: any, data: any, acEnabled: any, utils: any, defaultFn: any): void;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pubmatic = void 0;
4
+ /**
5
+ * Pubmatic custom override script
6
+ *
7
+ * From {@Link https://gist.github.com/abhinavsinha001/de46bd4ac4f02d98eb50c1f4f995545e}
8
+ */
9
+ const pubmatic = function (bid, data, acEnabled, utils, defaultFn) {
10
+ if (defaultFn) {
11
+ // keep this to move to default function once supported by RTD submodule
12
+ bid = defaultFn(bid, data, acEnabled);
13
+ }
14
+ else {
15
+ let segments = [];
16
+ // add all user segments
17
+ try {
18
+ const psegs = JSON.parse(localStorage._psegs || '[]').map(String);
19
+ const ppam = JSON.parse(localStorage._ppam || '[]');
20
+ const pcrprs = JSON.parse(localStorage._pcrprs || '[]');
21
+ segments = [...psegs, ...ppam, ...pcrprs];
22
+ }
23
+ catch (e) { }
24
+ // add AC specific segments (these would typically go to a separate key-value, but not sure if we can have 2 lists of segments here?)
25
+ if (acEnabled && data.ac && data.ac.length > 0) {
26
+ segments = segments.concat(data.ac);
27
+ }
28
+ segments = segments.map(function (seg) {
29
+ return { id: seg };
30
+ });
31
+ pbjs.setBidderConfig({
32
+ // Note this will replace existing bidder FPD config till merge is supported.
33
+ bidders: ['pubmatic'],
34
+ config: {
35
+ ortb2: {
36
+ user: {
37
+ data: [
38
+ {
39
+ name: 'permutive.com',
40
+ segment: segments,
41
+ },
42
+ ],
43
+ },
44
+ },
45
+ },
46
+ });
47
+ }
48
+ };
49
+ exports.pubmatic = pubmatic;
@@ -37,3 +37,7 @@ export { postMessage } from './messenger/post-message';
37
37
  export { buildPageTargeting } from './targeting/build-page-targeting';
38
38
  export { buildPageTargetingConsentless } from './targeting/build-page-targeting-consentless';
39
39
  export type { PageTargeting } from './targeting/build-page-targeting';
40
+ export { a9Apstag } from './__vendor/a9-apstag';
41
+ export { ipsosMoriStub } from './__vendor/ipsos-mori';
42
+ export { launchpad } from './__vendor/launchpad';
43
+ export { pubmatic } from './__vendor/pubmatic';
package/dist/cjs/index.js CHANGED
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  return result;
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.buildPageTargetingConsentless = exports.buildPageTargeting = exports.postMessage = exports.initMessenger = exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.concatSizeMappings = exports.createAdSlot = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackGpcSignal = exports.initTrackLabsContainer = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.isBreakpoint = exports.standardAdSizes = exports.slotSizeMappings = exports.outstreamSizes = exports.getAdSize = exports.createAdSize = exports.adSizes = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
27
+ exports.pubmatic = exports.launchpad = exports.ipsosMoriStub = exports.a9Apstag = exports.buildPageTargetingConsentless = exports.buildPageTargeting = exports.postMessage = exports.initMessenger = exports.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.concatSizeMappings = exports.createAdSlot = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackGpcSignal = exports.initTrackLabsContainer = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.isBreakpoint = exports.standardAdSizes = exports.slotSizeMappings = exports.outstreamSizes = exports.getAdSize = exports.createAdSize = exports.adSizes = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
28
28
  var ias_1 = require("./third-party-tags/ias");
29
29
  Object.defineProperty(exports, "ias", { enumerable: true, get: function () { return ias_1.ias; } });
30
30
  var permutive_1 = require("./third-party-tags/permutive");
@@ -90,3 +90,12 @@ var build_page_targeting_1 = require("./targeting/build-page-targeting");
90
90
  Object.defineProperty(exports, "buildPageTargeting", { enumerable: true, get: function () { return build_page_targeting_1.buildPageTargeting; } });
91
91
  var build_page_targeting_consentless_1 = require("./targeting/build-page-targeting-consentless");
92
92
  Object.defineProperty(exports, "buildPageTargetingConsentless", { enumerable: true, get: function () { return build_page_targeting_consentless_1.buildPageTargetingConsentless; } });
93
+ /* -- Vendor JavaScript -- */
94
+ var a9_apstag_1 = require("./__vendor/a9-apstag");
95
+ Object.defineProperty(exports, "a9Apstag", { enumerable: true, get: function () { return a9_apstag_1.a9Apstag; } });
96
+ var ipsos_mori_1 = require("./__vendor/ipsos-mori");
97
+ Object.defineProperty(exports, "ipsosMoriStub", { enumerable: true, get: function () { return ipsos_mori_1.ipsosMoriStub; } });
98
+ var launchpad_1 = require("./__vendor/launchpad");
99
+ Object.defineProperty(exports, "launchpad", { enumerable: true, get: function () { return launchpad_1.launchpad; } });
100
+ var pubmatic_1 = require("./__vendor/pubmatic");
101
+ Object.defineProperty(exports, "pubmatic", { enumerable: true, get: function () { return pubmatic_1.pubmatic; } });
@@ -0,0 +1 @@
1
+ export function a9Apstag(): void;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Load Amazon A9 library as {@link https://ams.amazon.com/webpublisher/uam/docs/web-integration-documentation/integration-guide/javascript-guide/display.html described here}
3
+ */
4
+ export const a9Apstag = () => {
5
+ (function (a9, a, p, s, t, A, g) {
6
+ if (a[a9])
7
+ return;
8
+ function q(c, r) {
9
+ a[a9]._Q.push([c, r]);
10
+ }
11
+ a[a9] = {
12
+ init() {
13
+ q('i', arguments);
14
+ },
15
+ fetchBids() {
16
+ q('f', arguments);
17
+ },
18
+ setDisplayBids() { },
19
+ targetingKeys() {
20
+ return [];
21
+ },
22
+ _Q: [],
23
+ };
24
+ A = p.createElement(s);
25
+ A.async = !0;
26
+ A.src = t;
27
+ g = p.getElementsByTagName(s)[0];
28
+ g.parentNode.insertBefore(A, g);
29
+ })('apstag', window, document, 'script', '//c.amazon-adsystem.com/aax2/apstag.js');
30
+ };
@@ -0,0 +1 @@
1
+ export function ipsosMoriStub(): void;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Load the Ipsos Mori Stub
3
+ *
4
+ * See {@Link https://github.com/guardian/dotcom-rendering/blob/150fc2d81e6a66d9c3336185e874fc8cd0288546/dotcom-rendering/docs/architecture/3rd%20party%20technical%20review/002-ipsos-mori.md documentation here }
5
+ */
6
+ export const ipsosMoriStub = () => {
7
+ window.dm = window.dm || { AjaxData: [] };
8
+ window.dm.AjaxEvent = (et, d, ssid, ad) => {
9
+ dm.AjaxData.push({ et, d, ssid, ad });
10
+ if (window.DotMetricsObj) {
11
+ DotMetricsObj.onAjaxDataUpdate();
12
+ }
13
+ };
14
+ };
@@ -0,0 +1 @@
1
+ export function launchpad(): void;
@@ -0,0 +1,21 @@
1
+ /**
2
+ *  Loads the Launchpad js tracker (used by Redplanet) into the page,
3
+ *  and creates the global "launchpad" method
4
+ */
5
+ export const launchpad = () => {
6
+ (function (p, l, o, w, i, n, g) {
7
+ if (!p[i]) {
8
+ p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || [];
9
+ p.GlobalSnowplowNamespace.push(i);
10
+ p[i] = function () {
11
+ (p[i].q = p[i].q || []).push(arguments);
12
+ };
13
+ p[i].q = p[i].q || [];
14
+ n = l.createElement(o);
15
+ g = l.getElementsByTagName(o)[0];
16
+ n.async = 1;
17
+ n.src = w;
18
+ g.parentNode.insertBefore(n, g);
19
+ }
20
+ }(window, document, "script", "https://lps.qantas.com/sp.js", "launchpad"));
21
+ };
@@ -0,0 +1 @@
1
+ export function pubmatic(bid: any, data: any, acEnabled: any, utils: any, defaultFn: any): void;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Pubmatic custom override script
3
+ *
4
+ * From {@Link https://gist.github.com/abhinavsinha001/de46bd4ac4f02d98eb50c1f4f995545e}
5
+ */
6
+ export const pubmatic = function (bid, data, acEnabled, utils, defaultFn) {
7
+ if (defaultFn) {
8
+ // keep this to move to default function once supported by RTD submodule
9
+ bid = defaultFn(bid, data, acEnabled);
10
+ }
11
+ else {
12
+ let segments = [];
13
+ // add all user segments
14
+ try {
15
+ const psegs = JSON.parse(localStorage._psegs || '[]').map(String);
16
+ const ppam = JSON.parse(localStorage._ppam || '[]');
17
+ const pcrprs = JSON.parse(localStorage._pcrprs || '[]');
18
+ segments = [...psegs, ...ppam, ...pcrprs];
19
+ }
20
+ catch (e) { }
21
+ // add AC specific segments (these would typically go to a separate key-value, but not sure if we can have 2 lists of segments here?)
22
+ if (acEnabled && data.ac && data.ac.length > 0) {
23
+ segments = segments.concat(data.ac);
24
+ }
25
+ segments = segments.map(function (seg) {
26
+ return { id: seg };
27
+ });
28
+ pbjs.setBidderConfig({
29
+ // Note this will replace existing bidder FPD config till merge is supported.
30
+ bidders: ['pubmatic'],
31
+ config: {
32
+ ortb2: {
33
+ user: {
34
+ data: [
35
+ {
36
+ name: 'permutive.com',
37
+ segment: segments,
38
+ },
39
+ ],
40
+ },
41
+ },
42
+ },
43
+ });
44
+ }
45
+ };
@@ -37,3 +37,7 @@ export { postMessage } from './messenger/post-message';
37
37
  export { buildPageTargeting } from './targeting/build-page-targeting';
38
38
  export { buildPageTargetingConsentless } from './targeting/build-page-targeting-consentless';
39
39
  export type { PageTargeting } from './targeting/build-page-targeting';
40
+ export { a9Apstag } from './__vendor/a9-apstag';
41
+ export { ipsosMoriStub } from './__vendor/ipsos-mori';
42
+ export { launchpad } from './__vendor/launchpad';
43
+ export { pubmatic } from './__vendor/pubmatic';
package/dist/esm/index.js CHANGED
@@ -28,3 +28,8 @@ export { init as initMessenger } from './messenger';
28
28
  export { postMessage } from './messenger/post-message';
29
29
  export { buildPageTargeting } from './targeting/build-page-targeting';
30
30
  export { buildPageTargetingConsentless } from './targeting/build-page-targeting-consentless';
31
+ /* -- Vendor JavaScript -- */
32
+ export { a9Apstag } from './__vendor/a9-apstag';
33
+ export { ipsosMoriStub } from './__vendor/ipsos-mori';
34
+ export { launchpad } from './__vendor/launchpad';
35
+ export { pubmatic } from './__vendor/pubmatic';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/commercial-core",
3
- "version": "4.17.0",
3
+ "version": "4.18.0",
4
4
  "description": "Guardian advertising business logic",
5
5
  "homepage": "https://github.com/guardian/commercial-core#readme",
6
6
  "bugs": {