@bugsnag/browser-performance
Advanced tools
Comparing version 1.2.1-alpha.3 to 2.0.0
@@ -83,3 +83,9 @@ function getHttpVersion(protocol) { | ||
}); | ||
observer.observe({ type: 'resource', buffered: true }); | ||
try { | ||
observer.observe({ type: 'resource', buffered: true }); | ||
} | ||
catch (err) { | ||
configuration.logger.warn('Unable to get previous resource loads as buffered observer not supported, only showing resource loads from this point on'); | ||
observer.observe({ entryTypes: ['resource'] }); | ||
} | ||
} | ||
@@ -86,0 +92,0 @@ } |
@@ -1,3 +0,6 @@ | ||
function createBrowserBackgroundingListener(document) { | ||
function createBrowserBackgroundingListener(window) { | ||
const callbacks = []; | ||
let state = window.document.visibilityState === 'hidden' | ||
? 'in-background' | ||
: 'in-foreground'; | ||
const backgroundingListener = { | ||
@@ -7,15 +10,29 @@ onStateChange(backgroundingListenerCallback) { | ||
// trigger the callback immediately if the document is already 'hidden' | ||
if (document.visibilityState === 'hidden') { | ||
backgroundingListenerCallback('in-background'); | ||
if (state === 'in-background') { | ||
backgroundingListenerCallback(state); | ||
} | ||
} | ||
}; | ||
document.addEventListener('visibilitychange', function () { | ||
const state = document.visibilityState === 'hidden' | ||
? 'in-background' | ||
: 'in-foreground'; | ||
const backgroundStateChanged = (newState) => { | ||
if (state === newState) | ||
return; | ||
state = newState; | ||
for (const callback of callbacks) { | ||
callback(state); | ||
} | ||
}; | ||
window.document.addEventListener('visibilitychange', function () { | ||
const newState = window.document.visibilityState === 'hidden' | ||
? 'in-background' | ||
: 'in-foreground'; | ||
backgroundStateChanged(newState); | ||
}); | ||
// some browsers don't fire the visibilitychange event when the page is suspended, | ||
// so we also listen for pagehide and pageshow events | ||
window.addEventListener('pagehide', function () { | ||
backgroundStateChanged('in-background'); | ||
}); | ||
window.addEventListener('pageshow', function () { | ||
backgroundStateChanged('in-foreground'); | ||
}); | ||
return backgroundingListener; | ||
@@ -22,0 +39,0 @@ } |
@@ -19,3 +19,3 @@ import { createClient, InMemoryQueue } from '@bugsnag/core-performance'; | ||
const backgroundingListener = createBrowserBackgroundingListener(document); | ||
const backgroundingListener = createBrowserBackgroundingListener(window); | ||
const spanAttributesSource = createSpanAttributesSource(document); | ||
@@ -22,0 +22,0 @@ const clock = createClock(performance, backgroundingListener); |
@@ -8,3 +8,3 @@ import cuid from '@bugsnag/cuid'; | ||
return function resourceAttributesSource(config) { | ||
const attributes = new ResourceAttributes(config.releaseStage, config.appVersion, 'bugsnag.performance.browser', '1.2.1-alpha.3'); | ||
const attributes = new ResourceAttributes(config.releaseStage, config.appVersion, 'bugsnag.performance.browser', '2.0.0'); | ||
attributes.set('browser.user_agent', navigator.userAgent); | ||
@@ -11,0 +11,0 @@ // chromium only |
@@ -6,4 +6,8 @@ import { type BackgroundingListener } from '@bugsnag/core-performance'; | ||
} | ||
export default function createBrowserBackgroundingListener(document: DocumentForVisibilityState): BackgroundingListener; | ||
interface WindowWithDocumentForVisibilityState { | ||
document: DocumentForVisibilityState; | ||
addEventListener: (event: string, callback: () => void) => void; | ||
} | ||
export default function createBrowserBackgroundingListener(window: WindowWithDocumentForVisibilityState): BackgroundingListener; | ||
export {}; | ||
//# sourceMappingURL=backgrounding-listener.d.ts.map |
{ | ||
"name": "@bugsnag/browser-performance", | ||
"version": "1.2.1-alpha.3", | ||
"version": "2.0.0", | ||
"description": "BugSnag performance monitoring for browsers", | ||
@@ -24,6 +24,6 @@ "homepage": "https://www.bugsnag.com/", | ||
"dependencies": { | ||
"@bugsnag/core-performance": "^1.2.1-alpha.3", | ||
"@bugsnag/core-performance": "^2.0.0", | ||
"@bugsnag/cuid": "^3.0.2", | ||
"@bugsnag/delivery-fetch-performance": "^1.2.1-alpha.3", | ||
"@bugsnag/request-tracker-performance": "^1.2.1-alpha.3" | ||
"@bugsnag/delivery-fetch-performance": "^2.0.0", | ||
"@bugsnag/request-tracker-performance": "^2.0.0" | ||
}, | ||
@@ -36,3 +36,3 @@ "type": "module", | ||
], | ||
"gitHead": "57660cefa40bed578bd44f8a03caa5971eb2ca5c" | ||
"gitHead": "13ce6d677a070b56aeab48a3e284c3c5a5b94d2c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
76735
1270
0
+ Added@bugsnag/core-performance@2.10.0(transitive)
+ Added@bugsnag/delivery-fetch-performance@2.10.0(transitive)
+ Added@bugsnag/request-tracker-performance@2.10.0(transitive)
- Removed@bugsnag/core-performance@1.2.1-alpha.4(transitive)
- Removed@bugsnag/delivery-fetch-performance@1.2.1-alpha.4(transitive)
- Removed@bugsnag/request-tracker-performance@1.2.1-alpha.4(transitive)