🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@sentry-internal/tracing

Package Overview
Dependencies
Maintainers
9
Versions
127
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

to
7.96.0

43

cjs/browser/instrument.js

@@ -20,5 +20,11 @@ Object.defineProperty(exports, '__esModule', { value: true });

* Returns a cleanup callback which can be called to remove the instrumentation handler.
*
* Pass `stopOnCallback = true` to stop listening for CLS when the cleanup callback is called.
* This will lead to the CLS being finalized and frozen.
*/
function addClsInstrumentationHandler(callback) {
return addMetricObserver('cls', callback, instrumentCls, _previousCls);
function addClsInstrumentationHandler(
callback,
stopOnCallback = false,
) {
return addMetricObserver('cls', callback, instrumentCls, _previousCls, stopOnCallback);
}

@@ -29,5 +35,11 @@

* Returns a cleanup callback which can be called to remove the instrumentation handler.
*
* Pass `stopOnCallback = true` to stop listening for LCP when the cleanup callback is called.
* This will lead to the LCP being finalized and frozen.
*/
function addLcpInstrumentationHandler(callback) {
return addMetricObserver('lcp', callback, instrumentLcp, _previousLcp);
function addLcpInstrumentationHandler(
callback,
stopOnCallback = false,
) {
return addMetricObserver('lcp', callback, instrumentLcp, _previousLcp, stopOnCallback);
}

@@ -84,3 +96,3 @@

function instrumentCls() {
getCLS.onCLS(metric => {
return getCLS.onCLS(metric => {
triggerHandlers('cls', {

@@ -94,3 +106,3 @@ metric,

function instrumentFid() {
getFID.onFID(metric => {
return getFID.onFID(metric => {
triggerHandlers('fid', {

@@ -104,3 +116,3 @@ metric,

function instrumentLcp() {
getLCP.onLCP(metric => {
return getLCP.onLCP(metric => {
triggerHandlers('lcp', {

@@ -118,7 +130,10 @@ metric,

previousValue,
stopOnCallback = false,
) {
addHandler(type, callback);
let stopListening;
if (!instrumented[type]) {
instrumentFn();
stopListening = instrumentFn();
instrumented[type] = true;

@@ -131,3 +146,3 @@ }

return getCleanupCallback(type, callback);
return getCleanupCallback(type, callback, stopOnCallback ? stopListening : undefined);
}

@@ -158,4 +173,12 @@

// Get a callback which can be called to remove the instrumentation handler
function getCleanupCallback(type, callback) {
function getCleanupCallback(
type,
callback,
stopListening,
) {
return () => {
if (stopListening) {
stopListening();
}
const typeHandlers = handlers[type];

@@ -162,0 +185,0 @@

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

/**
* Start tracking web vitals
* Start tracking web vitals.
* The callback returned by this function can be used to stop tracking & ensure all measurements are final & captured.
*

@@ -124,3 +125,3 @@ * @returns A function that forces web vitals collection

return instrument.addClsInstrumentationHandler(({ metric }) => {
const entry = metric.entries.pop();
const entry = metric.entries[metric.entries.length - 1];
if (!entry) {

@@ -133,3 +134,3 @@ return;

_clsEntry = entry ;
});
}, true);
}

@@ -140,3 +141,3 @@

return instrument.addLcpInstrumentationHandler(({ metric }) => {
const entry = metric.entries.pop();
const entry = metric.entries[metric.entries.length - 1];
if (!entry) {

@@ -149,3 +150,3 @@ return;

_lcpEntry = entry ;
});
}, true);
}

@@ -156,3 +157,3 @@

return instrument.addFidInstrumentationHandler(({ metric }) => {
const entry = metric.entries.pop();
const entry = metric.entries[metric.entries.length - 1];
if (!entry) {

@@ -159,0 +160,0 @@ return;

@@ -212,18 +212,15 @@ Object.defineProperty(exports, '__esModule', { value: true });

const scope = core.getCurrentScope();
const parentSpan = core.getActiveSpan();
const span =
shouldCreateSpanResult && parentSpan
? // eslint-disable-next-line deprecation/deprecation
parentSpan.startChild({
data: {
type: 'xhr',
'http.method': sentryXhrData.method,
url: sentryXhrData.url,
},
description: `${sentryXhrData.method} ${sentryXhrData.url}`,
op: 'http.client',
origin: 'auto.http.browser',
})
: undefined;
const span = shouldCreateSpanResult
? core.startInactiveSpan({
attributes: {
type: 'xhr',
'http.method': sentryXhrData.method,
url: sentryXhrData.url,
},
name: `${sentryXhrData.method} ${sentryXhrData.url}`,
op: 'http.client',
origin: 'auto.http.browser',
})
: undefined;

@@ -230,0 +227,0 @@ if (span) {

@@ -55,20 +55,17 @@ Object.defineProperty(exports, '__esModule', { value: true });

const client = core.getClient();
const parentSpan = core.getActiveSpan();
const { method, url } = handlerData.fetchData;
const span =
shouldCreateSpanResult && parentSpan
? // eslint-disable-next-line deprecation/deprecation
parentSpan.startChild({
data: {
url,
type: 'fetch',
'http.method': method,
},
description: `${method} ${url}`,
op: 'http.client',
origin: spanOrigin,
})
: undefined;
const span = shouldCreateSpanResult
? core.startInactiveSpan({
attributes: {
url,
type: 'fetch',
'http.method': method,
},
name: `${method} ${url}`,
op: 'http.client',
origin: spanOrigin,
})
: undefined;

@@ -75,0 +72,0 @@ if (span) {

@@ -18,5 +18,11 @@ import { logger, getFunctionName } from '@sentry/utils';

* Returns a cleanup callback which can be called to remove the instrumentation handler.
*
* Pass `stopOnCallback = true` to stop listening for CLS when the cleanup callback is called.
* This will lead to the CLS being finalized and frozen.
*/
function addClsInstrumentationHandler(callback) {
return addMetricObserver('cls', callback, instrumentCls, _previousCls);
function addClsInstrumentationHandler(
callback,
stopOnCallback = false,
) {
return addMetricObserver('cls', callback, instrumentCls, _previousCls, stopOnCallback);
}

@@ -27,5 +33,11 @@

* Returns a cleanup callback which can be called to remove the instrumentation handler.
*
* Pass `stopOnCallback = true` to stop listening for LCP when the cleanup callback is called.
* This will lead to the LCP being finalized and frozen.
*/
function addLcpInstrumentationHandler(callback) {
return addMetricObserver('lcp', callback, instrumentLcp, _previousLcp);
function addLcpInstrumentationHandler(
callback,
stopOnCallback = false,
) {
return addMetricObserver('lcp', callback, instrumentLcp, _previousLcp, stopOnCallback);
}

@@ -82,3 +94,3 @@

function instrumentCls() {
onCLS(metric => {
return onCLS(metric => {
triggerHandlers('cls', {

@@ -92,3 +104,3 @@ metric,

function instrumentFid() {
onFID(metric => {
return onFID(metric => {
triggerHandlers('fid', {

@@ -102,3 +114,3 @@ metric,

function instrumentLcp() {
onLCP(metric => {
return onLCP(metric => {
triggerHandlers('lcp', {

@@ -116,7 +128,10 @@ metric,

previousValue,
stopOnCallback = false,
) {
addHandler(type, callback);
let stopListening;
if (!instrumented[type]) {
instrumentFn();
stopListening = instrumentFn();
instrumented[type] = true;

@@ -129,3 +144,3 @@ }

return getCleanupCallback(type, callback);
return getCleanupCallback(type, callback, stopOnCallback ? stopListening : undefined);
}

@@ -156,4 +171,12 @@

// Get a callback which can be called to remove the instrumentation handler
function getCleanupCallback(type, callback) {
function getCleanupCallback(
type,
callback,
stopListening,
) {
return () => {
if (stopListening) {
stopListening();
}
const typeHandlers = handlers[type];

@@ -160,0 +183,0 @@

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

/**
* Start tracking web vitals
* Start tracking web vitals.
* The callback returned by this function can be used to stop tracking & ensure all measurements are final & captured.
*

@@ -122,3 +123,3 @@ * @returns A function that forces web vitals collection

return addClsInstrumentationHandler(({ metric }) => {
const entry = metric.entries.pop();
const entry = metric.entries[metric.entries.length - 1];
if (!entry) {

@@ -131,3 +132,3 @@ return;

_clsEntry = entry ;
});
}, true);
}

@@ -138,3 +139,3 @@

return addLcpInstrumentationHandler(({ metric }) => {
const entry = metric.entries.pop();
const entry = metric.entries[metric.entries.length - 1];
if (!entry) {

@@ -147,3 +148,3 @@ return;

_lcpEntry = entry ;
});
}, true);
}

@@ -154,3 +155,3 @@

return addFidInstrumentationHandler(({ metric }) => {
const entry = metric.entries.pop();
const entry = metric.entries[metric.entries.length - 1];
if (!entry) {

@@ -157,0 +158,0 @@ return;

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

import { spanToJSON, hasTracingEnabled, getCurrentScope, getActiveSpan, getRootSpan, getDynamicSamplingContextFromSpan, spanToTraceHeader, getClient, getDynamicSamplingContextFromClient } from '@sentry/core';
import { spanToJSON, hasTracingEnabled, getCurrentScope, startInactiveSpan, getRootSpan, getDynamicSamplingContextFromSpan, spanToTraceHeader, getClient, getDynamicSamplingContextFromClient } from '@sentry/core';
import { addFetchInstrumentationHandler, addXhrInstrumentationHandler, SENTRY_XHR_DATA_KEY, dynamicSamplingContextToSentryBaggageHeader, generateSentryTraceHeader, BAGGAGE_HEADER_NAME, browserPerformanceTimeOrigin, stringMatchesSomePattern } from '@sentry/utils';

@@ -210,18 +210,15 @@ import { instrumentFetchRequest } from '../common/fetch.js';

const scope = getCurrentScope();
const parentSpan = getActiveSpan();
const span =
shouldCreateSpanResult && parentSpan
? // eslint-disable-next-line deprecation/deprecation
parentSpan.startChild({
data: {
type: 'xhr',
'http.method': sentryXhrData.method,
url: sentryXhrData.url,
},
description: `${sentryXhrData.method} ${sentryXhrData.url}`,
op: 'http.client',
origin: 'auto.http.browser',
})
: undefined;
const span = shouldCreateSpanResult
? startInactiveSpan({
attributes: {
type: 'xhr',
'http.method': sentryXhrData.method,
url: sentryXhrData.url,
},
name: `${sentryXhrData.method} ${sentryXhrData.url}`,
op: 'http.client',
origin: 'auto.http.browser',
})
: undefined;

@@ -228,0 +225,0 @@ if (span) {

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

import { hasTracingEnabled, getCurrentScope, getClient, getActiveSpan, getRootSpan, spanToTraceHeader, getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromClient } from '@sentry/core';
import { hasTracingEnabled, getCurrentScope, getClient, startInactiveSpan, getRootSpan, spanToTraceHeader, getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromClient } from '@sentry/core';
import { generateSentryTraceHeader, dynamicSamplingContextToSentryBaggageHeader, isInstanceOf, BAGGAGE_HEADER_NAME } from '@sentry/utils';

@@ -53,20 +53,17 @@

const client = getClient();
const parentSpan = getActiveSpan();
const { method, url } = handlerData.fetchData;
const span =
shouldCreateSpanResult && parentSpan
? // eslint-disable-next-line deprecation/deprecation
parentSpan.startChild({
data: {
url,
type: 'fetch',
'http.method': method,
},
description: `${method} ${url}`,
op: 'http.client',
origin: spanOrigin,
})
: undefined;
const span = shouldCreateSpanResult
? startInactiveSpan({
attributes: {
url,
type: 'fetch',
'http.method': method,
},
name: `${method} ${url}`,
op: 'http.client',
origin: spanOrigin,
})
: undefined;

@@ -73,0 +70,0 @@ if (span) {

{
"name": "@sentry-internal/tracing",
"version": "7.95.0",
"version": "7.96.0",
"description": "Sentry Internal Tracing Package",

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

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

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

@@ -57,13 +57,19 @@ type InstrumentHandlerTypePerformanceObserver = 'longtask' | 'event' | 'navigation' | 'paint' | 'resource';

* Returns a cleanup callback which can be called to remove the instrumentation handler.
*
* Pass `stopOnCallback = true` to stop listening for CLS when the cleanup callback is called.
* This will lead to the CLS being finalized and frozen.
*/
export declare function addClsInstrumentationHandler(callback: (data: {
metric: Metric;
}) => void): CleanupHandlerCallback;
}) => void, stopOnCallback?: boolean): CleanupHandlerCallback;
/**
* Add a callback that will be triggered when a LCP metric is available.
* Returns a cleanup callback which can be called to remove the instrumentation handler.
*
* Pass `stopOnCallback = true` to stop listening for LCP when the cleanup callback is called.
* This will lead to the LCP being finalized and frozen.
*/
export declare function addLcpInstrumentationHandler(callback: (data: {
metric: Metric;
}) => void): CleanupHandlerCallback;
}) => void, stopOnCallback?: boolean): CleanupHandlerCallback;
/**

@@ -70,0 +76,0 @@ * Add a callback that will be triggered when a FID metric is available.

import { Transaction } from '@sentry/core';
import { Measurements } from '@sentry/types';
/**
* Start tracking web vitals
* Start tracking web vitals.
* The callback returned by this function can be used to stop tracking & ensure all measurements are final & captured.
*

@@ -6,0 +7,0 @@ * @returns A function that forces web vitals collection

@@ -57,13 +57,19 @@ type InstrumentHandlerTypePerformanceObserver = 'longtask' | 'event' | 'navigation' | 'paint' | 'resource';

* Returns a cleanup callback which can be called to remove the instrumentation handler.
*
* Pass `stopOnCallback = true` to stop listening for CLS when the cleanup callback is called.
* This will lead to the CLS being finalized and frozen.
*/
export declare function addClsInstrumentationHandler(callback: (data: {
metric: Metric;
}) => void): CleanupHandlerCallback;
}) => void, stopOnCallback?: boolean): CleanupHandlerCallback;
/**
* Add a callback that will be triggered when a LCP metric is available.
* Returns a cleanup callback which can be called to remove the instrumentation handler.
*
* Pass `stopOnCallback = true` to stop listening for LCP when the cleanup callback is called.
* This will lead to the LCP being finalized and frozen.
*/
export declare function addLcpInstrumentationHandler(callback: (data: {
metric: Metric;
}) => void): CleanupHandlerCallback;
}) => void, stopOnCallback?: boolean): CleanupHandlerCallback;
/**

@@ -70,0 +76,0 @@ * Add a callback that will be triggered when a FID metric is available.

import type { Transaction } from '@sentry/core';
import type { Measurements } from '@sentry/types';
/**
* Start tracking web vitals
* Start tracking web vitals.
* The callback returned by this function can be used to stop tracking & ensure all measurements are final & captured.
*

@@ -6,0 +7,0 @@ * @returns A function that forces web vitals collection

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

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