fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

View File

@@ -0,0 +1,17 @@
import { Integration } from '@sentry/types';
/** Console module integration */
export declare class Console implements Integration {
/**
* @inheritDoc
*/
static id: string;
/**
* @inheritDoc
*/
name: string;
/**
* @inheritDoc
*/
setupOnce(): void;
}
//# sourceMappingURL=console.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../src/integrations/console.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,iCAAiC;AACjC,qBAAa,OAAQ,YAAW,WAAW;IACzC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAa;IAErC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAc;IAEjC;;OAEG;IACI,SAAS,IAAI,IAAI;CAKzB"}

62
node_modules/@sentry/node/esm/integrations/console.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
import { __read, __spread, __values } from "tslib";
import { getCurrentHub } from '@sentry/core';
import { fill, severityFromString } from '@sentry/utils';
import * as util from 'util';
/** Console module integration */
var Console = /** @class */ (function () {
function Console() {
/**
* @inheritDoc
*/
this.name = Console.id;
}
/**
* @inheritDoc
*/
Console.prototype.setupOnce = function () {
var e_1, _a;
try {
for (var _b = __values(['debug', 'info', 'warn', 'error', 'log']), _c = _b.next(); !_c.done; _c = _b.next()) {
var level = _c.value;
fill(console, level, createConsoleWrapper(level));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
/**
* @inheritDoc
*/
Console.id = 'Console';
return Console;
}());
export { Console };
/**
* Wrapper function that'll be used for every console level
*/
function createConsoleWrapper(level) {
return function consoleWrapper(originalConsoleMethod) {
var sentryLevel = severityFromString(level);
/* eslint-disable prefer-rest-params */
return function () {
if (getCurrentHub().getIntegration(Console)) {
getCurrentHub().addBreadcrumb({
category: 'console',
level: sentryLevel,
message: util.format.apply(undefined, arguments),
}, {
input: __spread(arguments),
level: level,
});
}
originalConsoleMethod.apply(this, arguments);
};
/* eslint-enable prefer-rest-params */
};
}
//# sourceMappingURL=console.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../../src/integrations/console.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,iCAAiC;AACjC;IAAA;QAME;;WAEG;QACI,SAAI,GAAW,OAAO,CAAC,EAAE,CAAC;IAUnC,CAAC;IARC;;OAEG;IACI,2BAAS,GAAhB;;;YACE,KAAoB,IAAA,KAAA,SAAA,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA,gBAAA,4BAAE;gBAA1D,IAAM,KAAK,WAAA;gBACd,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;aACnD;;;;;;;;;IACH,CAAC;IAjBD;;OAEG;IACW,UAAE,GAAW,SAAS,CAAC;IAevC,cAAC;CAAA,AAnBD,IAmBC;SAnBY,OAAO;AAqBpB;;GAEG;AACH,SAAS,oBAAoB,CAAC,KAAa;IACzC,OAAO,SAAS,cAAc,CAAC,qBAAiC;QAC9D,IAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAE9C,uCAAuC;QACvC,OAAO;YACL,IAAI,aAAa,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;gBAC3C,aAAa,EAAE,CAAC,aAAa,CAC3B;oBACE,QAAQ,EAAE,SAAS;oBACnB,KAAK,EAAE,WAAW;oBAClB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC;iBACjD,EACD;oBACE,KAAK,WAAM,SAAS,CAAC;oBACrB,KAAK,OAAA;iBACN,CACF,CAAC;aACH;YAED,qBAAqB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC,CAAC;QACF,sCAAsC;IACxC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { getCurrentHub } from '@sentry/core';\nimport { Integration } from '@sentry/types';\nimport { fill, severityFromString } from '@sentry/utils';\nimport * as util from 'util';\n\n/** Console module integration */\nexport class Console implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Console';\n\n /**\n * @inheritDoc\n */\n public name: string = Console.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n for (const level of ['debug', 'info', 'warn', 'error', 'log']) {\n fill(console, level, createConsoleWrapper(level));\n }\n }\n}\n\n/**\n * Wrapper function that'll be used for every console level\n */\nfunction createConsoleWrapper(level: string): (originalConsoleMethod: () => void) => void {\n return function consoleWrapper(originalConsoleMethod: () => void): () => void {\n const sentryLevel = severityFromString(level);\n\n /* eslint-disable prefer-rest-params */\n return function (this: typeof console): void {\n if (getCurrentHub().getIntegration(Console)) {\n getCurrentHub().addBreadcrumb(\n {\n category: 'console',\n level: sentryLevel,\n message: util.format.apply(undefined, arguments),\n },\n {\n input: [...arguments],\n level,\n },\n );\n }\n\n originalConsoleMethod.apply(this, arguments);\n };\n /* eslint-enable prefer-rest-params */\n };\n}\n"]}

View File

@@ -0,0 +1,40 @@
import { Event, EventProcessor, Integration, StackFrame } from '@sentry/types';
/**
* Resets the file cache. Exists for testing purposes.
* @hidden
*/
export declare function resetFileContentCache(): void;
interface ContextLinesOptions {
/**
* Sets the number of context lines for each frame when loading a file.
* Defaults to 7.
*
* Set to 0 to disable loading and inclusion of source files.
**/
frameContextLines?: number;
}
/** Add node modules / packages to the event */
export declare class ContextLines implements Integration {
private readonly _options;
/**
* @inheritDoc
*/
static id: string;
/**
* @inheritDoc
*/
name: string;
constructor(_options?: ContextLinesOptions);
/** Get's the number of context lines to add */
private get _contextLines();
/**
* @inheritDoc
*/
setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void;
/** Processes an event and adds context lines */
addSourceContext(event: Event): Promise<Event>;
/** Adds context lines to frames */
addSourceContextToFrames(frames: StackFrame[]): Promise<void>;
}
export {};
//# sourceMappingURL=contextlines.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"contextlines.d.ts","sourceRoot":"","sources":["../../../src/integrations/contextlines.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAoB/E;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,UAAU,mBAAmB;IAC3B;;;;;QAKI;IACJ,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,+CAA+C;AAC/C,qBAAa,YAAa,YAAW,WAAW;IAW3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAV5C;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAkB;IAE1C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAmB;gBAEF,QAAQ,GAAE,mBAAwB;IAEtE,+CAA+C;IAC/C,OAAO,KAAK,aAAa,GAYxB;IAED;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI;IAInF,gDAAgD;IACnC,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAY3D,mCAAmC;IACtB,wBAAwB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAoB3E"}

View File

@@ -0,0 +1,195 @@
import { __awaiter, __generator, __values } from "tslib";
import { getCurrentHub } from '@sentry/core';
import { addContextToFrame } from '@sentry/utils';
import { readFile } from 'fs';
import { LRUMap } from 'lru_map';
var FILE_CONTENT_CACHE = new LRUMap(100);
var DEFAULT_LINES_OF_CONTEXT = 7;
// TODO: Replace with promisify when minimum supported node >= v8
function readTextFileAsync(path) {
return new Promise(function (resolve, reject) {
readFile(path, 'utf8', function (err, data) {
if (err)
reject(err);
else
resolve(data);
});
});
}
/**
* Resets the file cache. Exists for testing purposes.
* @hidden
*/
export function resetFileContentCache() {
FILE_CONTENT_CACHE.clear();
}
/** Add node modules / packages to the event */
var ContextLines = /** @class */ (function () {
function ContextLines(_options) {
if (_options === void 0) { _options = {}; }
this._options = _options;
/**
* @inheritDoc
*/
this.name = ContextLines.id;
}
Object.defineProperty(ContextLines.prototype, "_contextLines", {
/** Get's the number of context lines to add */
get: function () {
var _a, _b;
// This is only here to copy frameContextLines from init options if it hasn't
// been set via this integrations constructor.
//
// TODO: Remove on next major!
if (this._options.frameContextLines === undefined) {
var initOptions = (_a = getCurrentHub().getClient()) === null || _a === void 0 ? void 0 : _a.getOptions();
// eslint-disable-next-line deprecation/deprecation
this._options.frameContextLines = (_b = initOptions) === null || _b === void 0 ? void 0 : _b.frameContextLines;
}
return this._options.frameContextLines !== undefined ? this._options.frameContextLines : DEFAULT_LINES_OF_CONTEXT;
},
enumerable: true,
configurable: true
});
/**
* @inheritDoc
*/
ContextLines.prototype.setupOnce = function (addGlobalEventProcessor) {
var _this = this;
addGlobalEventProcessor(function (event) { return _this.addSourceContext(event); });
};
/** Processes an event and adds context lines */
ContextLines.prototype.addSourceContext = function (event) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var _c, _d, exception, e_1_1;
var e_1, _e;
return __generator(this, function (_f) {
switch (_f.label) {
case 0:
if (!(this._contextLines > 0 && ((_a = event.exception) === null || _a === void 0 ? void 0 : _a.values))) return [3 /*break*/, 8];
_f.label = 1;
case 1:
_f.trys.push([1, 6, 7, 8]);
_c = __values(event.exception.values), _d = _c.next();
_f.label = 2;
case 2:
if (!!_d.done) return [3 /*break*/, 5];
exception = _d.value;
if (!((_b = exception.stacktrace) === null || _b === void 0 ? void 0 : _b.frames)) return [3 /*break*/, 4];
return [4 /*yield*/, this.addSourceContextToFrames(exception.stacktrace.frames)];
case 3:
_f.sent();
_f.label = 4;
case 4:
_d = _c.next();
return [3 /*break*/, 2];
case 5: return [3 /*break*/, 8];
case 6:
e_1_1 = _f.sent();
e_1 = { error: e_1_1 };
return [3 /*break*/, 8];
case 7:
try {
if (_d && !_d.done && (_e = _c.return)) _e.call(_c);
}
finally { if (e_1) throw e_1.error; }
return [7 /*endfinally*/];
case 8: return [2 /*return*/, event];
}
});
});
};
/** Adds context lines to frames */
ContextLines.prototype.addSourceContextToFrames = function (frames) {
return __awaiter(this, void 0, void 0, function () {
var contextLines, frames_1, frames_1_1, frame, sourceFile, lines, e_2_1;
var e_2, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
contextLines = this._contextLines;
_b.label = 1;
case 1:
_b.trys.push([1, 6, 7, 8]);
frames_1 = __values(frames), frames_1_1 = frames_1.next();
_b.label = 2;
case 2:
if (!!frames_1_1.done) return [3 /*break*/, 5];
frame = frames_1_1.value;
if (!(frame.filename && frame.context_line === undefined)) return [3 /*break*/, 4];
return [4 /*yield*/, _readSourceFile(frame.filename)];
case 3:
sourceFile = _b.sent();
if (sourceFile) {
try {
lines = sourceFile.split('\n');
addContextToFrame(lines, frame, contextLines);
}
catch (e) {
// anomaly, being defensive in case
// unlikely to ever happen in practice but can definitely happen in theory
}
}
_b.label = 4;
case 4:
frames_1_1 = frames_1.next();
return [3 /*break*/, 2];
case 5: return [3 /*break*/, 8];
case 6:
e_2_1 = _b.sent();
e_2 = { error: e_2_1 };
return [3 /*break*/, 8];
case 7:
try {
if (frames_1_1 && !frames_1_1.done && (_a = frames_1.return)) _a.call(frames_1);
}
finally { if (e_2) throw e_2.error; }
return [7 /*endfinally*/];
case 8: return [2 /*return*/];
}
});
});
};
/**
* @inheritDoc
*/
ContextLines.id = 'ContextLines';
return ContextLines;
}());
export { ContextLines };
/**
* Reads file contents and caches them in a global LRU cache.
*
* @param filename filepath to read content from.
*/
function _readSourceFile(filename) {
return __awaiter(this, void 0, void 0, function () {
var cachedFile, content, _1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachedFile = FILE_CONTENT_CACHE.get(filename);
// We have a cache hit
if (cachedFile !== undefined) {
return [2 /*return*/, cachedFile];
}
content = null;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, readTextFileAsync(filename)];
case 2:
content = _a.sent();
return [3 /*break*/, 4];
case 3:
_1 = _a.sent();
return [3 /*break*/, 4];
case 4:
FILE_CONTENT_CACHE.set(filename, content);
return [2 /*return*/, content];
}
});
});
}
//# sourceMappingURL=contextlines.js.map

File diff suppressed because one or more lines are too long

32
node_modules/@sentry/node/esm/integrations/http.d.ts generated vendored Normal file
View File

@@ -0,0 +1,32 @@
import { Integration } from '@sentry/types';
/** http module integration */
export declare class Http implements Integration {
/**
* @inheritDoc
*/
static id: string;
/**
* @inheritDoc
*/
name: string;
/**
* @inheritDoc
*/
private readonly _breadcrumbs;
/**
* @inheritDoc
*/
private readonly _tracing;
/**
* @inheritDoc
*/
constructor(options?: {
breadcrumbs?: boolean;
tracing?: boolean;
});
/**
* @inheritDoc
*/
setupOnce(): void;
}
//# sourceMappingURL=http.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/integrations/http.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAQ,MAAM,eAAe,CAAC;AAiBlD,8BAA8B;AAC9B,qBAAa,IAAK,YAAW,WAAW;IACtC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAU;IAElC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAW;IAE9B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IAEvC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IAEnC;;OAEG;gBACgB,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO;IAK7E;;OAEG;IACI,SAAS,IAAI,IAAI;CAuBzB"}

145
node_modules/@sentry/node/esm/integrations/http.js generated vendored Normal file
View File

@@ -0,0 +1,145 @@
import { __assign } from "tslib";
import { getCurrentHub } from '@sentry/core';
import { fill, logger, parseSemver } from '@sentry/utils';
import { IS_DEBUG_BUILD } from '../flags';
import { cleanSpanDescription, extractUrl, isSentryRequest, normalizeRequestArgs, } from './utils/http';
var NODE_VERSION = parseSemver(process.versions.node);
/** http module integration */
var Http = /** @class */ (function () {
/**
* @inheritDoc
*/
function Http(options) {
if (options === void 0) { options = {}; }
/**
* @inheritDoc
*/
this.name = Http.id;
this._breadcrumbs = typeof options.breadcrumbs === 'undefined' ? true : options.breadcrumbs;
this._tracing = typeof options.tracing === 'undefined' ? false : options.tracing;
}
/**
* @inheritDoc
*/
Http.prototype.setupOnce = function () {
// No need to instrument if we don't want to track anything
if (!this._breadcrumbs && !this._tracing) {
return;
}
var wrappedHandlerMaker = _createWrappedRequestMethodFactory(this._breadcrumbs, this._tracing);
// eslint-disable-next-line @typescript-eslint/no-var-requires
var httpModule = require('http');
fill(httpModule, 'get', wrappedHandlerMaker);
fill(httpModule, 'request', wrappedHandlerMaker);
// NOTE: Prior to Node 9, `https` used internals of `http` module, thus we don't patch it.
// If we do, we'd get double breadcrumbs and double spans for `https` calls.
// It has been changed in Node 9, so for all versions equal and above, we patch `https` separately.
if (NODE_VERSION.major && NODE_VERSION.major > 8) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
var httpsModule = require('https');
fill(httpsModule, 'get', wrappedHandlerMaker);
fill(httpsModule, 'request', wrappedHandlerMaker);
}
};
/**
* @inheritDoc
*/
Http.id = 'Http';
return Http;
}());
export { Http };
/**
* Function which creates a function which creates wrapped versions of internal `request` and `get` calls within `http`
* and `https` modules. (NB: Not a typo - this is a creator^2!)
*
* @param breadcrumbsEnabled Whether or not to record outgoing requests as breadcrumbs
* @param tracingEnabled Whether or not to record outgoing requests as tracing spans
*
* @returns A function which accepts the exiting handler and returns a wrapped handler
*/
function _createWrappedRequestMethodFactory(breadcrumbsEnabled, tracingEnabled) {
return function wrappedRequestMethodFactory(originalRequestMethod) {
return function wrappedMethod() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
// eslint-disable-next-line @typescript-eslint/no-this-alias
var httpModule = this;
var requestArgs = normalizeRequestArgs(this, args);
var requestOptions = requestArgs[0];
var requestUrl = extractUrl(requestOptions);
// we don't want to record requests to Sentry as either breadcrumbs or spans, so just use the original method
if (isSentryRequest(requestUrl)) {
return originalRequestMethod.apply(httpModule, requestArgs);
}
var span;
var parentSpan;
var scope = getCurrentHub().getScope();
if (scope && tracingEnabled) {
parentSpan = scope.getSpan();
if (parentSpan) {
span = parentSpan.startChild({
description: (requestOptions.method || 'GET') + " " + requestUrl,
op: 'http.client',
});
var sentryTraceHeader = span.toTraceparent();
IS_DEBUG_BUILD &&
logger.log("[Tracing] Adding sentry-trace header " + sentryTraceHeader + " to outgoing request to " + requestUrl + ": ");
requestOptions.headers = __assign(__assign({}, requestOptions.headers), { 'sentry-trace': sentryTraceHeader });
}
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return originalRequestMethod
.apply(httpModule, requestArgs)
.once('response', function (res) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
var req = this;
if (breadcrumbsEnabled) {
addRequestBreadcrumb('response', requestUrl, req, res);
}
if (tracingEnabled && span) {
if (res.statusCode) {
span.setHttpStatus(res.statusCode);
}
span.description = cleanSpanDescription(span.description, requestOptions, req);
span.finish();
}
})
.once('error', function () {
// eslint-disable-next-line @typescript-eslint/no-this-alias
var req = this;
if (breadcrumbsEnabled) {
addRequestBreadcrumb('error', requestUrl, req);
}
if (tracingEnabled && span) {
span.setHttpStatus(500);
span.description = cleanSpanDescription(span.description, requestOptions, req);
span.finish();
}
});
};
};
}
/**
* Captures Breadcrumb based on provided request/response pair
*/
function addRequestBreadcrumb(event, url, req, res) {
if (!getCurrentHub().getIntegration(Http)) {
return;
}
getCurrentHub().addBreadcrumb({
category: 'http',
data: {
method: req.method,
status_code: res && res.statusCode,
url: url,
},
type: 'http',
}, {
event: event,
request: req,
response: res,
});
}
//# sourceMappingURL=http.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
export { Console } from './console';
export { Http } from './http';
export { OnUncaughtException } from './onuncaughtexception';
export { OnUnhandledRejection } from './onunhandledrejection';
export { LinkedErrors } from './linkederrors';
export { Modules } from './modules';
export { ContextLines } from './contextlines';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}

8
node_modules/@sentry/node/esm/integrations/index.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
export { Console } from './console';
export { Http } from './http';
export { OnUncaughtException } from './onuncaughtexception';
export { OnUnhandledRejection } from './onunhandledrejection';
export { LinkedErrors } from './linkederrors';
export { Modules } from './modules';
export { ContextLines } from './contextlines';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { Console } from './console';\nexport { Http } from './http';\nexport { OnUncaughtException } from './onuncaughtexception';\nexport { OnUnhandledRejection } from './onunhandledrejection';\nexport { LinkedErrors } from './linkederrors';\nexport { Modules } from './modules';\nexport { ContextLines } from './contextlines';\n"]}

View File

@@ -0,0 +1,40 @@
import { Integration } from '@sentry/types';
/** Adds SDK info to an event. */
export declare class LinkedErrors implements Integration {
/**
* @inheritDoc
*/
static id: string;
/**
* @inheritDoc
*/
readonly name: string;
/**
* @inheritDoc
*/
private readonly _key;
/**
* @inheritDoc
*/
private readonly _limit;
/**
* @inheritDoc
*/
constructor(options?: {
key?: string;
limit?: number;
});
/**
* @inheritDoc
*/
setupOnce(): void;
/**
* @inheritDoc
*/
private _handler;
/**
* @inheritDoc
*/
private _walkErrorTree;
}
//# sourceMappingURL=linkederrors.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"linkederrors.d.ts","sourceRoot":"","sources":["../../../src/integrations/linkederrors.ts"],"names":[],"mappings":"AACA,OAAO,EAA8C,WAAW,EAAE,MAAM,eAAe,CAAC;AASxF,iCAAiC;AACjC,qBAAa,YAAa,YAAW,WAAW;IAC9C;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAkB;IAE1C;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAmB;IAE/C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAE9B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;OAEG;gBACgB,OAAO,GAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO;IAKjE;;OAEG;IACI,SAAS,IAAI,IAAI;IAWxB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAmBhB;;OAEG;YACW,cAAc;CAsB7B"}

View File

@@ -0,0 +1,96 @@
import { __awaiter, __generator, __read, __spread } from "tslib";
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
import { isInstanceOf, resolvedSyncPromise, SyncPromise } from '@sentry/utils';
import { exceptionFromError } from '../eventbuilder';
import { ContextLines } from './contextlines';
var DEFAULT_KEY = 'cause';
var DEFAULT_LIMIT = 5;
/** Adds SDK info to an event. */
var LinkedErrors = /** @class */ (function () {
/**
* @inheritDoc
*/
function LinkedErrors(options) {
if (options === void 0) { options = {}; }
/**
* @inheritDoc
*/
this.name = LinkedErrors.id;
this._key = options.key || DEFAULT_KEY;
this._limit = options.limit || DEFAULT_LIMIT;
}
/**
* @inheritDoc
*/
LinkedErrors.prototype.setupOnce = function () {
addGlobalEventProcessor(function (event, hint) {
var self = getCurrentHub().getIntegration(LinkedErrors);
if (self) {
var handler = self._handler && self._handler.bind(self);
return typeof handler === 'function' ? handler(event, hint) : event;
}
return event;
});
};
/**
* @inheritDoc
*/
LinkedErrors.prototype._handler = function (event, hint) {
var _this = this;
if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {
return resolvedSyncPromise(event);
}
return new SyncPromise(function (resolve) {
void _this._walkErrorTree(hint.originalException, _this._key)
.then(function (linkedErrors) {
if (event && event.exception && event.exception.values) {
event.exception.values = __spread(linkedErrors, event.exception.values);
}
resolve(event);
})
.then(null, function () {
resolve(event);
});
});
};
/**
* @inheritDoc
*/
LinkedErrors.prototype._walkErrorTree = function (error, key, stack) {
if (stack === void 0) { stack = []; }
var _a;
return __awaiter(this, void 0, void 0, function () {
var exception, contextLines;
var _this = this;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!isInstanceOf(error[key], Error) || stack.length + 1 >= this._limit) {
return [2 /*return*/, Promise.resolve(stack)];
}
exception = exceptionFromError(error[key]);
contextLines = getCurrentHub().getIntegration(ContextLines);
if (!(contextLines && ((_a = exception.stacktrace) === null || _a === void 0 ? void 0 : _a.frames))) return [3 /*break*/, 2];
return [4 /*yield*/, contextLines.addSourceContextToFrames(exception.stacktrace.frames)];
case 1:
_b.sent();
_b.label = 2;
case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
void _this._walkErrorTree(error[key], key, __spread([exception], stack))
.then(resolve)
.then(null, function () {
reject();
});
})];
}
});
});
};
/**
* @inheritDoc
*/
LinkedErrors.id = 'LinkedErrors';
return LinkedErrors;
}());
export { LinkedErrors };
//# sourceMappingURL=linkederrors.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,19 @@
import { EventProcessor, Hub, Integration } from '@sentry/types';
/** Add node modules / packages to the event */
export declare class Modules implements Integration {
/**
* @inheritDoc
*/
static id: string;
/**
* @inheritDoc
*/
name: string;
/**
* @inheritDoc
*/
setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void;
/** Fetches the list of modules and the versions loaded by the entry file for your node.js app. */
private _getModules;
}
//# sourceMappingURL=modules.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../../src/integrations/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAmEjE,+CAA+C;AAC/C,qBAAa,OAAQ,YAAW,WAAW;IACzC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAa;IAErC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAc;IAEjC;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,GAAG,IAAI;IAY7G,kGAAkG;IAClG,OAAO,CAAC,WAAW;CAMpB"}

83
node_modules/@sentry/node/esm/integrations/modules.js generated vendored Normal file
View File

@@ -0,0 +1,83 @@
import { __assign } from "tslib";
import { existsSync, readFileSync } from 'fs';
import { dirname, join } from 'path';
var moduleCache;
/** Extract information about paths */
function getPaths() {
try {
return require.cache ? Object.keys(require.cache) : [];
}
catch (e) {
return [];
}
}
/** Extract information about package.json modules */
function collectModules() {
var mainPaths = (require.main && require.main.paths) || [];
var paths = getPaths();
var infos = {};
var seen = {};
paths.forEach(function (path) {
var dir = path;
/** Traverse directories upward in the search of package.json file */
var updir = function () {
var orig = dir;
dir = dirname(orig);
if (!dir || orig === dir || seen[orig]) {
return undefined;
}
if (mainPaths.indexOf(dir) < 0) {
return updir();
}
var pkgfile = join(orig, 'package.json');
seen[orig] = true;
if (!existsSync(pkgfile)) {
return updir();
}
try {
var info = JSON.parse(readFileSync(pkgfile, 'utf8'));
infos[info.name] = info.version;
}
catch (_oO) {
// no-empty
}
};
updir();
});
return infos;
}
/** Add node modules / packages to the event */
var Modules = /** @class */ (function () {
function Modules() {
/**
* @inheritDoc
*/
this.name = Modules.id;
}
/**
* @inheritDoc
*/
Modules.prototype.setupOnce = function (addGlobalEventProcessor, getCurrentHub) {
var _this = this;
addGlobalEventProcessor(function (event) {
if (!getCurrentHub().getIntegration(Modules)) {
return event;
}
return __assign(__assign({}, event), { modules: _this._getModules() });
});
};
/** Fetches the list of modules and the versions loaded by the entry file for your node.js app. */
Modules.prototype._getModules = function () {
if (!moduleCache) {
moduleCache = collectModules();
}
return moduleCache;
};
/**
* @inheritDoc
*/
Modules.id = 'Modules';
return Modules;
}());
export { Modules };
//# sourceMappingURL=modules.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"modules.js","sourceRoot":"","sources":["../../../src/integrations/modules.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAErC,IAAI,WAAsC,CAAC;AAE3C,sCAAsC;AACtC,SAAS,QAAQ;IACf,IAAI;QACF,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACnF;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAED,qDAAqD;AACrD,SAAS,cAAc;IAGrB,IAAM,SAAS,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7D,IAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,IAAM,KAAK,GAEP,EAAE,CAAC;IACP,IAAM,IAAI,GAEN,EAAE,CAAC;IAEP,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;QAChB,IAAI,GAAG,GAAG,IAAI,CAAC;QAEf,qEAAqE;QACrE,IAAM,KAAK,GAAG;YACZ,IAAM,IAAI,GAAG,GAAG,CAAC;YACjB,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;YAEpB,IAAI,CAAC,GAAG,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE;gBACtC,OAAO,SAAS,CAAC;aAClB;YACD,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBAC9B,OAAO,KAAK,EAAE,CAAC;aAChB;YAED,IAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;YAC3C,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;YAElB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;gBACxB,OAAO,KAAK,EAAE,CAAC;aAChB;YAED,IAAI;gBACF,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAGpD,CAAC;gBACF,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;aACjC;YAAC,OAAO,GAAG,EAAE;gBACZ,WAAW;aACZ;QACH,CAAC,CAAC;QAEF,KAAK,EAAE,CAAC;IACV,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,+CAA+C;AAC/C;IAAA;QAME;;WAEG;QACI,SAAI,GAAW,OAAO,CAAC,EAAE,CAAC;IAwBnC,CAAC;IAtBC;;OAEG;IACI,2BAAS,GAAhB,UAAiB,uBAA2D,EAAE,aAAwB;QAAtG,iBAUC;QATC,uBAAuB,CAAC,UAAA,KAAK;YAC3B,IAAI,CAAC,aAAa,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;gBAC5C,OAAO,KAAK,CAAC;aACd;YACD,6BACK,KAAK,KACR,OAAO,EAAE,KAAI,CAAC,WAAW,EAAE,IAC3B;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kGAAkG;IAC1F,6BAAW,GAAnB;QACE,IAAI,CAAC,WAAW,EAAE;YAChB,WAAW,GAAG,cAAc,EAAE,CAAC;SAChC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IA/BD;;OAEG;IACW,UAAE,GAAW,SAAS,CAAC;IA6BvC,cAAC;CAAA,AAjCD,IAiCC;SAjCY,OAAO","sourcesContent":["import { EventProcessor, Hub, Integration } from '@sentry/types';\nimport { existsSync, readFileSync } from 'fs';\nimport { dirname, join } from 'path';\n\nlet moduleCache: { [key: string]: string };\n\n/** Extract information about paths */\nfunction getPaths(): string[] {\n try {\n return require.cache ? Object.keys(require.cache as Record<string, unknown>) : [];\n } catch (e) {\n return [];\n }\n}\n\n/** Extract information about package.json modules */\nfunction collectModules(): {\n [name: string]: string;\n} {\n const mainPaths = (require.main && require.main.paths) || [];\n const paths = getPaths();\n const infos: {\n [name: string]: string;\n } = {};\n const seen: {\n [path: string]: boolean;\n } = {};\n\n paths.forEach(path => {\n let dir = path;\n\n /** Traverse directories upward in the search of package.json file */\n const updir = (): void | (() => void) => {\n const orig = dir;\n dir = dirname(orig);\n\n if (!dir || orig === dir || seen[orig]) {\n return undefined;\n }\n if (mainPaths.indexOf(dir) < 0) {\n return updir();\n }\n\n const pkgfile = join(orig, 'package.json');\n seen[orig] = true;\n\n if (!existsSync(pkgfile)) {\n return updir();\n }\n\n try {\n const info = JSON.parse(readFileSync(pkgfile, 'utf8')) as {\n name: string;\n version: string;\n };\n infos[info.name] = info.version;\n } catch (_oO) {\n // no-empty\n }\n };\n\n updir();\n });\n\n return infos;\n}\n\n/** Add node modules / packages to the event */\nexport class Modules implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Modules';\n\n /**\n * @inheritDoc\n */\n public name: string = Modules.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {\n addGlobalEventProcessor(event => {\n if (!getCurrentHub().getIntegration(Modules)) {\n return event;\n }\n return {\n ...event,\n modules: this._getModules(),\n };\n });\n }\n\n /** Fetches the list of modules and the versions loaded by the entry file for your node.js app. */\n private _getModules(): { [key: string]: string } {\n if (!moduleCache) {\n moduleCache = collectModules();\n }\n return moduleCache;\n }\n}\n"]}

View File

@@ -0,0 +1,37 @@
import { Integration } from '@sentry/types';
/** Global Promise Rejection handler */
export declare class OnUncaughtException implements Integration {
private readonly _options;
/**
* @inheritDoc
*/
static id: string;
/**
* @inheritDoc
*/
name: string;
/**
* @inheritDoc
*/
readonly handler: (error: Error) => void;
/**
* @inheritDoc
*/
constructor(_options?: {
/**
* Default onFatalError handler
* @param firstError Error that has been thrown
* @param secondError If this was called multiple times this will be set
*/
onFatalError?(firstError: Error, secondError?: Error): void;
});
/**
* @inheritDoc
*/
setupOnce(): void;
/**
* @hidden
*/
private _makeErrorHandler;
}
//# sourceMappingURL=onuncaughtexception.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"onuncaughtexception.d.ts","sourceRoot":"","sources":["../../../src/integrations/onuncaughtexception.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAY,MAAM,eAAe,CAAC;AAStD,uCAAuC;AACvC,qBAAa,mBAAoB,YAAW,WAAW;IAoBnD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAnB3B;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAyB;IAEjD;;OAEG;IACI,IAAI,EAAE,MAAM,CAA0B;IAE7C;;OAEG;IACH,SAAgB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAA4B;IAE3E;;OAEG;gBAEgB,QAAQ,GAAE;QACzB;;;;WAIG;QACH,YAAY,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,WAAW,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;KACxD;IAER;;OAEG;IACI,SAAS,IAAI,IAAI;IAIxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CA+E1B"}

View File

@@ -0,0 +1,119 @@
import { getCurrentHub } from '@sentry/core';
import { Severity } from '@sentry/types';
import { logger } from '@sentry/utils';
import { IS_DEBUG_BUILD } from '../flags';
import { logAndExitProcess } from './utils/errorhandling';
/** Global Promise Rejection handler */
var OnUncaughtException = /** @class */ (function () {
/**
* @inheritDoc
*/
function OnUncaughtException(_options) {
if (_options === void 0) { _options = {}; }
this._options = _options;
/**
* @inheritDoc
*/
this.name = OnUncaughtException.id;
/**
* @inheritDoc
*/
this.handler = this._makeErrorHandler();
}
/**
* @inheritDoc
*/
OnUncaughtException.prototype.setupOnce = function () {
global.process.on('uncaughtException', this.handler.bind(this));
};
/**
* @hidden
*/
OnUncaughtException.prototype._makeErrorHandler = function () {
var _this = this;
var timeout = 2000;
var caughtFirstError = false;
var caughtSecondError = false;
var calledFatalError = false;
var firstError;
return function (error) {
var onFatalError = logAndExitProcess;
var client = getCurrentHub().getClient();
if (_this._options.onFatalError) {
// eslint-disable-next-line @typescript-eslint/unbound-method
onFatalError = _this._options.onFatalError;
}
else if (client && client.getOptions().onFatalError) {
// eslint-disable-next-line @typescript-eslint/unbound-method
onFatalError = client.getOptions().onFatalError;
}
if (!caughtFirstError) {
var hub_1 = getCurrentHub();
// this is the first uncaught error and the ultimate reason for shutting down
// we want to do absolutely everything possible to ensure it gets captured
// also we want to make sure we don't go recursion crazy if more errors happen after this one
firstError = error;
caughtFirstError = true;
if (hub_1.getIntegration(OnUncaughtException)) {
hub_1.withScope(function (scope) {
scope.setLevel(Severity.Fatal);
hub_1.captureException(error, {
originalException: error,
data: { mechanism: { handled: false, type: 'onuncaughtexception' } },
});
if (!calledFatalError) {
calledFatalError = true;
onFatalError(error);
}
});
}
else {
if (!calledFatalError) {
calledFatalError = true;
onFatalError(error);
}
}
}
else if (calledFatalError) {
// we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down
IS_DEBUG_BUILD &&
logger.warn('uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown');
logAndExitProcess(error);
}
else if (!caughtSecondError) {
// two cases for how we can hit this branch:
// - capturing of first error blew up and we just caught the exception from that
// - quit trying to capture, proceed with shutdown
// - a second independent error happened while waiting for first error to capture
// - want to avoid causing premature shutdown before first error capture finishes
// it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff
// so let's instead just delay a bit before we proceed with our action here
// in case 1, we just wait a bit unnecessarily but ultimately do the same thing
// in case 2, the delay hopefully made us wait long enough for the capture to finish
// two potential nonideal outcomes:
// nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError
// nonideal case 2: case 2 happens, 1st error is captured but slowly, timeout completes before capture and we treat second error as the sendErr of (nonexistent) failure from trying to capture first error
// note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)
// we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish
caughtSecondError = true;
setTimeout(function () {
if (!calledFatalError) {
// it was probably case 1, let's treat err as the sendErr and call onFatalError
calledFatalError = true;
onFatalError(firstError, error);
}
else {
// it was probably case 2, our first error finished capturing while we waited, cool, do nothing
}
}, timeout); // capturing could take at least sendTimeout to fail, plus an arbitrary second for how long it takes to collect surrounding source etc
}
};
};
/**
* @inheritDoc
*/
OnUncaughtException.id = 'OnUncaughtException';
return OnUncaughtException;
}());
export { OnUncaughtException };
//# sourceMappingURL=onuncaughtexception.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,40 @@
import { Integration } from '@sentry/types';
declare type UnhandledRejectionMode = 'none' | 'warn' | 'strict';
/** Global Promise Rejection handler */
export declare class OnUnhandledRejection implements Integration {
private readonly _options;
/**
* @inheritDoc
*/
static id: string;
/**
* @inheritDoc
*/
name: string;
/**
* @inheritDoc
*/
constructor(_options?: {
/**
* Option deciding what to do after capturing unhandledRejection,
* that mimicks behavior of node's --unhandled-rejection flag.
*/
mode: UnhandledRejectionMode;
});
/**
* @inheritDoc
*/
setupOnce(): void;
/**
* Send an exception with reason
* @param reason string
* @param promise promise
*/
sendUnhandledPromise(reason: any, promise: any): void;
/**
* Handler for `mode` option
*/
private _handleRejection;
}
export {};
//# sourceMappingURL=onunhandledrejection.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"onunhandledrejection.d.ts","sourceRoot":"","sources":["../../../src/integrations/onunhandledrejection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,aAAK,sBAAsB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEzD,uCAAuC;AACvC,qBAAa,oBAAqB,YAAW,WAAW;IAepD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAd3B;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAA0B;IAElD;;OAEG;IACI,IAAI,EAAE,MAAM,CAA2B;IAE9C;;OAEG;gBAEgB,QAAQ,GAAE;QACzB;;;WAGG;QACH,IAAI,EAAE,sBAAsB,CAAC;KACX;IAGtB;;OAEG;IACI,SAAS,IAAI,IAAI;IAIxB;;;;OAIG;IAEI,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI;IAmC5D;;OAEG;IAEH,OAAO,CAAC,gBAAgB;CAuBzB"}

View File

@@ -0,0 +1,90 @@
import { getCurrentHub } from '@sentry/core';
import { consoleSandbox } from '@sentry/utils';
import { logAndExitProcess } from './utils/errorhandling';
/** Global Promise Rejection handler */
var OnUnhandledRejection = /** @class */ (function () {
/**
* @inheritDoc
*/
function OnUnhandledRejection(_options) {
if (_options === void 0) { _options = { mode: 'warn' }; }
this._options = _options;
/**
* @inheritDoc
*/
this.name = OnUnhandledRejection.id;
}
/**
* @inheritDoc
*/
OnUnhandledRejection.prototype.setupOnce = function () {
global.process.on('unhandledRejection', this.sendUnhandledPromise.bind(this));
};
/**
* Send an exception with reason
* @param reason string
* @param promise promise
*/
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
OnUnhandledRejection.prototype.sendUnhandledPromise = function (reason, promise) {
var hub = getCurrentHub();
if (!hub.getIntegration(OnUnhandledRejection)) {
this._handleRejection(reason);
return;
}
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
var context = (promise.domain && promise.domain.sentryContext) || {};
hub.withScope(function (scope) {
scope.setExtra('unhandledPromiseRejection', true);
// Preserve backwards compatibility with raven-node for now
if (context.user) {
scope.setUser(context.user);
}
if (context.tags) {
scope.setTags(context.tags);
}
if (context.extra) {
scope.setExtras(context.extra);
}
hub.captureException(reason, {
originalException: promise,
data: { mechanism: { handled: false, type: 'onunhandledrejection' } },
});
});
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
this._handleRejection(reason);
};
/**
* Handler for `mode` option
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
OnUnhandledRejection.prototype._handleRejection = function (reason) {
// https://github.com/nodejs/node/blob/7cf6f9e964aa00772965391c23acda6d71972a9a/lib/internal/process/promises.js#L234-L240
var rejectionWarning = 'This error originated either by ' +
'throwing inside of an async function without a catch block, ' +
'or by rejecting a promise which was not handled with .catch().' +
' The promise rejected with the reason:';
/* eslint-disable no-console */
if (this._options.mode === 'warn') {
consoleSandbox(function () {
console.warn(rejectionWarning);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
console.error(reason && reason.stack ? reason.stack : reason);
});
}
else if (this._options.mode === 'strict') {
consoleSandbox(function () {
console.warn(rejectionWarning);
});
logAndExitProcess(reason);
}
/* eslint-enable no-console */
};
/**
* @inheritDoc
*/
OnUnhandledRejection.id = 'OnUnhandledRejection';
return OnUnhandledRejection;
}());
export { OnUnhandledRejection };
//# sourceMappingURL=onunhandledrejection.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
/**
* @hidden
*/
export declare function logAndExitProcess(error: Error): void;
//# sourceMappingURL=errorhandling.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errorhandling.d.ts","sourceRoot":"","sources":["../../../../src/integrations/utils/errorhandling.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAuBpD"}

View File

@@ -0,0 +1,26 @@
import { getCurrentHub } from '@sentry/core';
import { forget, logger } from '@sentry/utils';
import { IS_DEBUG_BUILD } from '../../flags';
var DEFAULT_SHUTDOWN_TIMEOUT = 2000;
/**
* @hidden
*/
export function logAndExitProcess(error) {
// eslint-disable-next-line no-console
console.error(error && error.stack ? error.stack : error);
var client = getCurrentHub().getClient();
if (client === undefined) {
IS_DEBUG_BUILD && logger.warn('No NodeClient was defined, we are exiting the process now.');
global.process.exit(1);
}
var options = client.getOptions();
var timeout = (options && options.shutdownTimeout && options.shutdownTimeout > 0 && options.shutdownTimeout) ||
DEFAULT_SHUTDOWN_TIMEOUT;
forget(client.close(timeout).then(function (result) {
if (!result) {
IS_DEBUG_BUILD && logger.warn('We reached the timeout for emptying the request buffer, still exiting now!');
}
global.process.exit(1);
}));
}
//# sourceMappingURL=errorhandling.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errorhandling.js","sourceRoot":"","sources":["../../../../src/integrations/utils/errorhandling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,IAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAY;IAC5C,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAE1D,IAAM,MAAM,GAAG,aAAa,EAAE,CAAC,SAAS,EAAc,CAAC;IAEvD,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;QAC5F,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACxB;IAED,IAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IACpC,IAAM,OAAO,GACX,CAAC,OAAO,IAAI,OAAO,CAAC,eAAe,IAAI,OAAO,CAAC,eAAe,GAAG,CAAC,IAAI,OAAO,CAAC,eAAe,CAAC;QAC9F,wBAAwB,CAAC;IAC3B,MAAM,CACJ,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,UAAC,MAAe;QACzC,IAAI,CAAC,MAAM,EAAE;YACX,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC;SAC7G;QACD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { getCurrentHub } from '@sentry/core';\nimport { forget, logger } from '@sentry/utils';\n\nimport { NodeClient } from '../../client';\nimport { IS_DEBUG_BUILD } from '../../flags';\n\nconst DEFAULT_SHUTDOWN_TIMEOUT = 2000;\n\n/**\n * @hidden\n */\nexport function logAndExitProcess(error: Error): void {\n // eslint-disable-next-line no-console\n console.error(error && error.stack ? error.stack : error);\n\n const client = getCurrentHub().getClient<NodeClient>();\n\n if (client === undefined) {\n IS_DEBUG_BUILD && logger.warn('No NodeClient was defined, we are exiting the process now.');\n global.process.exit(1);\n }\n\n const options = client.getOptions();\n const timeout =\n (options && options.shutdownTimeout && options.shutdownTimeout > 0 && options.shutdownTimeout) ||\n DEFAULT_SHUTDOWN_TIMEOUT;\n forget(\n client.close(timeout).then((result: boolean) => {\n if (!result) {\n IS_DEBUG_BUILD && logger.warn('We reached the timeout for emptying the request buffer, still exiting now!');\n }\n global.process.exit(1);\n }),\n );\n}\n"]}

View File

@@ -0,0 +1,64 @@
/// <reference types="node" />
import * as http from 'http';
import * as https from 'https';
import { URL } from 'url';
/**
* Checks whether given url points to Sentry server
* @param url url to verify
*/
export declare function isSentryRequest(url: string): boolean;
/**
* Assemble a URL to be used for breadcrumbs and spans.
*
* @param requestOptions RequestOptions object containing the component parts for a URL
* @returns Fully-formed URL
*/
export declare function extractUrl(requestOptions: RequestOptions): string;
/**
* Handle various edge cases in the span description (for spans representing http(s) requests).
*
* @param description current `description` property of the span representing the request
* @param requestOptions Configuration data for the request
* @param Request Request object
*
* @returns The cleaned description
*/
export declare function cleanSpanDescription(description: string | undefined, requestOptions: RequestOptions, request: http.ClientRequest): string | undefined;
export declare type RequestOptions = http.RequestOptions & {
hash?: string;
search?: string;
pathname?: string;
href?: string;
};
declare type RequestCallback = (response: http.IncomingMessage) => void;
export declare type RequestMethodArgs = [RequestOptions | string | URL, RequestCallback?] | [string | URL, RequestOptions, RequestCallback?];
export declare type RequestMethod = (...args: RequestMethodArgs) => http.ClientRequest;
/**
* Convert a URL object into a RequestOptions object.
*
* Copied from Node's internals (where it's used in http(s).request() and http(s).get()), modified only to use the
* RequestOptions type above.
*
* See https://github.com/nodejs/node/blob/master/lib/internal/url.js.
*/
export declare function urlToOptions(url: URL): RequestOptions;
/**
* Normalize inputs to `http(s).request()` and `http(s).get()`.
*
* Legal inputs to `http(s).request()` and `http(s).get()` can take one of ten forms:
* [ RequestOptions | string | URL ],
* [ RequestOptions | string | URL, RequestCallback ],
* [ string | URL, RequestOptions ], and
* [ string | URL, RequestOptions, RequestCallback ].
*
* This standardizes to one of two forms: [ RequestOptions ] and [ RequestOptions, RequestCallback ]. A similar thing is
* done as the first step of `http(s).request()` and `http(s).get()`; this just does it early so that we can interact
* with the args in a standard way.
*
* @param requestArgs The inputs to `http(s).request()` or `http(s).get()`, as an array.
*
* @returns Equivalent args of the form [ RequestOptions ] or [ RequestOptions, RequestCallback ].
*/
export declare function normalizeRequestArgs(httpModule: typeof http | typeof https, requestArgs: RequestMethodArgs): [RequestOptions] | [RequestOptions, RequestCallback];
export {};
//# sourceMappingURL=http.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/integrations/utils/http.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAI1B;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGpD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,cAAc,EAAE,cAAc,GAAG,MAAM,CASjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,IAAI,CAAC,aAAa,GAC1B,MAAM,GAAG,SAAS,CAuBpB;AAGD,oBAAY,cAAc,GAAG,IAAI,CAAC,cAAc,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACxH,aAAK,eAAe,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,KAAK,IAAI,CAAC;AAChE,oBAAY,iBAAiB,GACzB,CAAC,cAAc,GAAG,MAAM,GAAG,GAAG,EAAE,eAAe,CAAC,CAAC,GACjD,CAAC,MAAM,GAAG,GAAG,EAAE,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC;AACrD,oBAAY,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC,aAAa,CAAC;AAE/E;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,cAAc,CAkBrD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,OAAO,IAAI,GAAG,OAAO,KAAK,EACtC,WAAW,EAAE,iBAAiB,GAC7B,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,EAAE,eAAe,CAAC,CAoDtD"}

View File

@@ -0,0 +1,150 @@
import { __assign, __read } from "tslib";
import { getCurrentHub } from '@sentry/core';
import { parseSemver } from '@sentry/utils';
import { URL } from 'url';
var NODE_VERSION = parseSemver(process.versions.node);
/**
* Checks whether given url points to Sentry server
* @param url url to verify
*/
export function isSentryRequest(url) {
var _a;
var dsn = (_a = getCurrentHub().getClient()) === null || _a === void 0 ? void 0 : _a.getDsn();
return dsn ? url.includes(dsn.host) : false;
}
/**
* Assemble a URL to be used for breadcrumbs and spans.
*
* @param requestOptions RequestOptions object containing the component parts for a URL
* @returns Fully-formed URL
*/
export function extractUrl(requestOptions) {
var protocol = requestOptions.protocol || '';
var hostname = requestOptions.hostname || requestOptions.host || '';
// Don't log standard :80 (http) and :443 (https) ports to reduce the noise
var port = !requestOptions.port || requestOptions.port === 80 || requestOptions.port === 443 ? '' : ":" + requestOptions.port;
var path = requestOptions.path ? requestOptions.path : '/';
return protocol + "//" + hostname + port + path;
}
/**
* Handle various edge cases in the span description (for spans representing http(s) requests).
*
* @param description current `description` property of the span representing the request
* @param requestOptions Configuration data for the request
* @param Request Request object
*
* @returns The cleaned description
*/
export function cleanSpanDescription(description, requestOptions, request) {
var _a, _b, _c;
// nothing to clean
if (!description) {
return description;
}
// eslint-disable-next-line prefer-const
var _d = __read(description.split(' '), 2), method = _d[0], requestUrl = _d[1];
// superagent sticks the protocol in a weird place (we check for host because if both host *and* protocol are missing,
// we're likely dealing with an internal route and this doesn't apply)
if (requestOptions.host && !requestOptions.protocol) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
requestOptions.protocol = (_b = (_a = request) === null || _a === void 0 ? void 0 : _a.agent) === null || _b === void 0 ? void 0 : _b.protocol; // worst comes to worst, this is undefined and nothing changes
requestUrl = extractUrl(requestOptions);
}
// internal routes can end up starting with a triple slash rather than a single one
if ((_c = requestUrl) === null || _c === void 0 ? void 0 : _c.startsWith('///')) {
requestUrl = requestUrl.slice(2);
}
return method + " " + requestUrl;
}
/**
* Convert a URL object into a RequestOptions object.
*
* Copied from Node's internals (where it's used in http(s).request() and http(s).get()), modified only to use the
* RequestOptions type above.
*
* See https://github.com/nodejs/node/blob/master/lib/internal/url.js.
*/
export function urlToOptions(url) {
var options = {
protocol: url.protocol,
hostname: typeof url.hostname === 'string' && url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname,
hash: url.hash,
search: url.search,
pathname: url.pathname,
path: "" + (url.pathname || '') + (url.search || ''),
href: url.href,
};
if (url.port !== '') {
options.port = Number(url.port);
}
if (url.username || url.password) {
options.auth = url.username + ":" + url.password;
}
return options;
}
/**
* Normalize inputs to `http(s).request()` and `http(s).get()`.
*
* Legal inputs to `http(s).request()` and `http(s).get()` can take one of ten forms:
* [ RequestOptions | string | URL ],
* [ RequestOptions | string | URL, RequestCallback ],
* [ string | URL, RequestOptions ], and
* [ string | URL, RequestOptions, RequestCallback ].
*
* This standardizes to one of two forms: [ RequestOptions ] and [ RequestOptions, RequestCallback ]. A similar thing is
* done as the first step of `http(s).request()` and `http(s).get()`; this just does it early so that we can interact
* with the args in a standard way.
*
* @param requestArgs The inputs to `http(s).request()` or `http(s).get()`, as an array.
*
* @returns Equivalent args of the form [ RequestOptions ] or [ RequestOptions, RequestCallback ].
*/
export function normalizeRequestArgs(httpModule, requestArgs) {
var _a, _b, _c, _d, _e, _f, _g, _h;
var callback, requestOptions;
// pop off the callback, if there is one
if (typeof requestArgs[requestArgs.length - 1] === 'function') {
callback = requestArgs.pop();
}
// create a RequestOptions object of whatever's at index 0
if (typeof requestArgs[0] === 'string') {
requestOptions = urlToOptions(new URL(requestArgs[0]));
}
else if (requestArgs[0] instanceof URL) {
requestOptions = urlToOptions(requestArgs[0]);
}
else {
requestOptions = requestArgs[0];
}
// if the options were given separately from the URL, fold them in
if (requestArgs.length === 2) {
requestOptions = __assign(__assign({}, requestOptions), requestArgs[1]);
}
// Figure out the protocol if it's currently missing
if (requestOptions.protocol === undefined) {
// Worst case we end up populating protocol with undefined, which it already is
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any */
// NOTE: Prior to Node 9, `https` used internals of `http` module, thus we don't patch it.
// Because of that, we cannot rely on `httpModule` to provide us with valid protocol,
// as it will always return `http`, even when using `https` module.
//
// See test/integrations/http.test.ts for more details on Node <=v8 protocol issue.
if (NODE_VERSION.major && NODE_VERSION.major > 8) {
requestOptions.protocol =
((_b = (_a = httpModule) === null || _a === void 0 ? void 0 : _a.globalAgent) === null || _b === void 0 ? void 0 : _b.protocol) || ((_c = requestOptions.agent) === null || _c === void 0 ? void 0 : _c.protocol) || ((_d = requestOptions._defaultAgent) === null || _d === void 0 ? void 0 : _d.protocol);
}
else {
requestOptions.protocol =
((_e = requestOptions.agent) === null || _e === void 0 ? void 0 : _e.protocol) || ((_f = requestOptions._defaultAgent) === null || _f === void 0 ? void 0 : _f.protocol) || ((_h = (_g = httpModule) === null || _g === void 0 ? void 0 : _g.globalAgent) === null || _h === void 0 ? void 0 : _h.protocol);
}
/* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any */
}
// return args in standardized form
if (callback) {
return [requestOptions, callback];
}
else {
return [requestOptions];
}
}
//# sourceMappingURL=http.js.map

File diff suppressed because one or more lines are too long