@sentry-internal/browser-utils
Advanced tools
Comparing version
@@ -5,2 +5,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
const browserMetrics = require('./metrics/browserMetrics.js'); | ||
const utils = require('./metrics/utils.js'); | ||
const dom = require('./instrument/dom.js'); | ||
@@ -25,2 +26,3 @@ const history = require('./instrument/history.js'); | ||
exports.startTrackingWebVitals = browserMetrics.startTrackingWebVitals; | ||
exports.extractNetworkProtocol = utils.extractNetworkProtocol; | ||
exports.addClickKeypressInstrumentationHandler = dom.addClickKeypressInstrumentationHandler; | ||
@@ -27,0 +29,0 @@ exports.addHistoryInstrumentationHandler = history.addHistoryInstrumentationHandler; |
@@ -511,2 +511,6 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
const { name, version } = utils.extractNetworkProtocol(entry.nextHopProtocol); | ||
attributes['network.protocol.name'] = name; | ||
attributes['network.protocol.version'] = version; | ||
const startTimestamp = timeOrigin + startTime; | ||
@@ -513,0 +517,0 @@ const endTimestamp = startTimestamp + duration; |
@@ -132,2 +132,34 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/** | ||
* Converts ALPN protocol ids to name and version. | ||
* | ||
* (https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids) | ||
* @param nextHopProtocol PerformanceResourceTiming.nextHopProtocol | ||
*/ | ||
function extractNetworkProtocol(nextHopProtocol) { | ||
let name = 'unknown'; | ||
let version = 'unknown'; | ||
let _name = ''; | ||
for (const char of nextHopProtocol) { | ||
// http/1.1 etc. | ||
if (char === '/') { | ||
[name, version] = nextHopProtocol.split('/') ; | ||
break; | ||
} | ||
// h2, h3 etc. | ||
if (!isNaN(Number(char))) { | ||
name = _name === 'h' ? 'http' : _name; | ||
version = nextHopProtocol.split(_name)[1] ; | ||
break; | ||
} | ||
_name += char; | ||
} | ||
if (_name === nextHopProtocol) { | ||
// webrtc, ftp, etc. | ||
name = _name; | ||
} | ||
return { name, version }; | ||
} | ||
exports.extractNetworkProtocol = extractNetworkProtocol; | ||
exports.getBrowserPerformanceAPI = getBrowserPerformanceAPI; | ||
@@ -134,0 +166,0 @@ exports.isMeasurementValue = isMeasurementValue; |
export { addClsInstrumentationHandler, addFidInstrumentationHandler, addInpInstrumentationHandler, addLcpInstrumentationHandler, addPerformanceInstrumentationHandler, addTtfbInstrumentationHandler } from './metrics/instrument.js'; | ||
export { addPerformanceEntries, startTrackingInteractions, startTrackingLongAnimationFrames, startTrackingLongTasks, startTrackingWebVitals } from './metrics/browserMetrics.js'; | ||
export { extractNetworkProtocol } from './metrics/utils.js'; | ||
export { addClickKeypressInstrumentationHandler } from './instrument/dom.js'; | ||
@@ -4,0 +5,0 @@ export { addHistoryInstrumentationHandler } from './instrument/history.js'; |
@@ -5,3 +5,3 @@ import { browserPerformanceTimeOrigin, getActiveSpan, spanToJSON, setMeasurement, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, parseUrl, htmlTreeAsString, getComponentName } from '@sentry/core'; | ||
import { addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addLcpInstrumentationHandler, addFidInstrumentationHandler, addTtfbInstrumentationHandler } from './instrument.js'; | ||
import { getBrowserPerformanceAPI, msToSec, startAndEndSpan, isMeasurementValue } from './utils.js'; | ||
import { getBrowserPerformanceAPI, msToSec, startAndEndSpan, extractNetworkProtocol, isMeasurementValue } from './utils.js'; | ||
import { getActivationStart } from './web-vitals/lib/getActivationStart.js'; | ||
@@ -510,2 +510,6 @@ import { getNavigationEntry } from './web-vitals/lib/getNavigationEntry.js'; | ||
const { name, version } = extractNetworkProtocol(entry.nextHopProtocol); | ||
attributes['network.protocol.name'] = name; | ||
attributes['network.protocol.version'] = version; | ||
const startTimestamp = timeOrigin + startTime; | ||
@@ -512,0 +516,0 @@ const endTimestamp = startTimestamp + duration; |
@@ -130,3 +130,34 @@ import { spanToJSON, withActiveSpan, startInactiveSpan, getClient, getCurrentScope } from '@sentry/core'; | ||
export { getBrowserPerformanceAPI, isMeasurementValue, msToSec, startAndEndSpan, startStandaloneWebVitalSpan }; | ||
/** | ||
* Converts ALPN protocol ids to name and version. | ||
* | ||
* (https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids) | ||
* @param nextHopProtocol PerformanceResourceTiming.nextHopProtocol | ||
*/ | ||
function extractNetworkProtocol(nextHopProtocol) { | ||
let name = 'unknown'; | ||
let version = 'unknown'; | ||
let _name = ''; | ||
for (const char of nextHopProtocol) { | ||
// http/1.1 etc. | ||
if (char === '/') { | ||
[name, version] = nextHopProtocol.split('/') ; | ||
break; | ||
} | ||
// h2, h3 etc. | ||
if (!isNaN(Number(char))) { | ||
name = _name === 'h' ? 'http' : _name; | ||
version = nextHopProtocol.split(_name)[1] ; | ||
break; | ||
} | ||
_name += char; | ||
} | ||
if (_name === nextHopProtocol) { | ||
// webrtc, ftp, etc. | ||
name = _name; | ||
} | ||
return { name, version }; | ||
} | ||
export { extractNetworkProtocol, getBrowserPerformanceAPI, isMeasurementValue, msToSec, startAndEndSpan, startStandaloneWebVitalSpan }; | ||
//# sourceMappingURL=utils.js.map |
@@ -1,1 +0,1 @@ | ||
{"type":"module","version":"8.52.0","sideEffects":false} | ||
{"type":"module","version":"8.52.1","sideEffects":false} |
export { addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addFidInstrumentationHandler, addTtfbInstrumentationHandler, addLcpInstrumentationHandler, addInpInstrumentationHandler, } from './metrics/instrument'; | ||
export { addPerformanceEntries, startTrackingInteractions, startTrackingLongTasks, startTrackingLongAnimationFrames, startTrackingWebVitals, startTrackingINP, registerInpInteractionListener, } from './metrics/browserMetrics'; | ||
export { extractNetworkProtocol } from './metrics/utils'; | ||
export { addClickKeypressInstrumentationHandler } from './instrument/dom'; | ||
@@ -4,0 +5,0 @@ export { addHistoryInstrumentationHandler } from './instrument/history'; |
@@ -42,3 +42,13 @@ import { Span, SpanAttributes, SpanTimeInput, StartSpanOptions } from '@sentry/core'; | ||
export declare function msToSec(time: number): number; | ||
/** | ||
* Converts ALPN protocol ids to name and version. | ||
* | ||
* (https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids) | ||
* @param nextHopProtocol PerformanceResourceTiming.nextHopProtocol | ||
*/ | ||
export declare function extractNetworkProtocol(nextHopProtocol: string): { | ||
name: string; | ||
version: string; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=utils.d.ts.map |
export { addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addFidInstrumentationHandler, addTtfbInstrumentationHandler, addLcpInstrumentationHandler, addInpInstrumentationHandler, } from './metrics/instrument'; | ||
export { addPerformanceEntries, startTrackingInteractions, startTrackingLongTasks, startTrackingLongAnimationFrames, startTrackingWebVitals, startTrackingINP, registerInpInteractionListener, } from './metrics/browserMetrics'; | ||
export { extractNetworkProtocol } from './metrics/utils'; | ||
export { addClickKeypressInstrumentationHandler } from './instrument/dom'; | ||
@@ -4,0 +5,0 @@ export { addHistoryInstrumentationHandler } from './instrument/history'; |
@@ -42,3 +42,13 @@ import type { Span, SpanAttributes, SpanTimeInput, StartSpanOptions } from '@sentry/core'; | ||
export declare function msToSec(time: number): number; | ||
/** | ||
* Converts ALPN protocol ids to name and version. | ||
* | ||
* (https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids) | ||
* @param nextHopProtocol PerformanceResourceTiming.nextHopProtocol | ||
*/ | ||
export declare function extractNetworkProtocol(nextHopProtocol: string): { | ||
name: string; | ||
version: string; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=utils.d.ts.map |
{ | ||
"name": "@sentry-internal/browser-utils", | ||
"version": "8.52.0", | ||
"version": "8.52.1", | ||
"description": "Browser Utilities for all Sentry JavaScript SDKs", | ||
@@ -42,3 +42,3 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/core": "8.52.0" | ||
"@sentry/core": "8.52.1" | ||
}, | ||
@@ -45,0 +45,0 @@ "scripts": { |
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
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
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
727722
1.01%7844
1.19%+ Added
- Removed
Updated