snyk
Version:
snyk library and cli utility
1,431 lines (1,252 loc) • 2.98 MB
JavaScript
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 56046:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "G": () => (/* binding */ lazyLoadedNodePerformanceMonitoringIntegrations)
/* harmony export */ });
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(61422);
/* module decorator */ module = __webpack_require__.hmd(module);
const lazyLoadedNodePerformanceMonitoringIntegrations = [
() => {
const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__/* .dynamicRequire */ .l$)(module, './apollo')
;
return new integration.Apollo();
},
() => {
const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__/* .dynamicRequire */ .l$)(module, './apollo')
;
return new integration.Apollo({ useNestjs: true });
},
() => {
const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__/* .dynamicRequire */ .l$)(module, './graphql')
;
return new integration.GraphQL();
},
() => {
const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__/* .dynamicRequire */ .l$)(module, './mongo')
;
return new integration.Mongo();
},
() => {
const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__/* .dynamicRequire */ .l$)(module, './mongo')
;
return new integration.Mongo({ mongoose: true });
},
() => {
const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__/* .dynamicRequire */ .l$)(module, './mysql')
;
return new integration.Mysql();
},
() => {
const integration = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__/* .dynamicRequire */ .l$)(module, './postgres')
;
return new integration.Postgres();
},
];
//# sourceMappingURL=lazy.js.map
/***/ }),
/***/ 51131:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "J": () => (/* binding */ DEFAULT_ENVIRONMENT)
/* harmony export */ });
const DEFAULT_ENVIRONMENT = 'production';
//# sourceMappingURL=constants.js.map
/***/ }),
/***/ 81703:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "X": () => (/* binding */ DEBUG_BUILD)
/* harmony export */ });
/**
* This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
*
* ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
*/
const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
//# sourceMappingURL=debug-build.js.map
/***/ }),
/***/ 71195:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "cc": () => (/* binding */ addGlobalEventProcessor),
/* harmony export */ "fH": () => (/* binding */ getGlobalEventProcessors),
/* harmony export */ "RP": () => (/* binding */ notifyEventProcessors)
/* harmony export */ });
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71235);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(96893);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12343);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(67597);
/* harmony import */ var _debug_build_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(81703);
/**
* Returns the global event processors.
* @deprecated Global event processors will be removed in v8.
*/
function getGlobalEventProcessors() {
return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__/* .getGlobalSingleton */ .YO)('globalEventProcessors', () => []);
}
/**
* Add a EventProcessor to be kept globally.
* @deprecated Use `addEventProcessor` instead. Global event processors will be removed in v8.
*/
function addGlobalEventProcessor(callback) {
// eslint-disable-next-line deprecation/deprecation
getGlobalEventProcessors().push(callback);
}
/**
* Process an array of event processors, returning the processed event (or `null` if the event was dropped).
*/
function notifyEventProcessors(
processors,
event,
hint,
index = 0,
) {
return new _sentry_utils__WEBPACK_IMPORTED_MODULE_1__/* .SyncPromise */ .cW((resolve, reject) => {
const processor = processors[index];
if (event === null || typeof processor !== 'function') {
resolve(event);
} else {
const result = processor({ ...event }, hint) ;
_debug_build_js__WEBPACK_IMPORTED_MODULE_2__/* .DEBUG_BUILD */ .X && processor.id && result === null && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__/* .logger.log */ .kg.log(`Event processor "${processor.id}" dropped event`);
if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__/* .isThenable */ .J8)(result)) {
void result
.then(final => notifyEventProcessors(processors, final, hint, index + 1).then(resolve))
.then(null, reject);
} else {
void notifyEventProcessors(processors, result, hint, index + 1)
.then(resolve)
.then(null, reject);
}
}
});
}
//# sourceMappingURL=eventProcessors.js.map
/***/ }),
/***/ 64487:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "n_": () => (/* binding */ addBreadcrumb),
/* harmony export */ "c": () => (/* binding */ captureCheckIn),
/* harmony export */ "eN": () => (/* binding */ captureEvent),
/* harmony export */ "Tb": () => (/* binding */ captureException),
/* harmony export */ "uT": () => (/* binding */ captureMessage),
/* harmony export */ "cg": () => (/* binding */ captureSession),
/* harmony export */ "xv": () => (/* binding */ close),
/* harmony export */ "e": () => (/* binding */ configureScope),
/* harmony export */ "TM": () => (/* binding */ endSession),
/* harmony export */ "yl": () => (/* binding */ flush),
/* harmony export */ "s3": () => (/* binding */ getClient),
/* harmony export */ "nZ": () => (/* binding */ getCurrentScope),
/* harmony export */ "dk": () => (/* binding */ isInitialized),
/* harmony export */ "eW": () => (/* binding */ lastEventId),
/* harmony export */ "v": () => (/* binding */ setContext),
/* harmony export */ "sU": () => (/* binding */ setExtra),
/* harmony export */ "rJ": () => (/* binding */ setExtras),
/* harmony export */ "YA": () => (/* binding */ setTag),
/* harmony export */ "mG": () => (/* binding */ setTags),
/* harmony export */ "av": () => (/* binding */ setUser),
/* harmony export */ "yj": () => (/* binding */ startSession),
/* harmony export */ "Yr": () => (/* binding */ startTransaction),
/* harmony export */ "_d": () => (/* binding */ withActiveSpan),
/* harmony export */ "wi": () => (/* binding */ withIsolationScope),
/* harmony export */ "sV": () => (/* binding */ withMonitor),
/* harmony export */ "$e": () => (/* binding */ withScope)
/* harmony export */ });
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12343);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(62844);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(21170);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(67597);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(71235);
/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(51131);
/* harmony import */ var _debug_build_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(81703);
/* harmony import */ var _hub_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(95659);
/* harmony import */ var _session_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(9015);
/* harmony import */ var _utils_prepareEvent_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(88942);
/**
* Captures an exception event and sends it to Sentry.
*
* @param exception The exception to capture.
* @param hint Optional additional data to attach to the Sentry event.
* @returns the id of the captured Sentry event.
*/
function captureException(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
exception,
hint,
) {
// eslint-disable-next-line deprecation/deprecation
return (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().captureException(exception, (0,_utils_prepareEvent_js__WEBPACK_IMPORTED_MODULE_1__/* .parseEventHintOrCaptureContext */ .U0)(hint));
}
/**
* Captures a message event and sends it to Sentry.
*
* @param exception The exception to capture.
* @param captureContext Define the level of the message or pass in additional data to attach to the message.
* @returns the id of the captured message.
*/
function captureMessage(
message,
// eslint-disable-next-line deprecation/deprecation
captureContext,
) {
// This is necessary to provide explicit scopes upgrade, without changing the original
// arity of the `captureMessage(message, level)` method.
const level = typeof captureContext === 'string' ? captureContext : undefined;
const context = typeof captureContext !== 'string' ? { captureContext } : undefined;
// eslint-disable-next-line deprecation/deprecation
return (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().captureMessage(message, level, context);
}
/**
* Captures a manually created event and sends it to Sentry.
*
* @param exception The event to send to Sentry.
* @param hint Optional additional data to attach to the Sentry event.
* @returns the id of the captured event.
*/
function captureEvent(event, hint) {
// eslint-disable-next-line deprecation/deprecation
return (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().captureEvent(event, hint);
}
/**
* Callback to set context information onto the scope.
* @param callback Callback function that receives Scope.
*
* @deprecated Use getCurrentScope() directly.
*/
// eslint-disable-next-line deprecation/deprecation
function configureScope(callback) {
// eslint-disable-next-line deprecation/deprecation
(0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().configureScope(callback);
}
/**
* Records a new breadcrumb which will be attached to future events.
*
* Breadcrumbs will be added to subsequent events to provide more context on
* user's actions prior to an error or crash.
*
* @param breadcrumb The breadcrumb to record.
*/
// eslint-disable-next-line deprecation/deprecation
function addBreadcrumb(breadcrumb, hint) {
// eslint-disable-next-line deprecation/deprecation
(0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().addBreadcrumb(breadcrumb, hint);
}
/**
* Sets context data with the given name.
* @param name of the context
* @param context Any kind of data. This data will be normalized.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any, deprecation/deprecation
function setContext(name, context) {
// eslint-disable-next-line deprecation/deprecation
(0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().setContext(name, context);
}
/**
* Set an object that will be merged sent as extra data with the event.
* @param extras Extras object to merge into current context.
*/
// eslint-disable-next-line deprecation/deprecation
function setExtras(extras) {
// eslint-disable-next-line deprecation/deprecation
(0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().setExtras(extras);
}
/**
* Set key:value that will be sent as extra data with the event.
* @param key String of extra
* @param extra Any kind of data. This data will be normalized.
*/
// eslint-disable-next-line deprecation/deprecation
function setExtra(key, extra) {
// eslint-disable-next-line deprecation/deprecation
(0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().setExtra(key, extra);
}
/**
* Set an object that will be merged sent as tags data with the event.
* @param tags Tags context object to merge into current context.
*/
// eslint-disable-next-line deprecation/deprecation
function setTags(tags) {
// eslint-disable-next-line deprecation/deprecation
(0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().setTags(tags);
}
/**
* Set key:value that will be sent as tags data with the event.
*
* Can also be used to unset a tag, by passing `undefined`.
*
* @param key String key of tag
* @param value Value of tag
*/
// eslint-disable-next-line deprecation/deprecation
function setTag(key, value) {
// eslint-disable-next-line deprecation/deprecation
(0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().setTag(key, value);
}
/**
* Updates user context information for future events.
*
* @param user User context object to be set in the current context. Pass `null` to unset the user.
*/
// eslint-disable-next-line deprecation/deprecation
function setUser(user) {
// eslint-disable-next-line deprecation/deprecation
(0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().setUser(user);
}
/**
* Creates a new scope with and executes the given operation within.
* The scope is automatically removed once the operation
* finishes or throws.
*
* This is essentially a convenience function for:
*
* pushScope();
* callback();
* popScope();
*/
/**
* Either creates a new active scope, or sets the given scope as active scope in the given callback.
*/
function withScope(
...rest
) {
// eslint-disable-next-line deprecation/deprecation
const hub = (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)();
// If a scope is defined, we want to make this the active scope instead of the default one
if (rest.length === 2) {
const [scope, callback] = rest;
if (!scope) {
// eslint-disable-next-line deprecation/deprecation
return hub.withScope(callback);
}
// eslint-disable-next-line deprecation/deprecation
return hub.withScope(() => {
// eslint-disable-next-line deprecation/deprecation
hub.getStackTop().scope = scope ;
return callback(scope );
});
}
// eslint-disable-next-line deprecation/deprecation
return hub.withScope(rest[0]);
}
/**
* Attempts to fork the current isolation scope and the current scope based on the current async context strategy. If no
* async context strategy is set, the isolation scope and the current scope will not be forked (this is currently the
* case, for example, in the browser).
*
* Usage of this function in environments without async context strategy is discouraged and may lead to unexpected behaviour.
*
* This function is intended for Sentry SDK and SDK integration development. It is not recommended to be used in "normal"
* applications directly because it comes with pitfalls. Use at your own risk!
*
* @param callback The callback in which the passed isolation scope is active. (Note: In environments without async
* context strategy, the currently active isolation scope may change within execution of the callback.)
* @returns The same value that `callback` returns.
*/
function withIsolationScope(callback) {
return (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .runWithAsyncContext */ .Ok)(() => {
return callback((0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getIsolationScope */ .aF)());
});
}
/**
* Forks the current scope and sets the provided span as active span in the context of the provided callback.
*
* @param span Spans started in the context of the provided callback will be children of this span.
* @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.
* @returns the value returned from the provided callback function.
*/
function withActiveSpan(span, callback) {
return withScope(scope => {
// eslint-disable-next-line deprecation/deprecation
scope.setSpan(span);
return callback(scope);
});
}
/**
* Starts a new `Transaction` and returns it. This is the entry point to manual tracing instrumentation.
*
* A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a
* new child span within the transaction or any span, call the respective `.startChild()` method.
*
* Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded.
*
* The transaction must be finished with a call to its `.end()` method, at which point the transaction with all its
* finished child spans will be sent to Sentry.
*
* NOTE: This function should only be used for *manual* instrumentation. Auto-instrumentation should call
* `startTransaction` directly on the hub.
*
* @param context Properties of the new `Transaction`.
* @param customSamplingContext Information given to the transaction sampling function (along with context-dependent
* default values). See {@link Options.tracesSampler}.
*
* @returns The transaction which was just started
*
* @deprecated Use `startSpan()`, `startSpanManual()` or `startInactiveSpan()` instead.
*/
function startTransaction(
context,
customSamplingContext,
// eslint-disable-next-line deprecation/deprecation
) {
// eslint-disable-next-line deprecation/deprecation
return (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().startTransaction({ ...context }, customSamplingContext);
}
/**
* Create a cron monitor check in and send it to Sentry.
*
* @param checkIn An object that describes a check in.
* @param upsertMonitorConfig An optional object that describes a monitor config. Use this if you want
* to create a monitor automatically when sending a check in.
*/
function captureCheckIn(checkIn, upsertMonitorConfig) {
const scope = getCurrentScope();
const client = getClient();
if (!client) {
_debug_build_js__WEBPACK_IMPORTED_MODULE_2__/* .DEBUG_BUILD */ .X && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__/* .logger.warn */ .kg.warn('Cannot capture check-in. No client defined.');
} else if (!client.captureCheckIn) {
_debug_build_js__WEBPACK_IMPORTED_MODULE_2__/* .DEBUG_BUILD */ .X && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__/* .logger.warn */ .kg.warn('Cannot capture check-in. Client does not support sending check-ins.');
} else {
return client.captureCheckIn(checkIn, upsertMonitorConfig, scope);
}
return (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__/* .uuid4 */ .DM)();
}
/**
* Wraps a callback with a cron monitor check in. The check in will be sent to Sentry when the callback finishes.
*
* @param monitorSlug The distinct slug of the monitor.
* @param upsertMonitorConfig An optional object that describes a monitor config. Use this if you want
* to create a monitor automatically when sending a check in.
*/
function withMonitor(
monitorSlug,
callback,
upsertMonitorConfig,
) {
const checkInId = captureCheckIn({ monitorSlug, status: 'in_progress' }, upsertMonitorConfig);
const now = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__/* .timestampInSeconds */ .ph)();
function finishCheckIn(status) {
captureCheckIn({ monitorSlug, status, checkInId, duration: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__/* .timestampInSeconds */ .ph)() - now });
}
let maybePromiseResult;
try {
maybePromiseResult = callback();
} catch (e) {
finishCheckIn('error');
throw e;
}
if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_6__/* .isThenable */ .J8)(maybePromiseResult)) {
Promise.resolve(maybePromiseResult).then(
() => {
finishCheckIn('ok');
},
() => {
finishCheckIn('error');
},
);
} else {
finishCheckIn('ok');
}
return maybePromiseResult;
}
/**
* Call `flush()` on the current client, if there is one. See {@link Client.flush}.
*
* @param timeout Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause
* the client to wait until all events are sent before resolving the promise.
* @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
* doesn't (or if there's no client defined).
*/
async function flush(timeout) {
const client = getClient();
if (client) {
return client.flush(timeout);
}
_debug_build_js__WEBPACK_IMPORTED_MODULE_2__/* .DEBUG_BUILD */ .X && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__/* .logger.warn */ .kg.warn('Cannot flush events. No client defined.');
return Promise.resolve(false);
}
/**
* Call `close()` on the current client, if there is one. See {@link Client.close}.
*
* @param timeout Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this
* parameter will cause the client to wait until all events are sent before disabling itself.
* @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
* doesn't (or if there's no client defined).
*/
async function close(timeout) {
const client = getClient();
if (client) {
return client.close(timeout);
}
_debug_build_js__WEBPACK_IMPORTED_MODULE_2__/* .DEBUG_BUILD */ .X && _sentry_utils__WEBPACK_IMPORTED_MODULE_3__/* .logger.warn */ .kg.warn('Cannot flush events and disable SDK. No client defined.');
return Promise.resolve(false);
}
/**
* This is the getter for lastEventId.
*
* @returns The last event id of a captured event.
*/
function lastEventId() {
// eslint-disable-next-line deprecation/deprecation
return (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().lastEventId();
}
/**
* Get the currently active client.
*/
function getClient() {
// eslint-disable-next-line deprecation/deprecation
return (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().getClient();
}
/**
* Returns true if Sentry has been properly initialized.
*/
function isInitialized() {
return !!getClient();
}
/**
* Get the currently active scope.
*/
function getCurrentScope() {
// eslint-disable-next-line deprecation/deprecation
return (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getCurrentHub */ .Gd)().getScope();
}
/**
* Start a session on the current isolation scope.
*
* @param context (optional) additional properties to be applied to the returned session object
*
* @returns the new active session
*/
function startSession(context) {
const client = getClient();
const isolationScope = (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getIsolationScope */ .aF)();
const currentScope = getCurrentScope();
const { release, environment = _constants_js__WEBPACK_IMPORTED_MODULE_7__/* .DEFAULT_ENVIRONMENT */ .J } = (client && client.getOptions()) || {};
// Will fetch userAgent if called from browser sdk
const { userAgent } = _sentry_utils__WEBPACK_IMPORTED_MODULE_8__/* .GLOBAL_OBJ.navigator */ .n2.navigator || {};
const session = (0,_session_js__WEBPACK_IMPORTED_MODULE_9__/* .makeSession */ .Hv)({
release,
environment,
user: currentScope.getUser() || isolationScope.getUser(),
...(userAgent && { userAgent }),
...context,
});
// End existing session if there's one
const currentSession = isolationScope.getSession();
if (currentSession && currentSession.status === 'ok') {
(0,_session_js__WEBPACK_IMPORTED_MODULE_9__/* .updateSession */ .CT)(currentSession, { status: 'exited' });
}
endSession();
// Afterwards we set the new session on the scope
isolationScope.setSession(session);
// TODO (v8): Remove this and only use the isolation scope(?).
// For v7 though, we can't "soft-break" people using getCurrentHub().getScope().setSession()
currentScope.setSession(session);
return session;
}
/**
* End the session on the current isolation scope.
*/
function endSession() {
const isolationScope = (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getIsolationScope */ .aF)();
const currentScope = getCurrentScope();
const session = currentScope.getSession() || isolationScope.getSession();
if (session) {
(0,_session_js__WEBPACK_IMPORTED_MODULE_9__/* .closeSession */ .RJ)(session);
}
_sendSessionUpdate();
// the session is over; take it off of the scope
isolationScope.setSession();
// TODO (v8): Remove this and only use the isolation scope(?).
// For v7 though, we can't "soft-break" people using getCurrentHub().getScope().setSession()
currentScope.setSession();
}
/**
* Sends the current Session on the scope
*/
function _sendSessionUpdate() {
const isolationScope = (0,_hub_js__WEBPACK_IMPORTED_MODULE_0__/* .getIsolationScope */ .aF)();
const currentScope = getCurrentScope();
const client = getClient();
// TODO (v8): Remove currentScope and only use the isolation scope(?).
// For v7 though, we can't "soft-break" people using getCurrentHub().getScope().setSession()
const session = currentScope.getSession() || isolationScope.getSession();
if (session && client && client.captureSession) {
client.captureSession(session);
}
}
/**
* Sends the current session on the scope to Sentry
*
* @param end If set the session will be marked as exited and removed from the scope.
* Defaults to `false`.
*/
function captureSession(end = false) {
// both send the update and pull the session from the scope
if (end) {
endSession();
return;
}
// only send the update
_sendSessionUpdate();
}
//# sourceMappingURL=exports.js.map
/***/ }),
/***/ 95659:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Xb": () => (/* binding */ Hub),
/* harmony export */ "uZ": () => (/* binding */ ensureHubOnCarrier),
/* harmony export */ "Gd": () => (/* binding */ getCurrentHub),
/* harmony export */ "vi": () => (/* binding */ getHubFromCarrier),
/* harmony export */ "aF": () => (/* binding */ getIsolationScope),
/* harmony export */ "cu": () => (/* binding */ getMainCarrier),
/* harmony export */ "pj": () => (/* binding */ makeMain),
/* harmony export */ "Ok": () => (/* binding */ runWithAsyncContext),
/* harmony export */ "$b": () => (/* binding */ setAsyncContextStrategy),
/* harmony export */ "j0": () => (/* binding */ setHubOnCarrier)
/* harmony export */ });
/* unused harmony export API_VERSION */
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(67597);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(62844);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(21170);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(12343);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(71235);
/* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(51131);
/* harmony import */ var _debug_build_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(81703);
/* harmony import */ var _scope_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10350);
/* harmony import */ var _session_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9015);
/* harmony import */ var _version_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40105);
/**
* API compatibility version of this hub.
*
* WARNING: This number should only be increased when the global interface
* changes and new methods are introduced.
*
* @hidden
*/
const API_VERSION = parseFloat(_version_js__WEBPACK_IMPORTED_MODULE_0__/* .SDK_VERSION */ .J);
/**
* Default maximum number of breadcrumbs added to an event. Can be overwritten
* with {@link Options.maxBreadcrumbs}.
*/
const DEFAULT_BREADCRUMBS = 100;
/**
* @deprecated The `Hub` class will be removed in version 8 of the SDK in favour of `Scope` and `Client` objects.
*
* If you previously used the `Hub` class directly, replace it with `Scope` and `Client` objects. More information:
* - [Multiple Sentry Instances](https://docs.sentry.io/platforms/javascript/best-practices/multiple-sentry-instances/)
* - [Browser Extensions](https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/)
*
* Some of our APIs are typed with the Hub class instead of the interface (e.g. `getCurrentHub`). Most of them are deprecated
* themselves and will also be removed in version 8. More information:
* - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub)
*/
// eslint-disable-next-line deprecation/deprecation
class Hub {
/** Is a {@link Layer}[] containing the client and scope */
/** Contains the last event id of a captured event. */
/**
* Creates a new instance of the hub, will push one {@link Layer} into the
* internal stack on creation.
*
* @param client bound to the hub.
* @param scope bound to the hub.
* @param version number, higher number means higher priority.
*
* @deprecated Instantiation of Hub objects is deprecated and the constructor will be removed in version 8 of the SDK.
*
* If you are currently using the Hub for multi-client use like so:
*
* ```
* // OLD
* const hub = new Hub();
* hub.bindClient(client);
* makeMain(hub)
* ```
*
* instead initialize the client as follows:
*
* ```
* // NEW
* Sentry.withIsolationScope(() => {
* Sentry.setCurrentClient(client);
* client.init();
* });
* ```
*
* If you are using the Hub to capture events like so:
*
* ```
* // OLD
* const client = new Client();
* const hub = new Hub(client);
* hub.captureException()
* ```
*
* instead capture isolated events as follows:
*
* ```
* // NEW
* const client = new Client();
* const scope = new Scope();
* scope.setClient(client);
* scope.captureException();
* ```
*/
constructor(
client,
scope,
isolationScope,
_version = API_VERSION,
) {this._version = _version;
let assignedScope;
if (!scope) {
assignedScope = new _scope_js__WEBPACK_IMPORTED_MODULE_1__/* .Scope */ .sX();
assignedScope.setClient(client);
} else {
assignedScope = scope;
}
let assignedIsolationScope;
if (!isolationScope) {
assignedIsolationScope = new _scope_js__WEBPACK_IMPORTED_MODULE_1__/* .Scope */ .sX();
assignedIsolationScope.setClient(client);
} else {
assignedIsolationScope = isolationScope;
}
this._stack = [{ scope: assignedScope }];
if (client) {
// eslint-disable-next-line deprecation/deprecation
this.bindClient(client);
}
this._isolationScope = assignedIsolationScope;
}
/**
* Checks if this hub's version is older than the given version.
*
* @param version A version number to compare to.
* @return True if the given version is newer; otherwise false.
*
* @deprecated This will be removed in v8.
*/
isOlderThan(version) {
return this._version < version;
}
/**
* This binds the given client to the current scope.
* @param client An SDK client (client) instance.
*
* @deprecated Use `initAndBind()` directly, or `setCurrentClient()` and/or `client.init()` instead.
*/
bindClient(client) {
// eslint-disable-next-line deprecation/deprecation
const top = this.getStackTop();
top.client = client;
top.scope.setClient(client);
// eslint-disable-next-line deprecation/deprecation
if (client && client.setupIntegrations) {
// eslint-disable-next-line deprecation/deprecation
client.setupIntegrations();
}
}
/**
* @inheritDoc
*
* @deprecated Use `withScope` instead.
*/
pushScope() {
// We want to clone the content of prev scope
// eslint-disable-next-line deprecation/deprecation
const scope = this.getScope().clone();
// eslint-disable-next-line deprecation/deprecation
this.getStack().push({
// eslint-disable-next-line deprecation/deprecation
client: this.getClient(),
scope,
});
return scope;
}
/**
* @inheritDoc
*
* @deprecated Use `withScope` instead.
*/
popScope() {
// eslint-disable-next-line deprecation/deprecation
if (this.getStack().length <= 1) return false;
// eslint-disable-next-line deprecation/deprecation
return !!this.getStack().pop();
}
/**
* @inheritDoc
*
* @deprecated Use `Sentry.withScope()` instead.
*/
withScope(callback) {
// eslint-disable-next-line deprecation/deprecation
const scope = this.pushScope();
let maybePromiseResult;
try {
maybePromiseResult = callback(scope);
} catch (e) {
// eslint-disable-next-line deprecation/deprecation
this.popScope();
throw e;
}
if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__/* .isThenable */ .J8)(maybePromiseResult)) {
// @ts-expect-error - isThenable returns the wrong type
return maybePromiseResult.then(
res => {
// eslint-disable-next-line deprecation/deprecation
this.popScope();
return res;
},
e => {
// eslint-disable-next-line deprecation/deprecation
this.popScope();
throw e;
},
);
}
// eslint-disable-next-line deprecation/deprecation
this.popScope();
return maybePromiseResult;
}
/**
* @inheritDoc
*
* @deprecated Use `Sentry.getClient()` instead.
*/
getClient() {
// eslint-disable-next-line deprecation/deprecation
return this.getStackTop().client ;
}
/**
* Returns the scope of the top stack.
*
* @deprecated Use `Sentry.getCurrentScope()` instead.
*/
getScope() {
// eslint-disable-next-line deprecation/deprecation
return this.getStackTop().scope;
}
/**
* @deprecated Use `Sentry.getIsolationScope()` instead.
*/
getIsolationScope() {
return this._isolationScope;
}
/**
* Returns the scope stack for domains or the process.
* @deprecated This will be removed in v8.
*/
getStack() {
return this._stack;
}
/**
* Returns the topmost scope layer in the order domain > local > process.
* @deprecated This will be removed in v8.
*/
getStackTop() {
return this._stack[this._stack.length - 1];
}
/**
* @inheritDoc
*
* @deprecated Use `Sentry.captureException()` instead.
*/
captureException(exception, hint) {
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__/* .uuid4 */ .DM)());
const syntheticException = new Error('Sentry syntheticException');
// eslint-disable-next-line deprecation/deprecation
this.getScope().captureException(exception, {
originalException: exception,
syntheticException,
...hint,
event_id: eventId,
});
return eventId;
}
/**
* @inheritDoc
*
* @deprecated Use `Sentry.captureMessage()` instead.
*/
captureMessage(
message,
// eslint-disable-next-line deprecation/deprecation
level,
hint,
) {
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__/* .uuid4 */ .DM)());
const syntheticException = new Error(message);
// eslint-disable-next-line deprecation/deprecation
this.getScope().captureMessage(message, level, {
originalException: message,
syntheticException,
...hint,
event_id: eventId,
});
return eventId;
}
/**
* @inheritDoc
*
* @deprecated Use `Sentry.captureEvent()` instead.
*/
captureEvent(event, hint) {
const eventId = hint && hint.event_id ? hint.event_id : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__/* .uuid4 */ .DM)();
if (!event.type) {
this._lastEventId = eventId;
}
// eslint-disable-next-line deprecation/deprecation
this.getScope().captureEvent(event, { ...hint, event_id: eventId });
return eventId;
}
/**
* @inheritDoc
*
* @deprecated This will be removed in v8.
*/
lastEventId() {
return this._lastEventId;
}
/**
* @inheritDoc
*
* @deprecated Use `Sentry.addBreadcrumb()` instead.
*/
addBreadcrumb(breadcrumb, hint) {
// eslint-disable-next-line deprecation/deprecation
const { scope, client } = this.getStackTop();
if (!client) return;
const { beforeBreadcrumb = null, maxBreadcrumbs = DEFAULT_BREADCRUMBS } =
(client.getOptions && client.getOptions()) || {};
if (maxBreadcrumbs <= 0) return;
const timestamp = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__/* .dateTimestampInSeconds */ .yW)();
const mergedBreadcrumb = { timestamp, ...breadcrumb };
const finalBreadcrumb = beforeBreadcrumb
? ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__/* .consoleSandbox */ .Cf)(() => beforeBreadcrumb(mergedBreadcrumb, hint)) )
: mergedBreadcrumb;
if (finalBreadcrumb === null) return;
if (client.emit) {
client.emit('beforeAddBreadcrumb', finalBreadcrumb, hint);
}
// TODO(v8): I know this comment doesn't make much sense because the hub will be deprecated but I still wanted to
// write it down. In theory, we would have to add the breadcrumbs to the isolation scope here, however, that would
// duplicate all of the breadcrumbs. There was the possibility of adding breadcrumbs to both, the isolation scope
// and the normal scope, and deduplicating it down the line in the event processing pipeline. However, that would
// have been very fragile, because the breadcrumb objects would have needed to keep their identity all throughout
// the event processing pipeline.
// In the new implementation, the top level `Sentry.addBreadcrumb()` should ONLY write to the isolation scope.
scope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);
}
/**
* @inheritDoc
* @deprecated Use `Sentry.setUser()` instead.
*/
setUser(user) {
// TODO(v8): The top level `Sentry.setUser()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setUser(user);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setUser(user);
}
/**
* @inheritDoc
* @deprecated Use `Sentry.setTags()` instead.
*/
setTags(tags) {
// TODO(v8): The top level `Sentry.setTags()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setTags(tags);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setTags(tags);
}
/**
* @inheritDoc
* @deprecated Use `Sentry.setExtras()` instead.
*/
setExtras(extras) {
// TODO(v8): The top level `Sentry.setExtras()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setExtras(extras);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setExtras(extras);
}
/**
* @inheritDoc
* @deprecated Use `Sentry.setTag()` instead.
*/
setTag(key, value) {
// TODO(v8): The top level `Sentry.setTag()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setTag(key, value);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setTag(key, value);
}
/**
* @inheritDoc
* @deprecated Use `Sentry.setExtra()` instead.
*/
setExtra(key, extra) {
// TODO(v8): The top level `Sentry.setExtra()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setExtra(key, extra);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setExtra(key, extra);
}
/**
* @inheritDoc
* @deprecated Use `Sentry.setContext()` instead.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setContext(name, context) {
// TODO(v8): The top level `Sentry.setContext()` function should write ONLY to the isolation scope.
// eslint-disable-next-line deprecation/deprecation
this.getScope().setContext(name, context);
// eslint-disable-next-line deprecation/deprecation
this.getIsolationScope().setContext(name, context);
}
/**
* @inheritDoc
*
* @deprecated Use `getScope()` directly.
*/
configureScope(callback) {
// eslint-disable-next-line deprecation/deprecation
const { scope, client } = this.getStackTop();
if (client) {
callback(scope);
}
}
/**
* @inheritDoc
*/
// eslint-disable-next-line deprecation/deprecation
run(callback) {
// eslint-disable-next-line deprecation/deprecation
const oldHub = makeMain(this);
try {
callback(this);
} finally {
// eslint-disable-next-line deprecation/deprecation
makeMain(oldHub);
}
}
/**
* @inheritDoc
* @deprecated Use `Sentry.getClient().getIntegrationByName()` instead.
*/
getIntegration(integration) {
// eslint-disable-next-line deprecation/deprecation
const client = this.getClient();
if (!client) return null;
try {
// eslint-disable-next-line deprecation/deprecation
return client.getIntegration(integration);
} catch (_oO) {
_debug_build_js__WEBPACK_IMPORTED_MODULE_6__/* .DEBUG_BUILD */ .X && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__/* .logger.warn */ .kg.warn(`Cannot retrieve integration ${integration.id} from the current Hub`);
return null;
}
}
/**
* Starts a new `Transaction` and returns it. This is the entry point to manual tracing instrumentation.
*
* A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a
* new child span within the transaction or any span, call the respective `.startChild()` method.
*
* Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded.
*
* The transaction must be finished with a call to its `.end()` method, at which point the transaction with all its
* finished child spans will be sent to Sentry.
*
* @param context Properties of the new `Transaction`.
* @param customSamplingContext Information given to the transaction sampling function (along with context-dependent
* default values). See {@link Options.tracesSampler}.
*
* @returns The transaction which was just started
*
* @deprecated Use `startSpan()`, `startSpanManual()` or `startInactiveSpan()` instead.
*/
startTransaction(context, customSamplingContext) {
const result = this._callExtensionMethod('startTransaction', context, customSamplingContext);
if (_debug_build_js__WEBPACK_IMPORTED_MODULE_6__/* .DEBUG_BUILD */ .X && !result) {
// eslint-disable-next-line deprecation/deprecation
const client = this.getClient();
if (!client) {
_sentry_utils__WEBPACK_IMPORTED_MODULE_5__/* .logger.warn */ .kg.warn(
"Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'",
);
} else {
_sentry_utils__WEBPACK_IMPORTED_MODULE_5__/* .logger.warn */ .kg.warn(`Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':
Sentry.addTracingExtensions();
Sentry.init({...});
`);
}
}
return result;
}
/**
* @inheritDoc
* @deprecated Use `spanToTraceHeader()` instead.
*/
traceHeaders() {
return this._callExtensionMethod('traceHeaders');
}
/**
* @inheritDoc
*
* @deprecated Use top level `captureSession` instead.
*/
captureSession(endSession = false) {
// both send the update and pull the session from the scope
if (endSession) {
// eslint-disable-next-line deprecation/deprecation
return this.endSession();
}
// only send the update
this._sendSessionUpdate();
}
/**
* @inheritDoc
* @deprecated Use top level `endSession` instead.
*/
endSession() {
// eslint-disable-next-line deprecation/deprecation
const layer = this.getStackTop();
const scope = layer.scope;
const session = scope.getSession();
if (session) {
(0,_session_js__WEBPACK_IMPORTED_MODULE_7__/* .closeSession */ .RJ)(session);
}
this._sendSessionUpdate();
// the session is over; take it off of the scope
scope.setSession();
}
/**
* @inheritDoc
* @deprecated Use top level `startSession` instead.
*/
startSession(context) {
// eslint-disable-next-line deprecation/deprecation
const { scope, client } = this.getStackTop();
const { release, environment = _constants_js__WEBPACK_IMPORTED_MODULE_8__/* .DEFAULT_ENVIRONMENT */ .J } = (client && client.getOptions()) || {};
// Will fetch userAgent if called from browser sdk
const { userAgent } = _sentry_utils__WEBPACK_IMPORTED_MODULE_9__/* .GLOBAL_OBJ.navigator */ .n2.navigator || {};
const session = (0,_session_js__WEBPACK_IMPORTED_MODULE_7__/* .makeSession */ .Hv)({
release,
environment,
user: scope.getUser(),
...(userAgent && { userAgent }),
...context,
});
// End existing session if there's one
const currentSession = scope.getSession && scope.getSession();
if (currentSession && currentSession.status === 'ok') {
(0,_session_js__WEBPACK_IMPORTED_MODULE_7__/* .updateSession */ .CT)(currentSession, { status: 'exited' });
}
// eslint-disable-next-line deprecation/deprecation
this.endSession();
// Afterwards we set the new session on the scope
scope.setSession(session);
return session;
}
/**
* Returns if default PII should be sent to Sentry and propagated in ourgoing requests
* when Tracing is used.
*
* @deprecated Use top-level `getClient().getOptions().sendDefaultPii` instead. This function
* only unnecessarily increased API surface but only wrapped accessing the option.
*/
shouldSendDefaultPii() {
// eslint-disable-next-line deprecation/deprecation
const client = this.getClient();
const options = client && client.getOptions();
return Boolean(options && options.sendDefaultPii);
}
/**
* Sends the current Session on the scope
*/
_sendSessionUpdate() {
// eslint-disable-next-line deprecation/deprecation
const { scope, client } = this.getStackTop();
const session = scope.getSession();
if (session && client && client.captureSession) {
client.captureSession(session);
}
}
/**
* Calls global extension method and binding current instance to the function call
*/
// @ts-expect-error Function lacks ending return statement and return type does not include 'undefined'. ts(2366)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_callExtensionMethod(method, ...args) {
const carrier = getMainCarrier();
const sentry = carrier.__SENTRY__;
if (sentry && sentry.extensions && typeof sentry.extensions[method] === 'function') {
return sentry.extensions[method].apply(this, args);
}
_debug_build_js__WEBPACK_IMPORTED_MODULE_6__/* .DEBUG_BUILD */ .X && _sentry_utils__WEBPACK_IMPORTED_MODULE_5__/* .logger.warn */ .kg.warn(`Extension method ${method} couldn't be found, doing nothing.`);
}
}
/**
* Returns the global shim registry.
*
* FIXME: This function is problematic, because despite always returning a valid Carrier,
* it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check
* at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.
**/
function getMainCarrier() {
_sentry_utils__WEBPACK_IMPORTED_MODULE_9__/* .GLOBAL_OBJ.__SENTRY__ */ .n2.__SENTRY__ = _sentry_utils__WEBPACK_IMPORTED_MODULE_9__/* .GLOBAL_OBJ.__SENTRY__ */ .n2.__SENTRY__ || {
extensions: {},
hub: undefined,
};
return _sentry_utils__WEBPACK_IMPORTED_MODULE_9__/* .GLOBAL_OBJ */ .n2;
}
/**
* Replaces the current main hub with the passed one on the global object
*
* @returns The old replaced hub
*
* @deprecated Use `setCurrentClient()` instead.
*/
// eslint-disable-next-line deprecation/deprecation
function makeMain(hub) {
const registry = getMainCarrier();
const oldHub = getHubFromCarrier(registry);
setHubOnCarrier(registry, hub);
return oldHub;
}
/**
* Returns the default hub instance.
*
* If a hub is already registered in the global carrier but this module
* contains a more recent version, it replaces the registered version.
* Otherwise, the currently registered hub will be returned.
*
* @deprecated Use the respective replacement method directly instead.
*/
// eslint-disable-next-line deprecation/deprecation
function getCurrentHub() {
// Get main carrier (global for every environment)
const registry = getMainCarrier();
if (registry.__SENTRY__ && registry.__SENTRY__.acs) {
const hub = registry.__SENTRY__.acs.getCurrentHub();
if (hub) {
return hub;
}
}
// Return hub that lives on a global object
return getGlobalHub(registry);
}
/**
* Get the currently active isolation scope.
* The isolation scope is active for the cu