Socket
Socket
Sign inDemoInstall

@sentry/core

Package Overview
Dependencies
Maintainers
11
Versions
521
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/core - npm Package Compare versions

Comparing version 8.0.0-beta.4 to 8.0.0-beta.5

75

cjs/baseclient.js

@@ -98,19 +98,22 @@ Object.defineProperty(exports, '__esModule', { value: true });

captureException(exception, hint, scope) {
const eventId = utils.uuid4();
// ensure we haven't captured this very object before
if (utils.checkOrSetAlreadyCaught(exception)) {
debugBuild.DEBUG_BUILD && utils.logger.log(ALREADY_SEEN_ERROR);
return;
return eventId;
}
let eventId = hint && hint.event_id;
const hintWithEventId = {
event_id: eventId,
...hint,
};
this._process(
this.eventFromException(exception, hint)
.then(event => this._captureEvent(event, hint, scope))
.then(result => {
eventId = result;
}),
this.eventFromException(exception, hintWithEventId).then(event =>
this._captureEvent(event, hintWithEventId, scope),
),
);
return eventId;
return hintWithEventId.event_id;
}

@@ -125,5 +128,8 @@

hint,
scope,
currentScope,
) {
let eventId = hint && hint.event_id;
const hintWithEventId = {
event_id: utils.uuid4(),
...hint,
};

@@ -133,14 +139,8 @@ const eventMessage = utils.isParameterizedString(message) ? message : String(message);

const promisedEvent = utils.isPrimitive(message)
? this.eventFromMessage(eventMessage, level, hint)
: this.eventFromException(message, hint);
? this.eventFromMessage(eventMessage, level, hintWithEventId)
: this.eventFromException(message, hintWithEventId);
this._process(
promisedEvent
.then(event => this._captureEvent(event, hint, scope))
.then(result => {
eventId = result;
}),
);
this._process(promisedEvent.then(event => this._captureEvent(event, hintWithEventId, currentScope)));
return eventId;
return hintWithEventId.event_id;
}

@@ -151,10 +151,15 @@

*/
captureEvent(event, hint, scope) {
captureEvent(event, hint, currentScope) {
const eventId = utils.uuid4();
// ensure we haven't captured this very object before
if (hint && hint.originalException && utils.checkOrSetAlreadyCaught(hint.originalException)) {
debugBuild.DEBUG_BUILD && utils.logger.log(ALREADY_SEEN_ERROR);
return;
return eventId;
}
let eventId = hint && hint.event_id;
const hintWithEventId = {
event_id: eventId,
...hint,
};

@@ -164,9 +169,5 @@ const sdkProcessingMetadata = event.sdkProcessingMetadata || {};

this._process(
this._captureEvent(event, hint, capturedSpanScope || scope).then(result => {
eventId = result;
}),
);
this._process(this._captureEvent(event, hintWithEventId, capturedSpanScope || currentScope));
return eventId;
return hintWithEventId.event_id;
}

@@ -463,3 +464,3 @@

* @param hint May contain additional information about the original exception.
* @param scope A scope containing event metadata.
* @param currentScope A scope containing event metadata.
* @returns A new event with more information.

@@ -470,3 +471,3 @@ */

hint,
scope,
currentScope,
isolationScope = currentScopes.getIsolationScope(),

@@ -482,3 +483,3 @@ ) {

return prepareEvent.prepareEvent(options, event, hint, scope, this, isolationScope).then(evt => {
return prepareEvent.prepareEvent(options, event, hint, currentScope, this, isolationScope).then(evt => {
if (evt === null) {

@@ -490,3 +491,3 @@ return evt;

...isolationScope.getPropagationContext(),
...(scope ? scope.getPropagationContext() : undefined),
...(currentScope ? currentScope.getPropagationContext() : undefined),
};

@@ -554,6 +555,6 @@

* @param hint May contain additional information about the original exception.
* @param scope A scope containing event metadata.
* @param currentScope A scope containing event metadata.
* @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
*/
_processEvent(event, hint, scope) {
_processEvent(event, hint, currentScope) {
const options = this.getOptions();

@@ -586,3 +587,3 @@ const { sampleRate } = options;

return this._prepareEvent(event, hint, scope, capturedSpanIsolationScope)
return this._prepareEvent(event, hint, currentScope, capturedSpanIsolationScope)
.then(prepared => {

@@ -608,3 +609,3 @@ if (prepared === null) {

const session = scope && scope.getSession();
const session = currentScope && currentScope.getSession();
if (!isTransaction && session) {

@@ -611,0 +612,0 @@ this._updateSessionFromEvent(session, processedEvent);

Object.defineProperty(exports, '__esModule', { value: true });
const utils = require('@sentry/utils');
require('./tracing/errors.js');
require('./debug-build.js');
const spanUtils = require('./utils/spanUtils.js');
const dynamicSamplingContext = require('./tracing/dynamicSamplingContext.js');

@@ -108,6 +111,15 @@ /**

function createSpanEnvelope(spans) {
function dscHasRequiredProps(dsc) {
return !!dsc.trace_id && !!dsc.public_key;
}
// For the moment we'll obtain the DSC from the first span in the array
// This might need to be changed if we permit sending multiple spans from
// different segments in one envelope
const dsc = dynamicSamplingContext.getDynamicSamplingContextFromSpan(spans[0]);
const headers = {
sent_at: new Date().toISOString(),
...(dscHasRequiredProps(dsc) && { trace: dsc }),
};
const items = spans.map(span => utils.createSpanEnvelopeItem(spanUtils.spanToJSON(span)));

@@ -114,0 +126,0 @@ return utils.createEnvelope(headers, items);

@@ -147,24 +147,26 @@ Object.defineProperty(exports, '__esModule', { value: true });

let maybePromiseResult;
try {
maybePromiseResult = callback();
} catch (e) {
finishCheckIn('error');
throw e;
}
return currentScopes.withIsolationScope(() => {
let maybePromiseResult;
try {
maybePromiseResult = callback();
} catch (e) {
finishCheckIn('error');
throw e;
}
if (utils.isThenable(maybePromiseResult)) {
Promise.resolve(maybePromiseResult).then(
() => {
finishCheckIn('ok');
},
() => {
finishCheckIn('error');
},
);
} else {
finishCheckIn('ok');
}
if (utils.isThenable(maybePromiseResult)) {
Promise.resolve(maybePromiseResult).then(
() => {
finishCheckIn('ok');
},
() => {
finishCheckIn('error');
},
);
} else {
finishCheckIn('ok');
}
return maybePromiseResult;
return maybePromiseResult;
});
}

@@ -171,0 +173,0 @@

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

const span =
shouldCreateSpanResult && hasParent
? trace.startInactiveSpan({
name: `${method} ${url}`,
attributes: {
url,
type: 'fetch',
'http.method': method,
'http.url': fullUrl,
'server.address': host,
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',
},
})
: new sentryNonRecordingSpan.SentryNonRecordingSpan();
const span = shouldCreateSpanResult
? trace.startInactiveSpan({
name: `${method} ${url}`,
attributes: {
url,
type: 'fetch',
'http.method': method,
'http.url': fullUrl,
'server.address': host,
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
[semanticAttributes.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',
},
experimental: {
standalone: !hasParent,
},
})
: new sentryNonRecordingSpan.SentryNonRecordingSpan();

@@ -91,7 +93,5 @@ handlerData.fetchData.__span = span.spanContext().spanId;

options,
// In the following cases, we do not want to use the span as base for the trace headers,
// which means that the headers will be generated from the scope:
// - If tracing is disabled (TWP)
// - If the span has no parent span - which means we ran into `onlyIfParent` check
hasTracingEnabled.hasTracingEnabled() && hasParent ? span : undefined,
// If performance is disabled (TWP), we do not want to use the span as base for the trace headers,
// which means that the headers will be generated from the scope and the sampling decision is deferred
hasTracingEnabled.hasTracingEnabled() ? span : undefined,
);

@@ -98,0 +98,0 @@ }

@@ -56,6 +56,8 @@ Object.defineProperty(exports, '__esModule', { value: true });

if (level === 'assert' && args[0] === false) {
const message = `Assertion failed: ${utils.safeJoin(args.slice(1), ' ') || 'console.assert'}`;
scope.setExtra('arguments', args.slice(1));
exports$1.captureMessage(message, captureContext);
if (level === 'assert') {
if (!args[0]) {
const message = `Assertion failed: ${utils.safeJoin(args.slice(1), ' ') || 'console.assert'}`;
scope.setExtra('arguments', args.slice(1));
exports$1.captureMessage(message, captureContext);
}
return;

@@ -62,0 +64,0 @@ }

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

const integration = require('../integration.js');
const spanUtils = require('../utils/spanUtils.js');

@@ -47,8 +46,7 @@ const DEFAULT_OPTIONS = {

name: INTEGRATION_NAME,
processEvent(event, _hint, client) {
processEvent(event) {
// Note: In the long run, most of the logic here should probably move into the request data utility functions. For
// the moment it lives here, though, until https://github.com/getsentry/sentry-javascript/issues/5718 is addressed.
// (TL;DR: Those functions touch many parts of the repo in many different ways, and need to be clened up. Once
// (TL;DR: Those functions touch many parts of the repo in many different ways, and need to be cleaned up. Once
// that's happened, it will be easier to add this logic in without worrying about unexpected side effects.)
const { transactionNamingScheme } = _options;

@@ -64,34 +62,3 @@ const { sdkProcessingMetadata = {} } = event;

const processedEvent = utils.addRequestDataToEvent(event, req, addRequestDataOptions);
// Transaction events already have the right `transaction` value
if (event.type === 'transaction' || transactionNamingScheme === 'handler') {
return processedEvent;
}
// In all other cases, use the request's associated transaction (if any) to overwrite the event's `transaction`
// value with a high-quality one
const reqWithTransaction = req ;
const transaction = reqWithTransaction._sentryTransaction;
if (transaction) {
const name = spanUtils.spanToJSON(transaction).description || '';
// TODO (v8): Remove the nextjs check and just base it on `transactionNamingScheme` for all SDKs. (We have to
// keep it the way it is for the moment, because changing the names of transactions in Sentry has the potential
// to break things like alert rules.)
const shouldIncludeMethodInTransactionName =
getSDKName(client) === 'sentry.javascript.nextjs'
? name.startsWith('/api')
: transactionNamingScheme !== 'path';
const [transactionValue] = utils.extractPathForTransaction(req, {
path: true,
method: shouldIncludeMethodInTransactionName,
customRoute: name,
});
processedEvent.transaction = transactionValue;
}
return processedEvent;
return utils.addRequestDataToEvent(event, req, addRequestDataOptions);
},

@@ -149,15 +116,3 @@ };

function getSDKName(client) {
try {
// For a long chain like this, it's fewer bytes to combine a try-catch with assuming everything is there than to
// write out a long chain of `a && a.b && a.b.c && ...`
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return client.getOptions()._metadata.sdk.name;
} catch (err) {
// In theory we should never get here
return undefined;
}
}
exports.requestDataIntegration = requestDataIntegration;
//# sourceMappingURL=requestdata.js.map

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

const debugBuild = require('../debug-build.js');
const envelope = require('../envelope.js');
const metricSummary = require('../metrics/metric-summary.js');

@@ -28,2 +29,4 @@ const semanticAttributes = require('../semanticAttributes.js');

/** if true, treat span as a standalone span (not part of a transaction) */
/**

@@ -67,2 +70,4 @@ * You should never call the constructor manually, always use `Sentry.startSpan()`

}
this._isStandaloneSpan = spanContext.isStandalone;
}

@@ -160,2 +165,4 @@

measurements: measurement.timedEventsToMeasurements(this._events),
is_segment: (this._isStandaloneSpan && spanUtils.getRootSpan(this) === this) || undefined,
segment_id: this._isStandaloneSpan ? spanUtils.getRootSpan(this).spanContext().spanId : undefined,
});

@@ -193,2 +200,14 @@ }

/**
* This method should generally not be used,
* but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.
* USE THIS WITH CAUTION!
* @internal
* @hidden
* @experimental
*/
isStandaloneSpan() {
return !!this._isStandaloneSpan;
}
/** Emit `spanEnd` when the span is ended. */

@@ -201,10 +220,22 @@ _onSpanEnded() {

// If this is a root span, send it when it is endedf
if (this === spanUtils.getRootSpan(this)) {
const transactionEvent = this._convertSpanToTransaction();
if (transactionEvent) {
const scope = utils$1.getCapturedScopesOnSpan(this).scope || currentScopes.getCurrentScope();
scope.captureEvent(transactionEvent);
}
// A segment span is basically the root span of a local span tree.
// So for now, this is either what we previously refer to as the root span,
// or a standalone span.
const isSegmentSpan = this._isStandaloneSpan || this === spanUtils.getRootSpan(this);
if (!isSegmentSpan) {
return;
}
// if this is a standalone span, we send it immediately
if (this._isStandaloneSpan) {
sendSpanEnvelope(envelope.createSpanEnvelope([this]));
return;
}
const transactionEvent = this._convertSpanToTransaction();
if (transactionEvent) {
const scope = utils$1.getCapturedScopesOnSpan(this).scope || currentScopes.getCurrentScope();
scope.captureEvent(transactionEvent);
}
}

@@ -241,4 +272,4 @@

// The transaction span itself should be filtered out
const finishedSpans = spanUtils.getSpanDescendants(this).filter(span => span !== this);
// The transaction span itself as well as any potential standalone spans should be filtered out
const finishedSpans = spanUtils.getSpanDescendants(this).filter(span => span !== this && !isStandaloneSpan(span));

@@ -295,3 +326,22 @@ const spans = finishedSpans.map(span => spanUtils.spanToJSON(span)).filter(isFullFinishedSpan);

/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */
function isStandaloneSpan(span) {
return span instanceof SentrySpan && span.isStandaloneSpan();
}
function sendSpanEnvelope(envelope) {
const client = currentScopes.getClient();
if (!client) {
return;
}
const transport = client.getTransport();
if (transport) {
transport.send(envelope).then(null, reason => {
debugBuild.DEBUG_BUILD && utils.logger.error('Error while sending span:', reason);
});
}
}
exports.SentrySpan = SentrySpan;
//# sourceMappingURL=sentrySpan.js.map

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

? new sentryNonRecordingSpan.SentryNonRecordingSpan()
: createChildSpanOrTransaction({
: createChildOrRootSpan({
parentSpan,

@@ -94,3 +94,3 @@ spanContext,

? new sentryNonRecordingSpan.SentryNonRecordingSpan()
: createChildSpanOrTransaction({
: createChildOrRootSpan({
parentSpan,

@@ -147,3 +147,3 @@ spanContext,

return createChildSpanOrTransaction({
return createChildOrRootSpan({
parentSpan,

@@ -215,3 +215,3 @@ spanContext,

function createChildSpanOrTransaction({
function createChildOrRootSpan({
parentSpan,

@@ -292,4 +292,10 @@ spanContext,

function normalizeContext(context) {
const exp = context.experimental || {};
const initialCtx = {
isStandalone: exp.standalone,
...context,
};
if (context.startTime) {
const ctx = { ...context };
const ctx = { ...initialCtx };
ctx.startTimestamp = spanUtils.spanTimeInputToSeconds(context.startTime);

@@ -300,3 +306,3 @@ delete ctx.startTime;

return context;
return initialCtx;
}

@@ -303,0 +309,0 @@

Object.defineProperty(exports, '__esModule', { value: true });
const SDK_VERSION = '8.0.0-beta.4';
const SDK_VERSION = '8.0.0-beta.5';
exports.SDK_VERSION = SDK_VERSION;
//# sourceMappingURL=version.js.map

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

import { makeDsn, logger, checkOrSetAlreadyCaught, isParameterizedString, isPrimitive, resolvedSyncPromise, addItemToEnvelope, createAttachmentEnvelopeItem, SyncPromise, rejectedSyncPromise, SentryError, isThenable, isPlainObject } from '@sentry/utils';
import { makeDsn, logger, uuid4, checkOrSetAlreadyCaught, isParameterizedString, isPrimitive, resolvedSyncPromise, addItemToEnvelope, createAttachmentEnvelopeItem, SyncPromise, rejectedSyncPromise, SentryError, isThenable, isPlainObject } from '@sentry/utils';
import { getEnvelopeEndpointWithUrlEncodedAuth } from './api.js';

@@ -96,19 +96,22 @@ import { getIsolationScope } from './currentScopes.js';

captureException(exception, hint, scope) {
const eventId = uuid4();
// ensure we haven't captured this very object before
if (checkOrSetAlreadyCaught(exception)) {
DEBUG_BUILD && logger.log(ALREADY_SEEN_ERROR);
return;
return eventId;
}
let eventId = hint && hint.event_id;
const hintWithEventId = {
event_id: eventId,
...hint,
};
this._process(
this.eventFromException(exception, hint)
.then(event => this._captureEvent(event, hint, scope))
.then(result => {
eventId = result;
}),
this.eventFromException(exception, hintWithEventId).then(event =>
this._captureEvent(event, hintWithEventId, scope),
),
);
return eventId;
return hintWithEventId.event_id;
}

@@ -123,5 +126,8 @@

hint,
scope,
currentScope,
) {
let eventId = hint && hint.event_id;
const hintWithEventId = {
event_id: uuid4(),
...hint,
};

@@ -131,14 +137,8 @@ const eventMessage = isParameterizedString(message) ? message : String(message);

const promisedEvent = isPrimitive(message)
? this.eventFromMessage(eventMessage, level, hint)
: this.eventFromException(message, hint);
? this.eventFromMessage(eventMessage, level, hintWithEventId)
: this.eventFromException(message, hintWithEventId);
this._process(
promisedEvent
.then(event => this._captureEvent(event, hint, scope))
.then(result => {
eventId = result;
}),
);
this._process(promisedEvent.then(event => this._captureEvent(event, hintWithEventId, currentScope)));
return eventId;
return hintWithEventId.event_id;
}

@@ -149,10 +149,15 @@

*/
captureEvent(event, hint, scope) {
captureEvent(event, hint, currentScope) {
const eventId = uuid4();
// ensure we haven't captured this very object before
if (hint && hint.originalException && checkOrSetAlreadyCaught(hint.originalException)) {
DEBUG_BUILD && logger.log(ALREADY_SEEN_ERROR);
return;
return eventId;
}
let eventId = hint && hint.event_id;
const hintWithEventId = {
event_id: eventId,
...hint,
};

@@ -162,9 +167,5 @@ const sdkProcessingMetadata = event.sdkProcessingMetadata || {};

this._process(
this._captureEvent(event, hint, capturedSpanScope || scope).then(result => {
eventId = result;
}),
);
this._process(this._captureEvent(event, hintWithEventId, capturedSpanScope || currentScope));
return eventId;
return hintWithEventId.event_id;
}

@@ -461,3 +462,3 @@

* @param hint May contain additional information about the original exception.
* @param scope A scope containing event metadata.
* @param currentScope A scope containing event metadata.
* @returns A new event with more information.

@@ -468,3 +469,3 @@ */

hint,
scope,
currentScope,
isolationScope = getIsolationScope(),

@@ -480,3 +481,3 @@ ) {

return prepareEvent(options, event, hint, scope, this, isolationScope).then(evt => {
return prepareEvent(options, event, hint, currentScope, this, isolationScope).then(evt => {
if (evt === null) {

@@ -488,3 +489,3 @@ return evt;

...isolationScope.getPropagationContext(),
...(scope ? scope.getPropagationContext() : undefined),
...(currentScope ? currentScope.getPropagationContext() : undefined),
};

@@ -552,6 +553,6 @@

* @param hint May contain additional information about the original exception.
* @param scope A scope containing event metadata.
* @param currentScope A scope containing event metadata.
* @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
*/
_processEvent(event, hint, scope) {
_processEvent(event, hint, currentScope) {
const options = this.getOptions();

@@ -584,3 +585,3 @@ const { sampleRate } = options;

return this._prepareEvent(event, hint, scope, capturedSpanIsolationScope)
return this._prepareEvent(event, hint, currentScope, capturedSpanIsolationScope)
.then(prepared => {

@@ -606,3 +607,3 @@ if (prepared === null) {

const session = scope && scope.getSession();
const session = currentScope && currentScope.getSession();
if (!isTransaction && session) {

@@ -609,0 +610,0 @@ this._updateSessionFromEvent(session, processedEvent);

import { getSdkMetadataForEnvelopeHeader, dsnToString, createEnvelope, createEventEnvelopeHeaders, createAttachmentEnvelopeItem, createSpanEnvelopeItem } from '@sentry/utils';
import './tracing/errors.js';
import './debug-build.js';
import { spanToJSON } from './utils/spanUtils.js';
import { getDynamicSamplingContextFromSpan } from './tracing/dynamicSamplingContext.js';

@@ -106,6 +109,15 @@ /**

function createSpanEnvelope(spans) {
function dscHasRequiredProps(dsc) {
return !!dsc.trace_id && !!dsc.public_key;
}
// For the moment we'll obtain the DSC from the first span in the array
// This might need to be changed if we permit sending multiple spans from
// different segments in one envelope
const dsc = getDynamicSamplingContextFromSpan(spans[0]);
const headers = {
sent_at: new Date().toISOString(),
...(dscHasRequiredProps(dsc) && { trace: dsc }),
};
const items = spans.map(span => createSpanEnvelopeItem(spanToJSON(span)));

@@ -112,0 +124,0 @@ return createEnvelope(headers, items);

import { logger, uuid4, timestampInSeconds, isThenable, GLOBAL_OBJ } from '@sentry/utils';
import { DEFAULT_ENVIRONMENT } from './constants.js';
import { getCurrentScope, getIsolationScope, getClient } from './currentScopes.js';
import { getCurrentScope, getIsolationScope, getClient, withIsolationScope } from './currentScopes.js';
import { DEBUG_BUILD } from './debug-build.js';

@@ -145,24 +145,26 @@ import { makeSession, updateSession, closeSession } from './session.js';

let maybePromiseResult;
try {
maybePromiseResult = callback();
} catch (e) {
finishCheckIn('error');
throw e;
}
return withIsolationScope(() => {
let maybePromiseResult;
try {
maybePromiseResult = callback();
} catch (e) {
finishCheckIn('error');
throw e;
}
if (isThenable(maybePromiseResult)) {
Promise.resolve(maybePromiseResult).then(
() => {
finishCheckIn('ok');
},
() => {
finishCheckIn('error');
},
);
} else {
finishCheckIn('ok');
}
if (isThenable(maybePromiseResult)) {
Promise.resolve(maybePromiseResult).then(
() => {
finishCheckIn('ok');
},
() => {
finishCheckIn('error');
},
);
} else {
finishCheckIn('ok');
}
return maybePromiseResult;
return maybePromiseResult;
});
}

@@ -169,0 +171,0 @@

@@ -55,17 +55,19 @@ import { parseUrl, generateSentryTraceHeader, dynamicSamplingContextToSentryBaggageHeader, isInstanceOf, BAGGAGE_HEADER_NAME } from '@sentry/utils';

const span =
shouldCreateSpanResult && hasParent
? startInactiveSpan({
name: `${method} ${url}`,
attributes: {
url,
type: 'fetch',
'http.method': method,
'http.url': fullUrl,
'server.address': host,
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',
},
})
: new SentryNonRecordingSpan();
const span = shouldCreateSpanResult
? startInactiveSpan({
name: `${method} ${url}`,
attributes: {
url,
type: 'fetch',
'http.method': method,
'http.url': fullUrl,
'server.address': host,
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanOrigin,
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.client',
},
experimental: {
standalone: !hasParent,
},
})
: new SentryNonRecordingSpan();

@@ -89,7 +91,5 @@ handlerData.fetchData.__span = span.spanContext().spanId;

options,
// In the following cases, we do not want to use the span as base for the trace headers,
// which means that the headers will be generated from the scope:
// - If tracing is disabled (TWP)
// - If the span has no parent span - which means we ran into `onlyIfParent` check
hasTracingEnabled() && hasParent ? span : undefined,
// If performance is disabled (TWP), we do not want to use the span as base for the trace headers,
// which means that the headers will be generated from the scope and the sampling decision is deferred
hasTracingEnabled() ? span : undefined,
);

@@ -96,0 +96,0 @@ }

@@ -54,6 +54,8 @@ import { CONSOLE_LEVELS, GLOBAL_OBJ, addConsoleInstrumentationHandler, severityLevelFromString, addExceptionMechanism, safeJoin } from '@sentry/utils';

if (level === 'assert' && args[0] === false) {
const message = `Assertion failed: ${safeJoin(args.slice(1), ' ') || 'console.assert'}`;
scope.setExtra('arguments', args.slice(1));
captureMessage(message, captureContext);
if (level === 'assert') {
if (!args[0]) {
const message = `Assertion failed: ${safeJoin(args.slice(1), ' ') || 'console.assert'}`;
scope.setExtra('arguments', args.slice(1));
captureMessage(message, captureContext);
}
return;

@@ -60,0 +62,0 @@ }

@@ -1,4 +0,3 @@

import { addRequestDataToEvent, extractPathForTransaction } from '@sentry/utils';
import { addRequestDataToEvent } from '@sentry/utils';
import { defineIntegration } from '../integration.js';
import { spanToJSON } from '../utils/spanUtils.js';

@@ -44,8 +43,7 @@ const DEFAULT_OPTIONS = {

name: INTEGRATION_NAME,
processEvent(event, _hint, client) {
processEvent(event) {
// Note: In the long run, most of the logic here should probably move into the request data utility functions. For
// the moment it lives here, though, until https://github.com/getsentry/sentry-javascript/issues/5718 is addressed.
// (TL;DR: Those functions touch many parts of the repo in many different ways, and need to be clened up. Once
// (TL;DR: Those functions touch many parts of the repo in many different ways, and need to be cleaned up. Once
// that's happened, it will be easier to add this logic in without worrying about unexpected side effects.)
const { transactionNamingScheme } = _options;

@@ -61,34 +59,3 @@ const { sdkProcessingMetadata = {} } = event;

const processedEvent = addRequestDataToEvent(event, req, addRequestDataOptions);
// Transaction events already have the right `transaction` value
if (event.type === 'transaction' || transactionNamingScheme === 'handler') {
return processedEvent;
}
// In all other cases, use the request's associated transaction (if any) to overwrite the event's `transaction`
// value with a high-quality one
const reqWithTransaction = req ;
const transaction = reqWithTransaction._sentryTransaction;
if (transaction) {
const name = spanToJSON(transaction).description || '';
// TODO (v8): Remove the nextjs check and just base it on `transactionNamingScheme` for all SDKs. (We have to
// keep it the way it is for the moment, because changing the names of transactions in Sentry has the potential
// to break things like alert rules.)
const shouldIncludeMethodInTransactionName =
getSDKName(client) === 'sentry.javascript.nextjs'
? name.startsWith('/api')
: transactionNamingScheme !== 'path';
const [transactionValue] = extractPathForTransaction(req, {
path: true,
method: shouldIncludeMethodInTransactionName,
customRoute: name,
});
processedEvent.transaction = transactionValue;
}
return processedEvent;
return addRequestDataToEvent(event, req, addRequestDataOptions);
},

@@ -146,15 +113,3 @@ };

function getSDKName(client) {
try {
// For a long chain like this, it's fewer bytes to combine a try-catch with assuming everything is there than to
// write out a long chain of `a && a.b && a.b.c && ...`
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return client.getOptions()._metadata.sdk.name;
} catch (err) {
// In theory we should never get here
return undefined;
}
}
export { requestDataIntegration };
//# sourceMappingURL=requestdata.js.map
import { uuid4, timestampInSeconds, dropUndefinedKeys, logger } from '@sentry/utils';
import { getClient, getCurrentScope } from '../currentScopes.js';
import { DEBUG_BUILD } from '../debug-build.js';
import { createSpanEnvelope } from '../envelope.js';
import { getMetricSummaryJsonForSpan } from '../metrics/metric-summary.js';

@@ -25,2 +26,4 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_PROFILE_ID, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '../semanticAttributes.js';

/** if true, treat span as a standalone span (not part of a transaction) */
/**

@@ -64,2 +67,4 @@ * You should never call the constructor manually, always use `Sentry.startSpan()`

}
this._isStandaloneSpan = spanContext.isStandalone;
}

@@ -157,2 +162,4 @@

measurements: timedEventsToMeasurements(this._events),
is_segment: (this._isStandaloneSpan && getRootSpan(this) === this) || undefined,
segment_id: this._isStandaloneSpan ? getRootSpan(this).spanContext().spanId : undefined,
});

@@ -190,2 +197,14 @@ }

/**
* This method should generally not be used,
* but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.
* USE THIS WITH CAUTION!
* @internal
* @hidden
* @experimental
*/
isStandaloneSpan() {
return !!this._isStandaloneSpan;
}
/** Emit `spanEnd` when the span is ended. */

@@ -198,10 +217,22 @@ _onSpanEnded() {

// If this is a root span, send it when it is endedf
if (this === getRootSpan(this)) {
const transactionEvent = this._convertSpanToTransaction();
if (transactionEvent) {
const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();
scope.captureEvent(transactionEvent);
}
// A segment span is basically the root span of a local span tree.
// So for now, this is either what we previously refer to as the root span,
// or a standalone span.
const isSegmentSpan = this._isStandaloneSpan || this === getRootSpan(this);
if (!isSegmentSpan) {
return;
}
// if this is a standalone span, we send it immediately
if (this._isStandaloneSpan) {
sendSpanEnvelope(createSpanEnvelope([this]));
return;
}
const transactionEvent = this._convertSpanToTransaction();
if (transactionEvent) {
const scope = getCapturedScopesOnSpan(this).scope || getCurrentScope();
scope.captureEvent(transactionEvent);
}
}

@@ -238,4 +269,4 @@

// The transaction span itself should be filtered out
const finishedSpans = getSpanDescendants(this).filter(span => span !== this);
// The transaction span itself as well as any potential standalone spans should be filtered out
const finishedSpans = getSpanDescendants(this).filter(span => span !== this && !isStandaloneSpan(span));

@@ -292,3 +323,22 @@ const spans = finishedSpans.map(span => spanToJSON(span)).filter(isFullFinishedSpan);

/** `SentrySpan`s can be sent as a standalone span rather than belonging to a transaction */
function isStandaloneSpan(span) {
return span instanceof SentrySpan && span.isStandaloneSpan();
}
function sendSpanEnvelope(envelope) {
const client = getClient();
if (!client) {
return;
}
const transport = client.getTransport();
if (transport) {
transport.send(envelope).then(null, reason => {
DEBUG_BUILD && logger.error('Error while sending span:', reason);
});
}
}
export { SentrySpan };
//# sourceMappingURL=sentrySpan.js.map

@@ -44,3 +44,3 @@ import { propagationContextFromHeaders } from '@sentry/utils';

? new SentryNonRecordingSpan()
: createChildSpanOrTransaction({
: createChildOrRootSpan({
parentSpan,

@@ -92,3 +92,3 @@ spanContext,

? new SentryNonRecordingSpan()
: createChildSpanOrTransaction({
: createChildOrRootSpan({
parentSpan,

@@ -145,3 +145,3 @@ spanContext,

return createChildSpanOrTransaction({
return createChildOrRootSpan({
parentSpan,

@@ -213,3 +213,3 @@ spanContext,

function createChildSpanOrTransaction({
function createChildOrRootSpan({
parentSpan,

@@ -290,4 +290,10 @@ spanContext,

function normalizeContext(context) {
const exp = context.experimental || {};
const initialCtx = {
isStandalone: exp.standalone,
...context,
};
if (context.startTime) {
const ctx = { ...context };
const ctx = { ...initialCtx };
ctx.startTimestamp = spanTimeInputToSeconds(context.startTime);

@@ -298,3 +304,3 @@ delete ctx.startTime;

return context;
return initialCtx;
}

@@ -301,0 +307,0 @@

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

const SDK_VERSION = '8.0.0-beta.4';
const SDK_VERSION = '8.0.0-beta.5';
export { SDK_VERSION };
//# sourceMappingURL=version.js.map
{
"name": "@sentry/core",
"version": "8.0.0-beta.4",
"version": "8.0.0-beta.5",
"description": "Base implementation for all Sentry JavaScript SDKs",

@@ -45,4 +45,4 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

"dependencies": {
"@sentry/types": "8.0.0-beta.4",
"@sentry/utils": "8.0.0-beta.4"
"@sentry/types": "8.0.0-beta.5",
"@sentry/utils": "8.0.0-beta.5"
},

@@ -49,0 +49,0 @@ "madge": {

@@ -58,11 +58,11 @@ import { Breadcrumb, BreadcrumbHint, Client, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, Integration, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, SeverityLevel, Span, SpanAttributes, SpanContextData, StartSpanOptions, Transport, TransportMakeRequestResponse } from '@sentry/types';

*/
captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined;
captureException(exception: any, hint?: EventHint, scope?: Scope): string;
/**
* @inheritDoc
*/
captureMessage(message: ParameterizedString, level?: SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined;
captureMessage(message: ParameterizedString, level?: SeverityLevel, hint?: EventHint, currentScope?: Scope): string;
/**
* @inheritDoc
*/
captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined;
captureEvent(event: Event, hint?: EventHint, currentScope?: Scope): string;
/**

@@ -240,6 +240,6 @@ * @inheritDoc

* @param hint May contain additional information about the original exception.
* @param scope A scope containing event metadata.
* @param currentScope A scope containing event metadata.
* @returns A new event with more information.
*/
protected _prepareEvent(event: Event, hint: EventHint, scope?: Scope, isolationScope?: import("@sentry/types").Scope): PromiseLike<Event | null>;
protected _prepareEvent(event: Event, hint: EventHint, currentScope?: Scope, isolationScope?: import("@sentry/types").Scope): PromiseLike<Event | null>;
/**

@@ -262,6 +262,6 @@ * Processes the event and logs an error in case of rejection

* @param hint May contain additional information about the original exception.
* @param scope A scope containing event metadata.
* @param currentScope A scope containing event metadata.
* @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
*/
protected _processEvent(event: Event, hint: EventHint, scope?: Scope): PromiseLike<Event>;
protected _processEvent(event: Event, hint: EventHint, currentScope?: Scope): PromiseLike<Event>;
/**

@@ -268,0 +268,0 @@ * Occupies the client with processing and event

@@ -34,7 +34,7 @@ import { BaseTransportOptions, CheckIn, ClientOptions, Event, EventHint, MonitorConfig, ParameterizedString, SeverityLevel } from '@sentry/types';

*/
captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined;
captureException(exception: any, hint?: EventHint, scope?: Scope): string;
/**
* @inheritDoc
*/
captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined;
captureEvent(event: Event, hint?: EventHint, scope?: Scope): string;
/**

@@ -41,0 +41,0 @@ *

@@ -20,2 +20,4 @@ import { SentrySpanArguments, Span, SpanAttributeValue, SpanAttributes, SpanContextData, SpanJSON, SpanStatus, SpanTimeInput, TimedEvent } from '@sentry/types';

protected _events: TimedEvent[];
/** if true, treat span as a standalone span (not part of a transaction) */
private _isStandaloneSpan?;
/**

@@ -69,2 +71,11 @@ * You should never call the constructor manually, always use `Sentry.startSpan()`

addEvent(name: string, attributesOrStartTime?: SpanAttributes | SpanTimeInput, startTime?: SpanTimeInput): this;
/**
* This method should generally not be used,
* but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.
* USE THIS WITH CAUTION!
* @internal
* @hidden
* @experimental
*/
isStandaloneSpan(): boolean;
/** Emit `spanEnd` when the span is ended. */

@@ -71,0 +82,0 @@ private _onSpanEnded;

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

export declare const SDK_VERSION = "8.0.0-beta.4";
export declare const SDK_VERSION = "8.0.0-beta.5";
//# sourceMappingURL=version.d.ts.map

@@ -58,11 +58,11 @@ import type { Breadcrumb, BreadcrumbHint, Client, ClientOptions, DataCategory, DsnComponents, DynamicSamplingContext, Envelope, Event, EventDropReason, EventHint, EventProcessor, FeedbackEvent, Integration, Outcome, ParameterizedString, SdkMetadata, Session, SessionAggregates, SeverityLevel, Span, SpanAttributes, SpanContextData, StartSpanOptions, Transport, TransportMakeRequestResponse } from '@sentry/types';

*/
captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined;
captureException(exception: any, hint?: EventHint, scope?: Scope): string;
/**
* @inheritDoc
*/
captureMessage(message: ParameterizedString, level?: SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined;
captureMessage(message: ParameterizedString, level?: SeverityLevel, hint?: EventHint, currentScope?: Scope): string;
/**
* @inheritDoc
*/
captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined;
captureEvent(event: Event, hint?: EventHint, currentScope?: Scope): string;
/**

@@ -240,6 +240,6 @@ * @inheritDoc

* @param hint May contain additional information about the original exception.
* @param scope A scope containing event metadata.
* @param currentScope A scope containing event metadata.
* @returns A new event with more information.
*/
protected _prepareEvent(event: Event, hint: EventHint, scope?: Scope, isolationScope?: import("@sentry/types").Scope): PromiseLike<Event | null>;
protected _prepareEvent(event: Event, hint: EventHint, currentScope?: Scope, isolationScope?: import("@sentry/types").Scope): PromiseLike<Event | null>;
/**

@@ -262,6 +262,6 @@ * Processes the event and logs an error in case of rejection

* @param hint May contain additional information about the original exception.
* @param scope A scope containing event metadata.
* @param currentScope A scope containing event metadata.
* @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send.
*/
protected _processEvent(event: Event, hint: EventHint, scope?: Scope): PromiseLike<Event>;
protected _processEvent(event: Event, hint: EventHint, currentScope?: Scope): PromiseLike<Event>;
/**

@@ -268,0 +268,0 @@ * Occupies the client with processing and event

import type { Attachment, DsnComponents, Event, EventEnvelope, SdkMetadata, Session, SessionAggregates, SessionEnvelope, SpanEnvelope } from '@sentry/types';
import type { SentrySpan } from './tracing';
import { type SentrySpan } from './tracing';
/** Creates an envelope from a Session */

@@ -4,0 +4,0 @@ export declare function createSessionEnvelope(session: Session | SessionAggregates, dsn?: DsnComponents, metadata?: SdkMetadata, tunnel?: string): SessionEnvelope;

@@ -34,7 +34,7 @@ import type { BaseTransportOptions, CheckIn, ClientOptions, Event, EventHint, MonitorConfig, ParameterizedString, SeverityLevel } from '@sentry/types';

*/
captureException(exception: any, hint?: EventHint, scope?: Scope): string | undefined;
captureException(exception: any, hint?: EventHint, scope?: Scope): string;
/**
* @inheritDoc
*/
captureEvent(event: Event, hint?: EventHint, scope?: Scope): string | undefined;
captureEvent(event: Event, hint?: EventHint, scope?: Scope): string;
/**

@@ -41,0 +41,0 @@ *

@@ -20,2 +20,4 @@ import type { SentrySpanArguments, Span, SpanAttributeValue, SpanAttributes, SpanContextData, SpanJSON, SpanStatus, SpanTimeInput, TimedEvent } from '@sentry/types';

protected _events: TimedEvent[];
/** if true, treat span as a standalone span (not part of a transaction) */
private _isStandaloneSpan?;
/**

@@ -69,2 +71,11 @@ * You should never call the constructor manually, always use `Sentry.startSpan()`

addEvent(name: string, attributesOrStartTime?: SpanAttributes | SpanTimeInput, startTime?: SpanTimeInput): this;
/**
* This method should generally not be used,
* but for now we need a way to publicly check if the `_isStandaloneSpan` flag is set.
* USE THIS WITH CAUTION!
* @internal
* @hidden
* @experimental
*/
isStandaloneSpan(): boolean;
/** Emit `spanEnd` when the span is ended. */

@@ -71,0 +82,0 @@ private _onSpanEnded;

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

export declare const SDK_VERSION = "8.0.0-beta.4";
export declare const SDK_VERSION = "8.0.0-beta.5";
//# sourceMappingURL=version.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

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

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