Socket
Socket
Sign inDemoInstall

@sentry-internal/tracing

Package Overview
Dependencies
Maintainers
9
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry-internal/tracing - npm Package Compare versions

Comparing version 7.94.1 to 7.95.0

2

cjs/browser/browsertracing.js

@@ -261,3 +261,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

spanId: idleTransaction.spanContext().spanId,
parentSpanId: idleTransaction.parentSpanId,
parentSpanId: core.spanToJSON(idleTransaction).parent_span_id,
sampled: core.spanIsSampled(idleTransaction),

@@ -264,0 +264,0 @@ });

@@ -233,21 +233,4 @@ Object.defineProperty(exports, '__esModule', { value: true });

if (op === 'pageload') {
// Generate TTFB (Time to First Byte), which measured as the time between the beginning of the transaction and the
// start of the response in milliseconds
if (typeof responseStartTimestamp === 'number' && transactionStartTime) {
debugBuild.DEBUG_BUILD && utils.logger.log('[Measurements] Adding TTFB');
_measurements['ttfb'] = {
value: (responseStartTimestamp - transactionStartTime) * 1000,
unit: 'millisecond',
};
_addTtfbToMeasurements(_measurements, responseStartTimestamp, requestStartTimestamp, transactionStartTime);
if (typeof requestStartTimestamp === 'number' && requestStartTimestamp <= responseStartTimestamp) {
// Capture the time spent making the request and receiving the first byte of the response.
// This is the time between the start of the request and the start of the response in milliseconds.
_measurements['ttfb.requestTime'] = {
value: (responseStartTimestamp - requestStartTimestamp) * 1000,
unit: 'millisecond',
};
}
}
['fcp', 'fp', 'lcp'].forEach(name => {

@@ -534,4 +517,43 @@ if (!_measurements[name] || !transactionStartTime || timeOrigin >= transactionStartTime) {

/**
* Add ttfb information to measurements
*
* Exported for tests
*/
function _addTtfbToMeasurements(
_measurements,
responseStartTimestamp,
requestStartTimestamp,
transactionStartTime,
) {
// Generate TTFB (Time to First Byte), which measured as the time between the beginning of the transaction and the
// start of the response in milliseconds
if (typeof responseStartTimestamp === 'number' && transactionStartTime) {
debugBuild.DEBUG_BUILD && utils.logger.log('[Measurements] Adding TTFB');
_measurements['ttfb'] = {
// As per https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStart,
// responseStart can be 0 if the request is coming straight from the cache.
// This might lead us to calculate a negative ttfb if we don't use Math.max here.
//
// This logic is the same as what is in the web-vitals library to calculate ttfb
// https://github.com/GoogleChrome/web-vitals/blob/2301de5015e82b09925238a228a0893635854587/src/onTTFB.ts#L92
// TODO(abhi): We should use the web-vitals library instead of this custom calculation.
value: Math.max(responseStartTimestamp - transactionStartTime, 0) * 1000,
unit: 'millisecond',
};
if (typeof requestStartTimestamp === 'number' && requestStartTimestamp <= responseStartTimestamp) {
// Capture the time spent making the request and receiving the first byte of the response.
// This is the time between the start of the request and the start of the response in milliseconds.
_measurements['ttfb.requestTime'] = {
value: (responseStartTimestamp - requestStartTimestamp) * 1000,
unit: 'millisecond',
};
}
}
}
exports._addMeasureSpans = _addMeasureSpans;
exports._addResourceSpans = _addResourceSpans;
exports._addTtfbToMeasurements = _addTtfbToMeasurements;
exports.addPerformanceEntries = addPerformanceEntries;

@@ -538,0 +560,0 @@ exports.startTrackingInteractions = startTrackingInteractions;

@@ -1,2 +0,2 @@

import { TRACING_DEFAULTS, addTracingExtensions, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startIdleTransaction, spanIsSampled, getActiveTransaction } from '@sentry/core';
import { TRACING_DEFAULTS, addTracingExtensions, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startIdleTransaction, spanToJSON, spanIsSampled, getActiveTransaction } from '@sentry/core';
import { logger, tracingContextFromHeaders, getDomElement } from '@sentry/utils';

@@ -259,3 +259,3 @@ import { DEBUG_BUILD } from '../common/debug-build.js';

spanId: idleTransaction.spanContext().spanId,
parentSpanId: idleTransaction.parentSpanId,
parentSpanId: spanToJSON(idleTransaction).parent_span_id,
sampled: spanIsSampled(idleTransaction),

@@ -262,0 +262,0 @@ });

@@ -231,21 +231,4 @@ import { getActiveTransaction, spanToJSON, setMeasurement } from '@sentry/core';

if (op === 'pageload') {
// Generate TTFB (Time to First Byte), which measured as the time between the beginning of the transaction and the
// start of the response in milliseconds
if (typeof responseStartTimestamp === 'number' && transactionStartTime) {
DEBUG_BUILD && logger.log('[Measurements] Adding TTFB');
_measurements['ttfb'] = {
value: (responseStartTimestamp - transactionStartTime) * 1000,
unit: 'millisecond',
};
_addTtfbToMeasurements(_measurements, responseStartTimestamp, requestStartTimestamp, transactionStartTime);
if (typeof requestStartTimestamp === 'number' && requestStartTimestamp <= responseStartTimestamp) {
// Capture the time spent making the request and receiving the first byte of the response.
// This is the time between the start of the request and the start of the response in milliseconds.
_measurements['ttfb.requestTime'] = {
value: (responseStartTimestamp - requestStartTimestamp) * 1000,
unit: 'millisecond',
};
}
}
['fcp', 'fp', 'lcp'].forEach(name => {

@@ -532,3 +515,41 @@ if (!_measurements[name] || !transactionStartTime || timeOrigin >= transactionStartTime) {

export { _addMeasureSpans, _addResourceSpans, addPerformanceEntries, startTrackingInteractions, startTrackingLongTasks, startTrackingWebVitals };
/**
* Add ttfb information to measurements
*
* Exported for tests
*/
function _addTtfbToMeasurements(
_measurements,
responseStartTimestamp,
requestStartTimestamp,
transactionStartTime,
) {
// Generate TTFB (Time to First Byte), which measured as the time between the beginning of the transaction and the
// start of the response in milliseconds
if (typeof responseStartTimestamp === 'number' && transactionStartTime) {
DEBUG_BUILD && logger.log('[Measurements] Adding TTFB');
_measurements['ttfb'] = {
// As per https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStart,
// responseStart can be 0 if the request is coming straight from the cache.
// This might lead us to calculate a negative ttfb if we don't use Math.max here.
//
// This logic is the same as what is in the web-vitals library to calculate ttfb
// https://github.com/GoogleChrome/web-vitals/blob/2301de5015e82b09925238a228a0893635854587/src/onTTFB.ts#L92
// TODO(abhi): We should use the web-vitals library instead of this custom calculation.
value: Math.max(responseStartTimestamp - transactionStartTime, 0) * 1000,
unit: 'millisecond',
};
if (typeof requestStartTimestamp === 'number' && requestStartTimestamp <= responseStartTimestamp) {
// Capture the time spent making the request and receiving the first byte of the response.
// This is the time between the start of the request and the start of the response in milliseconds.
_measurements['ttfb.requestTime'] = {
value: (responseStartTimestamp - requestStartTimestamp) * 1000,
unit: 'millisecond',
};
}
}
}
export { _addMeasureSpans, _addResourceSpans, _addTtfbToMeasurements, addPerformanceEntries, startTrackingInteractions, startTrackingLongTasks, startTrackingWebVitals };
//# sourceMappingURL=index.js.map
{
"name": "@sentry-internal/tracing",
"version": "7.94.1",
"version": "7.95.0",
"description": "Sentry Internal Tracing Package",

@@ -32,5 +32,5 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

"dependencies": {
"@sentry/core": "7.94.1",
"@sentry/types": "7.94.1",
"@sentry/utils": "7.94.1"
"@sentry/core": "7.95.0",
"@sentry/types": "7.95.0",
"@sentry/utils": "7.95.0"
},

@@ -37,0 +37,0 @@ "devDependencies": {

import { Transaction } from '@sentry/core';
import { Measurements } from '@sentry/types';
/**

@@ -29,2 +30,8 @@ * Start tracking web vitals

export declare function _addResourceSpans(transaction: Transaction, entry: ResourceEntry, resourceUrl: string, startTime: number, duration: number, timeOrigin: number): void;
/**
* Add ttfb information to measurements
*
* Exported for tests
*/
export declare function _addTtfbToMeasurements(_measurements: Measurements, responseStartTimestamp: number | undefined, requestStartTimestamp: number | undefined, transactionStartTime: number | undefined): void;
//# sourceMappingURL=index.d.ts.map
import type { Transaction } from '@sentry/core';
import type { Measurements } from '@sentry/types';
/**

@@ -29,2 +30,8 @@ * Start tracking web vitals

export declare function _addResourceSpans(transaction: Transaction, entry: ResourceEntry, resourceUrl: string, startTime: number, duration: number, timeOrigin: number): void;
/**
* Add ttfb information to measurements
*
* Exported for tests
*/
export declare function _addTtfbToMeasurements(_measurements: Measurements, responseStartTimestamp: number | undefined, requestStartTimestamp: number | undefined, transactionStartTime: number | undefined): void;
//# sourceMappingURL=index.d.ts.map

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc