@sentry/browser 6.19.7 → 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.
Files changed (265) hide show
  1. package/cjs/client.d.ts +63 -0
  2. package/cjs/client.d.ts.map +1 -0
  3. package/cjs/client.js +116 -0
  4. package/cjs/client.js.map +1 -0
  5. package/cjs/eventbuilder.d.ts +37 -0
  6. package/cjs/eventbuilder.d.ts.map +1 -0
  7. package/{dist → cjs}/eventbuilder.js +52 -53
  8. package/cjs/eventbuilder.js.map +1 -0
  9. package/cjs/exports.d.ts +11 -0
  10. package/cjs/exports.d.ts.map +1 -0
  11. package/{dist → cjs}/exports.js +21 -7
  12. package/cjs/exports.js.map +1 -0
  13. package/{dist → cjs}/flags.d.ts +0 -0
  14. package/{dist → cjs}/flags.d.ts.map +0 -0
  15. package/{dist → cjs}/flags.js +0 -0
  16. package/{dist → cjs}/flags.js.map +0 -0
  17. package/{dist → cjs}/helpers.d.ts +0 -5
  18. package/cjs/helpers.d.ts.map +1 -0
  19. package/{dist → cjs}/helpers.js +15 -49
  20. package/cjs/helpers.js.map +1 -0
  21. package/{dist → cjs}/index.d.ts +1 -2
  22. package/{dist → cjs}/index.d.ts.map +1 -1
  23. package/cjs/index.js +15 -0
  24. package/cjs/index.js.map +1 -0
  25. package/{dist → cjs}/integrations/breadcrumbs.d.ts +6 -7
  26. package/cjs/integrations/breadcrumbs.d.ts.map +1 -0
  27. package/{dist → cjs}/integrations/breadcrumbs.js +39 -57
  28. package/cjs/integrations/breadcrumbs.js.map +1 -0
  29. package/{dist → cjs}/integrations/dedupe.d.ts +0 -0
  30. package/{dist → cjs}/integrations/dedupe.d.ts.map +1 -1
  31. package/{dist → cjs}/integrations/dedupe.js +28 -30
  32. package/cjs/integrations/dedupe.js.map +1 -0
  33. package/{dist → cjs}/integrations/globalhandlers.d.ts +0 -0
  34. package/cjs/integrations/globalhandlers.d.ts.map +1 -0
  35. package/{dist → cjs}/integrations/globalhandlers.js +57 -57
  36. package/cjs/integrations/globalhandlers.js.map +1 -0
  37. package/{dist → cjs}/integrations/index.d.ts +0 -0
  38. package/{dist → cjs}/integrations/index.d.ts.map +0 -0
  39. package/{dist → cjs}/integrations/index.js +0 -0
  40. package/{dist → cjs}/integrations/index.js.map +0 -0
  41. package/{dist → cjs}/integrations/linkederrors.d.ts +3 -3
  42. package/cjs/integrations/linkederrors.d.ts.map +1 -0
  43. package/cjs/integrations/linkederrors.js +62 -0
  44. package/cjs/integrations/linkederrors.js.map +1 -0
  45. package/{dist → cjs}/integrations/trycatch.d.ts +0 -0
  46. package/{dist → cjs}/integrations/trycatch.d.ts.map +0 -0
  47. package/{dist → cjs}/integrations/trycatch.js +30 -40
  48. package/cjs/integrations/trycatch.js.map +1 -0
  49. package/{dist → cjs}/integrations/useragent.d.ts +0 -0
  50. package/{dist → cjs}/integrations/useragent.d.ts.map +0 -0
  51. package/cjs/integrations/useragent.js +40 -0
  52. package/cjs/integrations/useragent.js.map +1 -0
  53. package/{dist → cjs}/sdk.d.ts +3 -3
  54. package/cjs/sdk.d.ts.map +1 -0
  55. package/{dist → cjs}/sdk.js +47 -28
  56. package/cjs/sdk.js.map +1 -0
  57. package/cjs/stack-parsers.d.ts +9 -0
  58. package/cjs/stack-parsers.d.ts.map +1 -0
  59. package/{dist → cjs}/stack-parsers.js +45 -44
  60. package/cjs/stack-parsers.js.map +1 -0
  61. package/{esm/transports/new-fetch.d.ts → cjs/transports/fetch.d.ts} +3 -3
  62. package/cjs/transports/fetch.d.ts.map +1 -0
  63. package/cjs/transports/fetch.js +20 -0
  64. package/cjs/transports/fetch.js.map +1 -0
  65. package/cjs/transports/index.d.ts +3 -0
  66. package/cjs/transports/index.d.ts.map +1 -0
  67. package/cjs/transports/index.js +6 -0
  68. package/cjs/transports/index.js.map +1 -0
  69. package/{dist → cjs}/transports/utils.d.ts +0 -0
  70. package/{dist → cjs}/transports/utils.d.ts.map +1 -1
  71. package/{dist → cjs}/transports/utils.js +17 -17
  72. package/cjs/transports/utils.js.map +1 -0
  73. package/{types/transports/new-xhr.d.ts → cjs/transports/xhr.d.ts} +3 -3
  74. package/cjs/transports/xhr.d.ts.map +1 -0
  75. package/{esm/transports/new-xhr.js → cjs/transports/xhr.js} +14 -14
  76. package/cjs/transports/xhr.js.map +1 -0
  77. package/{dist → cjs}/version.d.ts +0 -0
  78. package/{dist → cjs}/version.d.ts.map +0 -0
  79. package/{dist → cjs}/version.js +0 -0
  80. package/{dist → cjs}/version.js.map +0 -0
  81. package/esm/client.d.ts +41 -11
  82. package/esm/client.d.ts.map +1 -1
  83. package/esm/client.js +79 -41
  84. package/esm/client.js.map +1 -1
  85. package/esm/eventbuilder.d.ts +10 -12
  86. package/esm/eventbuilder.d.ts.map +1 -1
  87. package/esm/eventbuilder.js +52 -53
  88. package/esm/eventbuilder.js.map +1 -1
  89. package/esm/exports.d.ts +7 -6
  90. package/esm/exports.d.ts.map +1 -1
  91. package/esm/exports.js +4 -4
  92. package/esm/exports.js.map +1 -1
  93. package/esm/flags.js +1 -1
  94. package/esm/flags.js.map +1 -1
  95. package/esm/helpers.d.ts +0 -5
  96. package/esm/helpers.d.ts.map +1 -1
  97. package/esm/helpers.js +15 -48
  98. package/esm/helpers.js.map +1 -1
  99. package/esm/index.d.ts +1 -2
  100. package/esm/index.d.ts.map +1 -1
  101. package/esm/index.js +4 -6
  102. package/esm/index.js.map +1 -1
  103. package/esm/integrations/breadcrumbs.d.ts +6 -7
  104. package/esm/integrations/breadcrumbs.d.ts.map +1 -1
  105. package/esm/integrations/breadcrumbs.js +38 -57
  106. package/esm/integrations/breadcrumbs.js.map +1 -1
  107. package/esm/integrations/dedupe.d.ts.map +1 -1
  108. package/esm/integrations/dedupe.js +26 -29
  109. package/esm/integrations/dedupe.js.map +1 -1
  110. package/esm/integrations/globalhandlers.d.ts.map +1 -1
  111. package/esm/integrations/globalhandlers.js +52 -53
  112. package/esm/integrations/globalhandlers.js.map +1 -1
  113. package/esm/integrations/linkederrors.d.ts +3 -3
  114. package/esm/integrations/linkederrors.d.ts.map +1 -1
  115. package/esm/integrations/linkederrors.js +24 -25
  116. package/esm/integrations/linkederrors.js.map +1 -1
  117. package/esm/integrations/trycatch.js +28 -39
  118. package/esm/integrations/trycatch.js.map +1 -1
  119. package/esm/integrations/useragent.js +17 -20
  120. package/esm/integrations/useragent.js.map +1 -1
  121. package/esm/sdk.d.ts +3 -3
  122. package/esm/sdk.d.ts.map +1 -1
  123. package/esm/sdk.js +44 -25
  124. package/esm/sdk.js.map +1 -1
  125. package/esm/stack-parsers.d.ts +8 -6
  126. package/esm/stack-parsers.d.ts.map +1 -1
  127. package/esm/stack-parsers.js +45 -44
  128. package/esm/stack-parsers.js.map +1 -1
  129. package/esm/transports/fetch.d.ts +7 -14
  130. package/esm/transports/fetch.d.ts.map +1 -1
  131. package/esm/transports/fetch.js +15 -77
  132. package/esm/transports/fetch.js.map +1 -1
  133. package/esm/transports/index.d.ts +2 -5
  134. package/esm/transports/index.d.ts.map +1 -1
  135. package/esm/transports/index.js +2 -5
  136. package/esm/transports/index.js.map +1 -1
  137. package/esm/transports/utils.d.ts.map +1 -1
  138. package/esm/transports/utils.js +16 -16
  139. package/esm/transports/utils.js.map +1 -1
  140. package/esm/transports/xhr.d.ts +9 -9
  141. package/esm/transports/xhr.d.ts.map +1 -1
  142. package/esm/transports/xhr.js +38 -59
  143. package/esm/transports/xhr.js.map +1 -1
  144. package/esm/version.js +1 -1
  145. package/esm/version.js.map +1 -1
  146. package/package.json +6 -7
  147. package/types/client.d.ts +41 -11
  148. package/types/client.d.ts.map +1 -1
  149. package/types/eventbuilder.d.ts +10 -12
  150. package/types/eventbuilder.d.ts.map +1 -1
  151. package/types/exports.d.ts +7 -6
  152. package/types/exports.d.ts.map +1 -1
  153. package/types/helpers.d.ts +0 -5
  154. package/types/helpers.d.ts.map +1 -1
  155. package/types/index.d.ts +1 -2
  156. package/types/index.d.ts.map +1 -1
  157. package/types/integrations/breadcrumbs.d.ts +6 -7
  158. package/types/integrations/breadcrumbs.d.ts.map +1 -1
  159. package/types/integrations/dedupe.d.ts.map +1 -1
  160. package/types/integrations/globalhandlers.d.ts.map +1 -1
  161. package/types/integrations/linkederrors.d.ts +3 -3
  162. package/types/integrations/linkederrors.d.ts.map +1 -1
  163. package/types/sdk.d.ts +3 -3
  164. package/types/sdk.d.ts.map +1 -1
  165. package/types/stack-parsers.d.ts +8 -6
  166. package/types/stack-parsers.d.ts.map +1 -1
  167. package/types/transports/fetch.d.ts +7 -14
  168. package/types/transports/fetch.d.ts.map +1 -1
  169. package/types/transports/index.d.ts +2 -5
  170. package/types/transports/index.d.ts.map +1 -1
  171. package/types/transports/utils.d.ts.map +1 -1
  172. package/types/transports/xhr.d.ts +9 -9
  173. package/types/transports/xhr.d.ts.map +1 -1
  174. package/build/bundle.debug.min.js +0 -3
  175. package/build/bundle.debug.min.js.map +0 -1
  176. package/build/bundle.es6.debug.min.js +0 -3
  177. package/build/bundle.es6.debug.min.js.map +0 -1
  178. package/build/bundle.es6.js +0 -6868
  179. package/build/bundle.es6.js.map +0 -1
  180. package/build/bundle.es6.min.js +0 -3
  181. package/build/bundle.es6.min.js.map +0 -1
  182. package/build/bundle.js +0 -7169
  183. package/build/bundle.js.map +0 -1
  184. package/build/bundle.min.js +0 -3
  185. package/build/bundle.min.js.map +0 -1
  186. package/dist/backend.d.ts +0 -43
  187. package/dist/backend.d.ts.map +0 -1
  188. package/dist/backend.js +0 -58
  189. package/dist/backend.js.map +0 -1
  190. package/dist/client.d.ts +0 -33
  191. package/dist/client.d.ts.map +0 -1
  192. package/dist/client.js +0 -77
  193. package/dist/client.js.map +0 -1
  194. package/dist/eventbuilder.d.ts +0 -39
  195. package/dist/eventbuilder.d.ts.map +0 -1
  196. package/dist/eventbuilder.js.map +0 -1
  197. package/dist/exports.d.ts +0 -10
  198. package/dist/exports.d.ts.map +0 -1
  199. package/dist/exports.js.map +0 -1
  200. package/dist/helpers.d.ts.map +0 -1
  201. package/dist/helpers.js.map +0 -1
  202. package/dist/index.js +0 -17
  203. package/dist/index.js.map +0 -1
  204. package/dist/integrations/breadcrumbs.d.ts.map +0 -1
  205. package/dist/integrations/breadcrumbs.js.map +0 -1
  206. package/dist/integrations/dedupe.js.map +0 -1
  207. package/dist/integrations/globalhandlers.d.ts.map +0 -1
  208. package/dist/integrations/globalhandlers.js.map +0 -1
  209. package/dist/integrations/linkederrors.d.ts.map +0 -1
  210. package/dist/integrations/linkederrors.js +0 -62
  211. package/dist/integrations/linkederrors.js.map +0 -1
  212. package/dist/integrations/trycatch.js.map +0 -1
  213. package/dist/integrations/useragent.js +0 -42
  214. package/dist/integrations/useragent.js.map +0 -1
  215. package/dist/sdk.d.ts.map +0 -1
  216. package/dist/sdk.js.map +0 -1
  217. package/dist/stack-parsers.d.ts +0 -7
  218. package/dist/stack-parsers.d.ts.map +0 -1
  219. package/dist/stack-parsers.js.map +0 -1
  220. package/dist/transports/base.d.ts +0 -65
  221. package/dist/transports/base.d.ts.map +0 -1
  222. package/dist/transports/base.js +0 -141
  223. package/dist/transports/base.js.map +0 -1
  224. package/dist/transports/fetch.d.ts +0 -17
  225. package/dist/transports/fetch.d.ts.map +0 -1
  226. package/dist/transports/fetch.js +0 -81
  227. package/dist/transports/fetch.js.map +0 -1
  228. package/dist/transports/index.d.ts +0 -6
  229. package/dist/transports/index.d.ts.map +0 -1
  230. package/dist/transports/index.js +0 -12
  231. package/dist/transports/index.js.map +0 -1
  232. package/dist/transports/new-fetch.d.ts +0 -10
  233. package/dist/transports/new-fetch.d.ts.map +0 -1
  234. package/dist/transports/new-fetch.js +0 -27
  235. package/dist/transports/new-fetch.js.map +0 -1
  236. package/dist/transports/new-xhr.d.ts +0 -11
  237. package/dist/transports/new-xhr.d.ts.map +0 -1
  238. package/dist/transports/new-xhr.js +0 -46
  239. package/dist/transports/new-xhr.js.map +0 -1
  240. package/dist/transports/utils.js.map +0 -1
  241. package/dist/transports/xhr.d.ts +0 -11
  242. package/dist/transports/xhr.d.ts.map +0 -1
  243. package/dist/transports/xhr.js +0 -64
  244. package/dist/transports/xhr.js.map +0 -1
  245. package/esm/backend.d.ts +0 -43
  246. package/esm/backend.d.ts.map +0 -1
  247. package/esm/backend.js +0 -57
  248. package/esm/backend.js.map +0 -1
  249. package/esm/transports/base.d.ts +0 -65
  250. package/esm/transports/base.d.ts.map +0 -1
  251. package/esm/transports/base.js +0 -140
  252. package/esm/transports/base.js.map +0 -1
  253. package/esm/transports/new-fetch.d.ts.map +0 -1
  254. package/esm/transports/new-fetch.js +0 -25
  255. package/esm/transports/new-fetch.js.map +0 -1
  256. package/esm/transports/new-xhr.d.ts +0 -11
  257. package/esm/transports/new-xhr.d.ts.map +0 -1
  258. package/esm/transports/new-xhr.js.map +0 -1
  259. package/types/backend.d.ts +0 -43
  260. package/types/backend.d.ts.map +0 -1
  261. package/types/transports/base.d.ts +0 -65
  262. package/types/transports/base.d.ts.map +0 -1
  263. package/types/transports/new-fetch.d.ts +0 -10
  264. package/types/transports/new-fetch.d.ts.map +0 -1
  265. package/types/transports/new-xhr.d.ts.map +0 -1
@@ -1,17 +1,10 @@
1
- import { Event, Response, SentryRequest, Session, TransportOptions } from '@sentry/types';
2
- import { BaseTransport } from './base';
1
+ import { BaseTransportOptions, Transport } from '@sentry/types';
3
2
  import { FetchImpl } from './utils';
4
- /** `fetch` based transport */
5
- export declare class FetchTransport extends BaseTransport {
6
- /**
7
- * Fetch API reference which always points to native browser implementation.
8
- */
9
- private _fetch;
10
- constructor(options: TransportOptions, fetchImpl?: FetchImpl);
11
- /**
12
- * @param sentryRequest Prepared SentryRequest to be delivered
13
- * @param originalPayload Original payload used to create SentryRequest
14
- */
15
- protected _sendRequest(sentryRequest: SentryRequest, originalPayload: Event | Session): PromiseLike<Response>;
3
+ export interface FetchTransportOptions extends BaseTransportOptions {
4
+ requestOptions?: RequestInit;
16
5
  }
6
+ /**
7
+ * Creates a Transport that uses the Fetch API to send events to Sentry.
8
+ */
9
+ export declare function makeFetchTransport(options: FetchTransportOptions, nativeFetch?: FetchImpl): Transport;
17
10
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/transports/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG1F,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,EAAgC,MAAM,SAAS,CAAC;AAElE,8BAA8B;AAC9B,qBAAa,cAAe,SAAQ,aAAa;IAC/C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAe;gBAEV,OAAO,EAAE,gBAAgB,EAAE,SAAS,GAAE,SAA0C;IAKnG;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,GAAG,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC;CA+D9G"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/transports/fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAkD,MAAM,eAAe,CAAC;AAEhH,OAAO,EAAE,SAAS,EAAgC,MAAM,SAAS,CAAC;AAElE,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,cAAc,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,qBAAqB,EAC9B,WAAW,GAAE,SAA0C,GACtD,SAAS,CAkBX"}
@@ -1,80 +1,18 @@
1
- import { __extends } from "tslib";
2
- import { SentryError, supportsReferrerPolicy, SyncPromise } from '@sentry/utils';
3
- import { BaseTransport } from './base';
1
+ import { createTransport } from '@sentry/core';
4
2
  import { getNativeFetchImplementation } from './utils';
5
- /** `fetch` based transport */
6
- var FetchTransport = /** @class */ (function (_super) {
7
- __extends(FetchTransport, _super);
8
- function FetchTransport(options, fetchImpl) {
9
- if (fetchImpl === void 0) { fetchImpl = getNativeFetchImplementation(); }
10
- var _this = _super.call(this, options) || this;
11
- _this._fetch = fetchImpl;
12
- return _this;
3
+ /**
4
+ * Creates a Transport that uses the Fetch API to send events to Sentry.
5
+ */
6
+ export function makeFetchTransport(options, nativeFetch = getNativeFetchImplementation()) {
7
+ function makeRequest(request) {
8
+ const requestOptions = Object.assign({ body: request.body, method: 'POST', referrerPolicy: 'origin' }, options.requestOptions);
9
+ return nativeFetch(options.url, requestOptions).then(response => ({
10
+ headers: {
11
+ 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),
12
+ 'retry-after': response.headers.get('Retry-After'),
13
+ },
14
+ }));
13
15
  }
14
- /**
15
- * @param sentryRequest Prepared SentryRequest to be delivered
16
- * @param originalPayload Original payload used to create SentryRequest
17
- */
18
- FetchTransport.prototype._sendRequest = function (sentryRequest, originalPayload) {
19
- var _this = this;
20
- // eslint-disable-next-line deprecation/deprecation
21
- if (this._isRateLimited(sentryRequest.type)) {
22
- this.recordLostEvent('ratelimit_backoff', sentryRequest.type);
23
- return Promise.reject({
24
- event: originalPayload,
25
- type: sentryRequest.type,
26
- // eslint-disable-next-line deprecation/deprecation
27
- reason: "Transport for " + sentryRequest.type + " requests locked till " + this._disabledUntil(sentryRequest.type) + " due to too many requests.",
28
- status: 429,
29
- });
30
- }
31
- var options = {
32
- body: sentryRequest.body,
33
- method: 'POST',
34
- // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default'
35
- // (see https://caniuse.com/#feat=referrer-policy),
36
- // it doesn't. And it throws an exception instead of ignoring this parameter...
37
- // REF: https://github.com/getsentry/raven-js/issues/1233
38
- referrerPolicy: (supportsReferrerPolicy() ? 'origin' : ''),
39
- };
40
- if (this.options.fetchParameters !== undefined) {
41
- Object.assign(options, this.options.fetchParameters);
42
- }
43
- if (this.options.headers !== undefined) {
44
- options.headers = this.options.headers;
45
- }
46
- return this._buffer
47
- .add(function () {
48
- return new SyncPromise(function (resolve, reject) {
49
- void _this._fetch(sentryRequest.url, options)
50
- .then(function (response) {
51
- var headers = {
52
- 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),
53
- 'retry-after': response.headers.get('Retry-After'),
54
- };
55
- _this._handleResponse({
56
- requestType: sentryRequest.type,
57
- response: response,
58
- headers: headers,
59
- resolve: resolve,
60
- reject: reject,
61
- });
62
- })
63
- .catch(reject);
64
- });
65
- })
66
- .then(undefined, function (reason) {
67
- // It's either buffer rejection or any other xhr/fetch error, which are treated as NetworkError.
68
- if (reason instanceof SentryError) {
69
- _this.recordLostEvent('queue_overflow', sentryRequest.type);
70
- }
71
- else {
72
- _this.recordLostEvent('network_error', sentryRequest.type);
73
- }
74
- throw reason;
75
- });
76
- };
77
- return FetchTransport;
78
- }(BaseTransport));
79
- export { FetchTransport };
16
+ return createTransport(options, makeRequest);
17
+ }
80
18
  //# sourceMappingURL=fetch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../../src/transports/fetch.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAa,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAElE,8BAA8B;AAC9B;IAAoC,kCAAa;IAM/C,wBAAmB,OAAyB,EAAE,SAAqD;QAArD,0BAAA,EAAA,YAAuB,4BAA4B,EAAE;QAAnG,YACE,kBAAM,OAAO,CAAC,SAEf;QADC,KAAI,CAAC,MAAM,GAAG,SAAS,CAAC;;IAC1B,CAAC;IAED;;;OAGG;IACO,qCAAY,GAAtB,UAAuB,aAA4B,EAAE,eAAgC;QAArF,iBA8DC;QA7DC,mDAAmD;QACnD,IAAI,IAAI,CAAC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BACpE,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;qBACnD,CAAC;oBACF,KAAI,CAAC,eAAe,CAAC;wBACnB,WAAW,EAAE,aAAa,CAAC,IAAI;wBAC/B,QAAQ,UAAA;wBACR,OAAO,SAAA;wBACP,OAAO,SAAA;wBACP,MAAM,QAAA;qBACP,CAAC,CAAC;gBACL,CAAC,CAAC;qBACD,KAAK,CAAC,MAAM,CAAC,CAAC;YACnB,CAAC,CAAC;QAhBF,CAgBE,CACL;aACA,IAAI,CAAC,SAAS,EAAE,UAAA,MAAM;YACrB,gGAAgG;YAChG,IAAI,MAAM,YAAY,WAAW,EAAE;gBACjC,KAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aAC5D;iBAAM;gBACL,KAAI,CAAC,eAAe,CAAC,eAAe,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aAC3D;YACD,MAAM,MAAM,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC;IACH,qBAAC;AAAD,CAAC,AA9ED,CAAoC,aAAa,GA8EhD","sourcesContent":["import { Event, Response, SentryRequest, Session, TransportOptions } from '@sentry/types';\nimport { SentryError, supportsReferrerPolicy, SyncPromise } from '@sentry/utils';\n\nimport { BaseTransport } from './base';\nimport { FetchImpl, getNativeFetchImplementation } from './utils';\n\n/** `fetch` based transport */\nexport class FetchTransport extends BaseTransport {\n /**\n * Fetch API reference which always points to native browser implementation.\n */\n private _fetch: typeof fetch;\n\n public constructor(options: TransportOptions, fetchImpl: FetchImpl = getNativeFetchImplementation()) {\n super(options);\n this._fetch = fetchImpl;\n }\n\n /**\n * @param sentryRequest Prepared SentryRequest to be delivered\n * @param originalPayload Original payload used to create SentryRequest\n */\n protected _sendRequest(sentryRequest: SentryRequest, originalPayload: Event | Session): PromiseLike<Response> {\n // eslint-disable-next-line deprecation/deprecation\n if (this._isRateLimited(sentryRequest.type)) {\n this.recordLostEvent('ratelimit_backoff', sentryRequest.type);\n\n return Promise.reject({\n event: originalPayload,\n type: sentryRequest.type,\n // eslint-disable-next-line deprecation/deprecation\n reason: `Transport for ${sentryRequest.type} requests locked till ${this._disabledUntil(\n sentryRequest.type,\n )} due to too many requests.`,\n status: 429,\n });\n }\n\n const options: RequestInit = {\n body: sentryRequest.body,\n method: 'POST',\n // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default'\n // (see https://caniuse.com/#feat=referrer-policy),\n // it doesn't. And it throws an exception instead of ignoring this parameter...\n // REF: https://github.com/getsentry/raven-js/issues/1233\n referrerPolicy: (supportsReferrerPolicy() ? 'origin' : '') as ReferrerPolicy,\n };\n if (this.options.fetchParameters !== undefined) {\n Object.assign(options, this.options.fetchParameters);\n }\n if (this.options.headers !== undefined) {\n options.headers = this.options.headers;\n }\n\n return this._buffer\n .add(\n () =>\n new SyncPromise<Response>((resolve, reject) => {\n void this._fetch(sentryRequest.url, options)\n .then(response => {\n const headers = {\n 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),\n 'retry-after': response.headers.get('Retry-After'),\n };\n this._handleResponse({\n requestType: sentryRequest.type,\n response,\n headers,\n resolve,\n reject,\n });\n })\n .catch(reject);\n }),\n )\n .then(undefined, reason => {\n // It's either buffer rejection or any other xhr/fetch error, which are treated as NetworkError.\n if (reason instanceof SentryError) {\n this.recordLostEvent('queue_overflow', sentryRequest.type);\n } else {\n this.recordLostEvent('network_error', sentryRequest.type);\n }\n throw reason;\n });\n }\n}\n"]}
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../../src/transports/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAa,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAMlE;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAA8B,EAC9B,cAAyB,4BAA4B,EAAE;IAEvD,SAAS,WAAW,CAAC,OAAyB;QAC5C,MAAM,cAAc,mBAClB,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,QAAQ,IACrB,OAAO,CAAC,cAAc,CAC1B,CAAC;QAEF,OAAO,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YAChE,OAAO,EAAE;gBACP,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;gBACpE,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;aACnD;SACF,CAAC,CAAC,CAAC;IACN,CAAC;IAED,OAAO,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { createTransport } from '@sentry/core';\nimport { BaseTransportOptions, Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/types';\n\nimport { FetchImpl, getNativeFetchImplementation } from './utils';\n\nexport interface FetchTransportOptions extends BaseTransportOptions {\n requestOptions?: RequestInit;\n}\n\n/**\n * Creates a Transport that uses the Fetch API to send events to Sentry.\n */\nexport function makeFetchTransport(\n options: FetchTransportOptions,\n nativeFetch: FetchImpl = getNativeFetchImplementation(),\n): Transport {\n function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n const requestOptions: RequestInit = {\n body: request.body,\n method: 'POST',\n referrerPolicy: 'origin',\n ...options.requestOptions,\n };\n\n return nativeFetch(options.url, requestOptions).then(response => ({\n headers: {\n 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),\n 'retry-after': response.headers.get('Retry-After'),\n },\n }));\n }\n\n return createTransport(options, makeRequest);\n}\n"]}
@@ -1,6 +1,3 @@
1
- export { BaseTransport } from './base';
2
- export { FetchTransport } from './fetch';
3
- export { XHRTransport } from './xhr';
4
- export { makeNewFetchTransport } from './new-fetch';
5
- export { makeNewXHRTransport } from './new-xhr';
1
+ export { makeFetchTransport } from './fetch';
2
+ export { makeXHRTransport } from './xhr';
6
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC"}
@@ -1,6 +1,3 @@
1
- export { BaseTransport } from './base';
2
- export { FetchTransport } from './fetch';
3
- export { XHRTransport } from './xhr';
4
- export { makeNewFetchTransport } from './new-fetch';
5
- export { makeNewXHRTransport } from './new-xhr';
1
+ export { makeFetchTransport } from './fetch';
2
+ export { makeXHRTransport } from './xhr';
6
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/transports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["export { BaseTransport } from './base';\nexport { FetchTransport } from './fetch';\nexport { XHRTransport } from './xhr';\n\nexport { makeNewFetchTransport } from './new-fetch';\nexport { makeNewXHRTransport } from './new-xhr';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/transports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export { makeFetchTransport } from './fetch';\nexport { makeXHRTransport } from './xhr';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/transports/utils.ts"],"names":[],"mappings":"AAOA,oBAAY,SAAS,GAAG,OAAO,KAAK,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,4BAA4B,IAAI,SAAS,CAiCxD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAqB1D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/transports/utils.ts"],"names":[],"mappings":"AAOA,oBAAY,SAAS,GAAG,OAAO,KAAK,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,4BAA4B,IAAI,SAAS,CAiCxD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAiB1D"}
@@ -1,7 +1,7 @@
1
- import { forget, getGlobalObject, isNativeFetch, logger, supportsFetch } from '@sentry/utils';
1
+ import { getGlobalObject, isNativeFetch, logger, supportsFetch } from '@sentry/utils';
2
2
  import { IS_DEBUG_BUILD } from '../flags';
3
- var global = getGlobalObject();
4
- var cachedFetchImpl;
3
+ const global = getGlobalObject();
4
+ let cachedFetchImpl;
5
5
  /**
6
6
  * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
7
7
  * Whenever someone wraps the Fetch API and returns the wrong promise chain,
@@ -49,15 +49,15 @@ export function getNativeFetchImplementation() {
49
49
  if (isNativeFetch(global.fetch)) {
50
50
  return (cachedFetchImpl = global.fetch.bind(global));
51
51
  }
52
- var document = global.document;
53
- var fetchImpl = global.fetch;
52
+ const document = global.document;
53
+ let fetchImpl = global.fetch;
54
54
  // eslint-disable-next-line deprecation/deprecation
55
55
  if (document && typeof document.createElement === 'function') {
56
56
  try {
57
- var sandbox = document.createElement('iframe');
57
+ const sandbox = document.createElement('iframe');
58
58
  sandbox.hidden = true;
59
59
  document.head.appendChild(sandbox);
60
- var contentWindow = sandbox.contentWindow;
60
+ const contentWindow = sandbox.contentWindow;
61
61
  if (contentWindow && contentWindow.fetch) {
62
62
  fetchImpl = contentWindow.fetch;
63
63
  }
@@ -78,21 +78,21 @@ export function getNativeFetchImplementation() {
78
78
  * @param body report payload
79
79
  */
80
80
  export function sendReport(url, body) {
81
- var isRealNavigator = Object.prototype.toString.call(global && global.navigator) === '[object Navigator]';
82
- var hasSendBeacon = isRealNavigator && typeof global.navigator.sendBeacon === 'function';
81
+ const isRealNavigator = Object.prototype.toString.call(global && global.navigator) === '[object Navigator]';
82
+ const hasSendBeacon = isRealNavigator && typeof global.navigator.sendBeacon === 'function';
83
83
  if (hasSendBeacon) {
84
84
  // Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
85
- var sendBeacon = global.navigator.sendBeacon.bind(global.navigator);
86
- return sendBeacon(url, body);
85
+ const sendBeacon = global.navigator.sendBeacon.bind(global.navigator);
86
+ sendBeacon(url, body);
87
87
  }
88
- if (supportsFetch()) {
89
- var fetch_1 = getNativeFetchImplementation();
90
- return forget(fetch_1(url, {
91
- body: body,
88
+ else if (supportsFetch()) {
89
+ const fetch = getNativeFetchImplementation();
90
+ fetch(url, {
91
+ body,
92
92
  method: 'POST',
93
93
  credentials: 'omit',
94
94
  keepalive: true,
95
- }));
95
+ }).then(null, error => logger.error(error));
96
96
  }
97
97
  }
98
98
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/transports/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,IAAM,MAAM,GAAG,eAAe,EAAU,CAAC;AACzC,IAAI,eAA0B,CAAC;AAI/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,4BAA4B;IAC1C,IAAI,eAAe,EAAE;QACnB,OAAO,eAAe,CAAC;KACxB;IAED,sDAAsD;IAEtD,6BAA6B;IAC7B,IAAI,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;QAC/B,OAAO,CAAC,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;KACtD;IAED,IAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,IAAI,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC;IAC7B,mDAAmD;IACnD,IAAI,QAAQ,IAAI,OAAO,QAAQ,CAAC,aAAa,KAAK,UAAU,EAAE;QAC5D,IAAI;YACF,IAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YACjD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YACtB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACnC,IAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;YAC5C,IAAI,aAAa,IAAI,aAAa,CAAC,KAAK,EAAE;gBACxC,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC;aACjC;YACD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;SACpC;QAAC,OAAO,CAAC,EAAE;YACV,cAAc;gBACZ,MAAM,CAAC,IAAI,CAAC,iFAAiF,EAAE,CAAC,CAAC,CAAC;SACrG;KACF;IAED,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,qDAAqD;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,IAAY;IAClD,IAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,oBAAoB,CAAC;IAC5G,IAAM,aAAa,GAAG,eAAe,IAAI,OAAO,MAAM,CAAC,SAAS,CAAC,UAAU,KAAK,UAAU,CAAC;IAE3F,IAAI,aAAa,EAAE;QACjB,wHAAwH;QACxH,IAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtE,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;KAC9B;IAED,IAAI,aAAa,EAAE,EAAE;QACnB,IAAM,OAAK,GAAG,4BAA4B,EAAE,CAAC;QAC7C,OAAO,MAAM,CACX,OAAK,CAAC,GAAG,EAAE;YACT,IAAI,MAAA;YACJ,MAAM,EAAE,MAAM;YACd,WAAW,EAAE,MAAM;YACnB,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;KACH;AACH,CAAC","sourcesContent":["import { forget, getGlobalObject, isNativeFetch, logger, supportsFetch } from '@sentry/utils';\n\nimport { IS_DEBUG_BUILD } from '../flags';\n\nconst global = getGlobalObject<Window>();\nlet cachedFetchImpl: FetchImpl;\n\nexport type FetchImpl = typeof fetch;\n\n/**\n * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.\n * Whenever someone wraps the Fetch API and returns the wrong promise chain,\n * this chain becomes orphaned and there is no possible way to capture it's rejections\n * other than allowing it bubble up to this very handler. eg.\n *\n * const f = window.fetch;\n * window.fetch = function () {\n * const p = f.apply(this, arguments);\n *\n * p.then(function() {\n * console.log('hi.');\n * });\n *\n * return p;\n * }\n *\n * `p.then(function () { ... })` is producing a completely separate promise chain,\n * however, what's returned is `p` - the result of original `fetch` call.\n *\n * This mean, that whenever we use the Fetch API to send our own requests, _and_\n * some ad-blocker blocks it, this orphaned chain will _always_ reject,\n * effectively causing another event to be captured.\n * This makes a whole process become an infinite loop, which we need to somehow\n * deal with, and break it in one way or another.\n *\n * To deal with this issue, we are making sure that we _always_ use the real\n * browser Fetch API, instead of relying on what `window.fetch` exposes.\n * The only downside to this would be missing our own requests as breadcrumbs,\n * but because we are already not doing this, it should be just fine.\n *\n * Possible failed fetch error messages per-browser:\n *\n * Chrome: Failed to fetch\n * Edge: Failed to Fetch\n * Firefox: NetworkError when attempting to fetch resource\n * Safari: resource blocked by content blocker\n */\nexport function getNativeFetchImplementation(): FetchImpl {\n if (cachedFetchImpl) {\n return cachedFetchImpl;\n }\n\n /* eslint-disable @typescript-eslint/unbound-method */\n\n // Fast path to avoid DOM I/O\n if (isNativeFetch(global.fetch)) {\n return (cachedFetchImpl = global.fetch.bind(global));\n }\n\n const document = global.document;\n let fetchImpl = global.fetch;\n // eslint-disable-next-line deprecation/deprecation\n if (document && typeof document.createElement === 'function') {\n try {\n const sandbox = document.createElement('iframe');\n sandbox.hidden = true;\n document.head.appendChild(sandbox);\n const contentWindow = sandbox.contentWindow;\n if (contentWindow && contentWindow.fetch) {\n fetchImpl = contentWindow.fetch;\n }\n document.head.removeChild(sandbox);\n } catch (e) {\n IS_DEBUG_BUILD &&\n logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);\n }\n }\n\n return (cachedFetchImpl = fetchImpl.bind(global));\n /* eslint-enable @typescript-eslint/unbound-method */\n}\n\n/**\n * Sends sdk client report using sendBeacon or fetch as a fallback if available\n *\n * @param url report endpoint\n * @param body report payload\n */\nexport function sendReport(url: string, body: string): void {\n const isRealNavigator = Object.prototype.toString.call(global && global.navigator) === '[object Navigator]';\n const hasSendBeacon = isRealNavigator && typeof global.navigator.sendBeacon === 'function';\n\n if (hasSendBeacon) {\n // Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch\n const sendBeacon = global.navigator.sendBeacon.bind(global.navigator);\n return sendBeacon(url, body);\n }\n\n if (supportsFetch()) {\n const fetch = getNativeFetchImplementation();\n return forget(\n fetch(url, {\n body,\n method: 'POST',\n credentials: 'omit',\n keepalive: true,\n }),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/transports/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEtF,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,GAAG,eAAe,EAAU,CAAC;AACzC,IAAI,eAA0B,CAAC;AAI/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,4BAA4B;IAC1C,IAAI,eAAe,EAAE;QACnB,OAAO,eAAe,CAAC;KACxB;IAED,sDAAsD;IAEtD,6BAA6B;IAC7B,IAAI,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;QAC/B,OAAO,CAAC,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;KACtD;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,IAAI,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC;IAC7B,mDAAmD;IACnD,IAAI,QAAQ,IAAI,OAAO,QAAQ,CAAC,aAAa,KAAK,UAAU,EA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AM;YACd,WAAW,EAAE,MAAM;YACnB,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;KAC7C;AACH,CAAC","sourcesContent":["import { getGlobalObject, isNativeFetch, logger, supportsFetch } from '@sentry/utils';\n\nimport { IS_DEBUG_BUILD } from '../flags';\n\nconst global = getGlobalObject<Window>();\nlet cachedFetchImpl: FetchImpl;\n\nexport type FetchImpl = typeof fetch;\n\n/**\n * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.\n * Whenever someone wraps the Fetch API and returns the wrong promise chain,\n * this chain becomes orphaned and there is no possible way to capture it's rejections\n * other than allowing it bubble up to this very handler. eg.\n *\n * const f = window.fetch;\n * window.fetch = function () {\n * const p = f.apply(this, arguments);\n *\n * p.then(function() {\n * console.log('hi.');\n * });\n *\n * return p;\n * }\n *\n * `p.then(function () { ... })` is producing a completely separate promise chain,\n * however, what's returned is `p` - the result of original `fetch` call.\n *\n * This mean, that whenever we use the Fetch API to send our own requests, _and_\n * some ad-blocker blocks it, this orphaned chain will _always_ reject,\n * effectively causing another event to be captured.\n * This makes a whole process become an infinite loop, which we need to somehow\n * deal with, and break it in one way or another.\n *\n * To deal with this issue, we are making sure that we _always_ use the real\n * browser Fetch API, instead of relying on what `window.fetch` exposes.\n * The only downside to this would be missing our own requests as breadcrumbs,\n * but because we are already not doing this, it should be just fine.\n *\n * Possible failed fetch error messages per-browser:\n *\n * Chrome: Failed to fetch\n * Edge: Failed to Fetch\n * Firefox: NetworkError when attempting to fetch resource\n * Safari: resource blocked by content blocker\n */\nexport function getNativeFetchImplementation(): FetchImpl {\n if (cachedFetchImpl) {\n return cachedFetchImpl;\n }\n\n /* eslint-disable @typescript-eslint/unbound-method */\n\n // Fast path to avoid DOM I/O\n if (isNativeFetch(global.fetch)) {\n return (cachedFetchImpl = global.fetch.bind(global));\n }\n\n const document = global.document;\n let fetchImpl = global.fetch;\n // eslint-disable-next-line deprecation/deprecation\n if (document && typeof document.createElement === 'function') {\n try {\n const sandbox = document.createElement('iframe');\n sandbox.hidden = true;\n document.head.appendChild(sandbox);\n const contentWindow = sandbox.contentWindow;\n if (contentWindow && contentWindow.fetch) {\n fetchImpl = contentWindow.fetch;\n }\n document.head.removeChild(sandbox);\n } catch (e) {\n IS_DEBUG_BUILD &&\n logger.warn('Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', e);\n }\n }\n\n return (cachedFetchImpl = fetchImpl.bind(global));\n /* eslint-enable @typescript-eslint/unbound-method */\n}\n\n/**\n * Sends sdk client report using sendBeacon or fetch as a fallback if available\n *\n * @param url report endpoint\n * @param body report payload\n */\nexport function sendReport(url: string, body: string): void {\n const isRealNavigator = Object.prototype.toString.call(global && global.navigator) === '[object Navigator]';\n const hasSendBeacon = isRealNavigator && typeof global.navigator.sendBeacon === 'function';\n\n if (hasSendBeacon) {\n // Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch\n const sendBeacon = global.navigator.sendBeacon.bind(global.navigator);\n sendBeacon(url, body);\n } else if (supportsFetch()) {\n const fetch = getNativeFetchImplementation();\n fetch(url, {\n body,\n method: 'POST',\n credentials: 'omit',\n keepalive: true,\n }).then(null, error => logger.error(error));\n }\n}\n"]}
@@ -1,11 +1,11 @@
1
- import { Event, Response, SentryRequest, Session } from '@sentry/types';
2
- import { BaseTransport } from './base';
3
- /** `XHR` based transport */
4
- export declare class XHRTransport extends BaseTransport {
5
- /**
6
- * @param sentryRequest Prepared SentryRequest to be delivered
7
- * @param originalPayload Original payload used to create SentryRequest
8
- */
9
- protected _sendRequest(sentryRequest: SentryRequest, originalPayload: Event | Session): PromiseLike<Response>;
1
+ import { BaseTransportOptions, Transport } from '@sentry/types';
2
+ export interface XHRTransportOptions extends BaseTransportOptions {
3
+ headers?: {
4
+ [key: string]: string;
5
+ };
10
6
  }
7
+ /**
8
+ * Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.
9
+ */
10
+ export declare function makeXHRTransport(options: XHRTransportOptions): Transport;
11
11
  //# sourceMappingURL=xhr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../../../src/transports/xhr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,4BAA4B;AAC5B,qBAAa,YAAa,SAAQ,aAAa;IAC7C;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,GAAG,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC;CAmD9G"}
1
+ {"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../../../src/transports/xhr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAkD,MAAM,eAAe,CAAC;AAahH,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACrC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAgCxE"}
@@ -1,63 +1,42 @@
1
- import { __extends } from "tslib";
2
- import { SentryError, SyncPromise } from '@sentry/utils';
3
- import { BaseTransport } from './base';
4
- /** `XHR` based transport */
5
- var XHRTransport = /** @class */ (function (_super) {
6
- __extends(XHRTransport, _super);
7
- function XHRTransport() {
8
- return _super !== null && _super.apply(this, arguments) || this;
9
- }
10
- /**
11
- * @param sentryRequest Prepared SentryRequest to be delivered
12
- * @param originalPayload Original payload used to create SentryRequest
13
- */
14
- XHRTransport.prototype._sendRequest = function (sentryRequest, originalPayload) {
15
- var _this = this;
16
- // eslint-disable-next-line deprecation/deprecation
17
- if (this._isRateLimited(sentryRequest.type)) {
18
- this.recordLostEvent('ratelimit_backoff', sentryRequest.type);
19
- return Promise.reject({
20
- event: originalPayload,
21
- type: sentryRequest.type,
22
- // eslint-disable-next-line deprecation/deprecation
23
- reason: "Transport for " + sentryRequest.type + " requests locked till " + this._disabledUntil(sentryRequest.type) + " due to too many requests.",
24
- status: 429,
25
- });
26
- }
27
- return this._buffer
28
- .add(function () {
29
- return new SyncPromise(function (resolve, reject) {
30
- var request = new XMLHttpRequest();
31
- request.onreadystatechange = function () {
32
- if (request.readyState === 4) {
33
- var headers = {
34
- 'x-sentry-rate-limits': request.getResponseHeader('X-Sentry-Rate-Limits'),
35
- 'retry-after': request.getResponseHeader('Retry-After'),
36
- };
37
- _this._handleResponse({ requestType: sentryRequest.type, response: request, headers: headers, resolve: resolve, reject: reject });
38
- }
39
- };
40
- request.open('POST', sentryRequest.url);
41
- for (var header in _this.options.headers) {
42
- if (Object.prototype.hasOwnProperty.call(_this.options.headers, header)) {
43
- request.setRequestHeader(header, _this.options.headers[header]);
44
- }
1
+ import { createTransport } from '@sentry/core';
2
+ import { SyncPromise } from '@sentry/utils';
3
+ /**
4
+ * The DONE ready state for XmlHttpRequest
5
+ *
6
+ * Defining it here as a constant b/c XMLHttpRequest.DONE is not always defined
7
+ * (e.g. during testing, it is `undefined`)
8
+ *
9
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState}
10
+ */
11
+ const XHR_READYSTATE_DONE = 4;
12
+ /**
13
+ * Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.
14
+ */
15
+ export function makeXHRTransport(options) {
16
+ function makeRequest(request) {
17
+ return new SyncPromise((resolve, reject) => {
18
+ const xhr = new XMLHttpRequest();
19
+ xhr.onerror = reject;
20
+ xhr.onreadystatechange = () => {
21
+ if (xhr.readyState === XHR_READYSTATE_DONE) {
22
+ const response = {
23
+ headers: {
24
+ 'x-sentry-rate-limits': xhr.getResponseHeader('X-Sentry-Rate-Limits'),
25
+ 'retry-after': xhr.getResponseHeader('Retry-After'),
26
+ },
27
+ };
28
+ resolve(response);
29
+ }
30
+ };
31
+ xhr.open('POST', options.url);
32
+ for (const header in options.headers) {
33
+ if (Object.prototype.hasOwnProperty.call(options.headers, header)) {
34
+ xhr.setRequestHeader(header, options.headers[header]);
45
35
  }
46
- request.send(sentryRequest.body);
47
- });
48
- })
49
- .then(undefined, function (reason) {
50
- // It's either buffer rejection or any other xhr/fetch error, which are treated as NetworkError.
51
- if (reason instanceof SentryError) {
52
- _this.recordLostEvent('queue_overflow', sentryRequest.type);
53
- }
54
- else {
55
- _this.recordLostEvent('network_error', sentryRequest.type);
56
36
  }
57
- throw reason;
37
+ xhr.send(request.body);
58
38
  });
59
- };
60
- return XHRTransport;
61
- }(BaseTransport));
62
- export { XHRTransport };
39
+ }
40
+ return createTransport(options, makeRequest);
41
+ }
63
42
  //# sourceMappingURL=xhr.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"xhr.js","sourceRoot":"","sources":["../../../../src/transports/xhr.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,4BAA4B;AAC5B;IAAkC,gCAAa;IAA/C;;IAwDA,CAAC;IAvDC;;;OAGG;IACO,mCAAY,GAAtB,UAAuB,aAA4B,EAAE,eAAgC;QAArF,iBAkDC;QAjDC,mDAAmD;QACnD,IAAI,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;YAC3C,IAAI,CAAC,eAAe,CAAC,mBAAmB,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;YAE9D,OAAO,OAAO,CAAC,MAAM,CAAC;gBACpB,KAAK,EAAE,eAAe;gBACtB,IAAI,EAAE,aAAa,CAAC,IAAI;gBACxB,mDAAmD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AAS,EAAE,UAAA,MAAM;YACrB,gGAAgG;YAChG,IAAI,MAAM,YAAY,WAAW,EAAE;gBACjC,KAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aAC5D;iBAAM;gBACL,KAAI,CAAC,eAAe,CAAC,eAAe,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;aAC3D;YACD,MAAM,MAAM,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC;IACH,mBAAC;AAAD,CAAC,AAxDD,CAAkC,aAAa,GAwD9C","sourcesContent":["import { Event, Response, SentryRequest, Session } from '@sentry/types';\nimport { SentryError, SyncPromise } from '@sentry/utils';\n\nimport { BaseTransport } from './base';\n\n/** `XHR` based transport */\nexport class XHRTransport extends BaseTransport {\n /**\n * @param sentryRequest Prepared SentryRequest to be delivered\n * @param originalPayload Original payload used to create SentryRequest\n */\n protected _sendRequest(sentryRequest: SentryRequest, originalPayload: Event | Session): PromiseLike<Response> {\n // eslint-disable-next-line deprecation/deprecation\n if (this._isRateLimited(sentryRequest.type)) {\n this.recordLostEvent('ratelimit_backoff', sentryRequest.type);\n\n return Promise.reject({\n event: originalPayload,\n type: sentryRequest.type,\n // eslint-disable-next-line deprecation/deprecation\n reason: `Transport for ${sentryRequest.type} requests locked till ${this._disabledUntil(\n sentryRequest.type,\n )} due to too many requests.`,\n status: 429,\n });\n }\n\n return this._buffer\n .add(\n () =>\n new SyncPromise<Response>((resolve, reject) => {\n const request = new XMLHttpRequest();\n\n request.onreadystatechange = (): void => {\n if (request.readyState === 4) {\n const headers = {\n 'x-sentry-rate-limits': request.getResponseHeader('X-Sentry-Rate-Limits'),\n 'retry-after': request.getResponseHeader('Retry-After'),\n };\n this._handleResponse({ requestType: sentryRequest.type, response: request, headers, resolve, reject });\n }\n };\n\n request.open('POST', sentryRequest.url);\n for (const header in this.options.headers) {\n if (Object.prototype.hasOwnProperty.call(this.options.headers, header)) {\n request.setRequestHeader(header, this.options.headers[header]);\n }\n }\n request.send(sentryRequest.body);\n }),\n )\n .then(undefined, reason => {\n // It's either buffer rejection or any other xhr/fetch error, which are treated as NetworkError.\n if (reason instanceof SentryError) {\n this.recordLostEvent('queue_overflow', sentryRequest.type);\n } else {\n this.recordLostEvent('network_error', sentryRequest.type);\n }\n throw reason;\n });\n }\n}\n"]}
1
+ {"version":3,"file":"xhr.js","sourceRoot":"","sources":["../../../../src/transports/xhr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAM9B;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA4B;IAC3D,SAAS,WAAW,CAAC,OAAyB;QAC5C,OAAO,IAAI,WAAW,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,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAC/C,CAAC","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/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // TODO: Remove in the next major release and rely only on @sentry/core SDK_VERSION and SdkInfo metadata
2
- export var SDK_NAME = 'sentry.javascript.browser';
2
+ export const SDK_NAME = 'sentry.javascript.browser';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/version.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,MAAM,CAAC,IAAM,QAAQ,GAAG,2BAA2B,CAAC","sourcesContent":["// TODO: Remove in the next major release and rely only on @sentry/core SDK_VERSION and SdkInfo metadata\nexport const SDK_NAME = 'sentry.javascript.browser';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/version.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,MAAM,CAAC,MAAM,QAAQ,GAAG,2BAA2B,CAAC","sourcesContent":["// TODO: Remove in the next major release and rely only on @sentry/core SDK_VERSION and SdkInfo metadata\nexport const SDK_NAME = 'sentry.javascript.browser';\n"]}
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@sentry/browser",
3
- "version": "6.19.7",
3
+ "version": "7.0.0-beta.0",
4
4
  "description": "Official Sentry SDK for browsers",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
7
7
  "author": "Sentry",
8
8
  "license": "BSD-3-Clause",
9
9
  "engines": {
10
- "node": ">=6"
10
+ "node": ">=8"
11
11
  },
12
- "main": "dist/index.js",
12
+ "main": "cjs/index.js",
13
13
  "module": "esm/index.js",
14
14
  "types": "types/index.d.ts",
15
15
  "publishConfig": {
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "@sentry/core": "6.19.7",
20
- "@sentry/types": "6.19.7",
21
- "@sentry/utils": "6.19.7",
19
+ "@sentry/core": "7.0.0-beta.0",
20
+ "@sentry/types": "7.0.0-beta.0",
21
+ "@sentry/utils": "7.0.0-beta.0",
22
22
  "tslib": "^1.9.3"
23
23
  },
24
24
  "devDependencies": {
@@ -26,7 +26,6 @@
26
26
  "btoa": "^1.2.1",
27
27
  "chai": "^4.1.2",
28
28
  "chokidar": "^3.0.2",
29
- "jsdom": "^15.0.0",
30
29
  "karma": "^6.3.16",
31
30
  "karma-chai": "^0.1.0",
32
31
  "karma-chrome-launcher": "^2.2.0",
package/types/client.d.ts CHANGED
@@ -1,33 +1,63 @@
1
1
  import { BaseClient, Scope } from '@sentry/core';
2
- import { Event, EventHint } from '@sentry/types';
3
- import { BrowserBackend, BrowserOptions } from './backend';
4
- import { ReportDialogOptions } from './helpers';
2
+ import { ClientOptions, Event, EventHint, Options, Severity, SeverityLevel } from '@sentry/types';
3
+ export interface BaseBrowserOptions {
4
+ /**
5
+ * A pattern for error URLs which should exclusively be sent to Sentry.
6
+ * This is the opposite of {@link Options.denyUrls}.
7
+ * By default, all errors will be sent.
8
+ */
9
+ allowUrls?: Array<string | RegExp>;
10
+ /**
11
+ * A pattern for error URLs which should not be sent to Sentry.
12
+ * To allow certain errors instead, use {@link Options.allowUrls}.
13
+ * By default, all errors will be sent.
14
+ */
15
+ denyUrls?: Array<string | RegExp>;
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
+ }
5
29
  /**
6
30
  * The Sentry Browser SDK Client.
7
31
  *
8
32
  * @see BrowserOptions for documentation on configuration options.
9
33
  * @see SentryClient for usage documentation.
10
34
  */
11
- export declare class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
35
+ export declare class BrowserClient extends BaseClient<BrowserClientOptions> {
12
36
  /**
13
37
  * Creates a new Browser SDK instance.
14
38
  *
15
39
  * @param options Configuration options for this SDK.
16
40
  */
17
- constructor(options?: BrowserOptions);
41
+ constructor(options: BrowserClientOptions);
18
42
  /**
19
- * Show a report dialog to the user to send feedback to a specific event.
20
- *
21
- * @param options Set individual options for the dialog
43
+ * @inheritDoc
22
44
  */
23
- showReportDialog(options?: ReportDialogOptions): void;
45
+ eventFromException(exception: unknown, hint?: EventHint): PromiseLike<Event>;
24
46
  /**
25
47
  * @inheritDoc
26
48
  */
27
- protected _prepareEvent(event: Event, scope?: Scope, hint?: EventHint): PromiseLike<Event | null>;
49
+ eventFromMessage(message: string, level?: Severity | SeverityLevel, hint?: EventHint): PromiseLike<Event>;
50
+ /**
51
+ * @inheritDoc
52
+ */
53
+ sendEvent(event: Event): void;
28
54
  /**
29
55
  * @inheritDoc
30
56
  */
31
- protected _sendEvent(event: Event): void;
57
+ protected _prepareEvent(event: Event, scope?: Scope, hint?: EventHint): PromiseLike<Event | null>;
58
+ /**
59
+ * Sends client reports as an envelope.
60
+ */
61
+ private _flushOutcomes;
32
62
  }
33
63
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAe,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EAAsB,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGpE;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,UAAU,CAAC,cAAc,EAAE,cAAc,CAAC;IAC3E;;;;OAIG;gBACgB,OAAO,GAAE,cAAmB;IAgB/C;;;;OAIG;IACI,gBAAgB,CAAC,OAAO,GAAE,mBAAwB,GAAG,IAAI;IAkBhE;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,KAA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