Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public captureException(exception: any, hint?: EventHint): string {
const eventId = (this._lastEventId = uuid4());
let finalHint = hint;
// If there's no explicit hint provided, mimick the same thing that would happen
// in the minimal itself to create a consistent behavior.
// We don't do this in the client, as it's the lowest level API, and doing this,
// would prevent user from having full control over direct calls.
if (!hint) {
let syntheticException: Error;
try {
throw new Error('Sentry syntheticException');
} catch (exception) {
syntheticException = exception as Error;
}
finalHint = {
originalException: exception,
syntheticException,
public constructor(
public readonly traceId?: string,
public readonly spanId: string = uuid4().substring(16), // private readonly parentId: string,
) {}
if (prepared.message) {
prepared.message = truncate(prepared.message, maxValueLength);
}
const exception = prepared.exception && prepared.exception.values && prepared.exception.values[0];
if (exception && exception.value) {
exception.value = truncate(exception.value, maxValueLength);
}
const request = prepared.request;
if (request && request.url) {
request.url = truncate(request.url, maxValueLength);
}
if (prepared.event_id === undefined) {
prepared.event_id = uuid4();
}
this._addIntegrations(prepared.sdk);
// We prepare the result here with a resolved Event.
let result = SyncPromise.resolve(prepared);
// This should be the last thing called, since we want that
// {@link Hub.addEventProcessor} gets the finished prepared event.
if (scope) {
// In case we have a hub we reassign it.
result = scope.applyToEvent(prepared, hint);
}
return result;
}
public captureMessage(message: string, level?: Severity, hint?: EventHint): string {
const eventId = (this._lastEventId = uuid4());
let finalHint = hint;
// If there's no explicit hint provided, mimick the same thing that would happen
// in the minimal itself to create a consistent behavior.
// We don't do this in the client, as it's the lowest level API, and doing this,
// would prevent user from having full control over direct calls.
if (!hint) {
let syntheticException: Error;
try {
throw new Error(message);
} catch (exception) {
syntheticException = exception as Error;
}
finalHint = {
originalException: message,
syntheticException,
*/
export class Span implements SpanInterface, SpanContext {
/**
* The reference to the current hub.
*/
private readonly _hub: Hub = (getCurrentHub() as unknown) as Hub;
/**
* @inheritDoc
*/
private readonly _traceId: string = uuid4();
/**
* @inheritDoc
*/
private readonly _spanId: string = uuid4().substring(16);
/**
* @inheritDoc
*/
private readonly _parentSpanId?: string;
/**
* @inheritDoc
*/
public sampled?: boolean;
/**
* Timestamp when the span was created.
*/
public readonly startTimestamp: number = timestampWithMs();
public constructor(
private readonly _traceId: string = uuid4(),
private readonly _spanId: string = uuid4().substring(16),
private _sampled?: boolean,
private _parent?: Span,
) {}
public captureEvent(event: Event, hint?: EventHint): string {
const eventId = (this._lastEventId = uuid4());
this._invokeClient('captureEvent', event, {
...hint,
event_id: eventId,
});
return eventId;
}
public constructor(
private readonly _traceId: string = uuid4(),
private readonly _spanId: string = uuid4().substring(16),
private _sampled?: boolean,
private _parent?: Span,
) {}