@guardian/commercial-core 4.9.0 → 4.10.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.
|
@@ -33,6 +33,7 @@ interface EventTimerProperties {
|
|
|
33
33
|
gpcSignal?: number;
|
|
34
34
|
lazyLoadMarginPercent?: number;
|
|
35
35
|
hasLabsContainer?: boolean;
|
|
36
|
+
labsUrl?: string;
|
|
36
37
|
}
|
|
37
38
|
export declare class EventTimer {
|
|
38
39
|
private _events;
|
|
@@ -71,9 +72,9 @@ export declare class EventTimer {
|
|
|
71
72
|
* Adds an event timer property
|
|
72
73
|
*
|
|
73
74
|
* @param {string} name - the property's name
|
|
74
|
-
* @param
|
|
75
|
+
* @param value - the property's value
|
|
75
76
|
*/
|
|
76
|
-
setProperty(name:
|
|
77
|
+
setProperty<T extends keyof EventTimerProperties>(name: T, value: EventTimerProperties[T]): void;
|
|
77
78
|
/**
|
|
78
79
|
* Creates a new performance mark
|
|
79
80
|
* For slot events also ensures each TYPE of event event is marked only once for 'first'
|
package/dist/cjs/event-timer.js
CHANGED
|
@@ -112,7 +112,7 @@ class EventTimer {
|
|
|
112
112
|
* Adds an event timer property
|
|
113
113
|
*
|
|
114
114
|
* @param {string} name - the property's name
|
|
115
|
-
* @param
|
|
115
|
+
* @param value - the property's value
|
|
116
116
|
*/
|
|
117
117
|
setProperty(name, value) {
|
|
118
118
|
this.properties[name] = value;
|
|
@@ -12,9 +12,15 @@ const initTrackLabsContainer = () => {
|
|
|
12
12
|
const target = document.querySelector('section.dumathoin');
|
|
13
13
|
if (target === null)
|
|
14
14
|
return;
|
|
15
|
+
const labsUrl = document
|
|
16
|
+
.querySelector('h1.dumathoin__title a')
|
|
17
|
+
?.getAttribute('href');
|
|
18
|
+
if (labsUrl === null)
|
|
19
|
+
return;
|
|
15
20
|
const eventTimer = event_timer_1.EventTimer.get();
|
|
16
21
|
(0, libs_1.log)('commercial', 'Page has labs container');
|
|
17
|
-
eventTimer.
|
|
22
|
+
eventTimer.setProperty('hasLabsContainer', true);
|
|
23
|
+
eventTimer.setProperty('labsUrl', labsUrl);
|
|
18
24
|
const observer = new IntersectionObserver((entries) => {
|
|
19
25
|
entries.map((entry) => {
|
|
20
26
|
if (entry.isIntersecting) {
|
|
@@ -33,6 +33,7 @@ interface EventTimerProperties {
|
|
|
33
33
|
gpcSignal?: number;
|
|
34
34
|
lazyLoadMarginPercent?: number;
|
|
35
35
|
hasLabsContainer?: boolean;
|
|
36
|
+
labsUrl?: string;
|
|
36
37
|
}
|
|
37
38
|
export declare class EventTimer {
|
|
38
39
|
private _events;
|
|
@@ -71,9 +72,9 @@ export declare class EventTimer {
|
|
|
71
72
|
* Adds an event timer property
|
|
72
73
|
*
|
|
73
74
|
* @param {string} name - the property's name
|
|
74
|
-
* @param
|
|
75
|
+
* @param value - the property's value
|
|
75
76
|
*/
|
|
76
|
-
setProperty(name:
|
|
77
|
+
setProperty<T extends keyof EventTimerProperties>(name: T, value: EventTimerProperties[T]): void;
|
|
77
78
|
/**
|
|
78
79
|
* Creates a new performance mark
|
|
79
80
|
* For slot events also ensures each TYPE of event event is marked only once for 'first'
|
package/dist/esm/event-timer.js
CHANGED
|
@@ -109,7 +109,7 @@ export class EventTimer {
|
|
|
109
109
|
* Adds an event timer property
|
|
110
110
|
*
|
|
111
111
|
* @param {string} name - the property's name
|
|
112
|
-
* @param
|
|
112
|
+
* @param value - the property's value
|
|
113
113
|
*/
|
|
114
114
|
setProperty(name, value) {
|
|
115
115
|
this.properties[name] = value;
|
|
@@ -9,9 +9,15 @@ const initTrackLabsContainer = () => {
|
|
|
9
9
|
const target = document.querySelector('section.dumathoin');
|
|
10
10
|
if (target === null)
|
|
11
11
|
return;
|
|
12
|
+
const labsUrl = document
|
|
13
|
+
.querySelector('h1.dumathoin__title a')
|
|
14
|
+
?.getAttribute('href');
|
|
15
|
+
if (labsUrl === null)
|
|
16
|
+
return;
|
|
12
17
|
const eventTimer = EventTimer.get();
|
|
13
18
|
log('commercial', 'Page has labs container');
|
|
14
|
-
eventTimer.
|
|
19
|
+
eventTimer.setProperty('hasLabsContainer', true);
|
|
20
|
+
eventTimer.setProperty('labsUrl', labsUrl);
|
|
15
21
|
const observer = new IntersectionObserver((entries) => {
|
|
16
22
|
entries.map((entry) => {
|
|
17
23
|
if (entry.isIntersecting) {
|