Skip to content

Commit 92dea44

Browse files
Add breakageReporting to Apple (#1995)
* Add breakageReporting to Apple * Refactor performance metrics loading methods * Lint fix
1 parent 78de57b commit 92dea44

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

injected/src/features.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const platformSupport = {
4343
'duckPlayer',
4444
'duckPlayerNative',
4545
'brokerProtection',
46+
'breakageReporting',
4647
'performanceMetrics',
4748
'clickToLoad',
4849
'messageBridge',

injected/src/features/performance-metrics.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,27 @@ export default class PerformanceMetrics extends ContentFeature {
1414

1515
// If the feature is enabled, we want to collect expanded performance metrics
1616
if (this.getFeatureSettingEnabled('expandedPerformanceMetricsOnLoad', 'enabled')) {
17-
this.waitForPageLoad(() => {
17+
this.waitForAfterPageLoad(() => {
1818
this.triggerExpandedPerformanceMetrics();
1919
});
2020
}
2121
}
2222

23-
waitForPageLoad(callback) {
23+
waitForNextTask(callback) {
24+
setTimeout(callback, 0);
25+
}
26+
27+
waitForAfterPageLoad(callback) {
2428
if (document.readyState === 'complete') {
25-
callback();
29+
this.waitForNextTask(callback);
2630
} else {
27-
window.addEventListener('load', callback, { once: true });
31+
window.addEventListener(
32+
'load',
33+
() => {
34+
this.waitForNextTask(callback);
35+
},
36+
{ once: true },
37+
);
2838
}
2939
}
3040

0 commit comments

Comments
 (0)