@guardian/commercial-core 0.37.0 → 0.37.1
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/EventTimer.d.ts +1 -1
- package/dist/cjs/EventTimer.js +12 -10
- package/dist/esm/EventTimer.d.ts +1 -1
- package/dist/esm/EventTimer.js +12 -10
- package/package.json +1 -1
package/dist/cjs/EventTimer.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare class EventTimer {
|
|
|
57
57
|
* by EventTimer so they need to be concatenated to EventTimer's private events array.
|
|
58
58
|
*/
|
|
59
59
|
get events(): Event[];
|
|
60
|
-
constructor();
|
|
60
|
+
private constructor();
|
|
61
61
|
/**
|
|
62
62
|
* Creates a new performance mark
|
|
63
63
|
* For slot events also ensures each TYPE of event event is marked only once for 'first'
|
package/dist/cjs/EventTimer.js
CHANGED
|
@@ -96,9 +96,13 @@ class EventTimer {
|
|
|
96
96
|
? [
|
|
97
97
|
...this._events,
|
|
98
98
|
...EventTimer._externallyDefinedEventNames
|
|
99
|
-
.
|
|
100
|
-
.
|
|
101
|
-
|
|
99
|
+
.map((eventName) => {
|
|
100
|
+
const entry = window.performance.getEntriesByName(eventName)[0];
|
|
101
|
+
return entry
|
|
102
|
+
? new Event(eventName, entry)
|
|
103
|
+
: undefined;
|
|
104
|
+
})
|
|
105
|
+
.filter((entry) => entry instanceof Event),
|
|
102
106
|
]
|
|
103
107
|
: this._events;
|
|
104
108
|
}
|
|
@@ -137,13 +141,11 @@ class EventTimer {
|
|
|
137
141
|
mark(name) {
|
|
138
142
|
const longName = `gu.commercial.${name}`;
|
|
139
143
|
if (typeof window.performance !== 'undefined' &&
|
|
140
|
-
'mark' in window.performance
|
|
141
|
-
window.performance.mark
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
.slice(-1)[0];
|
|
146
|
-
if (typeof mark !== 'undefined') {
|
|
144
|
+
'mark' in window.performance &&
|
|
145
|
+
typeof window.performance.mark === 'function') {
|
|
146
|
+
const mark = window.performance.mark(longName);
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- browser support is patchy
|
|
148
|
+
if (typeof mark?.startTime === 'number') {
|
|
147
149
|
this._events.push(new Event(name, mark));
|
|
148
150
|
}
|
|
149
151
|
}
|
package/dist/esm/EventTimer.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare class EventTimer {
|
|
|
57
57
|
* by EventTimer so they need to be concatenated to EventTimer's private events array.
|
|
58
58
|
*/
|
|
59
59
|
get events(): Event[];
|
|
60
|
-
constructor();
|
|
60
|
+
private constructor();
|
|
61
61
|
/**
|
|
62
62
|
* Creates a new performance mark
|
|
63
63
|
* For slot events also ensures each TYPE of event event is marked only once for 'first'
|
package/dist/esm/EventTimer.js
CHANGED
|
@@ -93,9 +93,13 @@ export class EventTimer {
|
|
|
93
93
|
? [
|
|
94
94
|
...this._events,
|
|
95
95
|
...EventTimer._externallyDefinedEventNames
|
|
96
|
-
.
|
|
97
|
-
.
|
|
98
|
-
|
|
96
|
+
.map((eventName) => {
|
|
97
|
+
const entry = window.performance.getEntriesByName(eventName)[0];
|
|
98
|
+
return entry
|
|
99
|
+
? new Event(eventName, entry)
|
|
100
|
+
: undefined;
|
|
101
|
+
})
|
|
102
|
+
.filter((entry) => entry instanceof Event),
|
|
99
103
|
]
|
|
100
104
|
: this._events;
|
|
101
105
|
}
|
|
@@ -134,13 +138,11 @@ export class EventTimer {
|
|
|
134
138
|
mark(name) {
|
|
135
139
|
const longName = `gu.commercial.${name}`;
|
|
136
140
|
if (typeof window.performance !== 'undefined' &&
|
|
137
|
-
'mark' in window.performance
|
|
138
|
-
window.performance.mark
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.slice(-1)[0];
|
|
143
|
-
if (typeof mark !== 'undefined') {
|
|
141
|
+
'mark' in window.performance &&
|
|
142
|
+
typeof window.performance.mark === 'function') {
|
|
143
|
+
const mark = window.performance.mark(longName);
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- browser support is patchy
|
|
145
|
+
if (typeof mark?.startTime === 'number') {
|
|
144
146
|
this._events.push(new Event(name, mark));
|
|
145
147
|
}
|
|
146
148
|
}
|