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

@sentry/browser

Package Overview
Dependencies
Maintainers
10
Versions
606
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/browser - npm Package Compare versions

Comparing version

to
9.16.0

build/npm/cjs/tracing/linkedTraces.js

20

build/npm/cjs/tracing/browserTracingIntegration.js

@@ -8,3 +8,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

const backgroundtab = require('./backgroundtab.js');
const previousTrace = require('./previousTrace.js');
const linkedTraces = require('./linkedTraces.js');
const request = require('./request.js');

@@ -23,2 +23,3 @@

linkPreviousTrace: 'in-memory',
consistentTraceSampling: false,
_experiments: {},

@@ -75,2 +76,3 @@ ...request.defaultRequestInstrumentationOptions,

linkPreviousTrace,
consistentTraceSampling,
onRequestSpanStart,

@@ -153,2 +155,3 @@ } = {

});
setActiveIdleSpan(client, idleSpan);

@@ -221,16 +224,3 @@

if (linkPreviousTrace !== 'off') {
let inMemoryPreviousTraceInfo = undefined;
client.on('spanStart', span => {
if (core.getRootSpan(span) !== span) {
return;
}
if (linkPreviousTrace === 'session-storage') {
const updatedPreviousTraceInfo = previousTrace.addPreviousTraceSpanLink(previousTrace.getPreviousTraceFromSessionStorage(), span);
previousTrace.storePreviousTraceInSessionStorage(updatedPreviousTraceInfo);
} else {
inMemoryPreviousTraceInfo = previousTrace.addPreviousTraceSpanLink(inMemoryPreviousTraceInfo, span);
}
});
linkedTraces.linkTraces(client, { linkPreviousTrace, consistentTraceSampling });
}

@@ -237,0 +227,0 @@

@@ -324,2 +324,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

) {
const originalHeaders = xhr.__sentry_xhr_v3__?.request_headers;
if (originalHeaders?.['sentry-trace']) {
// bail if a sentry-trace header is already set
return;
}
try {

@@ -329,7 +336,13 @@ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion

if (sentryBaggageHeader) {
// From MDN: "If this method is called several times with the same header, the values are merged into one single request header."
// We can therefore simply set a baggage header without checking what was there before
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
xhr.setRequestHeader('baggage', sentryBaggageHeader);
// only add our headers if
// - no pre-existing baggage header exists
// - or it is set and doesn't yet contain sentry values
const originalBaggageHeader = originalHeaders?.['baggage'];
if (!originalBaggageHeader || !baggageHeaderHasSentryValues(originalBaggageHeader)) {
// From MDN: "If this method is called several times with the same header, the values are merged into one single request header."
// We can therefore simply set a baggage header without checking what was there before
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
xhr.setRequestHeader('baggage', sentryBaggageHeader);
}
}

@@ -341,2 +354,6 @@ } catch (_) {

function baggageHeaderHasSentryValues(baggageHeader) {
return baggageHeader.split(',').some(value => value.trim().startsWith('sentry-'));
}
function getFullURL(url) {

@@ -343,0 +360,0 @@ try {

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

{"type":"module","version":"9.15.0","sideEffects":false}
{"type":"module","version":"9.16.0","sideEffects":false}

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

import { TRACING_DEFAULTS, registerSpanErrorInstrumentation, GLOBAL_OBJ, getLocationHref, getClient, getIsolationScope, generateTraceId, getCurrentScope, propagationContextFromHeaders, getRootSpan, browserPerformanceTimeOrigin, spanToJSON, logger, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startIdleSpan, getDynamicSamplingContextFromSpan, spanIsSampled, addNonEnumerableProperty, consoleSandbox, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON } from '@sentry/core';
import { TRACING_DEFAULTS, registerSpanErrorInstrumentation, GLOBAL_OBJ, getLocationHref, getClient, getIsolationScope, generateTraceId, getCurrentScope, propagationContextFromHeaders, browserPerformanceTimeOrigin, spanToJSON, logger, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startIdleSpan, getDynamicSamplingContextFromSpan, spanIsSampled, addNonEnumerableProperty, consoleSandbox, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON } from '@sentry/core';
import { startTrackingWebVitals, startTrackingINP, startTrackingLongAnimationFrames, startTrackingLongTasks, startTrackingInteractions, addHistoryInstrumentationHandler, registerInpInteractionListener, addPerformanceEntries } from '@sentry-internal/browser-utils';

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

import { registerBackgroundTabDetection } from './backgroundtab.js';
import { addPreviousTraceSpanLink, getPreviousTraceFromSessionStorage, storePreviousTraceInSessionStorage } from './previousTrace.js';
import { linkTraces } from './linkedTraces.js';
import { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from './request.js';

@@ -21,2 +21,3 @@

linkPreviousTrace: 'in-memory',
consistentTraceSampling: false,
_experiments: {},

@@ -73,2 +74,3 @@ ...defaultRequestInstrumentationOptions,

linkPreviousTrace,
consistentTraceSampling,
onRequestSpanStart,

@@ -151,2 +153,3 @@ } = {

});
setActiveIdleSpan(client, idleSpan);

@@ -219,16 +222,3 @@

if (linkPreviousTrace !== 'off') {
let inMemoryPreviousTraceInfo = undefined;
client.on('spanStart', span => {
if (getRootSpan(span) !== span) {
return;
}
if (linkPreviousTrace === 'session-storage') {
const updatedPreviousTraceInfo = addPreviousTraceSpanLink(getPreviousTraceFromSessionStorage(), span);
storePreviousTraceInSessionStorage(updatedPreviousTraceInfo);
} else {
inMemoryPreviousTraceInfo = addPreviousTraceSpanLink(inMemoryPreviousTraceInfo, span);
}
});
linkTraces(client, { linkPreviousTrace, consistentTraceSampling });
}

@@ -235,0 +225,0 @@

@@ -322,2 +322,9 @@ import { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler, instrumentFetchRequest, parseUrl, getLocationHref, stringMatchesSomePattern, spanToJSON, hasSpansEnabled, setHttpStatus, stripUrlQueryAndFragment, getActiveSpan, startInactiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SentryNonRecordingSpan, getClient, browserPerformanceTimeOrigin, getTraceData } from '@sentry/core';

) {
const originalHeaders = xhr.__sentry_xhr_v3__?.request_headers;
if (originalHeaders?.['sentry-trace']) {
// bail if a sentry-trace header is already set
return;
}
try {

@@ -327,7 +334,13 @@ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion

if (sentryBaggageHeader) {
// From MDN: "If this method is called several times with the same header, the values are merged into one single request header."
// We can therefore simply set a baggage header without checking what was there before
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
xhr.setRequestHeader('baggage', sentryBaggageHeader);
// only add our headers if
// - no pre-existing baggage header exists
// - or it is set and doesn't yet contain sentry values
const originalBaggageHeader = originalHeaders?.['baggage'];
if (!originalBaggageHeader || !baggageHeaderHasSentryValues(originalBaggageHeader)) {
// From MDN: "If this method is called several times with the same header, the values are merged into one single request header."
// We can therefore simply set a baggage header without checking what was there before
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
xhr.setRequestHeader('baggage', sentryBaggageHeader);
}
}

@@ -339,2 +352,6 @@ } catch (_) {

function baggageHeaderHasSentryValues(baggageHeader) {
return baggageHeader.split(',').some(value => value.trim().startsWith('sentry-'));
}
function getFullURL(url) {

@@ -341,0 +358,0 @@ try {

@@ -24,2 +24,3 @@ import { Mechanism, WrappedFunction } from '@sentry/core';

SENTRY_SDK_SOURCE?: import("@sentry/core").SdkSource | undefined;
_sentryClientToLogBufferMap?: WeakMap<import("@sentry/core").Client<import("@sentry/core").ClientOptions<import("@sentry/core").BaseTransportOptions>>, import("@sentry/core").SerializedLog[]> | undefined;
_sentryDebugIds?: Record<string, string> | undefined;

@@ -26,0 +27,0 @@ _sentryModuleMetadata?: Record<string, any> | undefined;

@@ -105,4 +105,6 @@ import { Client, Span, StartSpanOptions, WebFetchHeaders } from '@sentry/core';

*
* Note that your `tracesSampleRate` or `tracesSampler` config significantly influences
* how often traces will be linked.
* You can also use {@link BrowserTracingOptions.consistentTraceSampling} to get
* consistent trace sampling of subsequent traces. Otherwise, by default, your
* `tracesSampleRate` or `tracesSampler` config significantly influences how often
* traces will be linked.
*

@@ -113,2 +115,18 @@ * @default 'in-memory' - see explanation above

/**
* If true, Sentry will consistently sample subsequent traces based on the
* sampling decision of the initial trace. For example, if the initial page
* load trace was sampled positively, all subsequent traces (e.g. navigations)
* are also sampled positively. In case the initial trace was sampled negatively,
* all subsequent traces are also sampled negatively.
*
* This option allows you to get consistent, linked traces within a user journey
* while maintaining an overall quota based on your trace sampling settings.
*
* This option is only effective if {@link BrowserTracingOptions.linkPreviousTrace}
* is enabled (i.e. not set to `'off'`).
*
* @default `false` - this is an opt-in feature.
*/
consistentTraceSampling: boolean;
/**
* _experiments allows the user to send options to define how this integration works.

@@ -115,0 +133,0 @@ *

@@ -24,2 +24,3 @@ import type { Mechanism, WrappedFunction } from '@sentry/core';

SENTRY_SDK_SOURCE?: import("@sentry/core").SdkSource | undefined;
_sentryClientToLogBufferMap?: WeakMap<import("@sentry/core").Client<import("@sentry/core").ClientOptions<import("@sentry/core").BaseTransportOptions>>, import("@sentry/core").SerializedLog[]> | undefined;
_sentryDebugIds?: Record<string, string> | undefined;

@@ -26,0 +27,0 @@ _sentryModuleMetadata?: Record<string, any> | undefined;

@@ -105,4 +105,6 @@ import type { Client, Span, StartSpanOptions, WebFetchHeaders } from '@sentry/core';

*
* Note that your `tracesSampleRate` or `tracesSampler` config significantly influences
* how often traces will be linked.
* You can also use {@link BrowserTracingOptions.consistentTraceSampling} to get
* consistent trace sampling of subsequent traces. Otherwise, by default, your
* `tracesSampleRate` or `tracesSampler` config significantly influences how often
* traces will be linked.
*

@@ -113,2 +115,18 @@ * @default 'in-memory' - see explanation above

/**
* If true, Sentry will consistently sample subsequent traces based on the
* sampling decision of the initial trace. For example, if the initial page
* load trace was sampled positively, all subsequent traces (e.g. navigations)
* are also sampled positively. In case the initial trace was sampled negatively,
* all subsequent traces are also sampled negatively.
*
* This option allows you to get consistent, linked traces within a user journey
* while maintaining an overall quota based on your trace sampling settings.
*
* This option is only effective if {@link BrowserTracingOptions.linkPreviousTrace}
* is enabled (i.e. not set to `'off'`).
*
* @default `false` - this is an opt-in feature.
*/
consistentTraceSampling: boolean;
/**
* _experiments allows the user to send options to define how this integration works.

@@ -115,0 +133,0 @@ *

{
"name": "@sentry/browser",
"version": "9.15.0",
"version": "9.16.0",
"description": "Official Sentry SDK for browsers",

@@ -42,10 +42,10 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

"dependencies": {
"@sentry-internal/browser-utils": "9.15.0",
"@sentry-internal/feedback": "9.15.0",
"@sentry-internal/replay": "9.15.0",
"@sentry-internal/replay-canvas": "9.15.0",
"@sentry/core": "9.15.0"
"@sentry-internal/browser-utils": "9.16.0",
"@sentry-internal/feedback": "9.16.0",
"@sentry-internal/replay": "9.16.0",
"@sentry-internal/replay-canvas": "9.16.0",
"@sentry/core": "9.16.0"
},
"devDependencies": {
"@sentry-internal/integration-shims": "9.15.0",
"@sentry-internal/integration-shims": "9.16.0",
"fake-indexeddb": "^4.0.1"

@@ -52,0 +52,0 @@ },

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