@guardian/commercial-core 4.8.0 → 4.9.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.
- package/dist/cjs/ad-sizes.js +2 -1
- package/dist/cjs/event-timer.d.ts +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/track-labs-container.d.ts +7 -0
- package/dist/cjs/track-labs-container.js +29 -0
- package/dist/esm/ad-sizes.js +2 -1
- package/dist/esm/event-timer.d.ts +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/track-labs-container.d.ts +7 -0
- package/dist/esm/track-labs-container.js +26 -0
- package/package.json +6 -6
package/dist/cjs/ad-sizes.js
CHANGED
|
@@ -21,7 +21,8 @@ exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.ad
|
|
|
21
21
|
class AdSize extends Array {
|
|
22
22
|
constructor([width, height]) {
|
|
23
23
|
super();
|
|
24
|
-
this
|
|
24
|
+
this[0] = width;
|
|
25
|
+
this[1] = height;
|
|
25
26
|
}
|
|
26
27
|
toString() {
|
|
27
28
|
return this.width === 0 && this.height === 0
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type { SizeKeys, AdSizeString, AdSize, SizeMapping, SlotSizeMappings, Slo
|
|
|
14
14
|
export { isAdBlockInUse } from './detect-ad-blocker';
|
|
15
15
|
export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
|
|
16
16
|
export { initTrackScrollDepth } from './track-scroll-depth';
|
|
17
|
+
export { initTrackLabsContainer } from './track-labs-container';
|
|
17
18
|
export { initTrackGpcSignal } from './track-gpc-signal';
|
|
18
19
|
export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
|
|
19
20
|
export { createAdSlot, concatSizeMappings } from './create-ad-slot';
|
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.pickTargetingValues = exports.getViewportTargeting = exports.getSharedTargeting = exports.getSessionTargeting = exports.getPersonalisedTargeting = exports.getContentTargeting = exports.constants = exports.concatSizeMappings = exports.createAdSlot = exports.disabledAds = exports.buildAdsConfigWithConsent = exports.initTrackGpcSignal = exports.initTrackScrollDepth = exports.getPermutivePFPSegments = exports.getPermutiveSegments = exports.clearPermutiveSegments = exports.isAdBlockInUse = exports.isBreakpoint = exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.adSizes = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.EventTimer = exports.remarketing = exports.inizio = exports.twitter = exports.fbPixel = exports.permutive = exports.ias = void 0;
|
|
27
|
+
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.createAdSize = exports.slotSizeMappings = exports.getAdSize = 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");
|
|
@@ -57,6 +57,8 @@ Object.defineProperty(exports, "getPermutiveSegments", { enumerable: true, get:
|
|
|
57
57
|
Object.defineProperty(exports, "getPermutivePFPSegments", { enumerable: true, get: function () { return permutive_2.getPermutivePFPSegments; } });
|
|
58
58
|
var track_scroll_depth_1 = require("./track-scroll-depth");
|
|
59
59
|
Object.defineProperty(exports, "initTrackScrollDepth", { enumerable: true, get: function () { return track_scroll_depth_1.initTrackScrollDepth; } });
|
|
60
|
+
var track_labs_container_1 = require("./track-labs-container");
|
|
61
|
+
Object.defineProperty(exports, "initTrackLabsContainer", { enumerable: true, get: function () { return track_labs_container_1.initTrackLabsContainer; } });
|
|
60
62
|
var track_gpc_signal_1 = require("./track-gpc-signal");
|
|
61
63
|
Object.defineProperty(exports, "initTrackGpcSignal", { enumerable: true, get: function () { return track_gpc_signal_1.initTrackGpcSignal; } });
|
|
62
64
|
var ad_targeting_youtube_1 = require("./ad-targeting-youtube");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect commercial metrics on:
|
|
3
|
+
* - whether the page contains a Guardian Labs container element (aka 'dumathoin'), and if so
|
|
4
|
+
* - when the element is scrolled into view
|
|
5
|
+
*/
|
|
6
|
+
declare const initTrackLabsContainer: () => void;
|
|
7
|
+
export { initTrackLabsContainer };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initTrackLabsContainer = void 0;
|
|
4
|
+
const libs_1 = require("@guardian/libs");
|
|
5
|
+
const event_timer_1 = require("./event-timer");
|
|
6
|
+
/**
|
|
7
|
+
* Collect commercial metrics on:
|
|
8
|
+
* - whether the page contains a Guardian Labs container element (aka 'dumathoin'), and if so
|
|
9
|
+
* - when the element is scrolled into view
|
|
10
|
+
*/
|
|
11
|
+
const initTrackLabsContainer = () => {
|
|
12
|
+
const target = document.querySelector('section.dumathoin');
|
|
13
|
+
if (target === null)
|
|
14
|
+
return;
|
|
15
|
+
const eventTimer = event_timer_1.EventTimer.get();
|
|
16
|
+
(0, libs_1.log)('commercial', 'Page has labs container');
|
|
17
|
+
eventTimer.properties['hasLabsContainer'] = true;
|
|
18
|
+
const observer = new IntersectionObserver((entries) => {
|
|
19
|
+
entries.map((entry) => {
|
|
20
|
+
if (entry.isIntersecting) {
|
|
21
|
+
(0, libs_1.log)('commercial', 'Labs container in view');
|
|
22
|
+
eventTimer.trigger('labsContainerInView');
|
|
23
|
+
observer.unobserve(entry.target);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
observer.observe(target);
|
|
28
|
+
};
|
|
29
|
+
exports.initTrackLabsContainer = initTrackLabsContainer;
|
package/dist/esm/ad-sizes.js
CHANGED
package/dist/esm/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type { SizeKeys, AdSizeString, AdSize, SizeMapping, SlotSizeMappings, Slo
|
|
|
14
14
|
export { isAdBlockInUse } from './detect-ad-blocker';
|
|
15
15
|
export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
|
|
16
16
|
export { initTrackScrollDepth } from './track-scroll-depth';
|
|
17
|
+
export { initTrackLabsContainer } from './track-labs-container';
|
|
17
18
|
export { initTrackGpcSignal } from './track-gpc-signal';
|
|
18
19
|
export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
|
|
19
20
|
export { createAdSlot, concatSizeMappings } from './create-ad-slot';
|
package/dist/esm/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { isBreakpoint } from './lib/breakpoint';
|
|
|
12
12
|
export { isAdBlockInUse } from './detect-ad-blocker';
|
|
13
13
|
export { clearPermutiveSegments, getPermutiveSegments, getPermutivePFPSegments, } from './permutive';
|
|
14
14
|
export { initTrackScrollDepth } from './track-scroll-depth';
|
|
15
|
+
export { initTrackLabsContainer } from './track-labs-container';
|
|
15
16
|
export { initTrackGpcSignal } from './track-gpc-signal';
|
|
16
17
|
export { buildAdsConfigWithConsent, disabledAds } from './ad-targeting-youtube';
|
|
17
18
|
export { createAdSlot, concatSizeMappings } from './create-ad-slot';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect commercial metrics on:
|
|
3
|
+
* - whether the page contains a Guardian Labs container element (aka 'dumathoin'), and if so
|
|
4
|
+
* - when the element is scrolled into view
|
|
5
|
+
*/
|
|
6
|
+
declare const initTrackLabsContainer: () => void;
|
|
7
|
+
export { initTrackLabsContainer };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { log } from '@guardian/libs';
|
|
2
|
+
import { EventTimer } from './event-timer';
|
|
3
|
+
/**
|
|
4
|
+
* Collect commercial metrics on:
|
|
5
|
+
* - whether the page contains a Guardian Labs container element (aka 'dumathoin'), and if so
|
|
6
|
+
* - when the element is scrolled into view
|
|
7
|
+
*/
|
|
8
|
+
const initTrackLabsContainer = () => {
|
|
9
|
+
const target = document.querySelector('section.dumathoin');
|
|
10
|
+
if (target === null)
|
|
11
|
+
return;
|
|
12
|
+
const eventTimer = EventTimer.get();
|
|
13
|
+
log('commercial', 'Page has labs container');
|
|
14
|
+
eventTimer.properties['hasLabsContainer'] = true;
|
|
15
|
+
const observer = new IntersectionObserver((entries) => {
|
|
16
|
+
entries.map((entry) => {
|
|
17
|
+
if (entry.isIntersecting) {
|
|
18
|
+
log('commercial', 'Labs container in view');
|
|
19
|
+
eventTimer.trigger('labsContainerInView');
|
|
20
|
+
observer.unobserve(entry.target);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
observer.observe(target);
|
|
25
|
+
};
|
|
26
|
+
export { initTrackLabsContainer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guardian/commercial-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0",
|
|
4
4
|
"description": "Guardian advertising business logic",
|
|
5
5
|
"homepage": "https://github.com/guardian/commercial-core#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"@guardian/ab-core": "^2.0.0",
|
|
48
48
|
"@guardian/consent-management-platform": "^10.6.0",
|
|
49
49
|
"@guardian/eslint-config-typescript": "^1.0.0",
|
|
50
|
-
"@guardian/libs": "
|
|
51
|
-
"@guardian/prettier": "^1.
|
|
52
|
-
"@octokit/core": "^
|
|
50
|
+
"@guardian/libs": "^7.1.3",
|
|
51
|
+
"@guardian/prettier": "^2.1.1",
|
|
52
|
+
"@octokit/core": "^4.0.5",
|
|
53
53
|
"@semantic-release/github": "^8.0.2",
|
|
54
54
|
"@types/google.analytics": "^0.0.42",
|
|
55
55
|
"@types/googletag": "^2.0.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
58
58
|
"@typescript-eslint/parser": "^5.5.0",
|
|
59
59
|
"commitizen": "^4.2.4",
|
|
60
|
-
"conventional-changelog-conventionalcommits": "^
|
|
60
|
+
"conventional-changelog-conventionalcommits": "^5.0.0",
|
|
61
61
|
"cz-conventional-changelog": "^3.3.0",
|
|
62
62
|
"eslint": "^8.4.1",
|
|
63
63
|
"eslint-config-prettier": "^8.3.0",
|
|
@@ -82,6 +82,6 @@
|
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"@guardian/ab-core": "^2.0.0",
|
|
85
|
-
"@guardian/libs": "
|
|
85
|
+
"@guardian/libs": ">6"
|
|
86
86
|
}
|
|
87
87
|
}
|