@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/transports/xhr.js
CHANGED
|
@@ -1,64 +1,44 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'retry-after': request.getResponseHeader('Retry-After'),
|
|
37
|
-
};
|
|
38
|
-
_this._handleResponse({ requestType: sentryRequest.type, response: request, headers: headers, resolve: resolve, reject: reject });
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
request.open('POST', sentryRequest.url);
|
|
42
|
-
for (var header in _this.options.headers) {
|
|
43
|
-
if (Object.prototype.hasOwnProperty.call(_this.options.headers, header)) {
|
|
44
|
-
request.setRequestHeader(header, _this.options.headers[header]);
|
|
45
|
-
}
|
|
2
|
+
const core_1 = require("@sentry/core");
|
|
3
|
+
const utils_1 = require("@sentry/utils");
|
|
4
|
+
/**
|
|
5
|
+
* The DONE ready state for XmlHttpRequest
|
|
6
|
+
*
|
|
7
|
+
* Defining it here as a constant b/c XMLHttpRequest.DONE is not always defined
|
|
8
|
+
* (e.g. during testing, it is `undefined`)
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState}
|
|
11
|
+
*/
|
|
12
|
+
const XHR_READYSTATE_DONE = 4;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.
|
|
15
|
+
*/
|
|
16
|
+
function makeXHRTransport(options) {
|
|
17
|
+
function makeRequest(request) {
|
|
18
|
+
return new utils_1.SyncPromise((resolve, reject) => {
|
|
19
|
+
const xhr = new XMLHttpRequest();
|
|
20
|
+
xhr.onerror = reject;
|
|
21
|
+
xhr.onreadystatechange = () => {
|
|
22
|
+
if (xhr.readyState === XHR_READYSTATE_DONE) {
|
|
23
|
+
const response = {
|
|
24
|
+
headers: {
|
|
25
|
+
'x-sentry-rate-limits': xhr.getResponseHeader('X-Sentry-Rate-Limits'),
|
|
26
|
+
'retry-after': xhr.getResponseHeader('Retry-After'),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
resolve(response);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
xhr.open('POST', options.url);
|
|
33
|
+
for (const header in options.headers) {
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(options.headers, header)) {
|
|
35
|
+
xhr.setRequestHeader(header, options.headers[header]);
|
|
46
36
|
}
|
|
47
|
-
request.send(sentryRequest.body);
|
|
48
|
-
});
|
|
49
|
-
})
|
|
50
|
-
.then(undefined, function (reason) {
|
|
51
|
-
// It's either buffer rejection or any other xhr/fetch error, which are treated as NetworkError.
|
|
52
|
-
if (reason instanceof utils_1.SentryError) {
|
|
53
|
-
_this.recordLostEvent('queue_overflow', sentryRequest.type);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
_this.recordLostEvent('network_error', sentryRequest.type);
|
|
57
37
|
}
|
|
58
|
-
|
|
38
|
+
xhr.send(request.body);
|
|
59
39
|
});
|
|
60
|
-
}
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
exports.
|
|
40
|
+
}
|
|
41
|
+
return core_1.createTransport(options, makeRequest);
|
|
42
|
+
}
|
|
43
|
+
exports.makeXHRTransport = makeXHRTransport;
|
|
64
44
|
//# sourceMappingURL=xhr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xhr.js","sourceRoot":"","sources":["../../../../src/transports/xhr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"xhr.js","sourceRoot":"","sources":["../../../../src/transports/xhr.ts"],"names":[],"mappings":";AAAA,uCAA+C;AAE/C,yCAA4C;AAE5C;;;;;;;GAOG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAM9B;;GAEG;AACH,SAAgB,gBAAgB,CAAC,OAA4B;IAC3D,SAAS,WAAW,CAAC,OAAyB;QAC5C,OAAO,IAAI,mBAAW,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACzC,MAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;YAEjC,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC;YAErB,GAAG,CAAC,kBAAkB,GAAG,GAAS,EAAE;gBAClC,IAAI,GAAG,CAAC,UAAU,KAAK,mBAAmB,EAAE;oBAC1C,MAAM,QAAQ,GAAG;wBACf,OAAO,EAAE;4BACP,sBAAsB,EAAE,GAAG,CAAC,iBAAiB,CAAC,sBAAsB,CAAC;4BACrE,aAAa,EAAE,GAAG,CAAC,iBAAiB,CAAC,aAAa,CAAC;yBACpD;qBACF,CAAC;oBACF,OAAO,CAAC,QAAQ,CAAC,CAAC;iBACnB;YACH,CAAC,CAAC;YAEF,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YAE9B,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE;gBACpC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;oBACjE,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;iBACvD;aACF;YAED,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,sBAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAC/C,CAAC;AAhCD,4CAgCC","sourcesContent":["import { createTransport } from '@sentry/core';\nimport { BaseTransportOptions, Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/types';\nimport { SyncPromise } from '@sentry/utils';\n\n/**\n * The DONE ready state for XmlHttpRequest\n *\n * Defining it here as a constant b/c XMLHttpRequest.DONE is not always defined\n * (e.g. during testing, it is `undefined`)\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState}\n */\nconst XHR_READYSTATE_DONE = 4;\n\nexport interface XHRTransportOptions extends BaseTransportOptions {\n headers?: { [key: string]: string };\n}\n\n/**\n * Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.\n */\nexport function makeXHRTransport(options: XHRTransportOptions): Transport {\n function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n return new SyncPromise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n\n xhr.onerror = reject;\n\n xhr.onreadystatechange = (): void => {\n if (xhr.readyState === XHR_READYSTATE_DONE) {\n const response = {\n headers: {\n 'x-sentry-rate-limits': xhr.getResponseHeader('X-Sentry-Rate-Limits'),\n 'retry-after': xhr.getResponseHeader('Retry-After'),\n },\n };\n resolve(response);\n }\n };\n\n xhr.open('POST', options.url);\n\n for (const header in options.headers) {\n if (Object.prototype.hasOwnProperty.call(options.headers, header)) {\n xhr.setRequestHeader(header, options.headers[header]);\n }\n }\n\n xhr.send(request.body);\n });\n }\n\n return createTransport(options, makeRequest);\n}\n"]}
|
package/esm/client.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { BaseClient,
|
|
2
|
-
import { Event, EventHint, Options, Severity, SeverityLevel
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Configuration options for the Sentry Browser SDK.
|
|
6
|
-
* @see BrowserClient for more information.
|
|
7
|
-
*/
|
|
8
|
-
export interface BrowserOptions extends Options {
|
|
1
|
+
import { BaseClient, Scope } from '@sentry/core';
|
|
2
|
+
import { ClientOptions, Event, EventHint, Options, Severity, SeverityLevel } from '@sentry/types';
|
|
3
|
+
export interface BaseBrowserOptions {
|
|
9
4
|
/**
|
|
10
5
|
* A pattern for error URLs which should exclusively be sent to Sentry.
|
|
11
6
|
* This is the opposite of {@link Options.denyUrls}.
|
|
@@ -19,25 +14,31 @@ export interface BrowserOptions extends Options {
|
|
|
19
14
|
*/
|
|
20
15
|
denyUrls?: Array<string | RegExp>;
|
|
21
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Configuration options for the Sentry Browser SDK.
|
|
19
|
+
* @see @sentry/types Options for more information.
|
|
20
|
+
*/
|
|
21
|
+
export interface BrowserOptions extends Options, BaseBrowserOptions {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Configuration options for the Sentry Browser SDK Client class
|
|
25
|
+
* @see BrowserClient for more information.
|
|
26
|
+
*/
|
|
27
|
+
export interface BrowserClientOptions extends ClientOptions, BaseBrowserOptions {
|
|
28
|
+
}
|
|
22
29
|
/**
|
|
23
30
|
* The Sentry Browser SDK Client.
|
|
24
31
|
*
|
|
25
32
|
* @see BrowserOptions for documentation on configuration options.
|
|
26
33
|
* @see SentryClient for usage documentation.
|
|
27
34
|
*/
|
|
28
|
-
export declare class BrowserClient extends BaseClient<
|
|
35
|
+
export declare class BrowserClient extends BaseClient<BrowserClientOptions> {
|
|
29
36
|
/**
|
|
30
37
|
* Creates a new Browser SDK instance.
|
|
31
38
|
*
|
|
32
39
|
* @param options Configuration options for this SDK.
|
|
33
40
|
*/
|
|
34
|
-
constructor(options:
|
|
35
|
-
/**
|
|
36
|
-
* Show a report dialog to the user to send feedback to a specific event.
|
|
37
|
-
*
|
|
38
|
-
* @param options Set individual options for the dialog
|
|
39
|
-
*/
|
|
40
|
-
showReportDialog(options?: ReportDialogOptions): void;
|
|
41
|
+
constructor(options: BrowserClientOptions);
|
|
41
42
|
/**
|
|
42
43
|
* @inheritDoc
|
|
43
44
|
*/
|
|
@@ -49,10 +50,14 @@ export declare class BrowserClient extends BaseClient<BrowserOptions> {
|
|
|
49
50
|
/**
|
|
50
51
|
* @inheritDoc
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
+
sendEvent(event: Event): void;
|
|
53
54
|
/**
|
|
54
55
|
* @inheritDoc
|
|
55
56
|
*/
|
|
56
|
-
protected
|
|
57
|
+
protected _prepareEvent(event: Event, scope?: Scope, hint?: EventHint): PromiseLike<Event | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Sends client reports as an envelope.
|
|
60
|
+
*/
|
|
61
|
+
private _flushOutcomes;
|
|
57
62
|
}
|
|
58
63
|
//# sourceMappingURL=client.d.ts.map
|
package/esm/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwD,KAAK,EAAe,MAAM,cAAc,CAAC;AACpH,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAkBlG,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAEnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,OAAO,EAAE,kBAAkB;CAAG;AAEtE;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,aAAa,EAAE,kBAAkB;CAAG;AAElF;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,UAAU,CAAC,oBAAoB,CAAC;IACjE;;;;OAIG;gBACgB,OAAO,EAAE,oBAAoB;IAwBhD;;OAEG;IACI,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC;IAInF;;OAEG;IACI,gBAAgB,CACrB,OAAO,EAAE,MAAM,EAEf,KAAK,GAAE,QAAQ,GAAG,aAAsB,EACxC,IAAI,CAAC,EAAE,SAAS,GACf,WAAW,CAAC,KAAK,CAAC;IAIrB;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAgCpC;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,KAAK,GAAG,IAAI,CAAC;IAKjG;;OAEG;IACH,OAAO,CAAC,cAAc;CAwBvB"}
|
package/esm/client.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getGlobalObject, logger, stackParserFromOptions } from '@sentry/utils';
|
|
1
|
+
import { BaseClient, getCurrentHub, getEnvelopeEndpointWithUrlEncodedAuth, SDK_VERSION } from '@sentry/core';
|
|
2
|
+
import { createClientReportEnvelope, dsnToString, getEventDescription, getGlobalObject, logger, serializeEnvelope, } from '@sentry/utils';
|
|
4
3
|
import { eventFromException, eventFromMessage } from './eventbuilder';
|
|
5
4
|
import { IS_DEBUG_BUILD } from './flags';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { BREADCRUMB_INTEGRATION_ID } from './integrations/breadcrumbs';
|
|
6
|
+
import { sendReport } from './transports/utils';
|
|
7
|
+
const globalObject = getGlobalObject();
|
|
8
8
|
/**
|
|
9
9
|
* The Sentry Browser SDK Client.
|
|
10
10
|
*
|
|
11
11
|
* @see BrowserOptions for documentation on configuration options.
|
|
12
12
|
* @see SentryClient for usage documentation.
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
__extends(BrowserClient, _super);
|
|
14
|
+
export class BrowserClient extends BaseClient {
|
|
16
15
|
/**
|
|
17
16
|
* Creates a new Browser SDK instance.
|
|
18
17
|
*
|
|
19
18
|
* @param options Configuration options for this SDK.
|
|
20
19
|
*/
|
|
21
|
-
|
|
22
|
-
if (options === void 0) { options = {}; }
|
|
23
|
-
var _this = this;
|
|
20
|
+
constructor(options) {
|
|
24
21
|
options._metadata = options._metadata || {};
|
|
25
22
|
options._metadata.sdk = options._metadata.sdk || {
|
|
26
23
|
name: 'sentry.javascript.browser',
|
|
@@ -32,60 +29,86 @@ var BrowserClient = /** @class */ (function (_super) {
|
|
|
32
29
|
],
|
|
33
30
|
version: SDK_VERSION,
|
|
34
31
|
};
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
super(options);
|
|
33
|
+
if (options.sendClientReports && globalObject.document) {
|
|
34
|
+
globalObject.document.addEventListener('visibilitychange', () => {
|
|
35
|
+
if (globalObject.document.visibilityState === 'hidden') {
|
|
36
|
+
this._flushOutcomes();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @param options Set individual options for the dialog
|
|
42
|
+
* @inheritDoc
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var document = getGlobalObject().document;
|
|
47
|
-
if (!document) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (!this._isEnabled()) {
|
|
51
|
-
IS_DEBUG_BUILD && logger.error('Trying to call showReportDialog with Sentry Client disabled');
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
injectReportDialog(__assign(__assign({}, options), { dsn: options.dsn || this.getDsn() }));
|
|
55
|
-
};
|
|
44
|
+
eventFromException(exception, hint) {
|
|
45
|
+
return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace);
|
|
46
|
+
}
|
|
56
47
|
/**
|
|
57
48
|
* @inheritDoc
|
|
58
49
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
eventFromMessage(message,
|
|
51
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
52
|
+
level = 'info', hint) {
|
|
53
|
+
return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);
|
|
54
|
+
}
|
|
62
55
|
/**
|
|
63
56
|
* @inheritDoc
|
|
64
57
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
sendEvent(event) {
|
|
59
|
+
// We only want to add the sentry event breadcrumb when the user has the breadcrumb integration installed and
|
|
60
|
+
// activated its `sentry` option.
|
|
61
|
+
// We also do not want to use the `Breadcrumbs` class here directly, because we do not want it to be included in
|
|
62
|
+
// bundles, if it is not used by the SDK.
|
|
63
|
+
// This all sadly is a bit ugly, but we currently don't have a "pre-send" hook on the integrations so we do it this
|
|
64
|
+
// way for now.
|
|
65
|
+
const breadcrumbIntegration = this.getIntegrationById(BREADCRUMB_INTEGRATION_ID);
|
|
66
|
+
if (breadcrumbIntegration &&
|
|
67
|
+
// We check for definedness of `options`, even though it is not strictly necessary, because that access to
|
|
68
|
+
// `.sentry` below does not throw, in case users provided their own integration with id "Breadcrumbs" that does
|
|
69
|
+
// not have an`options` field
|
|
70
|
+
breadcrumbIntegration.options &&
|
|
71
|
+
breadcrumbIntegration.options.sentry) {
|
|
72
|
+
getCurrentHub().addBreadcrumb({
|
|
73
|
+
category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,
|
|
74
|
+
event_id: event.event_id,
|
|
75
|
+
level: event.level,
|
|
76
|
+
message: getEventDescription(event),
|
|
77
|
+
}, {
|
|
78
|
+
event,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
super.sendEvent(event);
|
|
82
|
+
}
|
|
71
83
|
/**
|
|
72
84
|
* @inheritDoc
|
|
73
85
|
*/
|
|
74
|
-
|
|
86
|
+
_prepareEvent(event, scope, hint) {
|
|
75
87
|
event.platform = event.platform || 'javascript';
|
|
76
|
-
return
|
|
77
|
-
}
|
|
88
|
+
return super._prepareEvent(event, scope, hint);
|
|
89
|
+
}
|
|
78
90
|
/**
|
|
79
|
-
*
|
|
91
|
+
* Sends client reports as an envelope.
|
|
80
92
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
93
|
+
_flushOutcomes() {
|
|
94
|
+
const outcomes = this._clearOutcomes();
|
|
95
|
+
if (outcomes.length === 0) {
|
|
96
|
+
IS_DEBUG_BUILD && logger.log('No outcomes to send');
|
|
97
|
+
return;
|
|
85
98
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
99
|
+
if (!this._dsn) {
|
|
100
|
+
IS_DEBUG_BUILD && logger.log('No dsn provided, will not send outcomes');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
IS_DEBUG_BUILD && logger.log('Sending outcomes:', outcomes);
|
|
104
|
+
const url = getEnvelopeEndpointWithUrlEncodedAuth(this._dsn, this._options.tunnel);
|
|
105
|
+
const envelope = createClientReportEnvelope(outcomes, this._options.tunnel && dsnToString(this._dsn));
|
|
106
|
+
try {
|
|
107
|
+
sendReport(url, serializeEnvelope(envelope));
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
IS_DEBUG_BUILD && logger.error(e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
91
114
|
//# sourceMappingURL=client.js.map
|
package/esm/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/client.ts"],"names":[],"mappings":"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","sourcesContent":["import { BaseClient, getCurrentHub, getEnvelopeEndpointWithUrlEncodedAuth, Scope, SDK_VERSION } from '@sentry/core';\nimport { ClientOptions, Event, EventHint, Options, Severity, SeverityLevel } from '@sentry/types';\nimport {\n createClientReportEnvelope,\n dsnToString,\n getEventDescription,\n getGlobalObject,\n logger,\n serializeEnvelope,\n} from '@sentry/utils';\n\nimport { eventFromException, eventFromMessage } from './eventbuilder';\nimport { IS_DEBUG_BUILD } from './flags';\nimport { Breadcrumbs } from './integrations';\nimport { BREADCRUMB_INTEGRATION_ID } from './integrations/breadcrumbs';\nimport { sendReport } from './transports/utils';\n\nconst globalObject = getGlobalObject<Window>();\n\nexport interface BaseBrowserOptions {\n /**\n * A pattern for error URLs which should exclusively be sent to Sentry.\n * This is the opposite of {@link Options.denyUrls}.\n * By default, all errors will be sent.\n */\n allowUrls?: Array<string | RegExp>;\n\n /**\n * A pattern for error URLs which should not be sent to Sentry.\n * To allow certain errors instead, use {@link Options.allowUrls}.\n * By default, all errors will be sent.\n */\n denyUrls?: Array<string | RegExp>;\n}\n\n/**\n * Configuration options for the Sentry Browser SDK.\n * @see @sentry/types Options for more information.\n */\nexport interface BrowserOptions extends Options, BaseBrowserOptions {}\n\n/**\n * Configuration options for the Sentry Browser SDK Client class\n * @see BrowserClient for more information.\n */\nexport interface BrowserClientOptions extends ClientOptions, BaseBrowserOptions {}\n\n/**\n * The Sentry Browser SDK Client.\n *\n * @see BrowserOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class BrowserClient extends BaseClient<BrowserClientOptions> {\n /**\n * Creates a new Browser SDK instance.\n *\n * @param options Configuration options for this SDK.\n */\n public constructor(options: BrowserClientOptions) {\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || {\n name: 'sentry.javascript.browser',\n packages: [\n {\n name: 'npm:@sentry/browser',\n version: SDK_VERSION,\n },\n ],\n version: SDK_VERSION,\n };\n\n super(options);\n\n if (options.sendClientReports && globalObject.document) {\n globalObject.document.addEventListener('visibilitychange', () => {\n if (globalObject.document.visibilityState === 'hidden') {\n this._flushOutcomes();\n }\n });\n }\n }\n\n /**\n * @inheritDoc\n */\n public eventFromException(exception: unknown, hint?: EventHint): PromiseLike<Event> {\n return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace);\n }\n\n /**\n * @inheritDoc\n */\n public eventFromMessage(\n message: string,\n // eslint-disable-next-line deprecation/deprecation\n level: Severity | SeverityLevel = 'info',\n hint?: EventHint,\n ): PromiseLike<Event> {\n return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);\n }\n\n /**\n * @inheritDoc\n */\n public sendEvent(event: Event): void {\n // We only want to add the sentry event breadcrumb when the user has the breadcrumb integration installed and\n // activated its `sentry` option.\n // We also do not want to use the `Breadcrumbs` class here directly, because we do not want it to be included in\n // bundles, if it is not used by the SDK.\n // This all sadly is a bit ugly, but we currently don't have a \"pre-send\" hook on the integrations so we do it this\n // way for now.\n const breadcrumbIntegration = this.getIntegrationById(BREADCRUMB_INTEGRATION_ID) as Breadcrumbs | null;\n if (\n breadcrumbIntegration &&\n // We check for definedness of `options`, even though it is not strictly necessary, because that access to\n // `.sentry` below does not throw, in case users provided their own integration with id \"Breadcrumbs\" that does\n // not have an`options` field\n breadcrumbIntegration.options &&\n breadcrumbIntegration.options.sentry\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 super.sendEvent(event);\n }\n\n /**\n * @inheritDoc\n */\n protected _prepareEvent(event: Event, scope?: Scope, hint?: EventHint): PromiseLike<Event | null> {\n event.platform = event.platform || 'javascript';\n return super._prepareEvent(event, scope, hint);\n }\n\n /**\n * Sends client reports as an envelope.\n */\n private _flushOutcomes(): void {\n const outcomes = this._clearOutcomes();\n\n if (outcomes.length === 0) {\n IS_DEBUG_BUILD && logger.log('No outcomes to send');\n return;\n }\n\n if (!this._dsn) {\n IS_DEBUG_BUILD && logger.log('No dsn provided, will not send outcomes');\n return;\n }\n\n IS_DEBUG_BUILD && logger.log('Sending outcomes:', outcomes);\n\n const url = getEnvelopeEndpointWithUrlEncodedAuth(this._dsn, this._options.tunnel);\n const envelope = createClientReportEnvelope(outcomes, this._options.tunnel && dsnToString(this._dsn));\n\n try {\n sendReport(url, serializeEnvelope(envelope));\n } catch (e) {\n IS_DEBUG_BUILD && logger.error(e);\n }\n }\n}\n"]}
|
package/esm/eventbuilder.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Event, EventHint, Exception, Severity, SeverityLevel, StackFrame, StackParser } from '@sentry/types';
|
|
2
2
|
/**
|
|
3
|
-
* This function creates an exception from
|
|
3
|
+
* This function creates an exception from a JavaScript Error
|
|
4
4
|
*/
|
|
5
5
|
export declare function exceptionFromError(stackParser: StackParser, ex: Error): Exception;
|
|
6
6
|
/**
|
package/esm/eventbuilder.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { addExceptionMechanism, addExceptionTypeValue, extractExceptionKeysForMessage, isDOMError, isDOMException, isError, isErrorEvent, isEvent, isPlainObject, normalizeToSize, resolvedSyncPromise, } from '@sentry/utils';
|
|
3
2
|
/**
|
|
4
|
-
* This function creates an exception from
|
|
3
|
+
* This function creates an exception from a JavaScript Error
|
|
5
4
|
*/
|
|
6
5
|
export function exceptionFromError(stackParser, ex) {
|
|
7
6
|
// Get the frames first since Opera can lose the stack if we touch anything else first
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const frames = parseStackFrames(stackParser, ex);
|
|
8
|
+
const exception = {
|
|
10
9
|
type: ex && ex.name,
|
|
11
10
|
value: extractMessage(ex),
|
|
12
11
|
};
|
|
13
12
|
if (frames.length) {
|
|
14
|
-
exception.stacktrace = { frames
|
|
13
|
+
exception.stacktrace = { frames };
|
|
15
14
|
}
|
|
16
15
|
if (exception.type === undefined && exception.value === '') {
|
|
17
16
|
exception.value = 'Unrecoverable error caught';
|
|
@@ -22,12 +21,12 @@ export function exceptionFromError(stackParser, ex) {
|
|
|
22
21
|
* @hidden
|
|
23
22
|
*/
|
|
24
23
|
export function eventFromPlainObject(stackParser, exception, syntheticException, isUnhandledRejection) {
|
|
25
|
-
|
|
24
|
+
const event = {
|
|
26
25
|
exception: {
|
|
27
26
|
values: [
|
|
28
27
|
{
|
|
29
28
|
type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error',
|
|
30
|
-
value:
|
|
29
|
+
value: `Non-Error ${isUnhandledRejection ? 'promise rejection' : 'exception'} captured with keys: ${extractExceptionKeysForMessage(exception)}`,
|
|
31
30
|
},
|
|
32
31
|
],
|
|
33
32
|
},
|
|
@@ -36,10 +35,10 @@ export function eventFromPlainObject(stackParser, exception, syntheticException,
|
|
|
36
35
|
},
|
|
37
36
|
};
|
|
38
37
|
if (syntheticException) {
|
|
39
|
-
|
|
40
|
-
if (
|
|
38
|
+
const frames = parseStackFrames(stackParser, syntheticException);
|
|
39
|
+
if (frames.length) {
|
|
41
40
|
// event.exception.values[0] has been set above
|
|
42
|
-
event.exception.values[0].stacktrace = { frames
|
|
41
|
+
event.exception.values[0].stacktrace = { frames };
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
return event;
|
|
@@ -59,8 +58,8 @@ export function parseStackFrames(stackParser, ex) {
|
|
|
59
58
|
// Access and store the stacktrace property before doing ANYTHING
|
|
60
59
|
// else to it because Opera is not very good at providing it
|
|
61
60
|
// reliably in other circumstances.
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
const stacktrace = ex.stacktrace || ex.stack || '';
|
|
62
|
+
const popSize = getPopSize(ex);
|
|
64
63
|
try {
|
|
65
64
|
return stackParser(stacktrace, popSize);
|
|
66
65
|
}
|
|
@@ -70,7 +69,7 @@ export function parseStackFrames(stackParser, ex) {
|
|
|
70
69
|
return [];
|
|
71
70
|
}
|
|
72
71
|
// Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
|
|
73
|
-
|
|
72
|
+
const reactMinifiedRegexp = /Minified React error #\d+;/i;
|
|
74
73
|
function getPopSize(ex) {
|
|
75
74
|
if (ex) {
|
|
76
75
|
if (typeof ex.framesToPop === 'number') {
|
|
@@ -88,7 +87,7 @@ function getPopSize(ex) {
|
|
|
88
87
|
* In this specific case we try to extract stacktrace.message.error.message
|
|
89
88
|
*/
|
|
90
89
|
function extractMessage(ex) {
|
|
91
|
-
|
|
90
|
+
const message = ex && ex.message;
|
|
92
91
|
if (!message) {
|
|
93
92
|
return 'No error message';
|
|
94
93
|
}
|
|
@@ -102,8 +101,8 @@ function extractMessage(ex) {
|
|
|
102
101
|
* @hidden
|
|
103
102
|
*/
|
|
104
103
|
export function eventFromException(stackParser, exception, hint, attachStacktrace) {
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
const syntheticException = (hint && hint.syntheticException) || undefined;
|
|
105
|
+
const event = eventFromUnknownInput(stackParser, exception, syntheticException, attachStacktrace);
|
|
107
106
|
addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
|
|
108
107
|
event.level = 'error';
|
|
109
108
|
if (hint && hint.event_id) {
|
|
@@ -117,10 +116,9 @@ export function eventFromException(stackParser, exception, hint, attachStacktrac
|
|
|
117
116
|
*/
|
|
118
117
|
export function eventFromMessage(stackParser, message,
|
|
119
118
|
// eslint-disable-next-line deprecation/deprecation
|
|
120
|
-
level, hint, attachStacktrace) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
var event = eventFromString(stackParser, message, syntheticException, attachStacktrace);
|
|
119
|
+
level = 'info', hint, attachStacktrace) {
|
|
120
|
+
const syntheticException = (hint && hint.syntheticException) || undefined;
|
|
121
|
+
const event = eventFromString(stackParser, message, syntheticException, attachStacktrace);
|
|
124
122
|
event.level = level;
|
|
125
123
|
if (hint && hint.event_id) {
|
|
126
124
|
event.event_id = hint.event_id;
|
|
@@ -131,10 +129,10 @@ level, hint, attachStacktrace) {
|
|
|
131
129
|
* @hidden
|
|
132
130
|
*/
|
|
133
131
|
export function eventFromUnknownInput(stackParser, exception, syntheticException, attachStacktrace, isUnhandledRejection) {
|
|
134
|
-
|
|
132
|
+
let event;
|
|
135
133
|
if (isErrorEvent(exception) && exception.error) {
|
|
136
134
|
// If it is an ErrorEvent with `error` property, extract it to get actual Error
|
|
137
|
-
|
|
135
|
+
const errorEvent = exception;
|
|
138
136
|
return eventFromError(stackParser, errorEvent.error);
|
|
139
137
|
}
|
|
140
138
|
// If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name
|
|
@@ -145,18 +143,18 @@ export function eventFromUnknownInput(stackParser, exception, syntheticException
|
|
|
145
143
|
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException
|
|
146
144
|
// https://webidl.spec.whatwg.org/#es-DOMException-specialness
|
|
147
145
|
if (isDOMError(exception) || isDOMException(exception)) {
|
|
148
|
-
|
|
146
|
+
const domException = exception;
|
|
149
147
|
if ('stack' in exception) {
|
|
150
148
|
event = eventFromError(stackParser, exception);
|
|
151
149
|
}
|
|
152
150
|
else {
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');
|
|
152
|
+
const message = domException.message ? `${name}: ${domException.message}` : name;
|
|
155
153
|
event = eventFromString(stackParser, message, syntheticException, attachStacktrace);
|
|
156
154
|
addExceptionTypeValue(event, message);
|
|
157
155
|
}
|
|
158
156
|
if ('code' in domException) {
|
|
159
|
-
event.tags =
|
|
157
|
+
event.tags = Object.assign(Object.assign({}, event.tags), { 'DOMException.code': `${domException.code}` });
|
|
160
158
|
}
|
|
161
159
|
return event;
|
|
162
160
|
}
|
|
@@ -168,7 +166,7 @@ export function eventFromUnknownInput(stackParser, exception, syntheticException
|
|
|
168
166
|
// If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize
|
|
169
167
|
// it manually. This will allow us to group events based on top-level keys which is much better than creating a new
|
|
170
168
|
// group on any key/value change.
|
|
171
|
-
|
|
169
|
+
const objectException = exception;
|
|
172
170
|
event = eventFromPlainObject(stackParser, objectException, syntheticException, isUnhandledRejection);
|
|
173
171
|
addExceptionMechanism(event, {
|
|
174
172
|
synthetic: true,
|
|
@@ -185,7 +183,7 @@ export function eventFromUnknownInput(stackParser, exception, syntheticException
|
|
|
185
183
|
//
|
|
186
184
|
// So bail out and capture it as a simple message:
|
|
187
185
|
event = eventFromString(stackParser, exception, syntheticException, attachStacktrace);
|
|
188
|
-
addExceptionTypeValue(event,
|
|
186
|
+
addExceptionTypeValue(event, `${exception}`, undefined);
|
|
189
187
|
addExceptionMechanism(event, {
|
|
190
188
|
synthetic: true,
|
|
191
189
|
});
|
|
@@ -195,14 +193,14 @@ export function eventFromUnknownInput(stackParser, exception, syntheticException
|
|
|
195
193
|
* @hidden
|
|
196
194
|
*/
|
|
197
195
|
export function eventFromString(stackParser, input, syntheticException, attachStacktrace) {
|
|
198
|
-
|
|
196
|
+
const event = {
|
|
199
197
|
message: input,
|
|
200
198
|
};
|
|
201
199
|
if (attachStacktrace && syntheticException) {
|
|
202
|
-
|
|
203
|
-
if (
|
|
200
|
+
const frames = parseStackFrames(stackParser, syntheticException);
|
|
201
|
+
if (frames.length) {
|
|
204
202
|
event.exception = {
|
|
205
|
-
values: [{ value: input, stacktrace: { frames
|
|
203
|
+
values: [{ value: input, stacktrace: { frames } }],
|
|
206
204
|
};
|
|
207
205
|
}
|
|
208
206
|
}
|