Newer
Older
240001
240002
240003
240004
240005
240006
240007
240008
240009
240010
240011
240012
240013
240014
240015
240016
240017
240018
240019
240020
240021
240022
240023
240024
240025
240026
240027
240028
240029
240030
240031
240032
240033
240034
240035
240036
240037
240038
240039
240040
240041
240042
240043
240044
240045
240046
240047
240048
240049
240050
240051
240052
240053
240054
240055
240056
240057
240058
240059
240060
240061
240062
240063
240064
240065
240066
240067
240068
240069
240070
240071
240072
240073
240074
240075
240076
240077
240078
240079
240080
240081
240082
240083
240084
240085
240086
240087
240088
240089
240090
240091
240092
240093
240094
240095
240096
240097
240098
240099
240100
240101
240102
240103
240104
240105
240106
240107
240108
240109
240110
240111
240112
240113
240114
240115
240116
240117
240118
240119
240120
240121
240122
240123
240124
240125
240126
240127
240128
240129
240130
240131
240132
240133
240134
240135
240136
240137
240138
240139
240140
240141
240142
240143
240144
240145
240146
240147
240148
240149
240150
240151
240152
240153
240154
240155
240156
240157
240158
240159
240160
240161
240162
240163
240164
240165
240166
240167
240168
240169
240170
240171
240172
240173
240174
240175
240176
240177
240178
240179
240180
240181
240182
240183
240184
240185
240186
240187
240188
240189
240190
240191
240192
240193
240194
240195
240196
240197
240198
240199
240200
240201
240202
240203
240204
240205
240206
240207
240208
240209
240210
240211
240212
240213
240214
240215
240216
240217
240218
240219
240220
240221
240222
240223
240224
240225
240226
240227
240228
240229
240230
240231
240232
240233
240234
240235
240236
240237
240238
240239
240240
240241
240242
240243
240244
240245
240246
240247
240248
240249
240250
240251
240252
240253
240254
240255
240256
240257
240258
240259
240260
240261
240262
240263
240264
240265
240266
240267
240268
240269
240270
240271
240272
240273
240274
240275
240276
240277
240278
240279
240280
240281
240282
240283
240284
240285
240286
240287
240288
240289
240290
240291
240292
240293
240294
240295
240296
240297
240298
240299
240300
240301
240302
240303
240304
240305
240306
240307
240308
240309
240310
240311
240312
240313
240314
240315
240316
240317
240318
240319
240320
240321
240322
240323
240324
240325
240326
240327
240328
240329
240330
240331
240332
240333
240334
240335
240336
240337
240338
240339
240340
240341
240342
240343
240344
240345
240346
240347
240348
240349
240350
240351
240352
240353
240354
240355
240356
240357
240358
240359
240360
240361
240362
240363
240364
240365
240366
240367
240368
240369
240370
240371
240372
240373
240374
240375
240376
240377
240378
240379
240380
240381
240382
240383
240384
240385
240386
240387
240388
240389
240390
240391
240392
240393
240394
240395
240396
240397
240398
240399
240400
240401
240402
240403
240404
240405
240406
240407
240408
240409
240410
240411
240412
240413
240414
240415
240416
240417
240418
240419
240420
240421
240422
240423
240424
240425
240426
240427
240428
240429
240430
240431
240432
240433
240434
240435
240436
240437
240438
240439
240440
240441
240442
240443
240444
240445
240446
240447
240448
240449
240450
240451
240452
240453
240454
240455
240456
240457
240458
240459
240460
240461
240462
240463
240464
240465
240466
240467
240468
240469
240470
240471
240472
240473
240474
240475
240476
240477
240478
240479
240480
240481
240482
240483
240484
240485
240486
240487
240488
240489
240490
240491
240492
240493
240494
240495
240496
240497
240498
240499
240500
240501
240502
240503
240504
240505
240506
240507
240508
240509
240510
240511
240512
240513
240514
240515
240516
240517
240518
240519
240520
240521
240522
240523
240524
240525
240526
240527
240528
240529
240530
240531
240532
240533
240534
240535
240536
240537
240538
240539
240540
240541
240542
240543
240544
240545
240546
240547
240548
240549
240550
240551
240552
240553
240554
240555
240556
240557
240558
240559
240560
240561
240562
240563
240564
240565
240566
240567
240568
240569
240570
240571
240572
240573
240574
240575
240576
240577
240578
240579
240580
240581
240582
240583
240584
240585
240586
240587
240588
240589
240590
240591
240592
240593
240594
240595
240596
240597
240598
240599
240600
240601
240602
240603
240604
240605
240606
240607
240608
240609
240610
240611
240612
240613
240614
240615
240616
240617
240618
240619
240620
240621
240622
240623
240624
240625
240626
240627
240628
240629
240630
240631
240632
240633
240634
240635
240636
240637
240638
240639
240640
240641
240642
240643
240644
240645
240646
240647
240648
240649
240650
240651
240652
240653
240654
240655
240656
240657
240658
240659
240660
240661
240662
240663
240664
240665
240666
240667
240668
240669
240670
240671
240672
240673
240674
240675
240676
240677
240678
240679
240680
240681
240682
240683
240684
240685
240686
240687
240688
240689
240690
240691
240692
240693
240694
240695
240696
240697
240698
240699
240700
240701
240702
240703
240704
240705
240706
240707
240708
240709
240710
240711
240712
240713
240714
240715
240716
240717
240718
240719
240720
240721
240722
240723
240724
240725
240726
240727
240728
240729
240730
240731
240732
240733
240734
240735
240736
240737
240738
240739
240740
240741
240742
240743
240744
240745
240746
240747
240748
240749
240750
240751
240752
240753
240754
240755
240756
240757
240758
240759
240760
240761
240762
240763
240764
240765
240766
240767
240768
240769
240770
240771
240772
240773
240774
240775
240776
240777
240778
240779
240780
240781
240782
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1609);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1610);
// "Script error." is hard coded into browsers for errors that it can't read.
// this is the result of a script being pulled in from an external domain and CORS.
const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/];
/** Options for the InboundFilters integration */
/** Inbound filters configurable by the user */
class InboundFilters {
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'InboundFilters';}
/**
* @inheritDoc
*/
__init() {this.name = InboundFilters.id;}
constructor( _options = {}) {;this._options = _options;InboundFilters.prototype.__init.call(this);}
/**
* @inheritDoc
*/
setupOnce(addGlobalEventProcessor, getCurrentHub) {
const eventProcess = (event) => {
const hub = getCurrentHub();
if (hub) {
const self = hub.getIntegration(InboundFilters);
if (self) {
const client = hub.getClient();
const clientOptions = client ? client.getOptions() : {};
const options = _mergeOptions(self._options, clientOptions);
return _shouldDropEvent(event, options) ? null : event;
}
}
return event;
};
eventProcess.id = this.name;
addGlobalEventProcessor(eventProcess);
}
} InboundFilters.__initStatic();
/** JSDoc */
function _mergeOptions(
internalOptions = {},
clientOptions = {},
) {
return {
allowUrls: [...(internalOptions.allowUrls || []), ...(clientOptions.allowUrls || [])],
denyUrls: [...(internalOptions.denyUrls || []), ...(clientOptions.denyUrls || [])],
ignoreErrors: [
...(internalOptions.ignoreErrors || []),
...(clientOptions.ignoreErrors || []),
...DEFAULT_IGNORE_ERRORS,
],
ignoreInternal: internalOptions.ignoreInternal !== undefined ? internalOptions.ignoreInternal : true,
};
}
/** JSDoc */
function _shouldDropEvent(event, options) {
if (options.ignoreInternal && _isSentryError(event)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.warn(`Event dropped due to being internal Sentry Error.\nEvent: ${(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.getEventDescription)(event)}`);
return true;
}
if (_isIgnoredError(event, options.ignoreErrors)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.warn(
`Event dropped due to being matched by \`ignoreErrors\` option.\nEvent: ${(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.getEventDescription)(event)}`,
);
return true;
}
if (_isDeniedUrl(event, options.denyUrls)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.warn(
`Event dropped due to being matched by \`denyUrls\` option.\nEvent: ${(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.getEventDescription)(
event,
)}.\nUrl: ${_getEventFilterUrl(event)}`,
);
return true;
}
if (!_isAllowedUrl(event, options.allowUrls)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.warn(
`Event dropped due to not being matched by \`allowUrls\` option.\nEvent: ${(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.getEventDescription)(
event,
)}.\nUrl: ${_getEventFilterUrl(event)}`,
);
return true;
}
return false;
}
function _isIgnoredError(event, ignoreErrors) {
if (!ignoreErrors || !ignoreErrors.length) {
return false;
}
return _getPossibleEventMessages(event).some(message => (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.stringMatchesSomePattern)(message, ignoreErrors));
}
function _isDeniedUrl(event, denyUrls) {
// TODO: Use Glob instead?
if (!denyUrls || !denyUrls.length) {
return false;
}
const url = _getEventFilterUrl(event);
return !url ? false : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.stringMatchesSomePattern)(url, denyUrls);
}
function _isAllowedUrl(event, allowUrls) {
// TODO: Use Glob instead?
if (!allowUrls || !allowUrls.length) {
return true;
}
const url = _getEventFilterUrl(event);
return !url ? true : (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.stringMatchesSomePattern)(url, allowUrls);
}
function _getPossibleEventMessages(event) {
if (event.message) {
return [event.message];
}
if (event.exception) {
try {
const { type = '', value = '' } = (event.exception.values && event.exception.values[0]) || {};
return [`${value}`, `${type}: ${value}`];
} catch (oO) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.error(`Cannot extract message for event ${(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.getEventDescription)(event)}`);
return [];
}
}
return [];
}
function _isSentryError(event) {
try {
// @ts-ignore can't be a sentry error if undefined
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return event.exception.values[0].type === 'SentryError';
} catch (e) {
// ignore
}
return false;
}
function _getLastValidUrl(frames = []) {
for (let i = frames.length - 1; i >= 0; i--) {
const frame = frames[i];
if (frame && frame.filename !== '<anonymous>' && frame.filename !== '[native code]') {
return frame.filename || null;
}
}
return null;
}
function _getEventFilterUrl(event) {
try {
let frames;
try {
// @ts-ignore we only care about frames if the whole thing here is defined
frames = event.exception.values[0].stacktrace.frames;
} catch (e) {
// ignore
}
return frames ? _getLastValidUrl(frames) : null;
} catch (oO) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.error(`Cannot extract url for event ${(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.getEventDescription)(event)}`);
return null;
}
}
//# sourceMappingURL=inboundfilters.js.map
/***/ }),
/* 1674 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "FunctionToString": () => (/* binding */ FunctionToString)
/* harmony export */ });
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1612);
let originalFunctionToString;
/** Patch toString calls to return proper name for wrapped functions */
class FunctionToString {constructor() { FunctionToString.prototype.__init.call(this); }
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'FunctionToString';}
/**
* @inheritDoc
*/
__init() {this.name = FunctionToString.id;}
/**
* @inheritDoc
*/
setupOnce() {
// eslint-disable-next-line @typescript-eslint/unbound-method
originalFunctionToString = Function.prototype.toString;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Function.prototype.toString = function ( ...args) {
const context = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.getOriginalFunction)(this) || this;
return originalFunctionToString.apply(context, args);
};
}
} FunctionToString.__initStatic();
//# sourceMappingURL=functiontostring.js.map
/***/ }),
/* 1675 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "initAndBind": () => (/* binding */ initAndBind)
/* harmony export */ });
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1615);
/* harmony import */ var _hub_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1602);
/** A class object that can instantiate Client objects. */
/**
* Internal function to create a new SDK client instance. The client is
* installed and then bound to the current scope.
*
* @param clientClass The client class to instantiate.
* @param options Options to pass to the client.
*/
function initAndBind(
clientClass,
options,
) {
if (options.debug === true) {
if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
_sentry_utils__WEBPACK_IMPORTED_MODULE_0__.logger.enable();
} else {
// use `console.warn` rather than `logger.warn` since by non-debug bundles have all `logger.x` statements stripped
// eslint-disable-next-line no-console
console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');
}
}
const hub = (0,_hub_js__WEBPACK_IMPORTED_MODULE_1__.getCurrentHub)();
const scope = hub.getScope();
if (scope) {
scope.update(options.initialScope);
}
const client = new clientClass(options);
hub.bindClient(client);
}
//# sourceMappingURL=sdk.js.map
/***/ }),
/* 1676 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "deepReadDirSync": () => (/* binding */ deepReadDirSync)
/* harmony export */ });
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(149);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(142);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
/**
* Recursively read the contents of a directory.
*
* @param targetDir Absolute or relative path of the directory to scan. All returned paths will be relative to this
* directory.
* @returns Array holding all relative paths
*/
function deepReadDirSync(targetDir) {
const targetDirAbsPath = path__WEBPACK_IMPORTED_MODULE_1__.resolve(targetDir);
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(targetDirAbsPath)) {
throw new Error(`Cannot read contents of ${targetDirAbsPath}. Directory does not exist.`);
}
if (!fs__WEBPACK_IMPORTED_MODULE_0__.statSync(targetDirAbsPath).isDirectory()) {
throw new Error(`Cannot read contents of ${targetDirAbsPath}, because it is not a directory.`);
}
// This does the same thing as its containing function, `deepReadDirSync` (except that - purely for convenience - it
// deals in absolute paths rather than relative ones). We need this to be separate from the outer function to preserve
// the difference between `targetDirAbsPath` and `currentDirAbsPath`.
const deepReadCurrentDir = (currentDirAbsPath) => {
return fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(currentDirAbsPath).reduce((absPaths, itemName) => {
const itemAbsPath = path__WEBPACK_IMPORTED_MODULE_1__.join(currentDirAbsPath, itemName);
if (fs__WEBPACK_IMPORTED_MODULE_0__.statSync(itemAbsPath).isDirectory()) {
return [...absPaths, ...deepReadCurrentDir(itemAbsPath)];
}
return [...absPaths, itemAbsPath];
}, []);
};
return deepReadCurrentDir(targetDirAbsPath).map(absPath => path__WEBPACK_IMPORTED_MODULE_1__.relative(targetDirAbsPath, absPath));
}
//# sourceMappingURL=utils.js.map
/***/ }),
/* 1677 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "extractRequestData": () => (/* reexport safe */ _requestDataDeprecated_js__WEBPACK_IMPORTED_MODULE_3__.extractRequestData),
/* harmony export */ "parseRequest": () => (/* reexport safe */ _requestDataDeprecated_js__WEBPACK_IMPORTED_MODULE_3__.parseRequest),
/* harmony export */ "errorHandler": () => (/* binding */ errorHandler),
/* harmony export */ "requestHandler": () => (/* binding */ requestHandler),
/* harmony export */ "tracingHandler": () => (/* binding */ tracingHandler)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1625);
/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1602);
/* harmony import */ var _sentry_core__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(1617);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1615);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1611);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1679);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1657);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1670);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(1612);
/* harmony import */ var domain__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1314);
/* harmony import */ var domain__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(domain__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _requestdata_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1667);
/* harmony import */ var _sdk_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1651);
/* harmony import */ var _requestDataDeprecated_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1678);
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* Express-compatible tracing handler.
* @see Exposed as `Handlers.tracingHandler`
*/
function tracingHandler()
{
return function sentryTracingMiddleware(
req,
res,
next,
) {
const hub = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_4__.getCurrentHub)();
const options = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([hub, 'access', _ => _.getClient, 'call', _2 => _2(), 'optionalAccess', _3 => _3.getOptions, 'call', _4 => _4()]);
if (
!options ||
options.instrumenter !== 'sentry' ||
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([req, 'access', _5 => _5.method, 'optionalAccess', _6 => _6.toUpperCase, 'call', _7 => _7()]) === 'OPTIONS' ||
(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([req, 'access', _8 => _8.method, 'optionalAccess', _9 => _9.toUpperCase, 'call', _10 => _10()]) === 'HEAD'
) {
return next();
}
// TODO: This is the `hasTracingEnabled` check, but we're doing it manually since `@sentry/tracing` isn't a
// dependency of `@sentry/node`. Long term, that function should probably move to `@sentry/hub.
if (!('tracesSampleRate' in options) && !('tracesSampler' in options)) {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
_sentry_utils__WEBPACK_IMPORTED_MODULE_6__.logger.warn(
'Sentry `tracingHandler` is being used, but tracing is disabled. Please enable tracing by setting ' +
'either `tracesSampleRate` or `tracesSampler` in your `Sentry.init()` options.',
);
return next();
}
// If there is a trace header set, we extract the data from it (parentSpanId, traceId, and sampling decision)
const traceparentData =
req.headers && (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_7__.isString)(req.headers['sentry-trace']) && (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_8__.extractTraceparentData)(req.headers['sentry-trace']);
const incomingBaggageHeaders = (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([req, 'access', _11 => _11.headers, 'optionalAccess', _12 => _12.baggage]);
const dynamicSamplingContext = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_9__.baggageHeaderToDynamicSamplingContext)(incomingBaggageHeaders);
const [name, source] = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_10__.extractPathForTransaction)(req, { path: true, method: true });
const transaction = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_11__.startTransaction)(
{
name,
op: 'http.server',
...traceparentData,
metadata: {
dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext,
// The request should already have been stored in `scope.sdkProcessingMetadata` (which will become
// `event.sdkProcessingMetadata` the same way the metadata here will) by `sentryRequestMiddleware`, but on the
// off chance someone is using `sentryTracingMiddleware` without `sentryRequestMiddleware`, it doesn't hurt to
// be sure
request: req,
source,
},
},
// extra context passed to the tracesSampler
{ request: (0,_requestdata_js__WEBPACK_IMPORTED_MODULE_1__.extractRequestData)(req) },
);
// We put the transaction on the scope so users can attach children to it
hub.configureScope(scope => {
scope.setSpan(transaction);
});
// We also set __sentry_transaction on the response so people can grab the transaction there to add
// spans to it later.
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(res ).__sentry_transaction = transaction;
res.once('finish', () => {
// Push `transaction.finish` to the next event loop so open spans have a chance to finish before the transaction
// closes
setImmediate(() => {
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_10__.addRequestDataToTransaction)(transaction, req);
transaction.setHttpStatus(res.statusCode);
transaction.finish();
});
});
next();
};
}
/**
* Backwards compatibility shim which can be removed in v8. Forces the given options to follow the
* `AddRequestDataToEventOptions` interface.
*
* TODO (v8): Get rid of this, and stop passing `requestDataOptionsFromExpressHandler` to `setSDKProcessingMetadata`.
*/
function convertReqHandlerOptsToAddReqDataOpts(
reqHandlerOptions = {},
) {
let addRequestDataOptions;
if ('include' in reqHandlerOptions) {
addRequestDataOptions = { include: reqHandlerOptions.include };
} else {
// eslint-disable-next-line deprecation/deprecation
const { ip, request, transaction, user } = reqHandlerOptions ;
if (ip || request || transaction || user) {
addRequestDataOptions = { include: (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_12__.dropUndefinedKeys)({ ip, request, transaction, user }) };
}
}
return addRequestDataOptions;
}
/**
* Express compatible request handler.
* @see Exposed as `Handlers.requestHandler`
*/
function requestHandler(
options,
) {
// TODO (v8): Get rid of this
const requestDataOptions = convertReqHandlerOptsToAddReqDataOpts(options);
const currentHub = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_4__.getCurrentHub)();
const client = currentHub.getClient();
// Initialise an instance of SessionFlusher on the client when `autoSessionTracking` is enabled and the
// `requestHandler` middleware is used indicating that we are running in SessionAggregates mode
if (client && (0,_sdk_js__WEBPACK_IMPORTED_MODULE_2__.isAutoSessionTrackingEnabled)(client)) {
client.initSessionFlusher();
// If Scope contains a Single mode Session, it is removed in favor of using Session Aggregates mode
const scope = currentHub.getScope();
if (scope && scope.getSession()) {
scope.setSession();
}
}
return function sentryRequestMiddleware(
req,
res,
next,
) {
if (options && options.flushTimeout && options.flushTimeout > 0) {
// eslint-disable-next-line @typescript-eslint/unbound-method
const _end = res.end;
res.end = function (chunk, encoding, cb) {
void (0,_sdk_js__WEBPACK_IMPORTED_MODULE_2__.flush)(options.flushTimeout)
.then(() => {
_end.call(this, chunk, encoding, cb);
})
.then(null, e => {
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && _sentry_utils__WEBPACK_IMPORTED_MODULE_6__.logger.error(e);
_end.call(this, chunk, encoding, cb);
});
};
}
const local = domain__WEBPACK_IMPORTED_MODULE_0__.create();
local.add(req);
local.add(res);
local.run(() => {
const currentHub = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_4__.getCurrentHub)();
currentHub.configureScope(scope => {
scope.setSDKProcessingMetadata({
request: req,
// TODO (v8): Stop passing this
requestDataOptionsFromExpressHandler: requestDataOptions,
});
const client = currentHub.getClient();
if ((0,_sdk_js__WEBPACK_IMPORTED_MODULE_2__.isAutoSessionTrackingEnabled)(client)) {
const scope = currentHub.getScope();
if (scope) {
// Set `status` of `RequestSession` to Ok, at the beginning of the request
scope.setRequestSession({ status: 'ok' });
}
}
});
res.once('finish', () => {
const client = currentHub.getClient();
if ((0,_sdk_js__WEBPACK_IMPORTED_MODULE_2__.isAutoSessionTrackingEnabled)(client)) {
setImmediate(() => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (client && (client )._captureRequestSession) {
// Calling _captureRequestSession to capture request session at the end of the request by incrementing
// the correct SessionAggregates bucket i.e. crashed, errored or exited
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(client )._captureRequestSession();
}
});
}
});
next();
});
};
}
/** JSDoc */
/** JSDoc */
function getStatusCodeFromResponse(error) {
const statusCode = error.status || error.statusCode || error.status_code || (error.output && error.output.statusCode);
return statusCode ? parseInt(statusCode , 10) : 500;
}
/** Returns true if response code is internal server error */
function defaultShouldHandleError(error) {
const status = getStatusCodeFromResponse(error);
return status >= 500;
}
/**
* Express compatible error handler.
* @see Exposed as `Handlers.errorHandler`
*/
function errorHandler(options
)
{
return function sentryErrorMiddleware(
error,
_req,
res,
next,
) {
// eslint-disable-next-line @typescript-eslint/unbound-method
const shouldHandleError = (options && options.shouldHandleError) || defaultShouldHandleError;
if (shouldHandleError(error)) {
(0,_sentry_core__WEBPACK_IMPORTED_MODULE_11__.withScope)(_scope => {
// The request should already have been stored in `scope.sdkProcessingMetadata` by `sentryRequestMiddleware`,
// but on the off chance someone is using `sentryErrorMiddleware` without `sentryRequestMiddleware`, it doesn't
// hurt to be sure
_scope.setSDKProcessingMetadata({ request: _req });
// For some reason we need to set the transaction on the scope again
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const transaction = (res ).__sentry_transaction ;
if (transaction && _scope.getSpan() === undefined) {
_scope.setSpan(transaction);
}
const client = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_4__.getCurrentHub)().getClient();
if (client && (0,_sdk_js__WEBPACK_IMPORTED_MODULE_2__.isAutoSessionTrackingEnabled)(client)) {
// Check if the `SessionFlusher` is instantiated on the client to go into this branch that marks the
// `requestSession.status` as `Crashed`, and this check is necessary because the `SessionFlusher` is only
// instantiated when the the`requestHandler` middleware is initialised, which indicates that we should be
// running in SessionAggregates mode
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const isSessionAggregatesMode = (client )._sessionFlusher !== undefined;
if (isSessionAggregatesMode) {
const requestSession = _scope.getRequestSession();
// If an error bubbles to the `errorHandler`, then this is an unhandled error, and should be reported as a
// Crashed session. The `_requestSession.status` is checked to ensure that this error is happening within
// the bounds of a request, and if so the status is updated
if (requestSession && requestSession.status !== undefined) {
requestSession.status = 'crashed';
}
}
}
const eventId = (0,_sentry_core__WEBPACK_IMPORTED_MODULE_11__.captureException)(error);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(res ).sentry = eventId;
next(error);
});
return;
}
next(error);
};
}
// TODO (v8 / #5257): Remove this
// eslint-disable-next-line deprecation/deprecation
;
//# sourceMappingURL=handlers.js.map
/***/ }),
/* 1678 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "extractRequestData": () => (/* binding */ extractRequestData),
/* harmony export */ "parseRequest": () => (/* binding */ parseRequest)
/* harmony export */ });
/* harmony import */ var _requestdata_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1667);
/**
* @deprecated `Handlers.ExpressRequest` is deprecated and will be removed in v8. Use `PolymorphicRequest` instead.
*/
/**
* Normalizes data from the request object, accounting for framework differences.
*
* @deprecated `Handlers.extractRequestData` is deprecated and will be removed in v8. Use `extractRequestData` instead.
*
* @param req The request object from which to extract data
* @param keys An optional array of keys to include in the normalized data.
* @returns An object containing normalized request data
*/
function extractRequestData(req, keys) {
return (0,_requestdata_js__WEBPACK_IMPORTED_MODULE_0__.extractRequestData)(req, { include: keys });
}
/**
* Options deciding what parts of the request to use when enhancing an event
*
* @deprecated `Handlers.ParseRequestOptions` is deprecated and will be removed in v8. Use
* `AddRequestDataToEventOptions` in `@sentry/utils` instead.
*/
/**
* Enriches passed event with request data.
*
* @deprecated `Handlers.parseRequest` is deprecated and will be removed in v8. Use `addRequestDataToEvent` instead.
*
* @param event Will be mutated and enriched with req data
* @param req Request object
* @param options object containing flags to enable functionality
* @hidden
*/
function parseRequest(event, req, options = {}) {
return (0,_requestdata_js__WEBPACK_IMPORTED_MODULE_0__.addRequestDataToEvent)(event, req, { include: options });
}
//# sourceMappingURL=requestDataDeprecated.js.map
/***/ }),
/* 1679 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "TRACEPARENT_REGEXP": () => (/* binding */ TRACEPARENT_REGEXP),
/* harmony export */ "extractTraceparentData": () => (/* binding */ extractTraceparentData)
/* harmony export */ });
const TRACEPARENT_REGEXP = new RegExp(
'^[ \\t]*' + // whitespace
'([0-9a-f]{32})?' + // trace_id
'-?([0-9a-f]{16})?' + // span_id
'-?([01])?' + // sampled
'[ \\t]*$', // whitespace
);
/**
* Extract transaction context data from a `sentry-trace` header.
*
* @param traceparent Traceparent string
*
* @returns Object containing data from the header, or undefined if traceparent string is malformed
*/
function extractTraceparentData(traceparent) {
const matches = traceparent.match(TRACEPARENT_REGEXP);
if (!traceparent || !matches) {
// empty string or no matches is invalid traceparent data
return undefined;
}
let parentSampled;
if (matches[3] === '1') {
parentSampled = true;
} else if (matches[3] === '0') {
parentSampled = false;
}
return {
traceId: matches[1],
parentSampled,
parentSpanId: matches[2],
};
}
//# sourceMappingURL=tracing.js.map
/***/ }),
/* 1680 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "FunctionToString": () => (/* reexport safe */ _functiontostring_js__WEBPACK_IMPORTED_MODULE_0__.FunctionToString),
/* harmony export */ "InboundFilters": () => (/* reexport safe */ _inboundfilters_js__WEBPACK_IMPORTED_MODULE_1__.InboundFilters)
/* harmony export */ });
/* harmony import */ var _functiontostring_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1674);
/* harmony import */ var _inboundfilters_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1673);
//# sourceMappingURL=index.js.map
/***/ }),
/* 1681 */,
/* 1682 */,
/* 1683 */,
/* 1684 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log, errors } = __webpack_require__(1)
const soapRequest = __webpack_require__(1337)
const { parseTags, parseValue } = __webpack_require__(1561)
const { commanderArretServiceSouscritMesures } = __webpack_require__(1562)
const xml2js = __webpack_require__(1519)
240792
240793
240794
240795
240796
240797
240798
240799
240800
240801
240802
240803
240804
240805
240806
240807
240808
240809
240810
240811
240812
240813
240814
240815
240816
240817
240818
240819
240820
240821
240822
240823
240824
240825
240826
/**
* @param {string} url
* @param {string} apiAuthKey
* @param {string} appLogin
* @param {number} pointId
* @param {number} serviceId
* @return {Promise<string>} User contractId
*/
async function terminateContract(
url,
apiAuthKey,
appLogin,
contractId,
pointId,
serviceId
) {
log('info', 'terminateContract')
const sgeHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
const { response } = await soapRequest({
url: `${url}/enedis_SGE_CommandeArretServiceSouscritMesures/1.0`,
headers: sgeHeaders,
xml: commanderArretServiceSouscritMesures(
appLogin,
contractId,
pointId,
serviceId
),
}).catch(err => {
log('error', 'commanderArretServiceSouscritMesures')
log('error', err)
Sentry.captureException('commanderArretServiceSouscritMesures', err)
240828
240829
240830
240831
240832
240833
240834
240835
240836
240837
240838
240839
240840
240841
240842
240843
240844
240845
240846
throw errors.VENDOR_DOWN
})
const parsedReply = await xml2js.parseStringPromise(response.body, {
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
})
try {
// We don't need any action on reply for now
if (parsedReply.Envelope.Body.Fault) {
log(
'error',
`Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
)
}
return parsedReply
} catch (error) {
const errorMessage =
'Error while parsing user contract termination: ' + error
log('error', errorMessage)
log('error', `Enedis issue ${JSON.stringify(parsedReply.Envelope.Body)}`)
throw errors.VENDOR_DOWN
}
}
module.exports = { terminateContract }
/***/ }),
/* 1685 */,
/* 1686 */,
/* 1687 */,
/* 1688 */,
/* 1689 */,
/* 1690 */,
/* 1691 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const { log, updateOrCreate } = __webpack_require__(1)
const { isLocal } = __webpack_require__(1692)
const cozyClient = __webpack_require__(485)
async function saveAccountData(accountId, accountData) {
log('info', `saveAccountData: ${accountId}`)
let account = await getAccount(accountId)
log('info', `saveAccountData account: ${JSON.stringify(account)}`)
log(
'info',
`saveAccountData account: ${JSON.stringify({
...account,
data: accountData,
})}`
)
log(
'info',
`saveAccountData account after id: ${JSON.stringify({
...account,
data: accountData,
})}`
)
account = await updateOrCreate(
[{ ...account, data: accountData }],
log('info', `saveAccountData account reply: ${JSON.stringify(account)}`)
/**
* Return account
* @param {string} accountId
* @returns {Account}
*/
async function getAccount(accountId) {
log('info', `getAccount: ${accountId}`)
const accounts = await cozyClient.data.findAll('io.cozy.accounts')
return accounts.filter(account =>
isLocal() ? account._id === accountId : account.account_type === accountId
)[0]
}
async function getAccountForDelete(accountId, accountRev) {
log('info', `getAccountForDelete: ${accountId} ${accountRev}`)
const body = await cozyClient.fetchJSON(
'GET',
`/data/io.cozy.accounts/${accountId}?rev=${accountRev}`
)
log('debug', `getAccountForDelete: ${body}`)
return body
}
module.exports = { getAccount, saveAccountData, getAccountForDelete }
/* 1692 */
return (
process.env.NODE_ENV === 'development' ||
process.env.NODE_ENV === 'local' ||
process.env.NODE_ENV === 'standalone'
)
}
/**
* Verify if it's an alpha URL
* @returns {boolean}
*/
function isDev() {
return (
process.env.COZY_URL.includes('alpha') ||
process.env.COZY_URL.includes('cozy.tools')
)
240957
240958
240959
240960
240961
240962
240963
240964
240965
240966
240967
240968
240969
240970
240971
240972
240973
240974
240975
240976
240977
240978
240979
240980
240981
240982
240983
240984
240985
240986
240987
240988
240989
240990
240991
240992
240993
240994
/* 1694 */,
/* 1695 */,
/* 1696 */,
/* 1697 */,
/* 1698 */,
/* 1699 */,
/* 1700 */,
/* 1701 */,
/* 1702 */,
/* 1703 */,
/* 1704 */,
/* 1705 */,
/* 1706 */,
/* 1707 */,
/* 1708 */,
/* 1709 */,
/* 1710 */,
/* 1711 */,
/* 1712 */,
/* 1713 */,
/* 1714 */,
/* 1715 */,
/* 1716 */,
/* 1717 */,
/* 1718 */,
/* 1719 */,
/* 1720 */,
/* 1721 */,
/* 1722 */,
/* 1723 */,
/* 1724 */,
/* 1725 */,
/* 1726 */,
/* 1727 */,
/* 1728 */,
/* 1729 */,
/* 1730 */,
/* 1731 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const {
getAccountRev,