Newer
Older
238001
238002
238003
238004
238005
238006
238007
238008
238009
238010
238011
238012
238013
238014
238015
238016
238017
238018
238019
238020
238021
238022
238023
238024
238025
238026
238027
238028
238029
238030
238031
238032
238033
238034
238035
238036
238037
238038
238039
238040
238041
238042
238043
238044
238045
238046
238047
238048
238049
238050
238051
238052
238053
238054
238055
238056
238057
238058
238059
238060
238061
238062
238063
238064
238065
238066
238067
238068
238069
238070
238071
238072
238073
238074
238075
238076
238077
238078
238079
238080
238081
238082
238083
238084
238085
238086
238087
238088
238089
238090
238091
238092
238093
238094
238095
238096
238097
238098
238099
238100
238101
238102
238103
238104
238105
238106
238107
238108
238109
238110
238111
238112
238113
238114
238115
238116
238117
238118
238119
238120
238121
238122
238123
238124
238125
238126
238127
238128
238129
238130
238131
238132
238133
238134
238135
238136
238137
238138
238139
238140
238141
238142
238143
238144
238145
238146
238147
238148
238149
238150
238151
238152
238153
238154
238155
238156
238157
238158
238159
238160
238161
238162
238163
238164
238165
238166
238167
238168
238169
238170
238171
238172
238173
238174
238175
238176
238177
238178
238179
238180
238181
238182
238183
238184
238185
238186
238187
238188
238189
238190
238191
238192
238193
238194
238195
238196
238197
238198
238199
238200
238201
238202
238203
238204
238205
238206
238207
238208
238209
238210
238211
238212
238213
238214
238215
238216
238217
238218
238219
238220
238221
238222
238223
238224
238225
238226
238227
238228
238229
238230
238231
238232
238233
238234
238235
238236
238237
238238
238239
238240
238241
238242
238243
238244
238245
238246
238247
238248
238249
238250
238251
238252
238253
238254
238255
238256
238257
238258
238259
238260
238261
238262
238263
238264
238265
238266
238267
238268
238269
238270
238271
238272
238273
238274
238275
238276
238277
238278
238279
238280
238281
238282
238283
238284
238285
238286
238287
238288
238289
238290
238291
238292
238293
238294
238295
238296
238297
238298
238299
238300
238301
238302
238303
238304
238305
238306
238307
238308
238309
238310
238311
238312
238313
238314
238315
238316
238317
238318
238319
238320
238321
238322
238323
238324
238325
238326
238327
238328
238329
238330
238331
238332
238333
238334
238335
238336
238337
238338
238339
238340
238341
238342
238343
238344
238345
238346
238347
238348
238349
238350
238351
238352
238353
238354
238355
238356
238357
238358
238359
238360
238361
238362
238363
238364
238365
238366
238367
238368
238369
238370
238371
238372
238373
238374
238375
238376
238377
238378
238379
238380
238381
238382
238383
238384
238385
238386
238387
238388
238389
238390
238391
238392
238393
238394
238395
238396
238397
238398
238399
238400
238401
238402
238403
238404
238405
238406
238407
238408
238409
238410
238411
238412
238413
238414
238415
238416
238417
238418
238419
238420
238421
238422
238423
238424
238425
238426
238427
238428
238429
238430
238431
238432
238433
238434
238435
238436
238437
238438
238439
238440
238441
238442
238443
238444
238445
238446
238447
238448
238449
238450
238451
238452
238453
238454
238455
238456
238457
238458
238459
238460
238461
238462
238463
238464
238465
238466
238467
238468
238469
238470
238471
238472
238473
238474
238475
238476
238477
238478
238479
238480
238481
238482
238483
238484
238485
238486
238487
238488
238489
238490
238491
238492
238493
238494
238495
238496
238497
238498
238499
238500
238501
238502
238503
238504
238505
238506
238507
238508
238509
238510
238511
238512
238513
238514
238515
238516
238517
238518
238519
238520
238521
238522
238523
238524
238525
238526
238527
238528
238529
238530
238531
238532
238533
238534
238535
238536
238537
238538
238539
238540
238541
238542
238543
238544
238545
238546
238547
238548
238549
238550
238551
238552
238553
238554
238555
238556
238557
238558
238559
238560
238561
238562
238563
238564
238565
238566
238567
238568
238569
238570
238571
238572
238573
238574
238575
238576
238577
238578
238579
238580
238581
238582
238583
238584
238585
238586
238587
238588
238589
238590
238591
238592
238593
238594
238595
238596
238597
238598
238599
238600
238601
238602
238603
238604
238605
238606
238607
238608
238609
238610
238611
238612
238613
238614
238615
238616
238617
238618
238619
238620
238621
238622
238623
238624
238625
238626
238627
238628
238629
238630
238631
238632
238633
238634
238635
238636
238637
238638
238639
238640
238641
238642
238643
238644
238645
238646
238647
238648
238649
238650
238651
238652
238653
238654
238655
238656
238657
238658
238659
238660
238661
238662
238663
238664
238665
238666
238667
238668
238669
238670
238671
238672
238673
238674
238675
238676
238677
238678
238679
238680
238681
238682
238683
238684
238685
238686
238687
238688
238689
238690
238691
238692
238693
238694
238695
238696
238697
238698
238699
238700
238701
238702
238703
238704
238705
238706
238707
238708
238709
238710
238711
238712
238713
238714
238715
238716
238717
238718
238719
238720
238721
238722
238723
238724
238725
238726
238727
238728
238729
238730
238731
238732
238733
238734
238735
238736
238737
238738
238739
238740
238741
238742
238743
238744
238745
238746
238747
238748
238749
238750
238751
238752
238753
238754
238755
238756
238757
238758
238759
238760
238761
238762
238763
238764
238765
238766
238767
238768
238769
238770
238771
238772
238773
238774
238775
238776
238777
238778
238779
238780
238781
238782
238783
238784
238785
238786
238787
238788
238789
238790
238791
238792
238793
238794
238795
238796
238797
238798
238799
238800
238801
238802
238803
238804
238805
238806
238807
238808
238809
238810
238811
238812
238813
238814
238815
238816
238817
238818
238819
238820
238821
238822
238823
238824
238825
238826
238827
238828
238829
238830
238831
238832
238833
238834
238835
238836
238837
238838
238839
238840
238841
238842
238843
238844
238845
238846
238847
238848
238849
238850
238851
238852
238853
238854
238855
238856
238857
238858
238859
238860
238861
238862
238863
238864
238865
238866
238867
238868
238869
238870
238871
238872
238873
238874
238875
238876
238877
238878
238879
238880
238881
238882
238883
238884
238885
238886
238887
238888
238889
238890
238891
238892
238893
238894
238895
238896
238897
238898
238899
238900
238901
238902
238903
238904
238905
238906
238907
238908
238909
238910
238911
238912
238913
238914
238915
238916
238917
238918
238919
238920
238921
238922
238923
238924
238925
238926
238927
238928
238929
238930
238931
238932
238933
238934
238935
238936
238937
238938
238939
238940
238941
238942
238943
238944
238945
238946
238947
238948
238949
238950
238951
238952
238953
238954
238955
238956
238957
238958
238959
238960
238961
238962
238963
238964
238965
238966
238967
238968
238969
238970
238971
238972
238973
238974
238975
238976
238977
238978
238979
238980
238981
238982
238983
238984
238985
238986
238987
238988
238989
238990
238991
238992
238993
238994
238995
238996
238997
238998
238999
239000
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;
};
});
/***/ }),
/* 1664 */
/***/ ((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
/***/ }),
/* 1665 */
/***/ ((__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__(1625);
/* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(828);
/* 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
/***/ }),
/* 1666 */
/***/ ((__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__(1670);
/* harmony import */ var _requestdata_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1667);
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,
...DEFAULT_OPTIONS.include,
...options.include,
user:
options.include && typeof options.include.user === 'boolean'
? options.include.user
: {
...DEFAULT_OPTIONS.include.user,
// Unclear why TS still thinks `options.include.user` could be a boolean at this point
...((options.include || {}).user ),
},
},
};
}
/**
* @inheritDoc
*/
setupOnce(addGlobalEventProcessor, getCurrentHub) {
// Note: In the long run, most of the logic here should probably move into the request data utility functions. For
// the moment it lives here, though, until https://github.com/getsentry/sentry-javascript/issues/5718 is addressed.
// (TL;DR: Those functions touch many parts of the repo in many different ways, and need to be clened up. Once
// that's happened, it will be easier to add this logic in without worrying about unexpected side effects.)
const { transactionNamingScheme } = this._options;
addGlobalEventProcessor(event => {
const hub = getCurrentHub();
const self = hub.getIntegration(RequestData);
const { sdkProcessingMetadata = {} } = event;
const req = sdkProcessingMetadata.request;
// If the globally installed instance of this integration isn't associated with the current hub, `self` will be
// undefined
if (!self || !req) {
return event;
}
// The Express request handler takes a similar `include` option to that which can be passed to this integration.
// If passed there, we store it in `sdkProcessingMetadata`. TODO(v8): Force express and GCP people to use this
// integration, so that all of this passing and conversion isn't necessary
const addRequestDataOptions =
sdkProcessingMetadata.requestDataOptionsFromExpressHandler ||
sdkProcessingMetadata.requestDataOptionsFromGCPWrapper ||
convertReqDataIntegrationOptsToAddReqDataOpts(this._options);
const processedEvent = this._addRequestData(event, req, addRequestDataOptions);
// Transaction events already have the right `transaction` value
if (event.type === 'transaction' || transactionNamingScheme === 'handler') {
return processedEvent;
}
// In all other cases, use the request's associated transaction (if any) to overwrite the event's `transaction`
// value with a high-quality one
const reqWithTransaction = req ;
const transaction = reqWithTransaction._sentryTransaction;
if (transaction) {
// TODO (v8): Remove the nextjs check and just base it on `transactionNamingScheme` for all SDKs. (We have to
// keep it the way it is for the moment, because changing the names of transactions in Sentry has the potential
// to break things like alert rules.)
const shouldIncludeMethodInTransactionName =
getSDKName(hub) === 'sentry.javascript.nextjs'
? transaction.name.startsWith('/api')
: transactionNamingScheme !== 'path';
const [transactionValue] = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_1__.extractPathForTransaction)(req, {
path: true,
method: shouldIncludeMethodInTransactionName,
customRoute: transaction.name,
});
processedEvent.transaction = transactionValue;
}
return processedEvent;
});
}
} RequestData.__initStatic();
/** Convert this integration's options to match what `addRequestDataToEvent` expects */
/** TODO: Can possibly be deleted once https://github.com/getsentry/sentry-javascript/issues/5718 is fixed */
function convertReqDataIntegrationOptsToAddReqDataOpts(
integrationOptions,
) {
const {
transactionNamingScheme,
include: { ip, user, ...requestOptions },
} = integrationOptions;
const requestIncludeKeys = [];
for (const [key, value] of Object.entries(requestOptions)) {
if (value) {
requestIncludeKeys.push(key);
}
}
let addReqDataUserOpt;
if (user === undefined) {
addReqDataUserOpt = true;
} else if (typeof user === 'boolean') {
addReqDataUserOpt = user;
} else {
const userIncludeKeys = [];
for (const [key, value] of Object.entries(user)) {
if (value) {
userIncludeKeys.push(key);
}
}
addReqDataUserOpt = userIncludeKeys;
}
return {
include: {
ip,
user: addReqDataUserOpt,
request: requestIncludeKeys.length !== 0 ? requestIncludeKeys : undefined,
transaction: transactionNamingScheme,
},
};
}
function getSDKName(hub) {
try {
// For a long chain like this, it's fewer bytes to combine a try-catch with assuming everything is there than to
// write out a long chain of `a && a.b && a.b.c && ...`
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return hub.getClient().getOptions()._metadata.sdk.name;
} catch (err) {
// In theory we should never get here
return undefined;
}
}
//# sourceMappingURL=requestdata.js.map
/***/ }),
/* 1667 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "DEFAULT_USER_INCLUDES": () => (/* binding */ DEFAULT_USER_INCLUDES),
/* harmony export */ "addRequestDataToEvent": () => (/* binding */ addRequestDataToEvent),
/* harmony export */ "addRequestDataToTransaction": () => (/* binding */ addRequestDataToTransaction),
/* harmony export */ "extractPathForTransaction": () => (/* binding */ extractPathForTransaction),
/* harmony export */ "extractRequestData": () => (/* binding */ extractRequestData)
/* harmony export */ });
/* harmony import */ var _sentry_utils_esm_buildPolyfills__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1625);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1669);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1611);
/* harmony import */ var _sentry_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1622);
/* harmony import */ var cookie__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1668);
/* harmony import */ var url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(63);
/* harmony import */ var url__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(url__WEBPACK_IMPORTED_MODULE_1__);
const DEFAULT_INCLUDES = {
ip: false,
request: true,
transaction: true,
user: true,
};
const DEFAULT_REQUEST_INCLUDES = ['cookies', 'data', 'headers', 'method', 'query_string', 'url'];
const DEFAULT_USER_INCLUDES = ['id', 'username', 'email'];
/**
* Options deciding what parts of the request to use when enhancing an event
*/
/**
* Sets parameterized route as transaction name e.g.: `GET /users/:id`
* Also adds more context data on the transaction from the request
*/
function addRequestDataToTransaction(transaction, req) {
if (!transaction) return;
if (!transaction.metadata.source || transaction.metadata.source === 'url') {
// Attempt to grab a parameterized route off of the request
transaction.setName(...extractPathForTransaction(req, { path: true, method: true }));
}
transaction.setData('url', req.originalUrl || req.url);
if (req.baseUrl) {
transaction.setData('baseUrl', req.baseUrl);
}
transaction.setData('query', extractQueryParams(req));
}
/**
* Extracts a complete and parameterized path from the request object and uses it to construct transaction name.
* If the parameterized transaction name cannot be extracted, we fall back to the raw URL.
*
* Additionally, this function determines and returns the transaction name source
*
* eg. GET /mountpoint/user/:id
*
* @param req A request object
* @param options What to include in the transaction name (method, path, or a custom route name to be
* used instead of the request's route)
*
* @returns A tuple of the fully constructed transaction name [0] and its source [1] (can be either 'route' or 'url')
*/
function extractPathForTransaction(
req,
options = {},
) {
const method = req.method && req.method.toUpperCase();
let path = '';
let source = 'url';
// Check to see if there's a parameterized route we can use (as there is in Express)
if (options.customRoute || req.route) {
path = options.customRoute || `${req.baseUrl || ''}${req.route && req.route.path}`;
source = 'route';
}
// Otherwise, just take the original URL
else if (req.originalUrl || req.url) {
path = (0,_sentry_utils__WEBPACK_IMPORTED_MODULE_2__.stripUrlQueryAndFragment)(req.originalUrl || req.url || '');
}
let name = '';
if (options.method && method) {
name += method;
}
if (options.method && options.path) {
name += ' ';
}
if (options.path && path) {
name += path;
}
return [name, source];
}
/** JSDoc */
function extractTransaction(req, type) {
switch (type) {
case 'path': {
return extractPathForTransaction(req, { path: true })[0];
}
case 'handler': {
return (req.route && req.route.stack && req.route.stack[0] && req.route.stack[0].name) || '<anonymous>';
}
case 'methodPath':
default: {
return extractPathForTransaction(req, { path: true, method: true })[0];
}
}
}
/** JSDoc */
function extractUserData(
user
,
keys,
) {
const extractedUser = {};
const attributes = Array.isArray(keys) ? keys : DEFAULT_USER_INCLUDES;
attributes.forEach(key => {
if (user && key in user) {
extractedUser[key] = user[key];
}
});
return extractedUser;
}
/**
* Normalize data from the request object
*
* @param req The request object from which to extract data
* @param options.include An optional array of keys to include in the normalized data. Defaults to
* DEFAULT_REQUEST_INCLUDES if not provided.
* @param options.deps Injected, platform-specific dependencies
*
* @returns An object containing normalized request data
*/
function extractRequestData(
req,
options
,
) {
const { include = DEFAULT_REQUEST_INCLUDES } = options || {};
const requestData = {};
// headers:
// node, express, koa, nextjs: req.headers
const headers = (req.headers || {})
;
// method:
// node, express, koa, nextjs: req.method
const method = req.method;
// host:
// express: req.hostname in > 4 and req.host in < 4
// koa: req.host
// node, nextjs: req.headers.host
const host = req.hostname || req.host || headers.host || '<no host>';
// protocol:
// node, nextjs: <n/a>
// express, koa: req.protocol
const protocol = req.protocol === 'https' || (req.socket && req.socket.encrypted) ? 'https' : 'http';
// url (including path and query string):
// node, express: req.originalUrl
// koa, nextjs: req.url
const originalUrl = req.originalUrl || req.url || '';
// absolute url
const absoluteUrl = originalUrl.startsWith(protocol) ? originalUrl : `${protocol}://${host}${originalUrl}`;
include.forEach(key => {
switch (key) {
case 'headers': {
requestData.headers = headers;
// Remove the Cookie header in case cookie data should not be included in the event
if (!include.includes('cookies')) {
delete (requestData.headers ).cookie;
}
break;
}
case 'method': {
requestData.method = method;
break;
}
case 'url': {
requestData.url = absoluteUrl;
break;
}
case 'cookies': {
// cookies:
// node, express, koa: req.headers.cookie
// vercel, sails.js, express (w/ cookie middleware), nextjs: req.cookies
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
requestData.cookies =
// TODO (v8 / #5257): We're only sending the empty object for backwards compatibility, so the last bit can
// come off in v8
req.cookies || (headers.cookie && cookie__WEBPACK_IMPORTED_MODULE_0__.parse(headers.cookie)) || {};
break;
}
case 'query_string': {
// query string:
// node: req.url (raw)
// express, koa, nextjs: req.query
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
requestData.query_string = extractQueryParams(req);
break;
}
case 'data': {
if (method === 'GET' || method === 'HEAD') {