Newer
Older
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "ContextLines": () => (/* binding */ ContextLines),
/* harmony export */ "resetFileContentCache": () => (/* binding */ resetFileContentCache)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1663);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1647);
/* 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 lru_map__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1701);
243013
243014
243015
243016
243017
243018
243019
243020
243021
243022
243023
243024
243025
243026
243027
243028
243029
243030
243031
243032
243033
243034
243035
243036
243037
243038
243039
243040
243041
243042
243043
243044
243045
243046
243047
243048
243049
243050
243051
243052
243053
243054
243055
243056
243057
243058
243059
243060
243061
243062
243063
243064
243065
243066
243067
243068
243069
243070
243071
243072
243073
243074
243075
243076
243077
243078
243079
243080
243081
243082
243083
243084
243085
243086
243087
243088
243089
243090
243091
243092
243093
243094
243095
243096
243097
243098
243099
243100
243101
243102
243103
243104
243105
243106
243107
243108
243109
243110
243111
243112
243113
243114
243115
243116
243117
243118
243119
243120
243121
243122
243123
243124
243125
243126
243127
243128
243129
/* harmony import */ var lru_map__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lru_map__WEBPACK_IMPORTED_MODULE_1__);
const FILE_CONTENT_CACHE = new lru_map__WEBPACK_IMPORTED_MODULE_1__.LRUMap(100);
const DEFAULT_LINES_OF_CONTEXT = 7;
// TODO: Replace with promisify when minimum supported node >= v8
function readTextFileAsync(path) {
return new Promise((resolve, reject) => {
(0,fs__WEBPACK_IMPORTED_MODULE_0__.readFile)(path, 'utf8', (err, data) => {
if (err) reject(err);
else resolve(data);
});
});
}
/**
* Resets the file cache. Exists for testing purposes.
* @hidden
*/
function resetFileContentCache() {
FILE_CONTENT_CACHE.clear();
}
/** Add node modules / packages to the event */
class ContextLines {
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'ContextLines';}
/**
* @inheritDoc
*/
__init() {this.name = ContextLines.id;}
constructor( _options = {}) {;this._options = _options;ContextLines.prototype.__init.call(this);}
/** Get's the number of context lines to add */
get _contextLines() {
return this._options.frameContextLines !== undefined ? this._options.frameContextLines : DEFAULT_LINES_OF_CONTEXT;
}
/**
* @inheritDoc
*/
setupOnce(addGlobalEventProcessor) {
addGlobalEventProcessor(event => this.addSourceContext(event));
}
/** Processes an event and adds context lines */
async addSourceContext(event) {
if (this._contextLines > 0 && (0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([event, 'access', _2 => _2.exception, 'optionalAccess', _3 => _3.values])) {
for (const exception of event.exception.values) {
if ((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_2__._optionalChain)([exception, 'access', _4 => _4.stacktrace, 'optionalAccess', _5 => _5.frames])) {
await this.addSourceContextToFrames(exception.stacktrace.frames);
}
}
}
return event;
}
/** Adds context lines to frames */
async addSourceContextToFrames(frames) {
const contextLines = this._contextLines;
for (const frame of frames) {
// Only add context if we have a filename and it hasn't already been added
if (frame.filename && frame.context_line === undefined) {
const sourceFile = await _readSourceFile(frame.filename);
if (sourceFile) {
try {
const lines = sourceFile.split('\n');
(0,_sentry_utils__WEBPACK_IMPORTED_MODULE_3__.addContextToFrame)(lines, frame, contextLines);
} catch (e) {
// anomaly, being defensive in case
// unlikely to ever happen in practice but can definitely happen in theory
}
}
}
}
}
}ContextLines.__initStatic();
/**
* Reads file contents and caches them in a global LRU cache.
*
* @param filename filepath to read content from.
*/
async function _readSourceFile(filename) {
const cachedFile = FILE_CONTENT_CACHE.get(filename);
// We have a cache hit
if (cachedFile !== undefined) {
return cachedFile;
}
let content = null;
try {
content = await readTextFileAsync(filename);
} catch (_) {
//
}
FILE_CONTENT_CACHE.set(filename, content);
return content;
}
//# sourceMappingURL=contextlines.js.map
/***/ }),
/* 1701 */
243131
243132
243133
243134
243135
243136
243137
243138
243139
243140
243141
243142
243143
243144
243145
243146
243147
243148
243149
243150
243151
243152
243153
243154
243155
243156
243157
243158
243159
243160
243161
243162
243163
243164
243165
243166
243167
243168
243169
243170
243171
243172
243173
243174
243175
243176
243177
243178
243179
243180
243181
243182
243183
243184
243185
243186
243187
243188
243189
243190
243191
243192
243193
243194
243195
243196
243197
243198
243199
243200
243201
243202
243203
243204
243205
243206
243207
243208
243209
243210
243211
243212
243213
243214
243215
243216
243217
243218
243219
243220
243221
243222
243223
243224
243225
243226
243227
243228
243229
243230
243231
243232
243233
243234
243235
243236
243237
243238
243239
243240
243241
243242
243243
243244
243245
243246
243247
243248
243249
243250
243251
243252
243253
243254
243255
243256
243257
243258
243259
243260
243261
243262
243263
243264
243265
243266
243267
243268
243269
243270
243271
243272
243273
243274
243275
243276
243277
243278
243279
243280
243281
243282
243283
243284
243285
243286
243287
243288
243289
243290
243291
243292
243293
243294
243295
243296
243297
243298
243299
243300
243301
243302
243303
243304
243305
243306
243307
243308
243309
243310
243311
243312
243313
243314
243315
243316
243317
243318
243319
243320
243321
243322
243323
243324
243325
243326
243327
243328
243329
243330
243331
243332
243333
243334
243335
243336
243337
243338
243339
243340
243341
243342
243343
243344
243345
243346
243347
243348
243349
243350
243351
243352
243353
243354
243355
243356
243357
243358
243359
243360
243361
243362
243363
243364
243365
243366
243367
243368
243369
243370
243371
243372
243373
243374
243375
243376
243377
243378
243379
243380
243381
243382
243383
243384
243385
243386
243387
243388
243389
243390
243391
243392
243393
243394
243395
243396
243397
243398
243399
243400
243401
243402
243403
243404
243405
243406
243407
243408
243409
243410
243411
243412
243413
243414
243415
243416
243417
243418
243419
243420
243421
243422
243423
243424
243425
243426
243427
243428
243429
243430
243431
243432
243433
243434
243435
243436
243437
243438
243439
243440
243441
243442
243443
243444
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most
* recently used items while discarding least recently used items when its limit
* is reached.
*
* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson <http://hunch.se/>
* See README.md for details.
*
* Illustration of the design:
*
* entry entry entry entry
* ______ ______ ______ ______
* | head |.newer => | |.newer => | |.newer => | tail |
* | A | | B | | C | | D |
* |______| <= older.|______| <= older.|______| <= older.|______|
*
* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added
*/
(function(g,f){
const e = true ? exports : 0;
f(e);
if (true) { !(__WEBPACK_AMD_DEFINE_FACTORY__ = (e),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
__WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); }
})(this, function(exports) {
const NEWER = Symbol('newer');
const OLDER = Symbol('older');
function LRUMap(limit, entries) {
if (typeof limit !== 'number') {
// called as (entries)
entries = limit;
limit = 0;
}
this.size = 0;
this.limit = limit;
this.oldest = this.newest = undefined;
this._keymap = new Map();
if (entries) {
this.assign(entries);
if (limit < 1) {
this.limit = this.size;
}
}
}
exports.LRUMap = LRUMap;
function Entry(key, value) {
this.key = key;
this.value = value;
this[NEWER] = undefined;
this[OLDER] = undefined;
}
LRUMap.prototype._markEntryAsUsed = function(entry) {
if (entry === this.newest) {
// Already the most recenlty used entry, so no need to update the list
return;
}
// HEAD--------------TAIL
// <.older .newer>
// <--- add direction --
// A B C <D> E
if (entry[NEWER]) {
if (entry === this.oldest) {
this.oldest = entry[NEWER];
}
entry[NEWER][OLDER] = entry[OLDER]; // C <-- E.
}
if (entry[OLDER]) {
entry[OLDER][NEWER] = entry[NEWER]; // C. --> E
}
entry[NEWER] = undefined; // D --x
entry[OLDER] = this.newest; // D. --> E
if (this.newest) {
this.newest[NEWER] = entry; // E. <-- D
}
this.newest = entry;
};
LRUMap.prototype.assign = function(entries) {
let entry, limit = this.limit || Number.MAX_VALUE;
this._keymap.clear();
let it = entries[Symbol.iterator]();
for (let itv = it.next(); !itv.done; itv = it.next()) {
let e = new Entry(itv.value[0], itv.value[1]);
this._keymap.set(e.key, e);
if (!entry) {
this.oldest = e;
} else {
entry[NEWER] = e;
e[OLDER] = entry;
}
entry = e;
if (limit-- == 0) {
throw new Error('overflow');
}
}
this.newest = entry;
this.size = this._keymap.size;
};
LRUMap.prototype.get = function(key) {
// First, find our cache entry
var entry = this._keymap.get(key);
if (!entry) return; // Not cached. Sorry.
// As <key> was found in the cache, register it as being requested recently
this._markEntryAsUsed(entry);
return entry.value;
};
LRUMap.prototype.set = function(key, value) {
var entry = this._keymap.get(key);
if (entry) {
// update existing
entry.value = value;
this._markEntryAsUsed(entry);
return this;
}
// new entry
this._keymap.set(key, (entry = new Entry(key, value)));
if (this.newest) {
// link previous tail to the new tail (entry)
this.newest[NEWER] = entry;
entry[OLDER] = this.newest;
} else {
// we're first in -- yay
this.oldest = entry;
}
// add new entry to the end of the linked list -- it's now the freshest entry.
this.newest = entry;
++this.size;
if (this.size > this.limit) {
// we hit the limit -- remove the head
this.shift();
}
return this;
};
LRUMap.prototype.shift = function() {
// todo: handle special case when limit == 1
var entry = this.oldest;
if (entry) {
if (this.oldest[NEWER]) {
// advance the list
this.oldest = this.oldest[NEWER];
this.oldest[OLDER] = undefined;
} else {
// the cache is exhausted
this.oldest = undefined;
this.newest = undefined;
}
// Remove last strong reference to <entry> and remove links from the purged
// entry being returned:
entry[NEWER] = entry[OLDER] = undefined;
this._keymap.delete(entry.key);
--this.size;
return [entry.key, entry.value];
}
};
// ----------------------------------------------------------------------------
// Following code is optional and can be removed without breaking the core
// functionality.
LRUMap.prototype.find = function(key) {
let e = this._keymap.get(key);
return e ? e.value : undefined;
};
LRUMap.prototype.has = function(key) {
return this._keymap.has(key);
};
LRUMap.prototype['delete'] = function(key) {
var entry = this._keymap.get(key);
if (!entry) return;
this._keymap.delete(entry.key);
if (entry[NEWER] && entry[OLDER]) {
// relink the older entry with the newer entry
entry[OLDER][NEWER] = entry[NEWER];
entry[NEWER][OLDER] = entry[OLDER];
} else if (entry[NEWER]) {
// remove the link to us
entry[NEWER][OLDER] = undefined;
// link the newer entry to head
this.oldest = entry[NEWER];
} else if (entry[OLDER]) {
// remove the link to us
entry[OLDER][NEWER] = undefined;
// link the newer entry to head
this.newest = entry[OLDER];
} else {// if(entry[OLDER] === undefined && entry.newer === undefined) {
this.oldest = this.newest = undefined;
}
this.size--;
return entry.value;
};
LRUMap.prototype.clear = function() {
// Not clearing links should be safe, as we don't expose live links to user
this.oldest = this.newest = undefined;
this.size = 0;
this._keymap.clear();
};
function EntryIterator(oldestEntry) { this.entry = oldestEntry; }
EntryIterator.prototype[Symbol.iterator] = function() { return this; }
EntryIterator.prototype.next = function() {
let ent = this.entry;
if (ent) {
this.entry = ent[NEWER];
return { done: false, value: [ent.key, ent.value] };
} else {
return { done: true, value: undefined };
}
};
function KeyIterator(oldestEntry) { this.entry = oldestEntry; }
KeyIterator.prototype[Symbol.iterator] = function() { return this; }
KeyIterator.prototype.next = function() {
let ent = this.entry;
if (ent) {
this.entry = ent[NEWER];
return { done: false, value: ent.key };
} else {
return { done: true, value: undefined };
}
};
function ValueIterator(oldestEntry) { this.entry = oldestEntry; }
ValueIterator.prototype[Symbol.iterator] = function() { return this; }
ValueIterator.prototype.next = function() {
let ent = this.entry;
if (ent) {
this.entry = ent[NEWER];
return { done: false, value: ent.value };
} else {
return { done: true, value: undefined };
}
};
LRUMap.prototype.keys = function() {
return new KeyIterator(this.oldest);
};
LRUMap.prototype.values = function() {
return new ValueIterator(this.oldest);
};
LRUMap.prototype.entries = function() {
return this;
};
LRUMap.prototype[Symbol.iterator] = function() {
return new EntryIterator(this.oldest);
};
LRUMap.prototype.forEach = function(fun, thisObj) {
if (typeof thisObj !== 'object') {
thisObj = this;
}
let entry = this.oldest;
while (entry) {
fun.call(thisObj, entry.value, entry.key, this);
entry = entry[NEWER];
}
};
/** Returns a JSON (array) representation */
LRUMap.prototype.toJSON = function() {
var s = new Array(this.size), i = 0, entry = this.oldest;
while (entry) {
s[i++] = { key: entry.key, value: entry.value };
entry = entry[NEWER];
}
return s;
};
/** Returns a String representation */
LRUMap.prototype.toString = function() {
var s = '', entry = this.oldest;
while (entry) {
s += String(entry.key)+':'+entry.value;
entry = entry[NEWER];
if (entry) {
s += ' < ';
}
}
return s;
};
});
/***/ }),
/* 1702 */
243446
243447
243448
243449
243450
243451
243452
243453
243454
243455
243456
243457
243458
243459
243460
243461
243462
243463
243464
243465
243466
243467
243468
243469
243470
243471
243472
243473
243474
243475
243476
243477
243478
243479
243480
243481
243482
243483
243484
243485
243486
243487
243488
243489
243490
243491
243492
243493
243494
243495
243496
243497
243498
243499
243500
243501
243502
243503
243504
243505
243506
243507
243508
243509
243510
243511
243512
243513
243514
243515
243516
243517
243518
243519
243520
243521
243522
243523
243524
243525
243526
243527
243528
243529
243530
243531
243532
243533
243534
243535
243536
243537
243538
243539
243540
243541
243542
243543
243544
243545
243546
243547
243548
243549
243550
243551
243552
243553
243554
243555
243556
243557
243558
243559
243560
243561
243562
243563
243564
243565
/***/ ((module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Modules": () => (/* binding */ Modules)
/* 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__);
let moduleCache;
/** Extract information about paths */
function getPaths() {
try {
return __webpack_require__.c ? Object.keys(__webpack_require__.c ) : [];
} catch (e) {
return [];
}
}
/** Extract information about package.json modules */
function collectModules()
{
const mainPaths = (__webpack_require__.c[__webpack_require__.s] && __webpack_require__.c[__webpack_require__.s].paths) || [];
const paths = getPaths();
const infos
= {};
const seen
= {};
paths.forEach(path => {
let dir = path;
/** Traverse directories upward in the search of package.json file */
const updir = () => {
const orig = dir;
dir = (0,path__WEBPACK_IMPORTED_MODULE_1__.dirname)(orig);
if (!dir || orig === dir || seen[orig]) {
return undefined;
}
if (mainPaths.indexOf(dir) < 0) {
return updir();
}
const pkgfile = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(orig, 'package.json');
seen[orig] = true;
if (!(0,fs__WEBPACK_IMPORTED_MODULE_0__.existsSync)(pkgfile)) {
return updir();
}
try {
const info = JSON.parse((0,fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync)(pkgfile, 'utf8'))
;
infos[info.name] = info.version;
} catch (_oO) {
// no-empty
}
};
updir();
});
return infos;
}
/** Add node modules / packages to the event */
class Modules {constructor() { Modules.prototype.__init.call(this); }
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'Modules';}
/**
* @inheritDoc
*/
__init() {this.name = Modules.id;}
/**
* @inheritDoc
*/
setupOnce(addGlobalEventProcessor, getCurrentHub) {
addGlobalEventProcessor(event => {
if (!getCurrentHub().getIntegration(Modules)) {
return event;
}
return {
...event,
modules: {
...event.modules,
...this._getModules(),
},
};
});
}
/** Fetches the list of modules and the versions loaded by the entry file for your node.js app. */
_getModules() {
if (!moduleCache) {
moduleCache = collectModules();
}
return moduleCache;
}
} Modules.__initStatic();
//# sourceMappingURL=modules.js.map
/***/ }),
/* 1703 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Context": () => (/* binding */ Context),
/* harmony export */ "getDeviceContext": () => (/* binding */ getDeviceContext),
/* harmony export */ "readDirAsync": () => (/* binding */ readDirAsync),
/* harmony export */ "readFileAsync": () => (/* binding */ readFileAsync)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1663);
/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(846);
243579
243580
243581
243582
243583
243584
243585
243586
243587
243588
243589
243590
243591
243592
243593
243594
243595
243596
243597
243598
243599
243600
243601
243602
243603
243604
243605
243606
243607
243608
243609
243610
243611
243612
243613
243614
243615
243616
243617
243618
243619
243620
243621
243622
243623
243624
243625
243626
243627
243628
243629
243630
243631
243632
243633
243634
243635
243636
243637
243638
243639
243640
243641
243642
243643
243644
243645
243646
243647
243648
243649
243650
243651
243652
243653
243654
243655
243656
243657
243658
243659
243660
243661
243662
243663
243664
243665
243666
243667
243668
243669
243670
243671
243672
243673
243674
243675
243676
243677
243678
243679
243680
243681
243682
243683
243684
243685
243686
243687
243688
243689
243690
243691
243692
243693
243694
243695
243696
243697
243698
243699
243700
243701
243702
243703
243704
243705
243706
243707
243708
243709
243710
243711
243712
243713
243714
243715
243716
243717
243718
243719
243720
243721
243722
243723
243724
243725
243726
243727
243728
243729
243730
243731
243732
243733
243734
243735
243736
243737
243738
243739
243740
243741
243742
243743
243744
243745
243746
243747
243748
243749
243750
243751
243752
243753
243754
243755
243756
243757
243758
243759
243760
243761
243762
243763
243764
243765
243766
243767
243768
243769
243770
243771
243772
243773
243774
243775
243776
243777
243778
243779
243780
243781
243782
243783
243784
243785
243786
243787
243788
243789
243790
243791
243792
243793
243794
243795
243796
243797
243798
243799
243800
243801
243802
243803
243804
243805
243806
243807
243808
243809
243810
243811
243812
243813
243814
243815
243816
243817
243818
243819
243820
243821
243822
243823
243824
243825
243826
243827
243828
243829
243830
243831
243832
243833
243834
243835
243836
243837
243838
243839
243840
243841
243842
243843
243844
243845
243846
243847
243848
243849
243850
243851
243852
243853
243854
243855
243856
243857
243858
243859
243860
243861
243862
243863
243864
243865
243866
243867
243868
243869
243870
243871
243872
243873
243874
243875
243876
243877
243878
243879
243880
243881
243882
243883
243884
243885
243886
243887
243888
243889
243890
243891
243892
243893
243894
243895
243896
243897
243898
243899
243900
243901
243902
243903
243904
243905
243906
243907
243908
243909
243910
243911
243912
243913
243914
243915
243916
243917
243918
243919
243920
243921
243922
243923
243924
243925
243926
243927
243928
243929
243930
243931
243932
243933
243934
243935
243936
243937
243938
243939
/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(149);
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(253);
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(os__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(142);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(64);
/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(util__WEBPACK_IMPORTED_MODULE_4__);
// TODO: Required until we drop support for Node v8
const readFileAsync = (0,util__WEBPACK_IMPORTED_MODULE_4__.promisify)(fs__WEBPACK_IMPORTED_MODULE_1__.readFile);
const readDirAsync = (0,util__WEBPACK_IMPORTED_MODULE_4__.promisify)(fs__WEBPACK_IMPORTED_MODULE_1__.readdir);
/** Add node modules / packages to the event */
class Context {
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'Context';}
/**
* @inheritDoc
*/
__init() {this.name = Context.id;}
/**
* Caches context so it's only evaluated once
*/
constructor( _options = { app: true, os: true, device: true, culture: true }) {;this._options = _options;Context.prototype.__init.call(this);
//
}
/**
* @inheritDoc
*/
setupOnce(addGlobalEventProcessor) {
addGlobalEventProcessor(event => this.addContext(event));
}
/** Processes an event and adds context */
async addContext(event) {
if (this._cachedContext === undefined) {
this._cachedContext = this._getContexts();
}
const updatedContext = this._updateContext(await this._cachedContext);
event.contexts = {
...event.contexts,
app: { ...updatedContext.app, ...(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([event, 'access', _ => _.contexts, 'optionalAccess', _2 => _2.app]) },
os: { ...updatedContext.os, ...(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([event, 'access', _3 => _3.contexts, 'optionalAccess', _4 => _4.os]) },
device: { ...updatedContext.device, ...(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([event, 'access', _5 => _5.contexts, 'optionalAccess', _6 => _6.device]) },
culture: { ...updatedContext.culture, ...(0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([event, 'access', _7 => _7.contexts, 'optionalAccess', _8 => _8.culture]) },
};
return event;
}
/**
* Updates the context with dynamic values that can change
*/
_updateContext(contexts) {
// Only update properties if they exist
if ((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([contexts, 'optionalAccess', _9 => _9.app, 'optionalAccess', _10 => _10.app_memory])) {
contexts.app.app_memory = process.memoryUsage().rss;
}
if ((0,_sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__._optionalChain)([contexts, 'optionalAccess', _11 => _11.device, 'optionalAccess', _12 => _12.free_memory])) {
contexts.device.free_memory = os__WEBPACK_IMPORTED_MODULE_2__.freemem();
}
return contexts;
}
/**
* Gets the contexts for the current environment
*/
async _getContexts() {
const contexts = {};
if (this._options.os) {
contexts.os = await getOsContext();
}
if (this._options.app) {
contexts.app = getAppContext();
}
if (this._options.device) {
contexts.device = getDeviceContext(this._options.device);
}
if (this._options.culture) {
const culture = getCultureContext();
if (culture) {
contexts.culture = culture;
}
}
return contexts;
}
}Context.__initStatic();
/**
* Returns the operating system context.
*
* Based on the current platform, this uses a different strategy to provide the
* most accurate OS information. Since this might involve spawning subprocesses
* or accessing the file system, this should only be executed lazily and cached.
*
* - On macOS (Darwin), this will execute the `sw_vers` utility. The context
* has a `name`, `version`, `build` and `kernel_version` set.
* - On Linux, this will try to load a distribution release from `/etc` and set
* the `name`, `version` and `kernel_version` fields.
* - On all other platforms, only a `name` and `version` will be returned. Note
* that `version` might actually be the kernel version.
*/
async function getOsContext() {
const platformId = os__WEBPACK_IMPORTED_MODULE_2__.platform();
switch (platformId) {
case 'darwin':
return getDarwinInfo();
case 'linux':
return getLinuxInfo();
default:
return {
name: PLATFORM_NAMES[platformId] || platformId,
version: os__WEBPACK_IMPORTED_MODULE_2__.release(),
};
}
}
function getCultureContext() {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
if (typeof (process.versions ).icu !== 'string') {
// Node was built without ICU support
return;
}
// Check that node was built with full Intl support. Its possible it was built without support for non-English
// locales which will make resolvedOptions inaccurate
//
// https://nodejs.org/api/intl.html#detecting-internationalization-support
const january = new Date(9e8);
const spanish = new Intl.DateTimeFormat('es', { month: 'long' });
if (spanish.format(january) === 'enero') {
const options = Intl.DateTimeFormat().resolvedOptions();
return {
locale: options.locale,
timezone: options.timeZone,
};
}
} catch (err) {
//
}
return;
}
function getAppContext() {
const app_memory = process.memoryUsage().rss;
const app_start_time = new Date(Date.now() - process.uptime() * 1000).toISOString();
return { app_start_time, app_memory };
}
/**
* Gets device information from os
*/
function getDeviceContext(deviceOpt) {
const device = {};
// os.uptime or its return value seem to be undefined in certain environments (e.g. Azure functions).
// Hence, we only set boot time, if we get a valid uptime value.
// @see https://github.com/getsentry/sentry-javascript/issues/5856
const uptime = os__WEBPACK_IMPORTED_MODULE_2__.uptime && os__WEBPACK_IMPORTED_MODULE_2__.uptime();
if (typeof uptime === 'number') {
device.boot_time = new Date(Date.now() - uptime * 1000).toISOString();
}
device.arch = os__WEBPACK_IMPORTED_MODULE_2__.arch();
if (deviceOpt === true || deviceOpt.memory) {
device.memory_size = os__WEBPACK_IMPORTED_MODULE_2__.totalmem();
device.free_memory = os__WEBPACK_IMPORTED_MODULE_2__.freemem();
}
if (deviceOpt === true || deviceOpt.cpu) {
const cpuInfo = os__WEBPACK_IMPORTED_MODULE_2__.cpus();
if (cpuInfo && cpuInfo.length) {
const firstCpu = cpuInfo[0];
device.processor_count = cpuInfo.length;
device.cpu_description = firstCpu.model;
device.processor_frequency = firstCpu.speed;
}
}
return device;
}
/** Mapping of Node's platform names to actual OS names. */
const PLATFORM_NAMES = {
aix: 'IBM AIX',
freebsd: 'FreeBSD',
openbsd: 'OpenBSD',
sunos: 'SunOS',
win32: 'Windows',
};
/** Linux version file to check for a distribution. */
/** Mapping of linux release files located in /etc to distributions. */
const LINUX_DISTROS = [
{ name: 'fedora-release', distros: ['Fedora'] },
{ name: 'redhat-release', distros: ['Red Hat Linux', 'Centos'] },
{ name: 'redhat_version', distros: ['Red Hat Linux'] },
{ name: 'SuSE-release', distros: ['SUSE Linux'] },
{ name: 'lsb-release', distros: ['Ubuntu Linux', 'Arch Linux'] },
{ name: 'debian_version', distros: ['Debian'] },
{ name: 'debian_release', distros: ['Debian'] },
{ name: 'arch-release', distros: ['Arch Linux'] },
{ name: 'gentoo-release', distros: ['Gentoo Linux'] },
{ name: 'novell-release', distros: ['SUSE Linux'] },
{ name: 'alpine-release', distros: ['Alpine Linux'] },
];
/** Functions to extract the OS version from Linux release files. */
const LINUX_VERSIONS
= {
alpine: content => content,
arch: content => matchFirst(/distrib_release=(.*)/, content),
centos: content => matchFirst(/release ([^ ]+)/, content),
debian: content => content,
fedora: content => matchFirst(/release (..)/, content),
mint: content => matchFirst(/distrib_release=(.*)/, content),
red: content => matchFirst(/release ([^ ]+)/, content),
suse: content => matchFirst(/VERSION = (.*)\n/, content),
ubuntu: content => matchFirst(/distrib_release=(.*)/, content),
};
/**
* Executes a regular expression with one capture group.
*
* @param regex A regular expression to execute.
* @param text Content to execute the RegEx on.
* @returns The captured string if matched; otherwise undefined.
*/
function matchFirst(regex, text) {
const match = regex.exec(text);
return match ? match[1] : undefined;
}
/** Loads the macOS operating system context. */
async function getDarwinInfo() {
// Default values that will be used in case no operating system information
// can be loaded. The default version is computed via heuristics from the
// kernel version, but the build ID is missing.
const darwinInfo = {
kernel_version: os__WEBPACK_IMPORTED_MODULE_2__.release(),
name: 'Mac OS X',
version: `10.${Number(os__WEBPACK_IMPORTED_MODULE_2__.release().split('.')[0]) - 4}`,
};
try {
// We try to load the actual macOS version by executing the `sw_vers` tool.
// This tool should be available on every standard macOS installation. In
// case this fails, we stick with the values computed above.
const output = await new Promise((resolve, reject) => {
(0,child_process__WEBPACK_IMPORTED_MODULE_0__.execFile)('/usr/bin/sw_vers', (error, stdout) => {
if (error) {
reject(error);
return;
}
resolve(stdout);
});
});
darwinInfo.name = matchFirst(/^ProductName:\s+(.*)$/m, output);
darwinInfo.version = matchFirst(/^ProductVersion:\s+(.*)$/m, output);
darwinInfo.build = matchFirst(/^BuildVersion:\s+(.*)$/m, output);
} catch (e) {
// ignore
}
return darwinInfo;
}
/** Returns a distribution identifier to look up version callbacks. */
function getLinuxDistroId(name) {
return name.split(' ')[0].toLowerCase();
}
/** Loads the Linux operating system context. */
async function getLinuxInfo() {
// By default, we cannot assume anything about the distribution or Linux
// version. `os.release()` returns the kernel version and we assume a generic
// "Linux" name, which will be replaced down below.
const linuxInfo = {
kernel_version: os__WEBPACK_IMPORTED_MODULE_2__.release(),
name: 'Linux',
};
try {
// We start guessing the distribution by listing files in the /etc
// directory. This is were most Linux distributions (except Knoppix) store
// release files with certain distribution-dependent meta data. We search
// for exactly one known file defined in `LINUX_DISTROS` and exit if none
// are found. In case there are more than one file, we just stick with the
// first one.
const etcFiles = await readDirAsync('/etc');
const distroFile = LINUX_DISTROS.find(file => etcFiles.includes(file.name));
if (!distroFile) {
return linuxInfo;
}
// Once that file is known, load its contents. To make searching in those
// files easier, we lowercase the file contents. Since these files are
// usually quite small, this should not allocate too much memory and we only
// hold on to it for a very short amount of time.
const distroPath = (0,path__WEBPACK_IMPORTED_MODULE_3__.join)('/etc', distroFile.name);
const contents = ((await readFileAsync(distroPath, { encoding: 'utf-8' })) ).toLowerCase();
// Some Linux distributions store their release information in the same file
// (e.g. RHEL and Centos). In those cases, we scan the file for an
// identifier, that basically consists of the first word of the linux
// distribution name (e.g. "red" for Red Hat). In case there is no match, we
// just assume the first distribution in our list.
const { distros } = distroFile;
linuxInfo.name = distros.find(d => contents.indexOf(getLinuxDistroId(d)) >= 0) || distros[0];
// Based on the found distribution, we can now compute the actual version
// number. This is different for every distribution, so several strategies
// are computed in `LINUX_VERSIONS`.
const id = getLinuxDistroId(linuxInfo.name);
linuxInfo.version = LINUX_VERSIONS[id](contents);
} catch (e) {
// ignore
}
return linuxInfo;
}
//# sourceMappingURL=context.js.map
/***/ }),
/* 1704 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "RequestData": () => (/* binding */ RequestData)
/* harmony export */ });
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1708);
/* harmony import */ var _requestdata_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1705);
243950
243951
243952
243953
243954
243955
243956
243957
243958
243959
243960
243961
243962
243963
243964
243965
243966
243967
243968
243969
243970
243971
243972
243973
243974
243975
243976
243977
243978
243979
243980
243981
243982
243983
243984
243985
243986
243987
243988
243989
243990
243991
243992
243993
243994
243995
243996
243997
243998
243999
244000
const DEFAULT_OPTIONS = {
include: {
cookies: true,
data: true,
headers: true,
ip: false,
query_string: true,
url: true,
user: {
id: true,
username: true,
email: true,
},
},
transactionNamingScheme: 'methodPath',
};
/** Add data about a request to an event. Primarily for use in Node-based SDKs, but included in `@sentry/integrations`
* so it can be used in cross-platform SDKs like `@sentry/nextjs`. */
class RequestData {
/**
* @inheritDoc
*/
static __initStatic() {this.id = 'RequestData';}
/**
* @inheritDoc
*/
__init() {this.name = RequestData.id;}
/**
* Function for adding request data to event. Defaults to `addRequestDataToEvent` from `@sentry/node` for now, but
* left as a property so this integration can be moved to `@sentry/core` as a base class in case we decide to use
* something similar in browser-based SDKs in the future.
*/
/**
* @inheritDoc
*/
constructor(options = {}) {;RequestData.prototype.__init.call(this);
this._addRequestData = _requestdata_js__WEBPACK_IMPORTED_MODULE_0__.addRequestDataToEvent;
this._options = {
...DEFAULT_OPTIONS,
...options,
include: {
// @ts-ignore It's mad because `method` isn't a known `include` key. (It's only here and not set by default in
// `addRequestDataToEvent` for legacy reasons. TODO (v8): Change that.)
method: true,