@sentry/core
Advanced tools
Comparing version 5.24.2 to 5.25.0-beta.0
@@ -0,1 +1,2 @@ | ||
import { Session } from '@sentry/hub'; | ||
import { Event, EventHint, Options, Severity, Transport } from '@sentry/types'; | ||
@@ -29,2 +30,4 @@ /** | ||
sendEvent(event: Event): void; | ||
/** Submits the session to Sentry */ | ||
sendSession(session: Session): void; | ||
/** | ||
@@ -69,2 +72,6 @@ * Returns the transport that is used by the backend. | ||
*/ | ||
sendSession(session: Session): void; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
getTransport(): Transport; | ||
@@ -71,0 +78,0 @@ /** |
@@ -41,2 +41,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
*/ | ||
BaseBackend.prototype.sendSession = function (session) { | ||
if (!this._transport.sendSession) { | ||
utils_1.logger.warn('sendSession not implemented for a transport used'); | ||
return; | ||
} | ||
this._transport.sendSession(session).then(null, function (reason) { | ||
utils_1.logger.error("Error while sending session: " + reason); | ||
}); | ||
}; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
BaseBackend.prototype.getTransport = function () { | ||
@@ -43,0 +55,0 @@ return this._transport; |
@@ -1,2 +0,2 @@ | ||
import { Scope } from '@sentry/hub'; | ||
import { Scope, Session } from '@sentry/hub'; | ||
import { Client, Event, EventHint, Integration, IntegrationClass, Options, Severity } from '@sentry/types'; | ||
@@ -75,2 +75,6 @@ import { Dsn } from '@sentry/utils'; | ||
*/ | ||
captureSession(session: Session): void; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
getDsn(): Dsn | undefined; | ||
@@ -97,2 +101,6 @@ /** | ||
getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null; | ||
/** Updates existing session based on the provided event */ | ||
protected _updateSessionFromEvent(session: Session, event: Event): void; | ||
/** Deliver captured session to Sentry */ | ||
protected _sendSession(session: Session): void; | ||
/** Waits for the client to be done with processing. */ | ||
@@ -99,0 +107,0 @@ protected _isClientProcessing(timeout?: number): PromiseLike<{ |
@@ -5,2 +5,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
var hub_1 = require("@sentry/hub"); | ||
var types_1 = require("@sentry/types"); | ||
var utils_1 = require("@sentry/utils"); | ||
@@ -112,2 +113,13 @@ var integration_1 = require("./integration"); | ||
*/ | ||
BaseClient.prototype.captureSession = function (session) { | ||
if (!session.release) { | ||
utils_1.logger.warn('Discarded session update because of missing release'); | ||
} | ||
else { | ||
this._sendSession(session); | ||
} | ||
}; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
BaseClient.prototype.getDsn = function () { | ||
@@ -165,2 +177,45 @@ return this._dsn; | ||
}; | ||
/** Updates existing session based on the provided event */ | ||
BaseClient.prototype._updateSessionFromEvent = function (session, event) { | ||
var e_1, _a; | ||
var crashed = false; | ||
var errored = false; | ||
var user_agent; | ||
var exceptions = event.exception && event.exception.values; | ||
if (exceptions) { | ||
errored = true; | ||
try { | ||
for (var exceptions_1 = tslib_1.__values(exceptions), exceptions_1_1 = exceptions_1.next(); !exceptions_1_1.done; exceptions_1_1 = exceptions_1.next()) { | ||
var ex = exceptions_1_1.value; | ||
var mechanism = ex.mechanism; | ||
if (mechanism && mechanism.handled === false) { | ||
crashed = true; | ||
break; | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (exceptions_1_1 && !exceptions_1_1.done && (_a = exceptions_1.return)) _a.call(exceptions_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
var user = event.user; | ||
if (!session.user_agent) { | ||
var headers = event.request ? event.request.headers : {}; | ||
for (var key in headers) { | ||
if (key.toLowerCase() === 'user-agent') { | ||
user_agent = headers[key]; | ||
break; | ||
} | ||
} | ||
} | ||
session.update(tslib_1.__assign(tslib_1.__assign({}, (crashed && { status: types_1.SessionStatus.Crashed })), { user: user, user_agent: user_agent, errors: session.errors + Number(errored || crashed) })); | ||
}; | ||
/** Deliver captured session to Sentry */ | ||
BaseClient.prototype._sendSession = function (session) { | ||
this._getBackend().sendSession(session); | ||
}; | ||
/** Waits for the client to be done with processing. */ | ||
@@ -365,2 +420,8 @@ BaseClient.prototype._isClientProcessing = function (timeout) { | ||
if (isInternalException || !beforeSend || isTransaction) { | ||
if (!isTransaction) { | ||
var session = scope && scope.getSession(); | ||
if (session) { | ||
_this._updateSessionFromEvent(session, finalEvent); | ||
} | ||
} | ||
_this._sendEvent(finalEvent); | ||
@@ -384,2 +445,6 @@ resolve(finalEvent); | ||
} | ||
var session = scope && scope.getSession(); | ||
if (session) { | ||
_this._updateSessionFromEvent(session, finalEvent); | ||
} | ||
// From here on we are really async | ||
@@ -386,0 +451,0 @@ _this._sendEvent(finalEvent); |
@@ -6,3 +6,3 @@ export { addBreadcrumb, captureException, captureEvent, captureMessage, configureScope, startTransaction, setContext, setExtra, setExtras, setTag, setTags, setUser, withScope, } from '@sentry/minimal'; | ||
export { BackendClass, BaseBackend } from './basebackend'; | ||
export { eventToSentryRequest, SentryRequest } from './request'; | ||
export { eventToSentryRequest, sessionToSentryRequest, SentryRequest } from './request'; | ||
export { initAndBind, ClientClass } from './sdk'; | ||
@@ -9,0 +9,0 @@ export { NoopTransport } from './transports/noop'; |
@@ -31,2 +31,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.eventToSentryRequest = request_1.eventToSentryRequest; | ||
exports.sessionToSentryRequest = request_1.sessionToSentryRequest; | ||
var sdk_1 = require("./sdk"); | ||
@@ -33,0 +34,0 @@ exports.initAndBind = sdk_1.initAndBind; |
@@ -0,1 +1,2 @@ | ||
import { Session } from '@sentry/hub'; | ||
import { Event } from '@sentry/types'; | ||
@@ -9,3 +10,5 @@ import { API } from './api'; | ||
/** Creates a SentryRequest from an event. */ | ||
export declare function sessionToSentryRequest(session: Session, api: API): SentryRequest; | ||
/** Creates a SentryRequest from an event. */ | ||
export declare function eventToSentryRequest(event: Event, api: API): SentryRequest; | ||
//# sourceMappingURL=request.d.ts.map |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var utils_1 = require("@sentry/utils"); | ||
/** Creates a SentryRequest from an event. */ | ||
function sessionToSentryRequest(session, api) { | ||
var envelopeHeaders = JSON.stringify({ | ||
sent_at: new Date(utils_1.timestampWithMs() * 1000).toISOString(), | ||
}); | ||
var itemHeaders = JSON.stringify({ | ||
type: 'session', | ||
}); | ||
return { | ||
body: envelopeHeaders + "\n" + itemHeaders + "\n" + JSON.stringify(session), | ||
url: api.getEnvelopeEndpointWithUrlEncodedAuth(), | ||
}; | ||
} | ||
exports.sessionToSentryRequest = sessionToSentryRequest; | ||
/** Creates a SentryRequest from an event. */ | ||
function eventToSentryRequest(event, api) { | ||
@@ -5,0 +19,0 @@ var useEnvelope = event.type === 'transaction'; |
@@ -0,1 +1,2 @@ | ||
import { Session } from '@sentry/hub'; | ||
import { Event, EventHint, Options, Severity, Transport } from '@sentry/types'; | ||
@@ -29,2 +30,4 @@ /** | ||
sendEvent(event: Event): void; | ||
/** Submits the session to Sentry */ | ||
sendSession(session: Session): void; | ||
/** | ||
@@ -69,2 +72,6 @@ * Returns the transport that is used by the backend. | ||
*/ | ||
sendSession(session: Session): void; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
getTransport(): Transport; | ||
@@ -71,0 +78,0 @@ /** |
@@ -40,2 +40,14 @@ import { logger, SentryError } from '@sentry/utils'; | ||
*/ | ||
BaseBackend.prototype.sendSession = function (session) { | ||
if (!this._transport.sendSession) { | ||
logger.warn('sendSession not implemented for a transport used'); | ||
return; | ||
} | ||
this._transport.sendSession(session).then(null, function (reason) { | ||
logger.error("Error while sending session: " + reason); | ||
}); | ||
}; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
BaseBackend.prototype.getTransport = function () { | ||
@@ -42,0 +54,0 @@ return this._transport; |
@@ -1,2 +0,2 @@ | ||
import { Scope } from '@sentry/hub'; | ||
import { Scope, Session } from '@sentry/hub'; | ||
import { Client, Event, EventHint, Integration, IntegrationClass, Options, Severity } from '@sentry/types'; | ||
@@ -75,2 +75,6 @@ import { Dsn } from '@sentry/utils'; | ||
*/ | ||
captureSession(session: Session): void; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
getDsn(): Dsn | undefined; | ||
@@ -97,2 +101,6 @@ /** | ||
getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null; | ||
/** Updates existing session based on the provided event */ | ||
protected _updateSessionFromEvent(session: Session, event: Event): void; | ||
/** Deliver captured session to Sentry */ | ||
protected _sendSession(session: Session): void; | ||
/** Waits for the client to be done with processing. */ | ||
@@ -99,0 +107,0 @@ protected _isClientProcessing(timeout?: number): PromiseLike<{ |
@@ -1,4 +0,5 @@ | ||
import { __assign } from "tslib"; | ||
import { __assign, __values } from "tslib"; | ||
/* eslint-disable max-lines */ | ||
import { Scope } from '@sentry/hub'; | ||
import { SessionStatus, } from '@sentry/types'; | ||
import { Dsn, isPrimitive, isThenable, logger, normalize, SyncPromise, timestampWithMs, truncate, uuid4, } from '@sentry/utils'; | ||
@@ -110,2 +111,13 @@ import { setupIntegrations } from './integration'; | ||
*/ | ||
BaseClient.prototype.captureSession = function (session) { | ||
if (!session.release) { | ||
logger.warn('Discarded session update because of missing release'); | ||
} | ||
else { | ||
this._sendSession(session); | ||
} | ||
}; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
BaseClient.prototype.getDsn = function () { | ||
@@ -163,2 +175,45 @@ return this._dsn; | ||
}; | ||
/** Updates existing session based on the provided event */ | ||
BaseClient.prototype._updateSessionFromEvent = function (session, event) { | ||
var e_1, _a; | ||
var crashed = false; | ||
var errored = false; | ||
var user_agent; | ||
var exceptions = event.exception && event.exception.values; | ||
if (exceptions) { | ||
errored = true; | ||
try { | ||
for (var exceptions_1 = __values(exceptions), exceptions_1_1 = exceptions_1.next(); !exceptions_1_1.done; exceptions_1_1 = exceptions_1.next()) { | ||
var ex = exceptions_1_1.value; | ||
var mechanism = ex.mechanism; | ||
if (mechanism && mechanism.handled === false) { | ||
crashed = true; | ||
break; | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (exceptions_1_1 && !exceptions_1_1.done && (_a = exceptions_1.return)) _a.call(exceptions_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
var user = event.user; | ||
if (!session.user_agent) { | ||
var headers = event.request ? event.request.headers : {}; | ||
for (var key in headers) { | ||
if (key.toLowerCase() === 'user-agent') { | ||
user_agent = headers[key]; | ||
break; | ||
} | ||
} | ||
} | ||
session.update(__assign(__assign({}, (crashed && { status: SessionStatus.Crashed })), { user: user, user_agent: user_agent, errors: session.errors + Number(errored || crashed) })); | ||
}; | ||
/** Deliver captured session to Sentry */ | ||
BaseClient.prototype._sendSession = function (session) { | ||
this._getBackend().sendSession(session); | ||
}; | ||
/** Waits for the client to be done with processing. */ | ||
@@ -363,2 +418,8 @@ BaseClient.prototype._isClientProcessing = function (timeout) { | ||
if (isInternalException || !beforeSend || isTransaction) { | ||
if (!isTransaction) { | ||
var session = scope && scope.getSession(); | ||
if (session) { | ||
_this._updateSessionFromEvent(session, finalEvent); | ||
} | ||
} | ||
_this._sendEvent(finalEvent); | ||
@@ -382,2 +443,6 @@ resolve(finalEvent); | ||
} | ||
var session = scope && scope.getSession(); | ||
if (session) { | ||
_this._updateSessionFromEvent(session, finalEvent); | ||
} | ||
// From here on we are really async | ||
@@ -384,0 +449,0 @@ _this._sendEvent(finalEvent); |
@@ -6,3 +6,3 @@ export { addBreadcrumb, captureException, captureEvent, captureMessage, configureScope, startTransaction, setContext, setExtra, setExtras, setTag, setTags, setUser, withScope, } from '@sentry/minimal'; | ||
export { BackendClass, BaseBackend } from './basebackend'; | ||
export { eventToSentryRequest, SentryRequest } from './request'; | ||
export { eventToSentryRequest, sessionToSentryRequest, SentryRequest } from './request'; | ||
export { initAndBind, ClientClass } from './sdk'; | ||
@@ -9,0 +9,0 @@ export { NoopTransport } from './transports/noop'; |
@@ -6,3 +6,3 @@ export { addBreadcrumb, captureException, captureEvent, captureMessage, configureScope, startTransaction, setContext, setExtra, setExtras, setTag, setTags, setUser, withScope, } from '@sentry/minimal'; | ||
export { BaseBackend } from './basebackend'; | ||
export { eventToSentryRequest } from './request'; | ||
export { eventToSentryRequest, sessionToSentryRequest } from './request'; | ||
export { initAndBind } from './sdk'; | ||
@@ -9,0 +9,0 @@ export { NoopTransport } from './transports/noop'; |
@@ -0,1 +1,2 @@ | ||
import { Session } from '@sentry/hub'; | ||
import { Event } from '@sentry/types'; | ||
@@ -9,3 +10,5 @@ import { API } from './api'; | ||
/** Creates a SentryRequest from an event. */ | ||
export declare function sessionToSentryRequest(session: Session, api: API): SentryRequest; | ||
/** Creates a SentryRequest from an event. */ | ||
export declare function eventToSentryRequest(event: Event, api: API): SentryRequest; | ||
//# sourceMappingURL=request.d.ts.map |
import { timestampWithMs } from '@sentry/utils'; | ||
/** Creates a SentryRequest from an event. */ | ||
export function sessionToSentryRequest(session, api) { | ||
var envelopeHeaders = JSON.stringify({ | ||
sent_at: new Date(timestampWithMs() * 1000).toISOString(), | ||
}); | ||
var itemHeaders = JSON.stringify({ | ||
type: 'session', | ||
}); | ||
return { | ||
body: envelopeHeaders + "\n" + itemHeaders + "\n" + JSON.stringify(session), | ||
url: api.getEnvelopeEndpointWithUrlEncodedAuth(), | ||
}; | ||
} | ||
/** Creates a SentryRequest from an event. */ | ||
export function eventToSentryRequest(event, api) { | ||
@@ -4,0 +17,0 @@ var useEnvelope = event.type === 'transaction'; |
{ | ||
"name": "@sentry/core", | ||
"version": "5.24.2", | ||
"version": "5.25.0-beta.0", | ||
"description": "Base implementation for all Sentry JavaScript SDKs", | ||
@@ -19,6 +19,6 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/hub": "5.24.2", | ||
"@sentry/minimal": "5.24.2", | ||
"@sentry/types": "5.24.2", | ||
"@sentry/utils": "5.24.2", | ||
"@sentry/hub": "5.25.0-beta.0", | ||
"@sentry/minimal": "5.25.0-beta.0", | ||
"@sentry/types": "5.25.0-beta.0", | ||
"@sentry/utils": "5.25.0-beta.0", | ||
"tslib": "^1.9.3" | ||
@@ -25,0 +25,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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
283386
2923
1
+ Added@sentry/hub@5.25.0-beta.0(transitive)
+ Added@sentry/minimal@5.25.0-beta.0(transitive)
+ Added@sentry/types@5.25.0-beta.0(transitive)
+ Added@sentry/utils@5.25.0-beta.0(transitive)
- Removed@sentry/hub@5.24.2(transitive)
- Removed@sentry/minimal@5.24.2(transitive)
- Removed@sentry/types@5.24.2(transitive)
- Removed@sentry/utils@5.24.2(transitive)
Updated@sentry/hub@5.25.0-beta.0
Updated@sentry/types@5.25.0-beta.0
Updated@sentry/utils@5.25.0-beta.0