Newer
Older
'removeEventListener',
function (originalRemoveEventListener) {
return function (
type,
listener,
options,
) {
if (type === 'click' || type == 'keypress') {
try {
const el = this ;
const handlers = el.__sentry_instrumentation_handlers__ || {};
const handlerForType = handlers[type];
if (handlerForType) {
handlerForType.refCount--;
// If there are no longer any custom handlers of the current type on this element, we can remove ours, too.
if (handlerForType.refCount <= 0) {
originalRemoveEventListener.call(this, type, handlerForType.handler, options);
handlerForType.handler = undefined;
delete handlers[type]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
}
// If there are no longer any custom handlers of any type on this element, cleanup everything.
if (Object.keys(handlers).length === 0) {
delete el.__sentry_instrumentation_handlers__;
}
}
} catch (e) {
// Accessing dom properties is always fragile.
// Also allows us to skip `addEventListenrs` calls with no proper `this` context.
}
}
return originalRemoveEventListener.call(this, type, listener, options);
};
},
);
});
}
let _oldOnErrorHandler = null;
/** JSDoc */
function instrumentError() {
_oldOnErrorHandler = WINDOW.onerror;
WINDOW.onerror = function (msg, url, line, column, error) {
triggerHandlers('error', {
column,
error,
line,
msg,
url,
});
if (_oldOnErrorHandler) {
// eslint-disable-next-line prefer-rest-params
return _oldOnErrorHandler.apply(this, arguments);
}
return false;
};
}
let _oldOnUnhandledRejectionHandler = null;
/** JSDoc */
function instrumentUnhandledRejection() {
_oldOnUnhandledRejectionHandler = WINDOW.onunhandledrejection;
WINDOW.onunhandledrejection = function (e) {
triggerHandlers('unhandledrejection', e);
if (_oldOnUnhandledRejectionHandler) {
// eslint-disable-next-line prefer-rest-params
return _oldOnUnhandledRejectionHandler.apply(this, arguments);
}
return true;
};
}
//# sourceMappingURL=instrument.js.map
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "isNativeFetch": () => (/* binding */ isNativeFetch),
/* harmony export */ "supportsDOMError": () => (/* binding */ supportsDOMError),
/* harmony export */ "supportsDOMException": () => (/* binding */ supportsDOMException),
/* harmony export */ "supportsErrorEvent": () => (/* binding */ supportsErrorEvent),
/* harmony export */ "supportsFetch": () => (/* binding */ supportsFetch),
/* harmony export */ "supportsHistory": () => (/* binding */ supportsHistory),
/* harmony export */ "supportsNativeFetch": () => (/* binding */ supportsNativeFetch),
/* harmony export */ "supportsReferrerPolicy": () => (/* binding */ supportsReferrerPolicy),
/* harmony export */ "supportsReportingObserver": () => (/* binding */ supportsReportingObserver)
/* harmony export */ });
/* harmony import */ var _logger_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1548);
/* harmony import */ var _worldwide_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1539);
// eslint-disable-next-line deprecation/deprecation
const WINDOW = (0,_worldwide_js__WEBPACK_IMPORTED_MODULE_0__.getGlobalObject)();
237111
237112
237113
237114
237115
237116
237117
237118
237119
237120
237121
237122
237123
237124
237125
237126
237127
237128
237129
237130
237131
237132
237133
237134
237135
237136
237137
237138
237139
237140
/**
* Tells whether current environment supports ErrorEvent objects
* {@link supportsErrorEvent}.
*
* @returns Answer to the given question.
*/
function supportsErrorEvent() {
try {
new ErrorEvent('');
return true;
} catch (e) {
return false;
}
}
/**
* Tells whether current environment supports DOMError objects
* {@link supportsDOMError}.
*
* @returns Answer to the given question.
*/
function supportsDOMError() {
try {
// Chrome: VM89:1 Uncaught TypeError: Failed to construct 'DOMError':
// 1 argument required, but only 0 present.
// @ts-ignore It really needs 1 argument, not 0.
new DOMError('');
return true;
} catch (e) {
return false;
}
}
/**
* Tells whether current environment supports DOMException objects
* {@link supportsDOMException}.
*
* @returns Answer to the given question.
*/
function supportsDOMException() {
try {
new DOMException('');
return true;
} catch (e) {
return false;
}
}
/**
* Tells whether current environment supports Fetch API
* {@link supportsFetch}.
*
* @returns Answer to the given question.
*/
function supportsFetch() {
if (!('fetch' in WINDOW)) {
return false;
}
237170
237171
237172
237173
237174
237175
237176
237177
237178
237179
237180
237181
237182
237183
237184
237185
try {
new Headers();
new Request('http://www.example.com');
new Response();
return true;
} catch (e) {
return false;
}
}
/**
* isNativeFetch checks if the given function is a native implementation of fetch()
*/
// eslint-disable-next-line @typescript-eslint/ban-types
function isNativeFetch(func) {
return func && /^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test(func.toString());
}
/**
* Tells whether current environment supports Fetch API natively
* {@link supportsNativeFetch}.
*
* @returns true if `window.fetch` is natively implemented, false otherwise
*/
function supportsNativeFetch() {
if (!supportsFetch()) {
return false;
}
237198
237199
237200
237201
237202
237203
237204
237205
237206
237207
237208
237209
237210
237211
237212
237213
237214
237215
237216
237217
237218
237219
237220
237221
237222
237223
237224
237225
237226
237227
237228
237229
237230
237231
237232
237233
237234
237235
237236
237237
237238
237239
237240
237241
237242
237243
237244
237245
237246
237247
237248
237249
237250
237251
237252
// Fast path to avoid DOM I/O
// eslint-disable-next-line @typescript-eslint/unbound-method
if (isNativeFetch(WINDOW.fetch)) {
return true;
}
// window.fetch is implemented, but is polyfilled or already wrapped (e.g: by a chrome extension)
// so create a "pure" iframe to see if that has native fetch
let result = false;
const doc = WINDOW.document;
// eslint-disable-next-line deprecation/deprecation
if (doc && typeof (doc.createElement ) === 'function') {
try {
const sandbox = doc.createElement('iframe');
sandbox.hidden = true;
doc.head.appendChild(sandbox);
if (sandbox.contentWindow && sandbox.contentWindow.fetch) {
// eslint-disable-next-line @typescript-eslint/unbound-method
result = isNativeFetch(sandbox.contentWindow.fetch);
}
doc.head.removeChild(sandbox);
} catch (err) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
_logger_js__WEBPACK_IMPORTED_MODULE_1__.logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', err);
}
}
return result;
}
/**
* Tells whether current environment supports ReportingObserver API
* {@link supportsReportingObserver}.
*
* @returns Answer to the given question.
*/
function supportsReportingObserver() {
return 'ReportingObserver' in WINDOW;
}
/**
* Tells whether current environment supports Referrer Policy API
* {@link supportsReferrerPolicy}.
*
* @returns Answer to the given question.
*/
function supportsReferrerPolicy() {
// Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default'
// (see https://caniuse.com/#feat=referrer-policy),
// it doesn't. And it throws an exception instead of ignoring this parameter...
// REF: https://github.com/getsentry/raven-js/issues/1233
if (!supportsFetch()) {
return false;
}
try {
new Request('_', {
referrerPolicy: 'origin' ,
});
return true;
} catch (e) {
return false;
}
}
237264
237265
237266
237267
237268
237269
237270
237271
237272
237273
237274
237275
237276
237277
237278
237279
/**
* Tells whether current environment supports History API
* {@link supportsHistory}.
*
* @returns Answer to the given question.
*/
function supportsHistory() {
// NOTE: in Chrome App environment, touching history.pushState, *even inside
// a try/catch block*, will cause Chrome to output an error to console.error
// borrowed from: https://github.com/angular/angular.js/pull/13945/files
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const chrome = (WINDOW ).chrome;
const isChromePackagedApp = chrome && chrome.app && chrome.app.runtime;
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
const hasHistoryApi = 'history' in WINDOW && !!WINDOW.history.pushState && !!WINDOW.history.replaceState;
return !isChromePackagedApp && hasHistoryApi;
}
//# sourceMappingURL=supports.js.map
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Apollo": () => (/* reexport safe */ _node_apollo_js__WEBPACK_IMPORTED_MODULE_6__.Apollo),
/* harmony export */ "BrowserTracing": () => (/* reexport safe */ _browser_browsertracing_js__WEBPACK_IMPORTED_MODULE_7__.BrowserTracing),
/* harmony export */ "Express": () => (/* reexport safe */ _node_express_js__WEBPACK_IMPORTED_MODULE_0__.Express),
/* harmony export */ "GraphQL": () => (/* reexport safe */ _node_graphql_js__WEBPACK_IMPORTED_MODULE_5__.GraphQL),
/* harmony export */ "Mongo": () => (/* reexport safe */ _node_mongo_js__WEBPACK_IMPORTED_MODULE_3__.Mongo),
/* harmony export */ "Mysql": () => (/* reexport safe */ _node_mysql_js__WEBPACK_IMPORTED_MODULE_2__.Mysql),
/* harmony export */ "Postgres": () => (/* reexport safe */ _node_postgres_js__WEBPACK_IMPORTED_MODULE_1__.Postgres),
/* harmony export */ "Prisma": () => (/* reexport safe */ _node_prisma_js__WEBPACK_IMPORTED_MODULE_4__.Prisma)
/* harmony import */ var _node_express_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1619);
/* harmony import */ var _node_postgres_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1621);
/* harmony import */ var _node_mysql_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1622);
/* harmony import */ var _node_mongo_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1623);
/* harmony import */ var _node_prisma_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1624);
/* harmony import */ var _node_graphql_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1625);
/* harmony import */ var _node_apollo_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1626);
/* harmony import */ var _browser_browsertracing_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1627);
//# sourceMappingURL=index.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Express": () => (/* binding */ Express)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1558);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1548);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1595);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1596);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1544);
/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1620);
237339
237340
237341
237342
237343
237344
237345
237346
237347
237348
237349
237350
237351
237352
237353
237354
237355
237356
237357
237358
237359
237360
237361
237362
237363
237364
237365
237366
237367
237368
237369
237370
237371
237372
237373
237374
237375
/**
* Express integration
*
* Provides an request and error handler for Express framework as well as tracing capabilities
*/
class Express {
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'Express';}
/**
* @inheritDoc
*/
__init() {this.name = Express.id;}
/**
* Express App instance
*/
/**
* @inheritDoc
*/
constructor(options = {}) {;Express.prototype.__init.call(this);
this._router = options.router || options.app;
this._methods = (Array.isArray(options.methods) ? options.methods : []).concat('use');
}
/**
* @inheritDoc
*/
setupOnce(_, getCurrentHub) {
if (!this._router) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.error('ExpressIntegration is missing an Express instance');
return;
}
if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_1__.shouldDisableAutoInstrumentation)(getCurrentHub)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.log('Express Integration is skipped because of instrumenter configuration.');
237382
237383
237384
237385
237386
237387
237388
237389
237390
237391
237392
237393
237394
237395
237396
237397
237398
237399
237400
237401
237402
237403
237404
237405
237406
237407
237408
237409
237410
237411
237412
237413
237414
237415
237416
237417
237418
237419
237420
237421
237422
237423
237424
237425
237426
237427
237428
237429
237430
237431
return;
}
instrumentMiddlewares(this._router, this._methods);
instrumentRouter(this._router );
}
}Express.__initStatic();
/**
* Wraps original middleware function in a tracing call, which stores the info about the call as a span,
* and finishes it once the middleware is done invoking.
*
* Express middlewares have 3 various forms, thus we have to take care of all of them:
* // sync
* app.use(function (req, res) { ... })
* // async
* app.use(function (req, res, next) { ... })
* // error handler
* app.use(function (err, req, res, next) { ... })
*
* They all internally delegate to the `router[method]` of the given application instance.
*/
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any
function wrap(fn, method) {
const arity = fn.length;
switch (arity) {
case 2: {
return function ( req, res) {
const transaction = res.__sentry_transaction;
if (transaction) {
const span = transaction.startChild({
description: fn.name,
op: `middleware.express.${method}`,
});
res.once('finish', () => {
span.finish();
});
}
return fn.call(this, req, res);
};
}
case 3: {
return function (
req,
res,
next,
) {
const transaction = res.__sentry_transaction;
const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([transaction, 'optionalAccess', _2 => _2.startChild, 'call', _3 => _3({
description: fn.name,
op: `middleware.express.${method}`,
})]);
fn.call(this, req, res, function ( ...args) {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([span, 'optionalAccess', _4 => _4.finish, 'call', _5 => _5()]);
next.call(this, ...args);
});
};
}
case 4: {
return function (
err,
req,
res,
next,
) {
const transaction = res.__sentry_transaction;
const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([transaction, 'optionalAccess', _6 => _6.startChild, 'call', _7 => _7({
description: fn.name,
op: `middleware.express.${method}`,
})]);
fn.call(this, err, req, res, function ( ...args) {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]);
237457
237458
237459
237460
237461
237462
237463
237464
237465
237466
237467
237468
237469
237470
237471
237472
237473
237474
237475
237476
237477
237478
237479
237480
237481
237482
237483
237484
237485
237486
237487
237488
237489
237490
237491
237492
237493
237494
237495
237496
237497
237498
237499
237500
237501
237502
237503
237504
237505
237506
237507
237508
237509
237510
237511
237512
237513
237514
237515
237516
237517
237518
237519
237520
237521
237522
237523
237524
237525
237526
237527
237528
237529
237530
237531
237532
237533
237534
237535
237536
237537
237538
237539
237540
237541
237542
237543
237544
237545
237546
next.call(this, ...args);
});
};
}
default: {
throw new Error(`Express middleware takes 2-4 arguments. Got: ${arity}`);
}
}
}
/**
* Takes all the function arguments passed to the original `app` or `router` method, eg. `app.use` or `router.use`
* and wraps every function, as well as array of functions with a call to our `wrap` method.
* We have to take care of the arrays as well as iterate over all of the arguments,
* as `app.use` can accept middlewares in few various forms.
*
* app.use([<path>], <fn>)
* app.use([<path>], <fn>, ...<fn>)
* app.use([<path>], ...<fn>[])
*/
function wrapMiddlewareArgs(args, method) {
return args.map((arg) => {
if (typeof arg === 'function') {
return wrap(arg, method);
}
if (Array.isArray(arg)) {
return arg.map((a) => {
if (typeof a === 'function') {
return wrap(a, method);
}
return a;
});
}
return arg;
});
}
/**
* Patches original router to utilize our tracing functionality
*/
function patchMiddleware(router, method) {
const originalCallback = router[method];
router[method] = function (...args) {
return originalCallback.call(this, ...wrapMiddlewareArgs(args, method));
};
return router;
}
/**
* Patches original router methods
*/
function instrumentMiddlewares(router, methods = []) {
methods.forEach((method) => patchMiddleware(router, method));
}
/**
* Patches the prototype of Express.Router to accumulate the resolved route
* if a layer instance's `match` function was called and it returned a successful match.
*
* @see https://github.com/expressjs/express/blob/master/lib/router/index.js
*
* @param appOrRouter the router instance which can either be an app (i.e. top-level) or a (nested) router.
*/
function instrumentRouter(appOrRouter) {
// This is how we can distinguish between app and routers
const isApp = 'settings' in appOrRouter;
// In case the app's top-level router hasn't been initialized yet, we have to do it now
if (isApp && appOrRouter._router === undefined && appOrRouter.lazyrouter) {
appOrRouter.lazyrouter();
}
const router = isApp ? appOrRouter._router : appOrRouter;
if (!router) {
/*
If we end up here, this means likely that this integration is used with Express 3 or Express 5.
For now, we don't support these versions (3 is very old and 5 is still in beta). To support Express 5,
we'd need to make more changes to the routing instrumentation because the router is no longer part of
the Express core package but maintained in its own package. The new router has different function
signatures and works slightly differently, demanding more changes than just taking the router from
`app.router` instead of `app._router`.
@see https://github.com/pillarjs/router
TODO: Proper Express 5 support
*/
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.debug('Cannot instrument router for URL Parameterization (did not find a valid router).');
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.debug('Routing instrumentation is currently only supported in Express 4.');
237549
237550
237551
237552
237553
237554
237555
237556
237557
237558
237559
237560
237561
237562
237563
237564
237565
237566
237567
237568
237569
237570
237571
237572
237573
237574
237575
237576
237577
237578
237579
237580
237581
237582
237583
237584
237585
237586
237587
237588
237589
237590
237591
237592
237593
237594
237595
return;
}
const routerProto = Object.getPrototypeOf(router) ;
const originalProcessParams = routerProto.process_params;
routerProto.process_params = function process_params(
layer,
called,
req,
res,
done,
) {
// Base case: We're in the first part of the URL (thus we start with the root '/')
if (!req._reconstructedRoute) {
req._reconstructedRoute = '';
}
// If the layer's partial route has params, is a regex or an array, the route is stored in layer.route.
const { layerRoutePath, isRegex, isArray, numExtraSegments } = getLayerRoutePathInfo(layer);
if (layerRoutePath || isRegex || isArray) {
req._hasParameters = true;
}
// Otherwise, the hardcoded path (i.e. a partial route without params) is stored in layer.path
const partialRoute = layerRoutePath || layer.path || '';
// Normalize the partial route so that it doesn't contain leading or trailing slashes
// and exclude empty or '*' wildcard routes.
// The exclusion of '*' routes is our best effort to not "pollute" the transaction name
// with interim handlers (e.g. ones that check authentication or do other middleware stuff).
// We want to end up with the parameterized URL of the incoming request without any extraneous path segments.
const finalPartialRoute = partialRoute
.split('/')
.filter(segment => segment.length > 0 && (isRegex || isArray || !segment.includes('*')))
.join('/');
// If we found a valid partial URL, we append it to the reconstructed route
if (finalPartialRoute && finalPartialRoute.length > 0) {
// If the partial route is from a regex route, we append a '/' to close the regex
req._reconstructedRoute += `/${finalPartialRoute}${isRegex ? '/' : ''}`;
}
// Now we check if we are in the "last" part of the route. We determine this by comparing the
// number of URL segments from the original URL to that of our reconstructed parameterized URL.
// If we've reached our final destination, we update the transaction name.
const urlLength = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getNumberOfUrlSegments)(req.originalUrl || '') + numExtraSegments;
const routeLength = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getNumberOfUrlSegments)(req._reconstructedRoute);
if (urlLength === routeLength) {
if (!req._hasParameters) {
if (req._reconstructedRoute !== req.originalUrl) {
req._reconstructedRoute = req.originalUrl;
}
}
const transaction = res.__sentry_transaction;
if (transaction && transaction.metadata.source !== 'custom') {
// If the request URL is '/' or empty, the reconstructed route will be empty.
// Therefore, we fall back to setting the final route to '/' in this case.
const finalRoute = req._reconstructedRoute || '/';
transaction.setName(...(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.extractPathForTransaction)(req, { path: true, method: true, customRoute: finalRoute }));
237613
237614
237615
237616
237617
237618
237619
237620
237621
237622
237623
237624
237625
237626
237627
237628
237629
237630
237631
}
}
return originalProcessParams.call(this, layer, called, req, res, done);
};
}
/**
* Extracts and stringifies the layer's route which can either be a string with parameters (`users/:id`),
* a RegEx (`/test/`) or an array of strings and regexes (`['/path1', /\/path[2-5]/, /path/:id]`). Additionally
* returns extra information about the route, such as if the route is defined as regex or as an array.
*
* @param layer the layer to extract the stringified route from
*
* @returns an object containing the stringified route, a flag determining if the route was a regex
* and the number of extra segments to the matched path that are additionally in the route,
* if the route was an array (defaults to 0).
*/
function getLayerRoutePathInfo(layer) {
const lrp = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([layer, 'access', _10 => _10.route, 'optionalAccess', _11 => _11.path]);
const isRegex = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isRegExp)(lrp);
const isArray = Array.isArray(lrp);
if (!lrp) {
return { isRegex, isArray, numExtraSegments: 0 };
}
const numExtraSegments = isArray
? Math.max(getNumberOfArrayUrlSegments(lrp ) - (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getNumberOfUrlSegments)(layer.path || ''), 0)
237643
237644
237645
237646
237647
237648
237649
237650
237651
237652
237653
237654
237655
237656
237657
: 0;
const layerRoutePath = getLayerRoutePathString(isArray, lrp);
return { layerRoutePath, isRegex, isArray, numExtraSegments };
}
/**
* Returns the number of URL segments in an array of routes
*
* Example: ['/api/test', /\/api\/post[0-9]/, '/users/:id/details`] -> 7
*/
function getNumberOfArrayUrlSegments(routesArray) {
return routesArray.reduce((accNumSegments, currentRoute) => {
// array members can be a RegEx -> convert them toString
return accNumSegments + (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.getNumberOfUrlSegments)(currentRoute.toString());
237659
237660
237661
237662
237663
237664
237665
237666
237667
237668
237669
237670
237671
237672
237673
237674
237675
237676
237677
237678
237679
}, 0);
}
/**
* Extracts and returns the stringified version of the layers route path
* Handles route arrays (by joining the paths together) as well as RegExp and normal
* string values (in the latter case the toString conversion is technically unnecessary but
* it doesn't hurt us either).
*/
function getLayerRoutePathString(isArray, lrp) {
if (isArray) {
return (lrp ).map(r => r.toString()).join(',');
}
return lrp && lrp.toString();
}
//# sourceMappingURL=express.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "shouldDisableAutoInstrumentation": () => (/* binding */ shouldDisableAutoInstrumentation)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1558);
/**
* Check if Sentry auto-instrumentation should be disabled.
*
* @param getCurrentHub A method to fetch the current hub
* @returns boolean
*/
function shouldDisableAutoInstrumentation(getCurrentHub) {
const clientOptions = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_0__._optionalChain)([getCurrentHub, 'call', _ => _(), 'access', _2 => _2.getClient, 'call', _3 => _3(), 'optionalAccess', _4 => _4.getOptions, 'call', _5 => _5()]);
const instrumenter = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_0__._optionalChain)([clientOptions, 'optionalAccess', _6 => _6.instrumenter]) || 'sentry';
return instrumenter !== 'sentry';
}
//# sourceMappingURL=node-utils.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Postgres": () => (/* binding */ Postgres)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1558);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1548);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1540);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1545);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1544);
/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1620);
237723
237724
237725
237726
237727
237728
237729
237730
237731
237732
237733
237734
237735
237736
237737
237738
237739
237740
237741
237742
237743
237744
237745
237746
/** Tracing integration for node-postgres package */
class Postgres {
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'Postgres';}
/**
* @inheritDoc
*/
__init() {this.name = Postgres.id;}
constructor(options = {}) {;Postgres.prototype.__init.call(this);
this._usePgNative = !!options.usePgNative;
}
/**
* @inheritDoc
*/
setupOnce(_, getCurrentHub) {
if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_0__.shouldDisableAutoInstrumentation)(getCurrentHub)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('Postgres Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.loadModule)('pg');
if (!pkg) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('Postgres Integration was unable to require `pg` package.');
return;
}
if (this._usePgNative && !(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([pkg, 'access', _2 => _2.native, 'optionalAccess', _3 => _3.Client])) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error("Postgres Integration was unable to access 'pg-native' bindings.");
return;
}
const { Client } = this._usePgNative ? pkg.native : pkg;
/**
* function (query, callback) => void
* function (query, params, callback) => void
* function (query) => Promise
* function (query, params) => Promise
* function (pg.Cursor) => pg.Cursor
*/
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_4__.fill)(Client.prototype, 'query', function (orig) {
return function ( config, values, callback) {
const scope = getCurrentHub().getScope();
const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([scope, 'optionalAccess', _4 => _4.getSpan, 'call', _5 => _5()]);
const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([parentSpan, 'optionalAccess', _6 => _6.startChild, 'call', _7 => _7({
description: typeof config === 'string' ? config : (config ).text,
op: 'db',
})]);
if (typeof callback === 'function') {
return orig.call(this, config, values, function (err, result) {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]);
callback(err, result);
});
}
if (typeof values === 'function') {
return orig.call(this, config, function (err, result) {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([span, 'optionalAccess', _10 => _10.finish, 'call', _11 => _11()]);
values(err, result);
});
}
const rv = typeof values !== 'undefined' ? orig.call(this, config, values) : orig.call(this, config);
if ((0,_sentry_utils__WEBPACK_IMPORTED_MODULE_5__.isThenable)(rv)) {
return rv.then((res) => {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([span, 'optionalAccess', _12 => _12.finish, 'call', _13 => _13()]);
return res;
});
}
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_3__._optionalChain)([span, 'optionalAccess', _14 => _14.finish, 'call', _15 => _15()]);
return rv;
};
});
}
}Postgres.__initStatic();
//# sourceMappingURL=postgres.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Mysql": () => (/* binding */ Mysql)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1558);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1548);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1540);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1545);
/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1620);
237830
237831
237832
237833
237834
237835
237836
237837
237838
237839
237840
237841
237842
237843
237844
237845
237846
237847
237848
237849
/** Tracing integration for node-mysql package */
class Mysql {constructor() { Mysql.prototype.__init.call(this); }
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'Mysql';}
/**
* @inheritDoc
*/
__init() {this.name = Mysql.id;}
/**
* @inheritDoc
*/
setupOnce(_, getCurrentHub) {
if ((0,_utils_node_utils_js__WEBPACK_IMPORTED_MODULE_0__.shouldDisableAutoInstrumentation)(getCurrentHub)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.log('Mysql Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.loadModule)('mysql/lib/Connection.js');
if (!pkg) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_1__.logger.error('Mysql Integration was unable to require `mysql` package.');
return;
}
// The original function will have one of these signatures:
// function (callback) => void
// function (options, callback) => void
// function (options, values, callback) => void
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.fill)(pkg, 'createQuery', function (orig) {
return function ( options, values, callback) {
const scope = getCurrentHub().getScope();
const parentSpan = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([scope, 'optionalAccess', _2 => _2.getSpan, 'call', _3 => _3()]);
const span = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5({
description: typeof options === 'string' ? options : (options ).sql,
op: 'db',
})]);
if (typeof callback === 'function') {
return orig.call(this, options, values, function (err, result, fields) {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _6 => _6.finish, 'call', _7 => _7()]);
callback(err, result, fields);
});
}
if (typeof values === 'function') {
return orig.call(this, options, function (err, result, fields) {
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__._optionalChain)([span, 'optionalAccess', _8 => _8.finish, 'call', _9 => _9()]);
237885
237886
237887
237888
237889
237890
237891
237892
237893
237894
237895
237896
237897
237898
237899
values(err, result, fields);
});
}
return orig.call(this, options, values, callback);
};
});
}
}Mysql.__initStatic();
//# sourceMappingURL=mysql.js.map
/***/ }),
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Mongo": () => (/* binding */ Mongo)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1558);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1548);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1540);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1545);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1544);
/* harmony import */ var _utils_node_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1620);
237914
237915
237916
237917
237918
237919
237920
237921
237922
237923
237924
237925
237926
237927
237928
237929
237930
237931
237932
237933
237934
237935
237936
237937
237938
237939
237940
237941
237942
237943
237944
237945
237946
237947
237948
237949
237950
237951
237952
237953
237954
237955
237956
237957
237958
237959
237960
237961
237962
237963
237964
237965
237966
237967
237968
237969
237970
237971
237972
237973
237974
237975
237976
237977
237978
237979
237980
237981
237982
237983
237984
237985
237986
237987
237988
// This allows us to use the same array for both defaults options and the type itself.
// (note `as const` at the end to make it a union of string literal types (i.e. "a" | "b" | ... )
// and not just a string[])
const OPERATIONS = [
'aggregate', // aggregate(pipeline, options, callback)
'bulkWrite', // bulkWrite(operations, options, callback)
'countDocuments', // countDocuments(query, options, callback)
'createIndex', // createIndex(fieldOrSpec, options, callback)
'createIndexes', // createIndexes(indexSpecs, options, callback)
'deleteMany', // deleteMany(filter, options, callback)
'deleteOne', // deleteOne(filter, options, callback)
'distinct', // distinct(key, query, options, callback)
'drop', // drop(options, callback)
'dropIndex', // dropIndex(indexName, options, callback)
'dropIndexes', // dropIndexes(options, callback)
'estimatedDocumentCount', // estimatedDocumentCount(options, callback)
'find', // find(query, options, callback)
'findOne', // findOne(query, options, callback)
'findOneAndDelete', // findOneAndDelete(filter, options, callback)
'findOneAndReplace', // findOneAndReplace(filter, replacement, options, callback)
'findOneAndUpdate', // findOneAndUpdate(filter, update, options, callback)
'indexes', // indexes(options, callback)
'indexExists', // indexExists(indexes, options, callback)
'indexInformation', // indexInformation(options, callback)
'initializeOrderedBulkOp', // initializeOrderedBulkOp(options, callback)
'insertMany', // insertMany(docs, options, callback)
'insertOne', // insertOne(doc, options, callback)
'isCapped', // isCapped(options, callback)
'mapReduce', // mapReduce(map, reduce, options, callback)
'options', // options(options, callback)
'parallelCollectionScan', // parallelCollectionScan(options, callback)
'rename', // rename(newName, options, callback)
'replaceOne', // replaceOne(filter, doc, options, callback)
'stats', // stats(options, callback)
'updateMany', // updateMany(filter, update, options, callback)
'updateOne', // updateOne(filter, update, options, callback)
] ;
// All of the operations above take `options` and `callback` as their final parameters, but some of them
// take additional parameters as well. For those operations, this is a map of
// { <operation name>: [<names of additional parameters>] }, as a way to know what to call the operation's
// positional arguments when we add them to the span's `data` object later
const OPERATION_SIGNATURES
= {
// aggregate intentionally not included because `pipeline` arguments are too complex to serialize well
// see https://github.com/getsentry/sentry-javascript/pull/3102
bulkWrite: ['operations'],
countDocuments: ['query'],
createIndex: ['fieldOrSpec'],
createIndexes: ['indexSpecs'],
deleteMany: ['filter'],
deleteOne: ['filter'],
distinct: ['key', 'query'],
dropIndex: ['indexName'],
find: ['query'],
findOne: ['query'],
findOneAndDelete: ['filter'],
findOneAndReplace: ['filter', 'replacement'],
findOneAndUpdate: ['filter', 'update'],
indexExists: ['indexes'],
insertMany: ['docs'],
insertOne: ['doc'],
mapReduce: ['map', 'reduce'],
rename: ['newName'],
replaceOne: ['filter', 'doc'],
updateMany: ['filter', 'update'],
updateOne: ['filter', 'update'],
};
function isCursor(maybeCursor) {
return maybeCursor && typeof maybeCursor === 'object' && maybeCursor.once && typeof maybeCursor.once === 'function';
}
/** Tracing integration for mongo package */
class Mongo {
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'Mongo';}
/**