@sentry/browser 7.0.0-alpha.0 → 7.0.0-beta.1
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/README.md +2 -3
- package/cjs/client.js +130 -68
- package/cjs/client.js.map +1 -1
- package/cjs/eventbuilder.js +227 -168
- package/cjs/eventbuilder.js.map +1 -1
- package/cjs/exports.js +55 -42
- package/cjs/exports.js.map +1 -1
- package/cjs/flags.js +7 -3
- package/cjs/flags.js.map +1 -1
- package/cjs/helpers.js +123 -130
- package/cjs/helpers.js.map +1 -1
- package/cjs/index.js +78 -13
- package/cjs/index.js.map +1 -1
- package/cjs/integrations/breadcrumbs.js +223 -193
- package/cjs/integrations/breadcrumbs.js.map +1 -1
- package/cjs/integrations/dedupe.js +183 -143
- package/cjs/integrations/dedupe.js.map +1 -1
- package/cjs/integrations/globalhandlers.js +212 -171
- package/cjs/integrations/globalhandlers.js.map +1 -1
- package/cjs/integrations/httpcontext.js +51 -0
- package/cjs/integrations/httpcontext.js.map +1 -0
- package/cjs/integrations/index.js +18 -14
- package/cjs/integrations/index.js.map +1 -1
- package/cjs/integrations/linkederrors.js +79 -48
- package/cjs/integrations/linkederrors.js.map +1 -1
- package/cjs/integrations/trycatch.js +245 -216
- package/cjs/integrations/trycatch.js.map +1 -1
- package/cjs/sdk.js +168 -108
- package/cjs/sdk.js.map +1 -1
- package/cjs/stack-parsers.js +134 -83
- package/cjs/stack-parsers.js.map +1 -1
- package/cjs/transports/fetch.js +34 -80
- package/cjs/transports/fetch.js.map +1 -1
- package/cjs/transports/index.js +10 -12
- package/cjs/transports/index.js.map +1 -1
- package/cjs/transports/utils.js +57 -52
- package/cjs/transports/utils.js.map +1 -1
- package/cjs/transports/xhr.js +53 -63
- package/cjs/transports/xhr.js.map +1 -1
- package/esm/client.js +128 -67
- package/esm/client.js.map +1 -1
- package/esm/eventbuilder.js +218 -159
- package/esm/eventbuilder.js.map +1 -1
- package/esm/exports.js +12 -7
- package/esm/exports.js.map +1 -1
- package/esm/flags.js +5 -2
- package/esm/flags.js.map +1 -1
- package/esm/helpers.js +121 -127
- package/esm/helpers.js.map +1 -1
- package/esm/index.js +28 -10
- package/esm/index.js.map +1 -1
- package/esm/integrations/breadcrumbs.js +219 -191
- package/esm/integrations/breadcrumbs.js.map +1 -1
- package/esm/integrations/dedupe.js +180 -141
- package/esm/integrations/dedupe.js.map +1 -1
- package/esm/integrations/globalhandlers.js +209 -169
- package/esm/integrations/globalhandlers.js.map +1 -1
- package/esm/integrations/httpcontext.js +49 -0
- package/esm/integrations/httpcontext.js.map +1 -0
- package/esm/integrations/index.js +7 -7
- package/esm/integrations/index.js.map +1 -1
- package/esm/integrations/linkederrors.js +75 -45
- package/esm/integrations/linkederrors.js.map +1 -1
- package/esm/integrations/trycatch.js +242 -214
- package/esm/integrations/trycatch.js.map +1 -1
- package/esm/sdk.js +164 -105
- package/esm/sdk.js.map +1 -1
- package/esm/stack-parsers.js +126 -82
- package/esm/stack-parsers.js.map +1 -1
- package/esm/transports/fetch.js +32 -79
- package/esm/transports/fetch.js.map +1 -1
- package/esm/transports/index.js +3 -6
- package/esm/transports/index.js.map +1 -1
- package/esm/transports/utils.js +56 -51
- package/esm/transports/utils.js.map +1 -1
- package/esm/transports/xhr.js +51 -62
- package/esm/transports/xhr.js.map +1 -1
- package/package.json +4 -5
- package/types/client.d.ts +42 -11
- package/types/client.d.ts.map +1 -1
- package/types/eventbuilder.d.ts +10 -12
- package/types/eventbuilder.d.ts.map +1 -1
- package/types/exports.d.ts +7 -6
- 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 +2 -3
- 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/dedupe.d.ts.map +1 -1
- package/types/integrations/globalhandlers.d.ts.map +1 -1
- package/types/integrations/{useragent.d.ts → httpcontext.d.ts} +3 -3
- package/types/integrations/httpcontext.d.ts.map +1 -0
- package/types/integrations/index.d.ts +1 -1
- package/types/integrations/index.d.ts.map +1 -1
- package/types/integrations/linkederrors.d.ts +3 -3
- package/types/integrations/linkederrors.d.ts.map +1 -1
- package/types/sdk.d.ts +5 -5
- package/types/sdk.d.ts.map +1 -1
- package/types/stack-parsers.d.ts +8 -6
- package/types/stack-parsers.d.ts.map +1 -1
- package/types/transports/fetch.d.ts +6 -15
- package/types/transports/fetch.d.ts.map +1 -1
- package/types/transports/index.d.ts +2 -5
- package/types/transports/index.d.ts.map +1 -1
- package/types/transports/types.d.ts +10 -0
- package/types/transports/types.d.ts.map +1 -0
- package/types/transports/utils.d.ts.map +1 -1
- package/types/transports/xhr.d.ts +6 -10
- package/types/transports/xhr.d.ts.map +1 -1
- package/cjs/backend.d.ts +0 -39
- package/cjs/backend.d.ts.map +0 -1
- package/cjs/backend.js +0 -58
- package/cjs/backend.js.map +0 -1
- package/cjs/client.d.ts +0 -33
- package/cjs/client.d.ts.map +0 -1
- package/cjs/eventbuilder.d.ts +0 -39
- package/cjs/eventbuilder.d.ts.map +0 -1
- package/cjs/exports.d.ts +0 -9
- package/cjs/exports.d.ts.map +0 -1
- package/cjs/flags.d.ts +0 -3
- package/cjs/flags.d.ts.map +0 -1
- package/cjs/helpers.d.ts +0 -52
- package/cjs/helpers.d.ts.map +0 -1
- package/cjs/index.d.ts +0 -16
- package/cjs/index.d.ts.map +0 -1
- package/cjs/integrations/breadcrumbs.d.ts +0 -47
- package/cjs/integrations/breadcrumbs.d.ts.map +0 -1
- package/cjs/integrations/dedupe.d.ts +0 -21
- package/cjs/integrations/dedupe.d.ts.map +0 -1
- package/cjs/integrations/globalhandlers.d.ts +0 -30
- package/cjs/integrations/globalhandlers.d.ts.map +0 -1
- package/cjs/integrations/index.d.ts +0 -7
- package/cjs/integrations/index.d.ts.map +0 -1
- package/cjs/integrations/linkederrors.d.ts +0 -42
- package/cjs/integrations/linkederrors.d.ts.map +0 -1
- package/cjs/integrations/trycatch.d.ts +0 -33
- package/cjs/integrations/trycatch.d.ts.map +0 -1
- package/cjs/integrations/useragent.d.ts +0 -17
- package/cjs/integrations/useragent.d.ts.map +0 -1
- package/cjs/integrations/useragent.js +0 -42
- package/cjs/integrations/useragent.js.map +0 -1
- package/cjs/sdk.d.ts +0 -112
- package/cjs/sdk.d.ts.map +0 -1
- package/cjs/stack-parsers.d.ts +0 -7
- package/cjs/stack-parsers.d.ts.map +0 -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/fetch.d.ts +0 -17
- package/cjs/transports/fetch.d.ts.map +0 -1
- package/cjs/transports/index.d.ts +0 -6
- package/cjs/transports/index.d.ts.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/utils.d.ts +0 -48
- package/cjs/transports/utils.d.ts.map +0 -1
- package/cjs/transports/xhr.d.ts +0 -11
- package/cjs/transports/xhr.d.ts.map +0 -1
- package/cjs/version.d.ts +0 -2
- package/cjs/version.d.ts.map +0 -1
- package/cjs/version.js +0 -4
- package/cjs/version.js.map +0 -1
- package/esm/backend.d.ts +0 -39
- package/esm/backend.d.ts.map +0 -1
- package/esm/backend.js +0 -57
- package/esm/backend.js.map +0 -1
- package/esm/client.d.ts +0 -33
- package/esm/client.d.ts.map +0 -1
- package/esm/eventbuilder.d.ts +0 -39
- package/esm/eventbuilder.d.ts.map +0 -1
- package/esm/exports.d.ts +0 -9
- package/esm/exports.d.ts.map +0 -1
- package/esm/flags.d.ts +0 -3
- package/esm/flags.d.ts.map +0 -1
- package/esm/helpers.d.ts +0 -52
- package/esm/helpers.d.ts.map +0 -1
- package/esm/index.d.ts +0 -16
- package/esm/index.d.ts.map +0 -1
- package/esm/integrations/breadcrumbs.d.ts +0 -47
- package/esm/integrations/breadcrumbs.d.ts.map +0 -1
- package/esm/integrations/dedupe.d.ts +0 -21
- package/esm/integrations/dedupe.d.ts.map +0 -1
- package/esm/integrations/globalhandlers.d.ts +0 -30
- package/esm/integrations/globalhandlers.d.ts.map +0 -1
- package/esm/integrations/index.d.ts +0 -7
- package/esm/integrations/index.d.ts.map +0 -1
- package/esm/integrations/linkederrors.d.ts +0 -42
- package/esm/integrations/linkederrors.d.ts.map +0 -1
- package/esm/integrations/trycatch.d.ts +0 -33
- package/esm/integrations/trycatch.d.ts.map +0 -1
- package/esm/integrations/useragent.d.ts +0 -17
- package/esm/integrations/useragent.d.ts.map +0 -1
- package/esm/integrations/useragent.js +0 -41
- package/esm/integrations/useragent.js.map +0 -1
- package/esm/sdk.d.ts +0 -112
- package/esm/sdk.d.ts.map +0 -1
- package/esm/stack-parsers.d.ts +0 -7
- package/esm/stack-parsers.d.ts.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/fetch.d.ts +0 -17
- package/esm/transports/fetch.d.ts.map +0 -1
- package/esm/transports/index.d.ts +0 -6
- package/esm/transports/index.d.ts.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/utils.d.ts +0 -48
- package/esm/transports/utils.d.ts.map +0 -1
- package/esm/transports/xhr.d.ts +0 -11
- package/esm/transports/xhr.d.ts.map +0 -1
- package/esm/version.d.ts +0 -2
- package/esm/version.d.ts.map +0 -1
- package/esm/version.js +0 -3
- package/esm/version.js.map +0 -1
- package/types/backend.d.ts +0 -39
- package/types/backend.d.ts.map +0 -1
- package/types/integrations/useragent.d.ts.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/version.d.ts +0 -2
- package/types/version.d.ts.map +0 -1
package/cjs/transports/xhr.js
CHANGED
|
@@ -1,64 +1,54 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
var core = require('@sentry/core');
|
|
4
|
+
var utils = require('@sentry/utils');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The DONE ready state for XmlHttpRequest
|
|
8
|
+
*
|
|
9
|
+
* Defining it here as a constant b/c XMLHttpRequest.DONE is not always defined
|
|
10
|
+
* (e.g. during testing, it is `undefined`)
|
|
11
|
+
*
|
|
12
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState}
|
|
13
|
+
*/
|
|
14
|
+
var XHR_READYSTATE_DONE = 4;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.
|
|
18
|
+
*/
|
|
19
|
+
function makeXHRTransport(options) {
|
|
20
|
+
function makeRequest(request) {
|
|
21
|
+
return new utils.SyncPromise((resolve, reject) => {
|
|
22
|
+
var xhr = new XMLHttpRequest();
|
|
23
|
+
|
|
24
|
+
xhr.onerror = reject;
|
|
25
|
+
|
|
26
|
+
xhr.onreadystatechange = () => {
|
|
27
|
+
if (xhr.readyState === XHR_READYSTATE_DONE) {
|
|
28
|
+
resolve({
|
|
29
|
+
statusCode: xhr.status,
|
|
30
|
+
headers: {
|
|
31
|
+
'x-sentry-rate-limits': xhr.getResponseHeader('X-Sentry-Rate-Limits'),
|
|
32
|
+
'retry-after': xhr.getResponseHeader('Retry-After'),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
27
35
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
}
|
|
58
|
-
throw reason;
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
return XHRTransport;
|
|
62
|
-
}(base_1.BaseTransport));
|
|
63
|
-
exports.XHRTransport = XHRTransport;
|
|
64
|
-
//# sourceMappingURL=xhr.js.map
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
xhr.open('POST', options.url);
|
|
39
|
+
|
|
40
|
+
for (var header in options.headers) {
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(options.headers, header)) {
|
|
42
|
+
xhr.setRequestHeader(header, options.headers[header]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
xhr.send(request.body);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return core.createTransport(options, makeRequest);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
exports.makeXHRTransport = makeXHRTransport;
|
|
54
|
+
//# sourceMappingURL=xhr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xhr.js","
|
|
1
|
+
{"version":3,"file":"xhr.js","sources":["../../../../src/transports/xhr.ts"],"sourcesContent":["import { createTransport } from '@sentry/core';\nimport { Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/types';\nimport { SyncPromise } from '@sentry/utils';\n\nimport { BrowserTransportOptions } from './types';\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\n/**\n * Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.\n */\nexport function makeXHRTransport(options: BrowserTransportOptions): 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 resolve({\n statusCode: xhr.status,\n headers: {\n 'x-sentry-rate-limits': xhr.getResponseHeader('X-Sentry-Rate-Limits'),\n 'retry-after': xhr.getResponseHeader('Retry-After'),\n },\n });\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"],"names":[],"mappings":";;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;"}
|
package/esm/client.js
CHANGED
|
@@ -1,76 +1,137 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { BaseClient, SDK_VERSION, getCurrentHub, getEnvelopeEndpointWithUrlEncodedAuth } from '@sentry/core';
|
|
2
|
+
import { getGlobalObject, getEventDescription, logger, createClientReportEnvelope, dsnToString, serializeEnvelope } from '@sentry/utils';
|
|
3
|
+
import { eventFromException, eventFromMessage } from './eventbuilder.js';
|
|
4
|
+
import { IS_DEBUG_BUILD } from './flags.js';
|
|
5
|
+
import { BREADCRUMB_INTEGRATION_ID } from './integrations/breadcrumbs.js';
|
|
6
|
+
import { sendReport } from './transports/utils.js';
|
|
7
|
+
|
|
8
|
+
var globalObject = getGlobalObject();
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* The Sentry Browser SDK Client.
|
|
10
12
|
*
|
|
11
13
|
* @see BrowserOptions for documentation on configuration options.
|
|
12
14
|
* @see SentryClient for usage documentation.
|
|
13
15
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
version: SDK_VERSION,
|
|
34
|
-
};
|
|
35
|
-
_this = _super.call(this, BrowserBackend, options) || this;
|
|
36
|
-
return _this;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Show a report dialog to the user to send feedback to a specific event.
|
|
40
|
-
*
|
|
41
|
-
* @param options Set individual options for the dialog
|
|
42
|
-
*/
|
|
43
|
-
BrowserClient.prototype.showReportDialog = function (options) {
|
|
44
|
-
if (options === void 0) { options = {}; }
|
|
45
|
-
// doesn't work without a document (React Native)
|
|
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() }));
|
|
16
|
+
class BrowserClient extends BaseClient {
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new Browser SDK instance.
|
|
19
|
+
*
|
|
20
|
+
* @param options Configuration options for this SDK.
|
|
21
|
+
*/
|
|
22
|
+
constructor(options) {
|
|
23
|
+
options._metadata = options._metadata || {};
|
|
24
|
+
options._metadata.sdk = options._metadata.sdk || {
|
|
25
|
+
name: 'sentry.javascript.browser',
|
|
26
|
+
packages: [
|
|
27
|
+
{
|
|
28
|
+
name: 'npm:@sentry/browser',
|
|
29
|
+
version: SDK_VERSION,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
version: SDK_VERSION,
|
|
55
33
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @inheritDoc
|
|
65
|
-
*/
|
|
66
|
-
BrowserClient.prototype._sendEvent = function (event) {
|
|
67
|
-
var integration = this.getIntegration(Breadcrumbs);
|
|
68
|
-
if (integration) {
|
|
69
|
-
integration.addSentryBreadcrumb(event);
|
|
34
|
+
|
|
35
|
+
super(options);
|
|
36
|
+
|
|
37
|
+
if (options.sendClientReports && globalObject.document) {
|
|
38
|
+
globalObject.document.addEventListener('visibilitychange', () => {
|
|
39
|
+
if (globalObject.document.visibilityState === 'hidden') {
|
|
40
|
+
this._flushOutcomes();
|
|
70
41
|
}
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @inheritDoc
|
|
48
|
+
*/
|
|
49
|
+
eventFromException(exception, hint) {
|
|
50
|
+
return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @inheritDoc
|
|
55
|
+
*/
|
|
56
|
+
eventFromMessage(
|
|
57
|
+
message,
|
|
58
|
+
level = 'info',
|
|
59
|
+
hint,
|
|
60
|
+
) {
|
|
61
|
+
return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @inheritDoc
|
|
66
|
+
*/
|
|
67
|
+
sendEvent(event) {
|
|
68
|
+
// We only want to add the sentry event breadcrumb when the user has the breadcrumb integration installed and
|
|
69
|
+
// activated its `sentry` option.
|
|
70
|
+
// We also do not want to use the `Breadcrumbs` class here directly, because we do not want it to be included in
|
|
71
|
+
// bundles, if it is not used by the SDK.
|
|
72
|
+
// 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
|
|
73
|
+
// way for now.
|
|
74
|
+
var breadcrumbIntegration = this.getIntegrationById(BREADCRUMB_INTEGRATION_ID) ;
|
|
75
|
+
if (
|
|
76
|
+
breadcrumbIntegration &&
|
|
77
|
+
// We check for definedness of `options`, even though it is not strictly necessary, because that access to
|
|
78
|
+
// `.sentry` below does not throw, in case users provided their own integration with id "Breadcrumbs" that does
|
|
79
|
+
// not have an`options` field
|
|
80
|
+
breadcrumbIntegration.options &&
|
|
81
|
+
breadcrumbIntegration.options.sentry
|
|
82
|
+
) {
|
|
83
|
+
getCurrentHub().addBreadcrumb(
|
|
84
|
+
{
|
|
85
|
+
category: `sentry.${event.type === 'transaction' ? 'transaction' : 'event'}`,
|
|
86
|
+
event_id: event.event_id,
|
|
87
|
+
level: event.level,
|
|
88
|
+
message: getEventDescription(event),
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
event,
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
super.sendEvent(event);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @inheritDoc
|
|
101
|
+
*/
|
|
102
|
+
_prepareEvent(event, scope, hint) {
|
|
103
|
+
event.platform = event.platform || 'javascript';
|
|
104
|
+
return super._prepareEvent(event, scope, hint);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Sends client reports as an envelope.
|
|
109
|
+
*/
|
|
110
|
+
_flushOutcomes() {
|
|
111
|
+
var outcomes = this._clearOutcomes();
|
|
112
|
+
|
|
113
|
+
if (outcomes.length === 0) {
|
|
114
|
+
IS_DEBUG_BUILD && logger.log('No outcomes to send');
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!this._dsn) {
|
|
119
|
+
IS_DEBUG_BUILD && logger.log('No dsn provided, will not send outcomes');
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
IS_DEBUG_BUILD && logger.log('Sending outcomes:', outcomes);
|
|
124
|
+
|
|
125
|
+
var url = getEnvelopeEndpointWithUrlEncodedAuth(this._dsn, this._options.tunnel);
|
|
126
|
+
var envelope = createClientReportEnvelope(outcomes, this._options.tunnel && dsnToString(this._dsn));
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
sendReport(url, serializeEnvelope(envelope));
|
|
130
|
+
} catch (e) {
|
|
131
|
+
IS_DEBUG_BUILD && logger.error(e);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
75
136
|
export { BrowserClient };
|
|
76
|
-
//# sourceMappingURL=client.js.map
|
|
137
|
+
//# sourceMappingURL=client.js.map
|
package/esm/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../src/client.ts"],"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 { BrowserTransportOptions } from './transports/types';\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<BrowserTransportOptions>, 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<BrowserTransportOptions>, 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"],"names":[],"mappings":";;;;;;;AAkBA;;AA8BA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
|