@bugsnag/browser-performance
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -1,2 +0,2 @@ | ||
import { isString, coreSpanOptionSchema } from '@bugsnag/core-performance'; | ||
import { isObject, isString, coreSpanOptionSchema } from '@bugsnag/core-performance'; | ||
import { getPermittedAttributes } from '../send-page-attributes.js'; | ||
@@ -67,6 +67,19 @@ import { defaultRouteResolver } from '../default-routing-provider.js'; | ||
isValid: span.isValid, | ||
end: (endTime) => { | ||
if (permittedAttributes.title) | ||
end: (endTimeOrOptions) => { | ||
const options = isObject(endTimeOrOptions) ? endTimeOrOptions : { endTime: endTimeOrOptions }; | ||
if (permittedAttributes.title) { | ||
span.setAttribute('bugsnag.browser.page.title', this.document.title); | ||
this.spanFactory.toPublicApi(span).end(endTime); | ||
} | ||
if (options.url) { | ||
const urlObject = ensureUrl(options.url); // convert strings to URL if necessary | ||
const route = configuration.routingProvider.resolveRoute(urlObject) || defaultRouteResolver(urlObject); | ||
span.name = `[RouteChange]${route}`; | ||
span.setAttribute('bugsnag.browser.page.route', route); | ||
previousRoute = route; | ||
// update the URL attribute as well | ||
if (permittedAttributes.url) { | ||
span.setAttribute('bugsnag.browser.page.url', urlObject.toString()); | ||
} | ||
} | ||
this.spanFactory.toPublicApi(span).end(options.endTime); | ||
} | ||
@@ -77,3 +90,9 @@ }; | ||
} | ||
function ensureUrl(url) { | ||
if (typeof url === 'string') { | ||
return new URL(url); | ||
} | ||
return url; | ||
} | ||
export { RouteChangePlugin }; |
@@ -27,7 +27,7 @@ import { Settler } from './settler.js'; | ||
const entry = typeof performance.getEntriesByType === 'function' ? performance.getEntriesByType('navigation')[0] : undefined; | ||
let settledTime; | ||
let settledTime = 0; | ||
if (isPerformanceNavigationTiming(entry)) { | ||
settledTime = entry.loadEventEnd; | ||
} | ||
else { | ||
else if (performance.timing) { | ||
settledTime = performance.timing.loadEventEnd - performance.timing.navigationStart; | ||
@@ -34,0 +34,0 @@ } |
@@ -8,3 +8,3 @@ import cuid from '@bugsnag/cuid'; | ||
return function resourceAttributesSource(config) { | ||
const attributes = new ResourceAttributes(config.releaseStage, config.appVersion, 'bugsnag.performance.browser', '2.0.0'); | ||
const attributes = new ResourceAttributes(config.releaseStage, config.appVersion, 'bugsnag.performance.browser', '2.1.0'); | ||
attributes.set('browser.user_agent', navigator.userAgent); | ||
@@ -11,0 +11,0 @@ // chromium only |
export { DefaultRoutingProvider, default, onSettle } from './browser'; | ||
export { type BrowserConfiguration } from './config'; | ||
export { type RouteResolver, type RoutingProvider, type StartRouteChangeCallback } from './routing-provider'; | ||
export type { RouteResolver, RoutingProvider, StartRouteChangeCallback, RouteChangeSpanEndOptions, RouteChangeSpan } from './routing-provider'; | ||
export { type SpanOptions, type Time } from '@bugsnag/core-performance'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,4 +0,11 @@ | ||
import { type Span, type SpanOptions } from '@bugsnag/core-performance'; | ||
import { type Time, type Span, type SpanOptions } from '@bugsnag/core-performance'; | ||
export type RouteChangeSpanOptions = Omit<SpanOptions, 'isFirstClass'>; | ||
export type StartRouteChangeCallback = (url: URL | string, trigger: string, options?: RouteChangeSpanOptions) => Span; | ||
export type StartRouteChangeCallback = (url: URL | string, trigger: string, options?: RouteChangeSpanOptions) => RouteChangeSpan; | ||
export interface RouteChangeSpanEndOptions { | ||
endTime?: number | Date; | ||
url?: URL | string; | ||
} | ||
export interface RouteChangeSpan extends Span { | ||
end: ((endTime?: Time) => void) & ((routeChangeSpanEndOptions: RouteChangeSpanEndOptions) => void); | ||
} | ||
export interface RoutingProvider { | ||
@@ -5,0 +12,0 @@ resolveRoute: (url: URL) => string; |
{ | ||
"name": "@bugsnag/browser-performance", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "BugSnag performance monitoring for browsers", | ||
@@ -24,6 +24,6 @@ "homepage": "https://www.bugsnag.com/", | ||
"dependencies": { | ||
"@bugsnag/core-performance": "^2.0.0", | ||
"@bugsnag/core-performance": "^2.1.0", | ||
"@bugsnag/cuid": "^3.0.2", | ||
"@bugsnag/delivery-fetch-performance": "^2.0.0", | ||
"@bugsnag/request-tracker-performance": "^2.0.0" | ||
"@bugsnag/delivery-fetch-performance": "^2.1.0", | ||
"@bugsnag/request-tracker-performance": "^2.1.0" | ||
}, | ||
@@ -36,3 +36,3 @@ "type": "module", | ||
], | ||
"gitHead": "13ce6d677a070b56aeab48a3e284c3c5a5b94d2c" | ||
"gitHead": "fe8c5d081446b8de576dae8f590c7c75313ec842" | ||
} |
Sorry, the diff of this file is not supported yet
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
78357
1296