@sentry/browser 7.0.0-alpha.1 → 7.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/client.d.ts +23 -18
- package/cjs/client.d.ts.map +1 -1
- package/cjs/client.js +75 -51
- package/cjs/client.js.map +1 -1
- package/cjs/eventbuilder.d.ts +1 -1
- package/cjs/eventbuilder.js +31 -33
- package/cjs/eventbuilder.js.map +1 -1
- package/cjs/exports.d.ts +5 -4
- package/cjs/exports.d.ts.map +1 -1
- package/cjs/exports.js +20 -8
- package/cjs/exports.js.map +1 -1
- package/cjs/helpers.d.ts +0 -5
- package/cjs/helpers.d.ts.map +1 -1
- package/cjs/helpers.js +15 -49
- package/cjs/helpers.js.map +1 -1
- package/cjs/index.d.ts +1 -2
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +7 -9
- package/cjs/index.js.map +1 -1
- package/cjs/integrations/breadcrumbs.d.ts +6 -7
- package/cjs/integrations/breadcrumbs.d.ts.map +1 -1
- package/cjs/integrations/breadcrumbs.js +37 -54
- package/cjs/integrations/breadcrumbs.js.map +1 -1
- package/cjs/integrations/dedupe.js +25 -26
- package/cjs/integrations/dedupe.js.map +1 -1
- package/cjs/integrations/globalhandlers.d.ts.map +1 -1
- package/cjs/integrations/globalhandlers.js +52 -53
- package/cjs/integrations/globalhandlers.js.map +1 -1
- package/cjs/integrations/linkederrors.d.ts.map +1 -1
- package/cjs/integrations/linkederrors.js +26 -29
- package/cjs/integrations/linkederrors.js.map +1 -1
- package/cjs/integrations/trycatch.js +30 -40
- package/cjs/integrations/trycatch.js.map +1 -1
- package/cjs/integrations/useragent.js +19 -21
- package/cjs/integrations/useragent.js.map +1 -1
- package/cjs/sdk.d.ts +2 -2
- package/cjs/sdk.d.ts.map +1 -1
- package/cjs/sdk.js +47 -34
- package/cjs/sdk.js.map +1 -1
- package/cjs/stack-parsers.d.ts +7 -6
- package/cjs/stack-parsers.d.ts.map +1 -1
- package/cjs/stack-parsers.js +45 -45
- package/cjs/stack-parsers.js.map +1 -1
- package/cjs/transports/fetch.d.ts +7 -14
- package/cjs/transports/fetch.d.ts.map +1 -1
- package/cjs/transports/fetch.js +17 -78
- package/cjs/transports/fetch.js.map +1 -1
- package/cjs/transports/index.d.ts +2 -6
- package/cjs/transports/index.d.ts.map +1 -1
- package/cjs/transports/index.js +2 -10
- package/cjs/transports/index.js.map +1 -1
- package/cjs/transports/utils.d.ts.map +1 -1
- package/cjs/transports/utils.js +17 -17
- package/cjs/transports/utils.js.map +1 -1
- package/cjs/transports/xhr.d.ts +9 -9
- package/cjs/transports/xhr.d.ts.map +1 -1
- package/cjs/transports/xhr.js +39 -59
- package/cjs/transports/xhr.js.map +1 -1
- package/esm/client.d.ts +23 -18
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +73 -50
- package/esm/client.js.map +1 -1
- package/esm/eventbuilder.d.ts +1 -1
- package/esm/eventbuilder.js +30 -32
- package/esm/eventbuilder.js.map +1 -1
- package/esm/exports.d.ts +5 -4
- package/esm/exports.d.ts.map +1 -1
- package/esm/exports.js +4 -3
- package/esm/exports.js.map +1 -1
- package/esm/flags.js +1 -1
- package/esm/flags.js.map +1 -1
- package/esm/helpers.d.ts +0 -5
- package/esm/helpers.d.ts.map +1 -1
- package/esm/helpers.js +15 -48
- package/esm/helpers.js.map +1 -1
- package/esm/index.d.ts +1 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +4 -6
- package/esm/index.js.map +1 -1
- package/esm/integrations/breadcrumbs.d.ts +6 -7
- package/esm/integrations/breadcrumbs.d.ts.map +1 -1
- package/esm/integrations/breadcrumbs.js +36 -54
- package/esm/integrations/breadcrumbs.js.map +1 -1
- package/esm/integrations/dedupe.js +23 -25
- package/esm/integrations/dedupe.js.map +1 -1
- package/esm/integrations/globalhandlers.d.ts.map +1 -1
- package/esm/integrations/globalhandlers.js +48 -50
- package/esm/integrations/globalhandlers.js.map +1 -1
- package/esm/integrations/linkederrors.d.ts.map +1 -1
- package/esm/integrations/linkederrors.js +24 -28
- package/esm/integrations/linkederrors.js.map +1 -1
- package/esm/integrations/trycatch.js +28 -39
- package/esm/integrations/trycatch.js.map +1 -1
- package/esm/integrations/useragent.js +17 -20
- package/esm/integrations/useragent.js.map +1 -1
- package/esm/sdk.d.ts +2 -2
- package/esm/sdk.d.ts.map +1 -1
- package/esm/sdk.js +44 -31
- package/esm/sdk.js.map +1 -1
- package/esm/stack-parsers.d.ts +7 -6
- package/esm/stack-parsers.d.ts.map +1 -1
- package/esm/stack-parsers.js +45 -45
- package/esm/stack-parsers.js.map +1 -1
- package/esm/transports/fetch.d.ts +7 -14
- package/esm/transports/fetch.d.ts.map +1 -1
- package/esm/transports/fetch.js +15 -77
- package/esm/transports/fetch.js.map +1 -1
- package/esm/transports/index.d.ts +2 -6
- package/esm/transports/index.d.ts.map +1 -1
- package/esm/transports/index.js +2 -6
- package/esm/transports/index.js.map +1 -1
- package/esm/transports/utils.d.ts.map +1 -1
- package/esm/transports/utils.js +16 -16
- package/esm/transports/utils.js.map +1 -1
- package/esm/transports/xhr.d.ts +9 -9
- package/esm/transports/xhr.d.ts.map +1 -1
- package/esm/transports/xhr.js +38 -59
- package/esm/transports/xhr.js.map +1 -1
- package/esm/version.js +1 -1
- package/esm/version.js.map +1 -1
- package/package.json +4 -4
- package/types/client.d.ts +23 -18
- package/types/client.d.ts.map +1 -1
- package/types/eventbuilder.d.ts +1 -1
- package/types/exports.d.ts +5 -4
- package/types/exports.d.ts.map +1 -1
- package/types/helpers.d.ts +0 -5
- package/types/helpers.d.ts.map +1 -1
- package/types/index.d.ts +1 -2
- package/types/index.d.ts.map +1 -1
- package/types/integrations/breadcrumbs.d.ts +6 -7
- package/types/integrations/breadcrumbs.d.ts.map +1 -1
- package/types/integrations/globalhandlers.d.ts.map +1 -1
- package/types/integrations/linkederrors.d.ts.map +1 -1
- package/types/sdk.d.ts +2 -2
- package/types/sdk.d.ts.map +1 -1
- package/types/stack-parsers.d.ts +7 -6
- package/types/stack-parsers.d.ts.map +1 -1
- package/types/transports/fetch.d.ts +7 -14
- package/types/transports/fetch.d.ts.map +1 -1
- package/types/transports/index.d.ts +2 -6
- package/types/transports/index.d.ts.map +1 -1
- package/types/transports/utils.d.ts.map +1 -1
- package/types/transports/xhr.d.ts +9 -9
- package/types/transports/xhr.d.ts.map +1 -1
- package/cjs/transports/base.d.ts +0 -65
- package/cjs/transports/base.d.ts.map +0 -1
- package/cjs/transports/base.js +0 -141
- package/cjs/transports/base.js.map +0 -1
- package/cjs/transports/new-fetch.d.ts +0 -10
- package/cjs/transports/new-fetch.d.ts.map +0 -1
- package/cjs/transports/new-fetch.js +0 -27
- package/cjs/transports/new-fetch.js.map +0 -1
- package/cjs/transports/new-xhr.d.ts +0 -11
- package/cjs/transports/new-xhr.d.ts.map +0 -1
- package/cjs/transports/new-xhr.js +0 -46
- package/cjs/transports/new-xhr.js.map +0 -1
- package/cjs/transports/setup.d.ts +0 -22
- package/cjs/transports/setup.d.ts.map +0 -1
- package/cjs/transports/setup.js +0 -44
- package/cjs/transports/setup.js.map +0 -1
- package/esm/transports/base.d.ts +0 -65
- package/esm/transports/base.d.ts.map +0 -1
- package/esm/transports/base.js +0 -140
- package/esm/transports/base.js.map +0 -1
- package/esm/transports/new-fetch.d.ts +0 -10
- package/esm/transports/new-fetch.d.ts.map +0 -1
- package/esm/transports/new-fetch.js +0 -25
- package/esm/transports/new-fetch.js.map +0 -1
- package/esm/transports/new-xhr.d.ts +0 -11
- package/esm/transports/new-xhr.d.ts.map +0 -1
- package/esm/transports/new-xhr.js +0 -44
- package/esm/transports/new-xhr.js.map +0 -1
- package/esm/transports/setup.d.ts +0 -22
- package/esm/transports/setup.d.ts.map +0 -1
- package/esm/transports/setup.js +0 -42
- package/esm/transports/setup.js.map +0 -1
- package/types/transports/base.d.ts +0 -65
- package/types/transports/base.d.ts.map +0 -1
- package/types/transports/new-fetch.d.ts +0 -10
- package/types/transports/new-fetch.d.ts.map +0 -1
- package/types/transports/new-xhr.d.ts +0 -11
- package/types/transports/new-xhr.d.ts.map +0 -1
- package/types/transports/setup.d.ts +0 -22
- package/types/transports/setup.d.ts.map +0 -1
package/cjs/exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../src/exports.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../src/exports.ts"],"names":[],"mappings":";AAoBA,qCAyBsB;AAxBpB,yCAAA,uBAAuB,CAAA;AACvB,+BAAA,aAAa,CAAA;AACb,kCAAA,gBAAgB,CAAA;AAChB,8BAAA,YAAY,CAAA;AACZ,gCAAA,cAAc,CAAA;AACd,gCAAA,cAAc,CAAA;AACd,iCAAA,eAAe,CAAA;AACf,mCAAA,iBAAiB,CAAA;AACjB,+BAAA,aAAa,CAAA;AACb,qBAAA,GAAG,CAAA;AACH,0BAAA,QAAQ,CAAA;AACR,uBAAA,KAAK,CAAA;AACL,yBAAA,OAAO,CAAA;AACP,kCAAA,gBAAgB,CAAA;AAChB,6BAAA,WAAW,CAAA;AACX,4BAAA,UAAU,CAAA;AACV,0BAAA,QAAQ,CAAA;AACR,2BAAA,SAAS,CAAA;AACT,wBAAA,MAAM,CAAA;AACN,yBAAA,OAAO,CAAA;AACP,yBAAA,OAAO,CAAA;AACP,2BAAA,SAAS,CAAA;AACT,kCAAA,gBAAgB,CAAA;AAChB,gCAAA,cAAc,CAAA;AAGhB,mCAAyC;AAAhC,iCAAA,aAAa,CAAA;AACtB,2CAAoE;AAA3D,0CAAA,kBAAkB,CAAA;AAAE,wCAAA,gBAAgB,CAAA;AAC7C,iDAQyB;AAPvB,6CAAA,kBAAkB,CAAA;AAClB,kDAAA,uBAAuB,CAAA;AACvB,gDAAA,qBAAqB,CAAA;AACrB,+CAAA,oBAAoB,CAAA;AACpB,iDAAA,sBAAsB,CAAA;AACtB,iDAAA,sBAAsB,CAAA;AACtB,+CAAA,oBAAoB,CAAA;AAEtB,6BAAwH;AAA/G,oCAAA,mBAAmB,CAAA;AAAE,0BAAA,SAAS,CAAA;AAAE,qBAAA,IAAI,CAAA;AAAE,4BAAA,WAAW,CAAA;AAAE,uBAAA,MAAM,CAAA;AAAE,iCAAA,gBAAgB,CAAA;AAAE,sBAAA,KAAK,CAAA;AAAE,sBAAA,KAAK,CAAA;AAAE,qBAAA,IAAI,CAAA;AACxG,qCAAqC;AAA5B,6BAAA,QAAQ,CAAA;AACjB,+CAAwG;AAA/F,wCAAA,cAAc,CAAA;AAAE,kCAAA,QAAQ,CAAA;AAAE,qCAAA,WAAW,CAAA;AAAE,sCAAA,YAAY,CAAA;AAAE,mCAAA,SAAS,CAAA;AAAE,gCAAA,MAAM,CAAA","sourcesContent":["export type {\n Breadcrumb,\n BreadcrumbHint,\n Request,\n SdkInfo,\n Event,\n EventHint,\n Exception,\n // eslint-disable-next-line deprecation/deprecation\n Severity,\n SeverityLevel,\n StackFrame,\n Stacktrace,\n Thread,\n User,\n} from '@sentry/types';\n\nexport type { BrowserOptions } from './client';\nexport type { ReportDialogOptions } from './helpers';\n\nexport {\n addGlobalEventProcessor,\n addBreadcrumb,\n captureException,\n captureEvent,\n captureMessage,\n configureScope,\n createTransport,\n getHubFromCarrier,\n getCurrentHub,\n Hub,\n makeMain,\n Scope,\n Session,\n startTransaction,\n SDK_VERSION,\n setContext,\n setExtra,\n setExtras,\n setTag,\n setTags,\n setUser,\n withScope,\n FunctionToString,\n InboundFilters,\n} from '@sentry/core';\n\nexport { BrowserClient } from './client';\nexport { makeFetchTransport, makeXHRTransport } from './transports';\nexport {\n defaultStackParser,\n defaultStackLineParsers,\n chromeStackLineParser,\n geckoStackLineParser,\n opera10StackLineParser,\n opera11StackLineParser,\n winjsStackLineParser,\n} from './stack-parsers';\nexport { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDialog, flush, close, wrap } from './sdk';\nexport { SDK_NAME } from './version';\nexport { GlobalHandlers, TryCatch, Breadcrumbs, LinkedErrors, UserAgent, Dedupe } from './integrations';\n"]}
|
package/cjs/helpers.d.ts
CHANGED
|
@@ -44,9 +44,4 @@ export interface ReportDialogOptions {
|
|
|
44
44
|
/** Callback after reportDialog showed up */
|
|
45
45
|
onLoad?(): void;
|
|
46
46
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Injects the Report Dialog script
|
|
49
|
-
* @hidden
|
|
50
|
-
*/
|
|
51
|
-
export declare function injectReportDialog(options?: ReportDialogOptions): void;
|
|
52
47
|
//# sourceMappingURL=helpers.d.ts.map
|
package/cjs/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAwB,SAAS,EAAS,eAAe,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAwB,SAAS,EAAS,eAAe,EAAE,MAAM,eAAe,CAAC;AAWjG;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAMxC;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAClB,EAAE,EAAE,eAAe,EACnB,OAAO,GAAE;IACP,SAAS,CAAC,EAAE,SAAS,CAAC;CAClB,EACN,MAAM,CAAC,EAAE,eAAe,GAEvB,GAAG,CAyGL;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAElC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4CAA4C;IAC5C,MAAM,CAAC,IAAI,IAAI,CAAC;CACjB"}
|
package/cjs/helpers.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var flags_1 = require("./flags");
|
|
6
|
-
var global = utils_1.getGlobalObject();
|
|
7
|
-
var ignoreOnError = 0;
|
|
2
|
+
const core_1 = require("@sentry/core");
|
|
3
|
+
const utils_1 = require("@sentry/utils");
|
|
4
|
+
let ignoreOnError = 0;
|
|
8
5
|
/**
|
|
9
6
|
* @hidden
|
|
10
7
|
*/
|
|
@@ -18,7 +15,7 @@ exports.shouldIgnoreOnError = shouldIgnoreOnError;
|
|
|
18
15
|
function ignoreNextOnError() {
|
|
19
16
|
// onerror should trigger before setTimeout
|
|
20
17
|
ignoreOnError += 1;
|
|
21
|
-
setTimeout(
|
|
18
|
+
setTimeout(() => {
|
|
22
19
|
ignoreOnError -= 1;
|
|
23
20
|
});
|
|
24
21
|
}
|
|
@@ -31,21 +28,20 @@ exports.ignoreNextOnError = ignoreNextOnError;
|
|
|
31
28
|
* @returns The wrapped function.
|
|
32
29
|
* @hidden
|
|
33
30
|
*/
|
|
34
|
-
function wrap(fn, options, before) {
|
|
31
|
+
function wrap(fn, options = {}, before) {
|
|
35
32
|
// for future readers what this does is wrap a function and then create
|
|
36
33
|
// a bi-directional wrapping between them.
|
|
37
34
|
//
|
|
38
35
|
// example: wrapped = wrap(original);
|
|
39
36
|
// original.__sentry_wrapped__ -> wrapped
|
|
40
37
|
// wrapped.__sentry_original__ -> original
|
|
41
|
-
if (options === void 0) { options = {}; }
|
|
42
38
|
if (typeof fn !== 'function') {
|
|
43
39
|
return fn;
|
|
44
40
|
}
|
|
45
41
|
try {
|
|
46
42
|
// if we're dealing with a function that was previously wrapped, return
|
|
47
43
|
// the original wrapper.
|
|
48
|
-
|
|
44
|
+
const wrapper = fn.__sentry_wrapped__;
|
|
49
45
|
if (wrapper) {
|
|
50
46
|
return wrapper;
|
|
51
47
|
}
|
|
@@ -62,14 +58,14 @@ function wrap(fn, options, before) {
|
|
|
62
58
|
}
|
|
63
59
|
/* eslint-disable prefer-rest-params */
|
|
64
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
const sentryWrapped = function () {
|
|
62
|
+
const args = Array.prototype.slice.call(arguments);
|
|
67
63
|
try {
|
|
68
64
|
if (before && typeof before === 'function') {
|
|
69
65
|
before.apply(this, arguments);
|
|
70
66
|
}
|
|
71
67
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
|
|
72
|
-
|
|
68
|
+
const wrappedArguments = args.map((arg) => wrap(arg, options));
|
|
73
69
|
// Attempt to invoke user-land function
|
|
74
70
|
// NOTE: If you are a Sentry user, and you are seeing this stack frame, it
|
|
75
71
|
// means the sentry.javascript SDK caught an error invoking your application code. This
|
|
@@ -78,13 +74,13 @@ function wrap(fn, options, before) {
|
|
|
78
74
|
}
|
|
79
75
|
catch (ex) {
|
|
80
76
|
ignoreNextOnError();
|
|
81
|
-
core_1.withScope(
|
|
82
|
-
scope.addEventProcessor(
|
|
77
|
+
core_1.withScope((scope) => {
|
|
78
|
+
scope.addEventProcessor((event) => {
|
|
83
79
|
if (options.mechanism) {
|
|
84
80
|
utils_1.addExceptionTypeValue(event, undefined, undefined);
|
|
85
81
|
utils_1.addExceptionMechanism(event, options.mechanism);
|
|
86
82
|
}
|
|
87
|
-
event.extra =
|
|
83
|
+
event.extra = Object.assign(Object.assign({}, event.extra), { arguments: args });
|
|
88
84
|
return event;
|
|
89
85
|
});
|
|
90
86
|
core_1.captureException(ex);
|
|
@@ -96,7 +92,7 @@ function wrap(fn, options, before) {
|
|
|
96
92
|
// Accessing some objects may throw
|
|
97
93
|
// ref: https://github.com/getsentry/sentry-javascript/issues/1168
|
|
98
94
|
try {
|
|
99
|
-
for (
|
|
95
|
+
for (const property in fn) {
|
|
100
96
|
if (Object.prototype.hasOwnProperty.call(fn, property)) {
|
|
101
97
|
sentryWrapped[property] = fn[property];
|
|
102
98
|
}
|
|
@@ -109,10 +105,10 @@ function wrap(fn, options, before) {
|
|
|
109
105
|
utils_1.addNonEnumerableProperty(fn, '__sentry_wrapped__', sentryWrapped);
|
|
110
106
|
// Restore original function name (not all browsers allow that)
|
|
111
107
|
try {
|
|
112
|
-
|
|
108
|
+
const descriptor = Object.getOwnPropertyDescriptor(sentryWrapped, 'name');
|
|
113
109
|
if (descriptor.configurable) {
|
|
114
110
|
Object.defineProperty(sentryWrapped, 'name', {
|
|
115
|
-
get
|
|
111
|
+
get() {
|
|
116
112
|
return fn.name;
|
|
117
113
|
},
|
|
118
114
|
});
|
|
@@ -123,34 +119,4 @@ function wrap(fn, options, before) {
|
|
|
123
119
|
return sentryWrapped;
|
|
124
120
|
}
|
|
125
121
|
exports.wrap = wrap;
|
|
126
|
-
/**
|
|
127
|
-
* Injects the Report Dialog script
|
|
128
|
-
* @hidden
|
|
129
|
-
*/
|
|
130
|
-
function injectReportDialog(options) {
|
|
131
|
-
if (options === void 0) { options = {}; }
|
|
132
|
-
if (!global.document) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (!options.eventId) {
|
|
136
|
-
flags_1.IS_DEBUG_BUILD && utils_1.logger.error('Missing eventId option in showReportDialog call');
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if (!options.dsn) {
|
|
140
|
-
flags_1.IS_DEBUG_BUILD && utils_1.logger.error('Missing dsn option in showReportDialog call');
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
var script = global.document.createElement('script');
|
|
144
|
-
script.async = true;
|
|
145
|
-
script.src = core_1.getReportDialogEndpoint(options.dsn, options);
|
|
146
|
-
if (options.onLoad) {
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
148
|
-
script.onload = options.onLoad;
|
|
149
|
-
}
|
|
150
|
-
var injectionPoint = global.document.head || global.document.body;
|
|
151
|
-
if (injectionPoint) {
|
|
152
|
-
injectionPoint.appendChild(script);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
exports.injectReportDialog = injectReportDialog;
|
|
156
122
|
//# sourceMappingURL=helpers.js.map
|
package/cjs/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/helpers.ts"],"names":[],"mappings":";AAAA,uCAA2D;AAE3D,yCAMuB;AAEvB,IAAI,aAAa,GAAW,CAAC,CAAC;AAE9B;;GAEG;AACH,SAAgB,mBAAmB;IACjC,OAAO,aAAa,GAAG,CAAC,CAAC;AAC3B,CAAC;AAFD,kDAEC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,2CAA2C;IAC3C,aAAa,IAAI,CAAC,CAAC;IACnB,UAAU,CAAC,GAAG,EAAE;QACd,aAAa,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAND,8CAMC;AAED;;;;;;;GAOG;AACH,SAAgB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AAE,GAAE;IAEhB,OAAO,aAAa,CAAC;AACvB,CAAC;AAhHD,oBAgHC","sourcesContent":["import { captureException, withScope } from '@sentry/core';\nimport { DsnLike, Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types';\nimport {\n addExceptionMechanism,\n addExceptionTypeValue,\n addNonEnumerableProperty,\n getOriginalFunction,\n markFunctionWrapped,\n} from '@sentry/utils';\n\nlet ignoreOnError: number = 0;\n\n/**\n * @hidden\n */\nexport function shouldIgnoreOnError(): boolean {\n return ignoreOnError > 0;\n}\n\n/**\n * @hidden\n */\nexport function ignoreNextOnError(): void {\n // onerror should trigger before setTimeout\n ignoreOnError += 1;\n setTimeout(() => {\n ignoreOnError -= 1;\n });\n}\n\n/**\n * Instruments the given function and sends an event to Sentry every time the\n * function throws an exception.\n *\n * @param fn A function to wrap.\n * @returns The wrapped function.\n * @hidden\n */\nexport function wrap(\n fn: WrappedFunction,\n options: {\n mechanism?: Mechanism;\n } = {},\n before?: WrappedFunction,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n // for future readers what this does is wrap a function and then create\n // a bi-directional wrapping between them.\n //\n // example: wrapped = wrap(original);\n // original.__sentry_wrapped__ -> wrapped\n // wrapped.__sentry_original__ -> original\n\n if (typeof fn !== 'function') {\n return fn;\n }\n\n try {\n // if we're dealing with a function that was previously wrapped, return\n // the original wrapper.\n const wrapper = fn.__sentry_wrapped__;\n if (wrapper) {\n return wrapper;\n }\n\n // We don't wanna wrap it twice\n if (getOriginalFunction(fn)) {\n return fn;\n }\n } catch (e) {\n // Just accessing custom props in some Selenium environments\n // can cause a \"Permission denied\" exception (see raven-js#495).\n // Bail on wrapping and return the function as-is (defers to window.onerror).\n return fn;\n }\n\n /* eslint-disable prefer-rest-params */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sentryWrapped: WrappedFunction = function (this: any): void {\n const args = Array.prototype.slice.call(arguments);\n\n try {\n if (before && typeof before === 'function') {\n before.apply(this, arguments);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n const wrappedArguments = args.map((arg: any) => wrap(arg, options));\n\n // Attempt to invoke user-land function\n // NOTE: If you are a Sentry user, and you are seeing this stack frame, it\n // means the sentry.javascript SDK caught an error invoking your application code. This\n // is expected behavior and NOT indicative of a bug with sentry.javascript.\n return fn.apply(this, wrappedArguments);\n } catch (ex) {\n ignoreNextOnError();\n\n withScope((scope: Scope) => {\n scope.addEventProcessor((event: SentryEvent) => {\n if (options.mechanism) {\n addExceptionTypeValue(event, undefined, undefined);\n addExceptionMechanism(event, options.mechanism);\n }\n\n event.extra = {\n ...event.extra,\n arguments: args,\n };\n\n return event;\n });\n\n captureException(ex);\n });\n\n throw ex;\n }\n };\n /* eslint-enable prefer-rest-params */\n\n // Accessing some objects may throw\n // ref: https://github.com/getsentry/sentry-javascript/issues/1168\n try {\n for (const property in fn) {\n if (Object.prototype.hasOwnProperty.call(fn, property)) {\n sentryWrapped[property] = fn[property];\n }\n }\n } catch (_oO) {} // eslint-disable-line no-empty\n\n // Signal that this function has been wrapped/filled already\n // for both debugging and to prevent it to being wrapped/filled twice\n markFunctionWrapped(sentryWrapped, fn);\n\n addNonEnumerableProperty(fn, '__sentry_wrapped__', sentryWrapped);\n\n // Restore original function name (not all browsers allow that)\n try {\n const descriptor = Object.getOwnPropertyDescriptor(sentryWrapped, 'name') as PropertyDescriptor;\n if (descriptor.configurable) {\n Object.defineProperty(sentryWrapped, 'name', {\n get(): string {\n return fn.name;\n },\n });\n }\n // eslint-disable-next-line no-empty\n } catch (_oO) {}\n\n return sentryWrapped;\n}\n\n/**\n * All properties the report dialog supports\n */\nexport interface ReportDialogOptions {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n eventId?: string;\n dsn?: DsnLike;\n user?: {\n email?: string;\n name?: string;\n };\n lang?: string;\n title?: string;\n subtitle?: string;\n subtitle2?: string;\n labelName?: string;\n labelEmail?: string;\n labelComments?: string;\n labelClose?: string;\n labelSubmit?: string;\n errorGeneric?: string;\n errorFormEntry?: string;\n successMessage?: string;\n /** Callback after reportDialog showed up */\n onLoad?(): void;\n}\n"]}
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './exports';
|
|
2
2
|
import { Integrations as CoreIntegrations } from '@sentry/core';
|
|
3
3
|
import * as BrowserIntegrations from './integrations';
|
|
4
|
-
import * as Transports from './transports';
|
|
5
4
|
declare const INTEGRATIONS: {
|
|
6
5
|
GlobalHandlers: typeof BrowserIntegrations.GlobalHandlers;
|
|
7
6
|
TryCatch: typeof BrowserIntegrations.TryCatch;
|
|
@@ -12,5 +11,5 @@ declare const INTEGRATIONS: {
|
|
|
12
11
|
FunctionToString: typeof CoreIntegrations.FunctionToString;
|
|
13
12
|
InboundFilters: typeof CoreIntegrations.InboundFilters;
|
|
14
13
|
};
|
|
15
|
-
export { INTEGRATIONS as Integrations
|
|
14
|
+
export { INTEGRATIONS as Integrations };
|
|
16
15
|
//# sourceMappingURL=index.d.ts.map
|
package/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAE1B,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhE,OAAO,KAAK,mBAAmB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAE1B,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhE,OAAO,KAAK,mBAAmB,MAAM,gBAAgB,CAAC;AAUtD,QAAA,MAAM,YAAY;;;;;;;;;CAIjB,CAAC;AAEF,OAAO,EAAE,YAAY,IAAI,YAAY,EAAE,CAAC"}
|
package/cjs/index.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
|
|
2
|
+
const tslib_1 = require("tslib");
|
|
3
3
|
tslib_1.__exportStar(require("./exports"), exports);
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.Transports = Transports;
|
|
9
|
-
var windowIntegrations = {};
|
|
4
|
+
const core_1 = require("@sentry/core");
|
|
5
|
+
const utils_1 = require("@sentry/utils");
|
|
6
|
+
const BrowserIntegrations = require("./integrations");
|
|
7
|
+
let windowIntegrations = {};
|
|
10
8
|
// This block is needed to add compatibility with the integrations packages when used with a CDN
|
|
11
|
-
|
|
9
|
+
const _window = utils_1.getGlobalObject();
|
|
12
10
|
if (_window.Sentry && _window.Sentry.Integrations) {
|
|
13
11
|
windowIntegrations = _window.Sentry.Integrations;
|
|
14
12
|
}
|
|
15
|
-
|
|
13
|
+
const INTEGRATIONS = Object.assign(Object.assign(Object.assign({}, windowIntegrations), core_1.Integrations), BrowserIntegrations);
|
|
16
14
|
exports.Integrations = INTEGRATIONS;
|
|
17
15
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;AAAA,oDAA0B;AAE1B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;AAAA,oDAA0B;AAE1B,uCAAgE;AAChE,yCAAgD;AAEhD,sDAAsD;AAEtD,IAAI,kBAAkB,GAAG,EAAE,CAAC;AAE5B,gGAAgG;AAChG,MAAM,OAAO,GAAG,uBAAe,EAAU,CAAC;AAC1C,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE;IACjD,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;CAClD;AAED,MAAM,YAAY,iDACb,kBAAkB,GAClB,mBAAgB,GAChB,mBAAmB,CACvB,CAAC;AAEuB,oCAAY","sourcesContent":["export * from './exports';\n\nimport { Integrations as CoreIntegrations } from '@sentry/core';\nimport { getGlobalObject } from '@sentry/utils';\n\nimport * as BrowserIntegrations from './integrations';\n\nlet windowIntegrations = {};\n\n// This block is needed to add compatibility with the integrations packages when used with a CDN\nconst _window = getGlobalObject<Window>();\nif (_window.Sentry && _window.Sentry.Integrations) {\n windowIntegrations = _window.Sentry.Integrations;\n}\n\nconst INTEGRATIONS = {\n ...windowIntegrations,\n ...CoreIntegrations,\n ...BrowserIntegrations,\n};\n\nexport { INTEGRATIONS as Integrations };\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Integration } from '@sentry/types';
|
|
2
2
|
/** JSDoc */
|
|
3
3
|
interface BreadcrumbsOptions {
|
|
4
4
|
console: boolean;
|
|
@@ -10,6 +10,7 @@ interface BreadcrumbsOptions {
|
|
|
10
10
|
sentry: boolean;
|
|
11
11
|
xhr: boolean;
|
|
12
12
|
}
|
|
13
|
+
export declare const BREADCRUMB_INTEGRATION_ID = "Breadcrumbs";
|
|
13
14
|
/**
|
|
14
15
|
* Default Breadcrumbs instrumentations
|
|
15
16
|
* TODO: Deprecated - with v6, this will be renamed to `Instrument`
|
|
@@ -23,16 +24,14 @@ export declare class Breadcrumbs implements Integration {
|
|
|
23
24
|
* @inheritDoc
|
|
24
25
|
*/
|
|
25
26
|
name: string;
|
|
26
|
-
/** JSDoc */
|
|
27
|
-
private readonly _options;
|
|
28
27
|
/**
|
|
29
|
-
*
|
|
28
|
+
* Options of the breadcrumbs integration.
|
|
30
29
|
*/
|
|
31
|
-
|
|
30
|
+
readonly options: Readonly<BreadcrumbsOptions>;
|
|
32
31
|
/**
|
|
33
|
-
*
|
|
32
|
+
* @inheritDoc
|
|
34
33
|
*/
|
|
35
|
-
|
|
34
|
+
constructor(options?: Partial<BreadcrumbsOptions>);
|
|
36
35
|
/**
|
|
37
36
|
* Instrument browser built-ins w/ breadcrumb capturing
|
|
38
37
|
* - Console API
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumbs.d.ts","sourceRoot":"","sources":["../../../../src/integrations/breadcrumbs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"breadcrumbs.d.ts","sourceRoot":"","sources":["../../../../src/integrations/breadcrumbs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAU5C,YAAY;AACZ,UAAU,kBAAkB;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,OAAO,GAAG;QAAE,kBAAkB,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAC;IACzD,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;CACd;AAED,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AAEvD;;;GAGG;AACH,qBAAa,WAAY,YAAW,WAAW;IAC7C;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAA6B;IAErD;;OAEG;IACI,IAAI,EAAE,MAAM,CAAkB;IAErC;;OAEG;IAEH,SAAgB,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAEtD;;OAEG;gBACgB,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAYxD;;;;;;;OAOG;IACI,SAAS,IAAI,IAAI;CAiBzB"}
|
|
@@ -1,40 +1,24 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
var tslib_1 = require("tslib");
|
|
3
2
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
4
3
|
/* eslint-disable max-lines */
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const core_1 = require("@sentry/core");
|
|
5
|
+
const utils_1 = require("@sentry/utils");
|
|
6
|
+
exports.BREADCRUMB_INTEGRATION_ID = 'Breadcrumbs';
|
|
7
7
|
/**
|
|
8
8
|
* Default Breadcrumbs instrumentations
|
|
9
9
|
* TODO: Deprecated - with v6, this will be renamed to `Instrument`
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
class Breadcrumbs {
|
|
12
12
|
/**
|
|
13
13
|
* @inheritDoc
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
constructor(options) {
|
|
16
16
|
/**
|
|
17
17
|
* @inheritDoc
|
|
18
18
|
*/
|
|
19
19
|
this.name = Breadcrumbs.id;
|
|
20
|
-
this.
|
|
20
|
+
this.options = Object.assign({ console: true, dom: true, fetch: true, history: true, sentry: true, xhr: true }, options);
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Create a breadcrumb of `sentry` from the events themselves
|
|
24
|
-
*/
|
|
25
|
-
Breadcrumbs.prototype.addSentryBreadcrumb = function (event) {
|
|
26
|
-
if (!this._options.sentry) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
core_1.getCurrentHub().addBreadcrumb({
|
|
30
|
-
category: "sentry." + (event.type === 'transaction' ? 'transaction' : 'event'),
|
|
31
|
-
event_id: event.event_id,
|
|
32
|
-
level: event.level,
|
|
33
|
-
message: utils_1.getEventDescription(event),
|
|
34
|
-
}, {
|
|
35
|
-
event: event,
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
22
|
/**
|
|
39
23
|
* Instrument browser built-ins w/ breadcrumb capturing
|
|
40
24
|
* - Console API
|
|
@@ -43,30 +27,29 @@ var Breadcrumbs = /** @class */ (function () {
|
|
|
43
27
|
* - Fetch API
|
|
44
28
|
* - History API
|
|
45
29
|
*/
|
|
46
|
-
|
|
47
|
-
if (this.
|
|
30
|
+
setupOnce() {
|
|
31
|
+
if (this.options.console) {
|
|
48
32
|
utils_1.addInstrumentationHandler('console', _consoleBreadcrumb);
|
|
49
33
|
}
|
|
50
|
-
if (this.
|
|
51
|
-
utils_1.addInstrumentationHandler('dom', _domBreadcrumb(this.
|
|
34
|
+
if (this.options.dom) {
|
|
35
|
+
utils_1.addInstrumentationHandler('dom', _domBreadcrumb(this.options.dom));
|
|
52
36
|
}
|
|
53
|
-
if (this.
|
|
37
|
+
if (this.options.xhr) {
|
|
54
38
|
utils_1.addInstrumentationHandler('xhr', _xhrBreadcrumb);
|
|
55
39
|
}
|
|
56
|
-
if (this.
|
|
40
|
+
if (this.options.fetch) {
|
|
57
41
|
utils_1.addInstrumentationHandler('fetch', _fetchBreadcrumb);
|
|
58
42
|
}
|
|
59
|
-
if (this.
|
|
43
|
+
if (this.options.history) {
|
|
60
44
|
utils_1.addInstrumentationHandler('history', _historyBreadcrumb);
|
|
61
45
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
* @inheritDoc
|
|
65
|
-
*/
|
|
66
|
-
Breadcrumbs.id = 'Breadcrumbs';
|
|
67
|
-
return Breadcrumbs;
|
|
68
|
-
}());
|
|
46
|
+
}
|
|
47
|
+
}
|
|
69
48
|
exports.Breadcrumbs = Breadcrumbs;
|
|
49
|
+
/**
|
|
50
|
+
* @inheritDoc
|
|
51
|
+
*/
|
|
52
|
+
Breadcrumbs.id = exports.BREADCRUMB_INTEGRATION_ID;
|
|
70
53
|
/**
|
|
71
54
|
* A HOC that creaes a function that creates breadcrumbs from DOM API calls.
|
|
72
55
|
* This is a HOC so that we get access to dom options in the closure.
|
|
@@ -75,8 +58,8 @@ exports.Breadcrumbs = Breadcrumbs;
|
|
|
75
58
|
function _domBreadcrumb(dom) {
|
|
76
59
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
60
|
function _innerDomBreadcrumb(handlerData) {
|
|
78
|
-
|
|
79
|
-
|
|
61
|
+
let target;
|
|
62
|
+
let keyAttrs = typeof dom === 'object' ? dom.serializeAttribute : undefined;
|
|
80
63
|
if (typeof keyAttrs === 'string') {
|
|
81
64
|
keyAttrs = [keyAttrs];
|
|
82
65
|
}
|
|
@@ -93,7 +76,7 @@ function _domBreadcrumb(dom) {
|
|
|
93
76
|
return;
|
|
94
77
|
}
|
|
95
78
|
core_1.getCurrentHub().addBreadcrumb({
|
|
96
|
-
category:
|
|
79
|
+
category: `ui.${handlerData.name}`,
|
|
97
80
|
message: target,
|
|
98
81
|
}, {
|
|
99
82
|
event: handlerData.event,
|
|
@@ -108,7 +91,7 @@ function _domBreadcrumb(dom) {
|
|
|
108
91
|
*/
|
|
109
92
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
93
|
function _consoleBreadcrumb(handlerData) {
|
|
111
|
-
|
|
94
|
+
const breadcrumb = {
|
|
112
95
|
category: 'console',
|
|
113
96
|
data: {
|
|
114
97
|
arguments: handlerData.args,
|
|
@@ -119,7 +102,7 @@ function _consoleBreadcrumb(handlerData) {
|
|
|
119
102
|
};
|
|
120
103
|
if (handlerData.level === 'assert') {
|
|
121
104
|
if (handlerData.args[0] === false) {
|
|
122
|
-
breadcrumb.message =
|
|
105
|
+
breadcrumb.message = `Assertion failed: ${utils_1.safeJoin(handlerData.args.slice(1), ' ') || 'console.assert'}`;
|
|
123
106
|
breadcrumb.data.arguments = handlerData.args.slice(1);
|
|
124
107
|
}
|
|
125
108
|
else {
|
|
@@ -142,13 +125,13 @@ function _xhrBreadcrumb(handlerData) {
|
|
|
142
125
|
if (handlerData.xhr.__sentry_own_request__) {
|
|
143
126
|
return;
|
|
144
127
|
}
|
|
145
|
-
|
|
128
|
+
const { method, url, status_code, body } = handlerData.xhr.__sentry_xhr__ || {};
|
|
146
129
|
core_1.getCurrentHub().addBreadcrumb({
|
|
147
130
|
category: 'xhr',
|
|
148
131
|
data: {
|
|
149
|
-
method
|
|
150
|
-
url
|
|
151
|
-
status_code
|
|
132
|
+
method,
|
|
133
|
+
url,
|
|
134
|
+
status_code,
|
|
152
135
|
},
|
|
153
136
|
type: 'http',
|
|
154
137
|
}, {
|
|
@@ -185,7 +168,7 @@ function _fetchBreadcrumb(handlerData) {
|
|
|
185
168
|
else {
|
|
186
169
|
core_1.getCurrentHub().addBreadcrumb({
|
|
187
170
|
category: 'fetch',
|
|
188
|
-
data:
|
|
171
|
+
data: Object.assign(Object.assign({}, handlerData.fetchData), { status_code: handlerData.response.status }),
|
|
189
172
|
type: 'http',
|
|
190
173
|
}, {
|
|
191
174
|
input: handlerData.args,
|
|
@@ -198,12 +181,12 @@ function _fetchBreadcrumb(handlerData) {
|
|
|
198
181
|
*/
|
|
199
182
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
183
|
function _historyBreadcrumb(handlerData) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
184
|
+
const global = utils_1.getGlobalObject();
|
|
185
|
+
let from = handlerData.from;
|
|
186
|
+
let to = handlerData.to;
|
|
187
|
+
const parsedLoc = utils_1.parseUrl(global.location.href);
|
|
188
|
+
let parsedFrom = utils_1.parseUrl(from);
|
|
189
|
+
const parsedTo = utils_1.parseUrl(to);
|
|
207
190
|
// Initial pushState doesn't provide `from` information
|
|
208
191
|
if (!parsedFrom.path) {
|
|
209
192
|
parsedFrom = parsedLoc;
|
|
@@ -219,8 +202,8 @@ function _historyBreadcrumb(handlerData) {
|
|
|
219
202
|
core_1.getCurrentHub().addBreadcrumb({
|
|
220
203
|
category: 'navigation',
|
|
221
204
|
data: {
|
|
222
|
-
from
|
|
223
|
-
to
|
|
205
|
+
from,
|
|
206
|
+
to,
|
|
224
207
|
},
|
|
225
208
|
});
|
|
226
209
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"breadcrumbs.js","sourceRoot":"","sources":["../../../../src/integrations/breadcrumbs.ts"],"names":[],"mappings":";;AAAA,+DAA+D;AAC/D,8BAA8B;AAC9B,qCAA6C;AAE7C,uCAQuB;AAYvB;;;GAGG;AACH;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AW,CAAC,EAAE,CAAC;IACxB,IAAM,SAAS,GAAG,gBAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,UAAU,GAAG,gBAAQ,CAAC,IAAI,CAAC,CAAC;IAChC,IAAM,QAAQ,GAAG,gBAAQ,CAAC,EAAE,CAAC,CAAC;IAE9B,uDAAuD;IACvD,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;QACpB,UAAU,GAAG,SAAS,CAAC;KACxB;IAED,wEAAwE;IACxE,sDAAsD;IACtD,IAAI,SAAS,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,IAAI,SAAS,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE;QAChF,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC;KACxB;IACD,IAAI,SAAS,CAAC,QAAQ,KAAK,UAAU,CAAC,QAAQ,IAAI,SAAS,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,EAAE;QACpF,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC;KAC5B;IAED,oBAAa,EAAE,CAAC,aAAa,CAAC;QAC5B,QAAQ,EAAE,YAAY;QACtB,IAAI,EAAE;YACJ,IAAI,MAAA;YACJ,EAAE,IAAA;SACH;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable max-lines */\nimport { getCurrentHub } from '@sentry/core';\nimport { Event, Integration } from '@sentry/types';\nimport {\n addInstrumentationHandler,\n getEventDescription,\n getGlobalObject,\n htmlTreeAsString,\n parseUrl,\n safeJoin,\n severityLevelFromString,\n} from '@sentry/utils';\n\n/** JSDoc */\ninterface BreadcrumbsOptions {\n console: boolean;\n dom: boolean | { serializeAttribute: string | string[] };\n fetch: boolean;\n history: boolean;\n sentry: boolean;\n xhr: boolean;\n}\n\n/**\n * Default Breadcrumbs instrumentations\n * TODO: Deprecated - with v6, this will be renamed to `Instrument`\n */\nexport class Breadcrumbs implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Breadcrumbs';\n\n /**\n * @inheritDoc\n */\n public name: string = Breadcrumbs.id;\n\n /** JSDoc */\n private readonly _options: BreadcrumbsOptions;\n\n /**\n * @inheritDoc\n */\n public constructor(options?: Partial<BreadcrumbsOptions>) {\n this._options = {\n console: true,\n dom: true,\n fetch: true,\n history: true,\n sentry: true,\n xhr: true,\n ...options,\n };\n }\n\n /**\n * Create a breadcrumb of `sentry` from the events themselves\n */\n public addSentryBreadcrumb(event: Event): void {\n if (!this._options.sentry) {\n return;\n }\n getCurrentHub().addBreadcrumb(\n {\n category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,\n event_id: event.event_id,\n level: event.level,\n message: getEventDescription(event),\n },\n {\n event,\n },\n );\n }\n\n /**\n * Instrument browser built-ins w/ breadcrumb capturing\n * - Console API\n * - DOM API (click/typing)\n * - XMLHttpRequest API\n * - Fetch API\n * - History API\n */\n public setupOnce(): void {\n if (this._options.console) {\n addInstrumentationHandler('console', _consoleBreadcrumb);\n }\n if (this._options.dom) {\n addInstrumentationHandler('dom', _domBreadcrumb(this._options.dom));\n }\n if (this._options.xhr) {\n addInstrumentationHandler('xhr', _xhrBreadcrumb);\n }\n if (this._options.fetch) {\n addInstrumentationHandler('fetch', _fetchBreadcrumb);\n }\n if (this._options.history) {\n addInstrumentationHandler('history', _historyBreadcrumb);\n }\n }\n}\n\n/**\n * A HOC that creaes a function that creates breadcrumbs from DOM API calls.\n * This is a HOC so that we get access to dom options in the closure.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _domBreadcrumb(dom: BreadcrumbsOptions['dom']): (handlerData: { [key: string]: any }) => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function _innerDomBreadcrumb(handlerData: { [key: string]: any }): void {\n let target;\n let keyAttrs = typeof dom === 'object' ? dom.serializeAttribute : undefined;\n\n if (typeof keyAttrs === 'string') {\n keyAttrs = [keyAttrs];\n }\n\n // Accessing event.target can throw (see getsentry/raven-js#838, #768)\n try {\n target = handlerData.event.target\n ? htmlTreeAsString(handlerData.event.target as Node, keyAttrs)\n : htmlTreeAsString(handlerData.event as unknown as Node, keyAttrs);\n } catch (e) {\n target = '<unknown>';\n }\n\n if (target.length === 0) {\n return;\n }\n\n getCurrentHub().addBreadcrumb(\n {\n category: `ui.${handlerData.name}`,\n message: target,\n },\n {\n event: handlerData.event,\n name: handlerData.name,\n global: handlerData.global,\n },\n );\n }\n\n return _innerDomBreadcrumb;\n}\n\n/**\n * Creates breadcrumbs from console API calls\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _consoleBreadcrumb(handlerData: { [key: string]: any }): void {\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: handlerData.args,\n logger: 'console',\n },\n level: severityLevelFromString(handlerData.level),\n message: safeJoin(handlerData.args, ' '),\n };\n\n if (handlerData.level === 'assert') {\n if (handlerData.args[0] === false) {\n breadcrumb.message = `Assertion failed: ${safeJoin(handlerData.args.slice(1), ' ') || 'console.assert'}`;\n breadcrumb.data.arguments = handlerData.args.slice(1);\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n getCurrentHub().addBreadcrumb(breadcrumb, {\n input: handlerData.args,\n level: handlerData.level,\n });\n}\n\n/**\n * Creates breadcrumbs from XHR API calls\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _xhrBreadcrumb(handlerData: { [key: string]: any }): void {\n if (handlerData.endTimestamp) {\n // We only capture complete, non-sentry requests\n if (handlerData.xhr.__sentry_own_request__) {\n return;\n }\n\n const { method, url, status_code, body } = handlerData.xhr.__sentry_xhr__ || {};\n\n getCurrentHub().addBreadcrumb(\n {\n category: 'xhr',\n data: {\n method,\n url,\n status_code,\n },\n type: 'http',\n },\n {\n xhr: handlerData.xhr,\n input: body,\n },\n );\n\n return;\n }\n}\n\n/**\n * Creates breadcrumbs from fetch API calls\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _fetchBreadcrumb(handlerData: { [key: string]: any }): void {\n // We only capture complete fetch requests\n if (!handlerData.endTimestamp) {\n return;\n }\n\n if (handlerData.fetchData.url.match(/sentry_key/) && handlerData.fetchData.method === 'POST') {\n // We will not create breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)\n return;\n }\n\n if (handlerData.error) {\n getCurrentHub().addBreadcrumb(\n {\n category: 'fetch',\n data: handlerData.fetchData,\n level: 'error',\n type: 'http',\n },\n {\n data: handlerData.error,\n input: handlerData.args,\n },\n );\n } else {\n getCurrentHub().addBreadcrumb(\n {\n category: 'fetch',\n data: {\n ...handlerData.fetchData,\n status_code: handlerData.response.status,\n },\n type: 'http',\n },\n {\n input: handlerData.args,\n response: handlerData.response,\n },\n );\n }\n}\n\n/**\n * Creates breadcrumbs from history API calls\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _historyBreadcrumb(handlerData: { [key: string]: any }): void {\n const global = getGlobalObject<Window>();\n let from = handlerData.from;\n let to = handlerData.to;\n const parsedLoc = parseUrl(global.location.href);\n let parsedFrom = parseUrl(from);\n const parsedTo = parseUrl(to);\n\n // Initial pushState doesn't provide `from` information\n if (!parsedFrom.path) {\n parsedFrom = parsedLoc;\n }\n\n // Use only the path component of the URL if the URL matches the current\n // document (almost all the time when using pushState)\n if (parsedLoc.protocol === parsedTo.protocol && parsedLoc.host === parsedTo.host) {\n to = parsedTo.relative;\n }\n if (parsedLoc.protocol === parsedFrom.protocol && parsedLoc.host === parsedFrom.host) {\n from = parsedFrom.relative;\n }\n\n getCurrentHub().addBreadcrumb({\n category: 'navigation',\n data: {\n from,\n to,\n },\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"breadcrumbs.js","sourceRoot":"","sources":["../../../../src/integrations/breadcrumbs.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,8BAA8B;AAC9B,uCAA6C;AAE7C,yCAOuB;AAYV,QAAA,yBAAyB,GAAG,aAAa,CAA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KAAK,QAAQ,CAAC,IAAI,EAAE;QAChF,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC;KACxB;IACD,IAAI,SAAS,CAAC,QAAQ,KAAK,UAAU,CAAC,QAAQ,IAAI,SAAS,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,EAAE;QACpF,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC;KAC5B;IAED,oBAAa,EAAE,CAAC,aAAa,CAAC;QAC5B,QAAQ,EAAE,YAAY;QACtB,IAAI,EAAE;YACJ,IAAI;YACJ,EAAE;SACH;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable max-lines */\nimport { getCurrentHub } from '@sentry/core';\nimport { Integration } from '@sentry/types';\nimport {\n addInstrumentationHandler,\n getGlobalObject,\n htmlTreeAsString,\n parseUrl,\n safeJoin,\n severityLevelFromString,\n} from '@sentry/utils';\n\n/** JSDoc */\ninterface BreadcrumbsOptions {\n console: boolean;\n dom: boolean | { serializeAttribute: string | string[] };\n fetch: boolean;\n history: boolean;\n sentry: boolean;\n xhr: boolean;\n}\n\nexport const BREADCRUMB_INTEGRATION_ID = 'Breadcrumbs';\n\n/**\n * Default Breadcrumbs instrumentations\n * TODO: Deprecated - with v6, this will be renamed to `Instrument`\n */\nexport class Breadcrumbs implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = BREADCRUMB_INTEGRATION_ID;\n\n /**\n * @inheritDoc\n */\n public name: string = Breadcrumbs.id;\n\n /**\n * Options of the breadcrumbs integration.\n */\n // This field is public, because we use it in the browser client to check if the `sentry` option is enabled.\n public readonly options: Readonly<BreadcrumbsOptions>;\n\n /**\n * @inheritDoc\n */\n public constructor(options?: Partial<BreadcrumbsOptions>) {\n this.options = {\n console: true,\n dom: true,\n fetch: true,\n history: true,\n sentry: true,\n xhr: true,\n ...options,\n };\n }\n\n /**\n * Instrument browser built-ins w/ breadcrumb capturing\n * - Console API\n * - DOM API (click/typing)\n * - XMLHttpRequest API\n * - Fetch API\n * - History API\n */\n public setupOnce(): void {\n if (this.options.console) {\n addInstrumentationHandler('console', _consoleBreadcrumb);\n }\n if (this.options.dom) {\n addInstrumentationHandler('dom', _domBreadcrumb(this.options.dom));\n }\n if (this.options.xhr) {\n addInstrumentationHandler('xhr', _xhrBreadcrumb);\n }\n if (this.options.fetch) {\n addInstrumentationHandler('fetch', _fetchBreadcrumb);\n }\n if (this.options.history) {\n addInstrumentationHandler('history', _historyBreadcrumb);\n }\n }\n}\n\n/**\n * A HOC that creaes a function that creates breadcrumbs from DOM API calls.\n * This is a HOC so that we get access to dom options in the closure.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _domBreadcrumb(dom: BreadcrumbsOptions['dom']): (handlerData: { [key: string]: any }) => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function _innerDomBreadcrumb(handlerData: { [key: string]: any }): void {\n let target;\n let keyAttrs = typeof dom === 'object' ? dom.serializeAttribute : undefined;\n\n if (typeof keyAttrs === 'string') {\n keyAttrs = [keyAttrs];\n }\n\n // Accessing event.target can throw (see getsentry/raven-js#838, #768)\n try {\n target = handlerData.event.target\n ? htmlTreeAsString(handlerData.event.target as Node, keyAttrs)\n : htmlTreeAsString(handlerData.event as unknown as Node, keyAttrs);\n } catch (e) {\n target = '<unknown>';\n }\n\n if (target.length === 0) {\n return;\n }\n\n getCurrentHub().addBreadcrumb(\n {\n category: `ui.${handlerData.name}`,\n message: target,\n },\n {\n event: handlerData.event,\n name: handlerData.name,\n global: handlerData.global,\n },\n );\n }\n\n return _innerDomBreadcrumb;\n}\n\n/**\n * Creates breadcrumbs from console API calls\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _consoleBreadcrumb(handlerData: { [key: string]: any }): void {\n const breadcrumb = {\n category: 'console',\n data: {\n arguments: handlerData.args,\n logger: 'console',\n },\n level: severityLevelFromString(handlerData.level),\n message: safeJoin(handlerData.args, ' '),\n };\n\n if (handlerData.level === 'assert') {\n if (handlerData.args[0] === false) {\n breadcrumb.message = `Assertion failed: ${safeJoin(handlerData.args.slice(1), ' ') || 'console.assert'}`;\n breadcrumb.data.arguments = handlerData.args.slice(1);\n } else {\n // Don't capture a breadcrumb for passed assertions\n return;\n }\n }\n\n getCurrentHub().addBreadcrumb(breadcrumb, {\n input: handlerData.args,\n level: handlerData.level,\n });\n}\n\n/**\n * Creates breadcrumbs from XHR API calls\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _xhrBreadcrumb(handlerData: { [key: string]: any }): void {\n if (handlerData.endTimestamp) {\n // We only capture complete, non-sentry requests\n if (handlerData.xhr.__sentry_own_request__) {\n return;\n }\n\n const { method, url, status_code, body } = handlerData.xhr.__sentry_xhr__ || {};\n\n getCurrentHub().addBreadcrumb(\n {\n category: 'xhr',\n data: {\n method,\n url,\n status_code,\n },\n type: 'http',\n },\n {\n xhr: handlerData.xhr,\n input: body,\n },\n );\n\n return;\n }\n}\n\n/**\n * Creates breadcrumbs from fetch API calls\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _fetchBreadcrumb(handlerData: { [key: string]: any }): void {\n // We only capture complete fetch requests\n if (!handlerData.endTimestamp) {\n return;\n }\n\n if (handlerData.fetchData.url.match(/sentry_key/) && handlerData.fetchData.method === 'POST') {\n // We will not create breadcrumbs for fetch requests that contain `sentry_key` (internal sentry requests)\n return;\n }\n\n if (handlerData.error) {\n getCurrentHub().addBreadcrumb(\n {\n category: 'fetch',\n data: handlerData.fetchData,\n level: 'error',\n type: 'http',\n },\n {\n data: handlerData.error,\n input: handlerData.args,\n },\n );\n } else {\n getCurrentHub().addBreadcrumb(\n {\n category: 'fetch',\n data: {\n ...handlerData.fetchData,\n status_code: handlerData.response.status,\n },\n type: 'http',\n },\n {\n input: handlerData.args,\n response: handlerData.response,\n },\n );\n }\n}\n\n/**\n * Creates breadcrumbs from history API calls\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _historyBreadcrumb(handlerData: { [key: string]: any }): void {\n const global = getGlobalObject<Window>();\n let from = handlerData.from;\n let to = handlerData.to;\n const parsedLoc = parseUrl(global.location.href);\n let parsedFrom = parseUrl(from);\n const parsedTo = parseUrl(to);\n\n // Initial pushState doesn't provide `from` information\n if (!parsedFrom.path) {\n parsedFrom = parsedLoc;\n }\n\n // Use only the path component of the URL if the URL matches the current\n // document (almost all the time when using pushState)\n if (parsedLoc.protocol === parsedTo.protocol && parsedLoc.host === parsedTo.host) {\n to = parsedTo.relative;\n }\n if (parsedLoc.protocol === parsedFrom.protocol && parsedLoc.host === parsedFrom.host) {\n from = parsedFrom.relative;\n }\n\n getCurrentHub().addBreadcrumb({\n category: 'navigation',\n data: {\n from,\n to,\n },\n });\n}\n"]}
|