You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

@sentry/browser

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.11.0

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

const DEFAULT_FLUSH_INTERVAL = 5000;
/**

@@ -20,2 +22,3 @@ * Configuration options for the Sentry Browser SDK.

class BrowserClient extends core.Client {
/**

@@ -37,2 +40,7 @@ * Creates a new Browser SDK instance.

// eslint-disable-next-line @typescript-eslint/no-this-alias
const client = this;
const { sendDefaultPii, _experiments } = client._options;
const enableLogs = _experiments?.enableLogs;
if (opts.sendClientReports && helpers.WINDOW.document) {

@@ -42,2 +50,5 @@ helpers.WINDOW.document.addEventListener('visibilitychange', () => {

this._flushOutcomes();
if (enableLogs) {
core._INTERNAL_flushLogsBuffer(client);
}
}

@@ -47,6 +58,22 @@ });

if (this._options.sendDefaultPii) {
this.on('postprocessEvent', core.addAutoIpAddressToUser);
this.on('beforeSendSession', core.addAutoIpAddressToSession);
if (enableLogs) {
client.on('flush', () => {
core._INTERNAL_flushLogsBuffer(client);
});
client.on('afterCaptureLog', () => {
if (client._logFlushIdleTimeout) {
clearTimeout(client._logFlushIdleTimeout);
}
client._logFlushIdleTimeout = setTimeout(() => {
core._INTERNAL_flushLogsBuffer(client);
}, DEFAULT_FLUSH_INTERVAL);
});
}
if (sendDefaultPii) {
client.on('postprocessEvent', core.addAutoIpAddressToUser);
client.on('beforeSendSession', core.addAutoIpAddressToSession);
}
}

@@ -53,0 +80,0 @@

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

exports.close = core.close;
exports.consoleLoggingIntegration = core.consoleLoggingIntegration;
exports.continueTrace = core.continueTrace;

@@ -60,0 +61,0 @@ exports.createTransport = core.createTransport;

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

options.stackParser,
options.maxValueLength,
key,

@@ -27,0 +26,0 @@ limit,

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const core = require('@sentry/core');
const helpers = require('./helpers.js');
/**
* TODO: Make this configurable
*/
const DEFAULT_FLUSH_INTERVAL = 5000;
let timeout;
/**
* This is a global timeout that is used to flush the logs buffer.
* It is used to ensure that logs are flushed even if the client is not flushed.
*/
function startFlushTimeout(client) {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
core._INTERNAL_flushLogsBuffer(client);
}, DEFAULT_FLUSH_INTERVAL);
}
let isClientListenerAdded = false;
/**
* This is a function that is used to add a flush listener to the client.
* It is used to ensure that the logger buffer is flushed when the client is flushed.
*/
function addFlushingListeners(client) {
if (isClientListenerAdded || !client.getOptions()._experiments?.enableLogs) {
return;
}
isClientListenerAdded = true;
if (helpers.WINDOW.document) {
helpers.WINDOW.document.addEventListener('visibilitychange', () => {
if (helpers.WINDOW.document.visibilityState === 'hidden') {
core._INTERNAL_flushLogsBuffer(client);
}
});
}
client.on('flush', () => {
core._INTERNAL_flushLogsBuffer(client);
});
}
/**
* Capture a log with the given level.

@@ -66,10 +19,3 @@ *

) {
const client = core.getClient();
if (client) {
addFlushingListeners(client);
startFlushTimeout(client);
}
core._INTERNAL_captureLog({ level, message, attributes, severityNumber }, client, undefined);
core._INTERNAL_captureLog({ level, message, attributes, severityNumber });
}

@@ -76,0 +22,0 @@

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

const PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE = 'sentry.previous_trace';
/**

@@ -42,3 +44,4 @@ * Adds a previous_trace span link to the passed span if the passed

if (previousTraceInfo.spanContext.traceId === spanJson.trace_id) {
const previousTraceSpanCtx = previousTraceInfo.spanContext;
if (previousTraceSpanCtx.traceId === spanJson.trace_id) {
// This means, we're still in the same trace so let's not update the previous trace info

@@ -58,3 +61,3 @@ // or add a link to the current span.

core.logger.info(
`Adding previous_trace ${previousTraceInfo.spanContext} link to span ${{
`Adding previous_trace ${previousTraceSpanCtx} link to span ${{
op: spanJson.op,

@@ -67,3 +70,3 @@ ...span.spanContext(),

span.addLink({
context: previousTraceInfo.spanContext,
context: previousTraceSpanCtx,
attributes: {

@@ -73,2 +76,13 @@ [core.SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace',

});
// TODO: Remove this once EAP can store span links. We currently only set this attribute so that we
// can obtain the previous trace information from the EAP store. Long-term, EAP will handle
// span links and then we should remove this again. Also throwing in a TODO(v10), to remind us
// to check this at v10 time :)
span.setAttribute(
PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE,
`${previousTraceSpanCtx.traceId}-${previousTraceSpanCtx.spanId}-${
previousTraceSpanCtx.traceFlags === 0x1 ? 1 : 0
}`,
);
}

@@ -109,2 +123,3 @@

exports.PREVIOUS_TRACE_MAX_DURATION = PREVIOUS_TRACE_MAX_DURATION;
exports.PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE = PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE;
exports.addPreviousTraceSpanLink = addPreviousTraceSpanLink;

@@ -111,0 +126,0 @@ exports.getPreviousTraceFromSessionStorage = getPreviousTraceFromSessionStorage;

@@ -1,5 +0,7 @@

import { Client, getSDKSource, applySdkMetadata, addAutoIpAddressToUser, addAutoIpAddressToSession } from '@sentry/core';
import { Client, getSDKSource, applySdkMetadata, _INTERNAL_flushLogsBuffer, addAutoIpAddressToUser, addAutoIpAddressToSession } from '@sentry/core';
import { eventFromException, eventFromMessage } from './eventbuilder.js';
import { WINDOW } from './helpers.js';
const DEFAULT_FLUSH_INTERVAL = 5000;
/**

@@ -17,2 +19,3 @@ * Configuration options for the Sentry Browser SDK.

class BrowserClient extends Client {
/**

@@ -34,2 +37,7 @@ * Creates a new Browser SDK instance.

// eslint-disable-next-line @typescript-eslint/no-this-alias
const client = this;
const { sendDefaultPii, _experiments } = client._options;
const enableLogs = _experiments?.enableLogs;
if (opts.sendClientReports && WINDOW.document) {

@@ -39,2 +47,5 @@ WINDOW.document.addEventListener('visibilitychange', () => {

this._flushOutcomes();
if (enableLogs) {
_INTERNAL_flushLogsBuffer(client);
}
}

@@ -44,6 +55,22 @@ });

if (this._options.sendDefaultPii) {
this.on('postprocessEvent', addAutoIpAddressToUser);
this.on('beforeSendSession', addAutoIpAddressToSession);
if (enableLogs) {
client.on('flush', () => {
_INTERNAL_flushLogsBuffer(client);
});
client.on('afterCaptureLog', () => {
if (client._logFlushIdleTimeout) {
clearTimeout(client._logFlushIdleTimeout);
}
client._logFlushIdleTimeout = setTimeout(() => {
_INTERNAL_flushLogsBuffer(client);
}, DEFAULT_FLUSH_INTERVAL);
});
}
if (sendDefaultPii) {
client.on('postprocessEvent', addAutoIpAddressToUser);
client.on('beforeSendSession', addAutoIpAddressToSession);
}
}

@@ -50,0 +77,0 @@

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

export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, continueTrace, createTransport, dedupeIntegration, endSession, eventFiltersIntegration, extraErrorDataIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, inboundFiltersIntegration, isInitialized, lastEventId, makeMultiplexedTransport, moduleMetadataIntegration, parameterize, registerSpanErrorInstrumentation, rewriteFramesIntegration, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanToBaggageHeader, spanToJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, suppressTracing, thirdPartyErrorFilterIntegration, updateSpanName, withActiveSpan, withIsolationScope, withScope, zodErrorsIntegration } from '@sentry/core';
export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleLoggingIntegration, continueTrace, createTransport, dedupeIntegration, endSession, eventFiltersIntegration, extraErrorDataIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, inboundFiltersIntegration, isInitialized, lastEventId, makeMultiplexedTransport, moduleMetadataIntegration, parameterize, registerSpanErrorInstrumentation, rewriteFramesIntegration, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanToBaggageHeader, spanToJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, suppressTracing, thirdPartyErrorFilterIntegration, updateSpanName, withActiveSpan, withIsolationScope, withScope, zodErrorsIntegration } from '@sentry/core';
export { WINDOW } from './helpers.js';

@@ -3,0 +3,0 @@ export { BrowserClient } from './client.js';

@@ -22,3 +22,2 @@ import { defineIntegration, applyAggregateErrorsToEvent } from '@sentry/core';

options.stackParser,
options.maxValueLength,
key,

@@ -25,0 +24,0 @@ limit,

@@ -1,52 +0,5 @@

import { getClient, _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer } from '@sentry/core';
import { _INTERNAL_captureLog } from '@sentry/core';
export { fmt } from '@sentry/core';
import { WINDOW } from './helpers.js';
/**
* TODO: Make this configurable
*/
const DEFAULT_FLUSH_INTERVAL = 5000;
let timeout;
/**
* This is a global timeout that is used to flush the logs buffer.
* It is used to ensure that logs are flushed even if the client is not flushed.
*/
function startFlushTimeout(client) {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
_INTERNAL_flushLogsBuffer(client);
}, DEFAULT_FLUSH_INTERVAL);
}
let isClientListenerAdded = false;
/**
* This is a function that is used to add a flush listener to the client.
* It is used to ensure that the logger buffer is flushed when the client is flushed.
*/
function addFlushingListeners(client) {
if (isClientListenerAdded || !client.getOptions()._experiments?.enableLogs) {
return;
}
isClientListenerAdded = true;
if (WINDOW.document) {
WINDOW.document.addEventListener('visibilitychange', () => {
if (WINDOW.document.visibilityState === 'hidden') {
_INTERNAL_flushLogsBuffer(client);
}
});
}
client.on('flush', () => {
_INTERNAL_flushLogsBuffer(client);
});
}
/**
* Capture a log with the given level.

@@ -65,10 +18,3 @@ *

) {
const client = getClient();
if (client) {
addFlushingListeners(client);
startFlushTimeout(client);
}
_INTERNAL_captureLog({ level, message, attributes, severityNumber }, client, undefined);
_INTERNAL_captureLog({ level, message, attributes, severityNumber });
}

@@ -75,0 +21,0 @@

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

{"type":"module","version":"9.10.1","sideEffects":false}
{"type":"module","version":"9.11.0","sideEffects":false}

@@ -19,2 +19,4 @@ import { spanToJSON, logger, SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE } from '@sentry/core';

const PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE = 'sentry.previous_trace';
/**

@@ -40,3 +42,4 @@ * Adds a previous_trace span link to the passed span if the passed

if (previousTraceInfo.spanContext.traceId === spanJson.trace_id) {
const previousTraceSpanCtx = previousTraceInfo.spanContext;
if (previousTraceSpanCtx.traceId === spanJson.trace_id) {
// This means, we're still in the same trace so let's not update the previous trace info

@@ -56,3 +59,3 @@ // or add a link to the current span.

logger.info(
`Adding previous_trace ${previousTraceInfo.spanContext} link to span ${{
`Adding previous_trace ${previousTraceSpanCtx} link to span ${{
op: spanJson.op,

@@ -65,3 +68,3 @@ ...span.spanContext(),

span.addLink({
context: previousTraceInfo.spanContext,
context: previousTraceSpanCtx,
attributes: {

@@ -71,2 +74,13 @@ [SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace',

});
// TODO: Remove this once EAP can store span links. We currently only set this attribute so that we
// can obtain the previous trace information from the EAP store. Long-term, EAP will handle
// span links and then we should remove this again. Also throwing in a TODO(v10), to remind us
// to check this at v10 time :)
span.setAttribute(
PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE,
`${previousTraceSpanCtx.traceId}-${previousTraceSpanCtx.spanId}-${
previousTraceSpanCtx.traceFlags === 0x1 ? 1 : 0
}`,
);
}

@@ -105,3 +119,3 @@

export { PREVIOUS_TRACE_KEY, PREVIOUS_TRACE_MAX_DURATION, addPreviousTraceSpanLink, getPreviousTraceFromSessionStorage, storePreviousTraceInSessionStorage };
export { PREVIOUS_TRACE_KEY, PREVIOUS_TRACE_MAX_DURATION, PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE, addPreviousTraceSpanLink, getPreviousTraceFromSessionStorage, storePreviousTraceInSessionStorage };
//# sourceMappingURL=previousTrace.js.map

@@ -43,2 +43,3 @@ import { BrowserClientProfilingOptions, BrowserClientReplayOptions, ClientOptions, Event, EventHint, Options, ParameterizedString, Scope, SeverityLevel } from '@sentry/core';

export declare class BrowserClient extends Client<BrowserClientOptions> {
private _logFlushIdleTimeout;
/**

@@ -45,0 +46,0 @@ * Creates a new Browser SDK instance.

@@ -8,3 +8,3 @@ export * from './exports';

export { graphqlClientIntegration } from './integrations/graphqlClient';
export { captureConsoleIntegration, extraErrorDataIntegration, rewriteFramesIntegration, captureFeedback, } from '@sentry/core';
export { captureConsoleIntegration, extraErrorDataIntegration, rewriteFramesIntegration, captureFeedback, consoleLoggingIntegration, } from '@sentry/core';
export { replayIntegration, getReplay } from '@sentry-internal/replay';

@@ -11,0 +11,0 @@ export { ReplayEventType, ReplayEventWithTime, ReplayBreadcrumbFrame, ReplayBreadcrumbFrameEvent, ReplayOptionFrameEvent, ReplayFrame, ReplayFrameEvent, ReplaySpanFrame, ReplaySpanFrameEvent, } from '@sentry-internal/replay';

@@ -15,2 +15,3 @@ import { Span } from '@sentry/core';

export declare const PREVIOUS_TRACE_KEY = "sentry_previous_trace";
export declare const PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE = "sentry.previous_trace";
/**

@@ -17,0 +18,0 @@ * Adds a previous_trace span link to the passed span if the passed

@@ -43,2 +43,3 @@ import type { BrowserClientProfilingOptions, BrowserClientReplayOptions, ClientOptions, Event, EventHint, Options, ParameterizedString, Scope, SeverityLevel } from '@sentry/core';

export declare class BrowserClient extends Client<BrowserClientOptions> {
private _logFlushIdleTimeout;
/**

@@ -45,0 +46,0 @@ * Creates a new Browser SDK instance.

@@ -8,3 +8,3 @@ export * from './exports';

export { graphqlClientIntegration } from './integrations/graphqlClient';
export { captureConsoleIntegration, extraErrorDataIntegration, rewriteFramesIntegration, captureFeedback, } from '@sentry/core';
export { captureConsoleIntegration, extraErrorDataIntegration, rewriteFramesIntegration, captureFeedback, consoleLoggingIntegration, } from '@sentry/core';
export { replayIntegration, getReplay } from '@sentry-internal/replay';

@@ -11,0 +11,0 @@ export type { ReplayEventType, ReplayEventWithTime, ReplayBreadcrumbFrame, ReplayBreadcrumbFrameEvent, ReplayOptionFrameEvent, ReplayFrame, ReplayFrameEvent, ReplaySpanFrame, ReplaySpanFrameEvent, } from '@sentry-internal/replay';

@@ -15,2 +15,3 @@ import type { Span } from '@sentry/core';

export declare const PREVIOUS_TRACE_KEY = "sentry_previous_trace";
export declare const PREVIOUS_TRACE_TMP_SPAN_ATTRIBUTE = "sentry.previous_trace";
/**

@@ -17,0 +18,0 @@ * Adds a previous_trace span link to the passed span if the passed

{
"name": "@sentry/browser",
"version": "9.10.1",
"version": "9.11.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.10.1",
"@sentry-internal/feedback": "9.10.1",
"@sentry-internal/replay": "9.10.1",
"@sentry-internal/replay-canvas": "9.10.1",
"@sentry/core": "9.10.1"
"@sentry-internal/browser-utils": "9.11.0",
"@sentry-internal/feedback": "9.11.0",
"@sentry-internal/replay": "9.11.0",
"@sentry-internal/replay-canvas": "9.11.0",
"@sentry/core": "9.11.0"
},
"devDependencies": {
"@sentry-internal/integration-shims": "9.10.1",
"@sentry-internal/integration-shims": "9.11.0",
"fake-indexeddb": "^4.0.1"

@@ -71,2 +71,3 @@ },

"lint": "eslint . --format stylish",
"lint:es-compatibility": "es-check es2020 ./build/{bundles,npm/cjs}/*.js && es-check es2020 ./build/npm/esm/*.js --module",
"size:check": "cat build/bundles/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES2017: \",$1,\"kB\";}'",

@@ -73,0 +74,0 @@ "test": "vitest run",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet