@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.
Files changed (242) hide show
  1. package/README.md +2 -3
  2. package/cjs/client.js +130 -68
  3. package/cjs/client.js.map +1 -1
  4. package/cjs/eventbuilder.js +227 -168
  5. package/cjs/eventbuilder.js.map +1 -1
  6. package/cjs/exports.js +55 -42
  7. package/cjs/exports.js.map +1 -1
  8. package/cjs/flags.js +7 -3
  9. package/cjs/flags.js.map +1 -1
  10. package/cjs/helpers.js +123 -130
  11. package/cjs/helpers.js.map +1 -1
  12. package/cjs/index.js +78 -13
  13. package/cjs/index.js.map +1 -1
  14. package/cjs/integrations/breadcrumbs.js +223 -193
  15. package/cjs/integrations/breadcrumbs.js.map +1 -1
  16. package/cjs/integrations/dedupe.js +183 -143
  17. package/cjs/integrations/dedupe.js.map +1 -1
  18. package/cjs/integrations/globalhandlers.js +212 -171
  19. package/cjs/integrations/globalhandlers.js.map +1 -1
  20. package/cjs/integrations/httpcontext.js +51 -0
  21. package/cjs/integrations/httpcontext.js.map +1 -0
  22. package/cjs/integrations/index.js +18 -14
  23. package/cjs/integrations/index.js.map +1 -1
  24. package/cjs/integrations/linkederrors.js +79 -48
  25. package/cjs/integrations/linkederrors.js.map +1 -1
  26. package/cjs/integrations/trycatch.js +245 -216
  27. package/cjs/integrations/trycatch.js.map +1 -1
  28. package/cjs/sdk.js +168 -108
  29. package/cjs/sdk.js.map +1 -1
  30. package/cjs/stack-parsers.js +134 -83
  31. package/cjs/stack-parsers.js.map +1 -1
  32. package/cjs/transports/fetch.js +34 -80
  33. package/cjs/transports/fetch.js.map +1 -1
  34. package/cjs/transports/index.js +10 -12
  35. package/cjs/transports/index.js.map +1 -1
  36. package/cjs/transports/utils.js +57 -52
  37. package/cjs/transports/utils.js.map +1 -1
  38. package/cjs/transports/xhr.js +53 -63
  39. package/cjs/transports/xhr.js.map +1 -1
  40. package/esm/client.js +128 -67
  41. package/esm/client.js.map +1 -1
  42. package/esm/eventbuilder.js +218 -159
  43. package/esm/eventbuilder.js.map +1 -1
  44. package/esm/exports.js +12 -7
  45. package/esm/exports.js.map +1 -1
  46. package/esm/flags.js +5 -2
  47. package/esm/flags.js.map +1 -1
  48. package/esm/helpers.js +121 -127
  49. package/esm/helpers.js.map +1 -1
  50. package/esm/index.js +28 -10
  51. package/esm/index.js.map +1 -1
  52. package/esm/integrations/breadcrumbs.js +219 -191
  53. package/esm/integrations/breadcrumbs.js.map +1 -1
  54. package/esm/integrations/dedupe.js +180 -141
  55. package/esm/integrations/dedupe.js.map +1 -1
  56. package/esm/integrations/globalhandlers.js +209 -169
  57. package/esm/integrations/globalhandlers.js.map +1 -1
  58. package/esm/integrations/httpcontext.js +49 -0
  59. package/esm/integrations/httpcontext.js.map +1 -0
  60. package/esm/integrations/index.js +7 -7
  61. package/esm/integrations/index.js.map +1 -1
  62. package/esm/integrations/linkederrors.js +75 -45
  63. package/esm/integrations/linkederrors.js.map +1 -1
  64. package/esm/integrations/trycatch.js +242 -214
  65. package/esm/integrations/trycatch.js.map +1 -1
  66. package/esm/sdk.js +164 -105
  67. package/esm/sdk.js.map +1 -1
  68. package/esm/stack-parsers.js +126 -82
  69. package/esm/stack-parsers.js.map +1 -1
  70. package/esm/transports/fetch.js +32 -79
  71. package/esm/transports/fetch.js.map +1 -1
  72. package/esm/transports/index.js +3 -6
  73. package/esm/transports/index.js.map +1 -1
  74. package/esm/transports/utils.js +56 -51
  75. package/esm/transports/utils.js.map +1 -1
  76. package/esm/transports/xhr.js +51 -62
  77. package/esm/transports/xhr.js.map +1 -1
  78. package/package.json +4 -5
  79. package/types/client.d.ts +42 -11
  80. package/types/client.d.ts.map +1 -1
  81. package/types/eventbuilder.d.ts +10 -12
  82. package/types/eventbuilder.d.ts.map +1 -1
  83. package/types/exports.d.ts +7 -6
  84. package/types/exports.d.ts.map +1 -1
  85. package/types/helpers.d.ts +0 -5
  86. package/types/helpers.d.ts.map +1 -1
  87. package/types/index.d.ts +2 -3
  88. package/types/index.d.ts.map +1 -1
  89. package/types/integrations/breadcrumbs.d.ts +6 -7
  90. package/types/integrations/breadcrumbs.d.ts.map +1 -1
  91. package/types/integrations/dedupe.d.ts.map +1 -1
  92. package/types/integrations/globalhandlers.d.ts.map +1 -1
  93. package/types/integrations/{useragent.d.ts → httpcontext.d.ts} +3 -3
  94. package/types/integrations/httpcontext.d.ts.map +1 -0
  95. package/types/integrations/index.d.ts +1 -1
  96. package/types/integrations/index.d.ts.map +1 -1
  97. package/types/integrations/linkederrors.d.ts +3 -3
  98. package/types/integrations/linkederrors.d.ts.map +1 -1
  99. package/types/sdk.d.ts +5 -5
  100. package/types/sdk.d.ts.map +1 -1
  101. package/types/stack-parsers.d.ts +8 -6
  102. package/types/stack-parsers.d.ts.map +1 -1
  103. package/types/transports/fetch.d.ts +6 -15
  104. package/types/transports/fetch.d.ts.map +1 -1
  105. package/types/transports/index.d.ts +2 -5
  106. package/types/transports/index.d.ts.map +1 -1
  107. package/types/transports/types.d.ts +10 -0
  108. package/types/transports/types.d.ts.map +1 -0
  109. package/types/transports/utils.d.ts.map +1 -1
  110. package/types/transports/xhr.d.ts +6 -10
  111. package/types/transports/xhr.d.ts.map +1 -1
  112. package/cjs/backend.d.ts +0 -39
  113. package/cjs/backend.d.ts.map +0 -1
  114. package/cjs/backend.js +0 -58
  115. package/cjs/backend.js.map +0 -1
  116. package/cjs/client.d.ts +0 -33
  117. package/cjs/client.d.ts.map +0 -1
  118. package/cjs/eventbuilder.d.ts +0 -39
  119. package/cjs/eventbuilder.d.ts.map +0 -1
  120. package/cjs/exports.d.ts +0 -9
  121. package/cjs/exports.d.ts.map +0 -1
  122. package/cjs/flags.d.ts +0 -3
  123. package/cjs/flags.d.ts.map +0 -1
  124. package/cjs/helpers.d.ts +0 -52
  125. package/cjs/helpers.d.ts.map +0 -1
  126. package/cjs/index.d.ts +0 -16
  127. package/cjs/index.d.ts.map +0 -1
  128. package/cjs/integrations/breadcrumbs.d.ts +0 -47
  129. package/cjs/integrations/breadcrumbs.d.ts.map +0 -1
  130. package/cjs/integrations/dedupe.d.ts +0 -21
  131. package/cjs/integrations/dedupe.d.ts.map +0 -1
  132. package/cjs/integrations/globalhandlers.d.ts +0 -30
  133. package/cjs/integrations/globalhandlers.d.ts.map +0 -1
  134. package/cjs/integrations/index.d.ts +0 -7
  135. package/cjs/integrations/index.d.ts.map +0 -1
  136. package/cjs/integrations/linkederrors.d.ts +0 -42
  137. package/cjs/integrations/linkederrors.d.ts.map +0 -1
  138. package/cjs/integrations/trycatch.d.ts +0 -33
  139. package/cjs/integrations/trycatch.d.ts.map +0 -1
  140. package/cjs/integrations/useragent.d.ts +0 -17
  141. package/cjs/integrations/useragent.d.ts.map +0 -1
  142. package/cjs/integrations/useragent.js +0 -42
  143. package/cjs/integrations/useragent.js.map +0 -1
  144. package/cjs/sdk.d.ts +0 -112
  145. package/cjs/sdk.d.ts.map +0 -1
  146. package/cjs/stack-parsers.d.ts +0 -7
  147. package/cjs/stack-parsers.d.ts.map +0 -1
  148. package/cjs/transports/base.d.ts +0 -65
  149. package/cjs/transports/base.d.ts.map +0 -1
  150. package/cjs/transports/base.js +0 -141
  151. package/cjs/transports/base.js.map +0 -1
  152. package/cjs/transports/fetch.d.ts +0 -17
  153. package/cjs/transports/fetch.d.ts.map +0 -1
  154. package/cjs/transports/index.d.ts +0 -6
  155. package/cjs/transports/index.d.ts.map +0 -1
  156. package/cjs/transports/new-fetch.d.ts +0 -10
  157. package/cjs/transports/new-fetch.d.ts.map +0 -1
  158. package/cjs/transports/new-fetch.js +0 -27
  159. package/cjs/transports/new-fetch.js.map +0 -1
  160. package/cjs/transports/new-xhr.d.ts +0 -11
  161. package/cjs/transports/new-xhr.d.ts.map +0 -1
  162. package/cjs/transports/new-xhr.js +0 -46
  163. package/cjs/transports/new-xhr.js.map +0 -1
  164. package/cjs/transports/utils.d.ts +0 -48
  165. package/cjs/transports/utils.d.ts.map +0 -1
  166. package/cjs/transports/xhr.d.ts +0 -11
  167. package/cjs/transports/xhr.d.ts.map +0 -1
  168. package/cjs/version.d.ts +0 -2
  169. package/cjs/version.d.ts.map +0 -1
  170. package/cjs/version.js +0 -4
  171. package/cjs/version.js.map +0 -1
  172. package/esm/backend.d.ts +0 -39
  173. package/esm/backend.d.ts.map +0 -1
  174. package/esm/backend.js +0 -57
  175. package/esm/backend.js.map +0 -1
  176. package/esm/client.d.ts +0 -33
  177. package/esm/client.d.ts.map +0 -1
  178. package/esm/eventbuilder.d.ts +0 -39
  179. package/esm/eventbuilder.d.ts.map +0 -1
  180. package/esm/exports.d.ts +0 -9
  181. package/esm/exports.d.ts.map +0 -1
  182. package/esm/flags.d.ts +0 -3
  183. package/esm/flags.d.ts.map +0 -1
  184. package/esm/helpers.d.ts +0 -52
  185. package/esm/helpers.d.ts.map +0 -1
  186. package/esm/index.d.ts +0 -16
  187. package/esm/index.d.ts.map +0 -1
  188. package/esm/integrations/breadcrumbs.d.ts +0 -47
  189. package/esm/integrations/breadcrumbs.d.ts.map +0 -1
  190. package/esm/integrations/dedupe.d.ts +0 -21
  191. package/esm/integrations/dedupe.d.ts.map +0 -1
  192. package/esm/integrations/globalhandlers.d.ts +0 -30
  193. package/esm/integrations/globalhandlers.d.ts.map +0 -1
  194. package/esm/integrations/index.d.ts +0 -7
  195. package/esm/integrations/index.d.ts.map +0 -1
  196. package/esm/integrations/linkederrors.d.ts +0 -42
  197. package/esm/integrations/linkederrors.d.ts.map +0 -1
  198. package/esm/integrations/trycatch.d.ts +0 -33
  199. package/esm/integrations/trycatch.d.ts.map +0 -1
  200. package/esm/integrations/useragent.d.ts +0 -17
  201. package/esm/integrations/useragent.d.ts.map +0 -1
  202. package/esm/integrations/useragent.js +0 -41
  203. package/esm/integrations/useragent.js.map +0 -1
  204. package/esm/sdk.d.ts +0 -112
  205. package/esm/sdk.d.ts.map +0 -1
  206. package/esm/stack-parsers.d.ts +0 -7
  207. package/esm/stack-parsers.d.ts.map +0 -1
  208. package/esm/transports/base.d.ts +0 -65
  209. package/esm/transports/base.d.ts.map +0 -1
  210. package/esm/transports/base.js +0 -140
  211. package/esm/transports/base.js.map +0 -1
  212. package/esm/transports/fetch.d.ts +0 -17
  213. package/esm/transports/fetch.d.ts.map +0 -1
  214. package/esm/transports/index.d.ts +0 -6
  215. package/esm/transports/index.d.ts.map +0 -1
  216. package/esm/transports/new-fetch.d.ts +0 -10
  217. package/esm/transports/new-fetch.d.ts.map +0 -1
  218. package/esm/transports/new-fetch.js +0 -25
  219. package/esm/transports/new-fetch.js.map +0 -1
  220. package/esm/transports/new-xhr.d.ts +0 -11
  221. package/esm/transports/new-xhr.d.ts.map +0 -1
  222. package/esm/transports/new-xhr.js +0 -44
  223. package/esm/transports/new-xhr.js.map +0 -1
  224. package/esm/transports/utils.d.ts +0 -48
  225. package/esm/transports/utils.d.ts.map +0 -1
  226. package/esm/transports/xhr.d.ts +0 -11
  227. package/esm/transports/xhr.d.ts.map +0 -1
  228. package/esm/version.d.ts +0 -2
  229. package/esm/version.d.ts.map +0 -1
  230. package/esm/version.js +0 -3
  231. package/esm/version.js.map +0 -1
  232. package/types/backend.d.ts +0 -39
  233. package/types/backend.d.ts.map +0 -1
  234. package/types/integrations/useragent.d.ts.map +0 -1
  235. package/types/transports/base.d.ts +0 -65
  236. package/types/transports/base.d.ts.map +0 -1
  237. package/types/transports/new-fetch.d.ts +0 -10
  238. package/types/transports/new-fetch.d.ts.map +0 -1
  239. package/types/transports/new-xhr.d.ts +0 -11
  240. package/types/transports/new-xhr.d.ts.map +0 -1
  241. package/types/version.d.ts +0 -2
  242. package/types/version.d.ts.map +0 -1
@@ -1,59 +1,89 @@
1
- import { __read, __spread } from "tslib";
2
- import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
1
+ import { getCurrentHub, addGlobalEventProcessor } from '@sentry/core';
3
2
  import { isInstanceOf } from '@sentry/utils';
4
- import { exceptionFromError } from '../eventbuilder';
3
+ import { exceptionFromError } from '../eventbuilder.js';
4
+
5
5
  var DEFAULT_KEY = 'cause';
6
6
  var DEFAULT_LIMIT = 5;
7
+
7
8
  /** Adds SDK info to an event. */
8
- var LinkedErrors = /** @class */ (function () {
9
- /**
10
- * @inheritDoc
11
- */
12
- function LinkedErrors(options) {
13
- if (options === void 0) { options = {}; }
14
- /**
15
- * @inheritDoc
16
- */
17
- this.name = LinkedErrors.id;
18
- this._key = options.key || DEFAULT_KEY;
19
- this._limit = options.limit || DEFAULT_LIMIT;
9
+ class LinkedErrors {
10
+ /**
11
+ * @inheritDoc
12
+ */
13
+ static __initStatic() {this.id = 'LinkedErrors';}
14
+
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ __init() {this.name = LinkedErrors.id;}
19
+
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+
24
+
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+
29
+
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ constructor(options = {}) {;LinkedErrors.prototype.__init.call(this);
34
+ this._key = options.key || DEFAULT_KEY;
35
+ this._limit = options.limit || DEFAULT_LIMIT;
36
+ }
37
+
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ setupOnce() {
42
+ var client = getCurrentHub().getClient();
43
+ if (!client) {
44
+ return;
20
45
  }
21
- /**
22
- * @inheritDoc
23
- */
24
- LinkedErrors.prototype.setupOnce = function () {
25
- addGlobalEventProcessor(function (event, hint) {
26
- var self = getCurrentHub().getIntegration(LinkedErrors);
27
- return self ? _handler(self._key, self._limit, event, hint) : event;
28
- });
29
- };
30
- /**
31
- * @inheritDoc
32
- */
33
- LinkedErrors.id = 'LinkedErrors';
34
- return LinkedErrors;
35
- }());
36
- export { LinkedErrors };
46
+ addGlobalEventProcessor((event, hint) => {
47
+ var self = getCurrentHub().getIntegration(LinkedErrors);
48
+ return self ? _handler(client.getOptions().stackParser, self._key, self._limit, event, hint) : event;
49
+ });
50
+ }
51
+ } LinkedErrors.__initStatic();
52
+
37
53
  /**
38
54
  * @inheritDoc
39
55
  */
40
- export function _handler(key, limit, event, hint) {
41
- if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {
42
- return event;
43
- }
44
- var linkedErrors = _walkErrorTree(limit, hint.originalException, key);
45
- event.exception.values = __spread(linkedErrors, event.exception.values);
56
+ function _handler(
57
+ parser,
58
+ key,
59
+ limit,
60
+ event,
61
+ hint,
62
+ ) {
63
+ if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {
46
64
  return event;
65
+ }
66
+ var linkedErrors = _walkErrorTree(parser, limit, hint.originalException , key);
67
+ event.exception.values = [...linkedErrors, ...event.exception.values];
68
+ return event;
47
69
  }
70
+
48
71
  /**
49
72
  * JSDOC
50
73
  */
51
- export function _walkErrorTree(limit, error, key, stack) {
52
- if (stack === void 0) { stack = []; }
53
- if (!isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {
54
- return stack;
55
- }
56
- var exception = exceptionFromError(error[key]);
57
- return _walkErrorTree(limit, error[key], key, __spread([exception], stack));
74
+ function _walkErrorTree(
75
+ parser,
76
+ limit,
77
+ error,
78
+ key,
79
+ stack = [],
80
+ ) {
81
+ if (!isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {
82
+ return stack;
83
+ }
84
+ var exception = exceptionFromError(parser, error[key]);
85
+ return _walkErrorTree(parser, limit, error[key], key, [exception, ...stack]);
58
86
  }
59
- //# sourceMappingURL=linkederrors.js.map
87
+
88
+ export { LinkedErrors, _handler, _walkErrorTree };
89
+ //# sourceMappingURL=linkederrors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"linkederrors.js","sourceRoot":"","sources":["../../../../src/integrations/linkederrors.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,IAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,IAAM,aAAa,GAAG,CAAC,CAAC;AAOxB,iCAAiC;AACjC;IAqBE;;OAEG;IACH,sBAAmB,OAA0C;QAA1C,wBAAA,EAAA,YAA0C;QAlB7D;;WAEG;QACa,SAAI,GAAW,YAAY,CAAC,EAAE,CAAC;QAgB7C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,IAAI,WAAW,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,gCAAS,GAAhB;QACE,uBAAuB,CAAC,UAAC,KAAY,EAAE,IAAgB;YACrD,IAAM,IAAI,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;YAC1D,OAAO,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACtE,CAAC,CAAC,CAAC;IACL,CAAC;IApCD;;OAEG;IACW,eAAE,GAAW,cAAc,CAAC;IAkC5C,mBAAC;CAAA,AAtCD,IAsCC;SAtCY,YAAY;AAwCzB;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,KAAa,EAAE,KAAY,EAAE,IAAgB;IACjF,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,EAAE;QACxG,OAAO,KAAK,CAAC;KACd;IACD,IAAM,YAAY,GAAG,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,iBAAkC,EAAE,GAAG,CAAC,CAAC;IACzF,KAAK,CAAC,SAAS,CAAC,MAAM,YAAO,YAAY,EAAK,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,KAAoB,EAAE,GAAW,EAAE,KAAuB;IAAvB,sBAAA,EAAA,UAAuB;IACtG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,EAAE;QACjE,OAAO,KAAK,CAAC;KACd;IACD,IAAM,SAAS,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,OAAO,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,YAAG,SAAS,GAAK,KAAK,EAAE,CAAC;AACvE,CAAC","sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';\nimport { Event, EventHint, Exception, ExtendedError, Integration } from '@sentry/types';\nimport { isInstanceOf } from '@sentry/utils';\n\nimport { exceptionFromError } from '../eventbuilder';\n\nconst DEFAULT_KEY = 'cause';\nconst DEFAULT_LIMIT = 5;\n\ninterface LinkedErrorsOptions {\n key: string;\n limit: number;\n}\n\n/** Adds SDK info to an event. */\nexport class LinkedErrors implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'LinkedErrors';\n\n /**\n * @inheritDoc\n */\n public readonly name: string = LinkedErrors.id;\n\n /**\n * @inheritDoc\n */\n private readonly _key: LinkedErrorsOptions['key'];\n\n /**\n * @inheritDoc\n */\n private readonly _limit: LinkedErrorsOptions['limit'];\n\n /**\n * @inheritDoc\n */\n public constructor(options: Partial<LinkedErrorsOptions> = {}) {\n this._key = options.key || DEFAULT_KEY;\n this._limit = options.limit || DEFAULT_LIMIT;\n }\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n addGlobalEventProcessor((event: Event, hint?: EventHint) => {\n const self = getCurrentHub().getIntegration(LinkedErrors);\n return self ? _handler(self._key, self._limit, event, hint) : event;\n });\n }\n}\n\n/**\n * @inheritDoc\n */\nexport function _handler(key: string, limit: number, event: Event, hint?: EventHint): Event | null {\n if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {\n return event;\n }\n const linkedErrors = _walkErrorTree(limit, hint.originalException as ExtendedError, key);\n event.exception.values = [...linkedErrors, ...event.exception.values];\n return event;\n}\n\n/**\n * JSDOC\n */\nexport function _walkErrorTree(limit: number, error: ExtendedError, key: string, stack: Exception[] = []): Exception[] {\n if (!isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {\n return stack;\n }\n const exception = exceptionFromError(error[key]);\n return _walkErrorTree(limit, error[key], key, [exception, ...stack]);\n}\n"]}
1
+ {"version":3,"file":"linkederrors.js","sources":["../../../../src/integrations/linkederrors.ts"],"sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';\nimport { Event, EventHint, Exception, ExtendedError, Integration, StackParser } from '@sentry/types';\nimport { isInstanceOf } from '@sentry/utils';\n\nimport { BrowserClient } from '../client';\nimport { exceptionFromError } from '../eventbuilder';\n\nconst DEFAULT_KEY = 'cause';\nconst DEFAULT_LIMIT = 5;\n\ninterface LinkedErrorsOptions {\n key: string;\n limit: number;\n}\n\n/** Adds SDK info to an event. */\nexport class LinkedErrors implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'LinkedErrors';\n\n /**\n * @inheritDoc\n */\n public readonly name: string = LinkedErrors.id;\n\n /**\n * @inheritDoc\n */\n private readonly _key: LinkedErrorsOptions['key'];\n\n /**\n * @inheritDoc\n */\n private readonly _limit: LinkedErrorsOptions['limit'];\n\n /**\n * @inheritDoc\n */\n public constructor(options: Partial<LinkedErrorsOptions> = {}) {\n this._key = options.key || DEFAULT_KEY;\n this._limit = options.limit || DEFAULT_LIMIT;\n }\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n const client = getCurrentHub().getClient<BrowserClient>();\n if (!client) {\n return;\n }\n addGlobalEventProcessor((event: Event, hint?: EventHint) => {\n const self = getCurrentHub().getIntegration(LinkedErrors);\n return self ? _handler(client.getOptions().stackParser, self._key, self._limit, event, hint) : event;\n });\n }\n}\n\n/**\n * @inheritDoc\n */\nexport function _handler(\n parser: StackParser,\n key: string,\n limit: number,\n event: Event,\n hint?: EventHint,\n): Event | null {\n if (!event.exception || !event.exception.values || !hint || !isInstanceOf(hint.originalException, Error)) {\n return event;\n }\n const linkedErrors = _walkErrorTree(parser, limit, hint.originalException as ExtendedError, key);\n event.exception.values = [...linkedErrors, ...event.exception.values];\n return event;\n}\n\n/**\n * JSDOC\n */\nexport function _walkErrorTree(\n parser: StackParser,\n limit: number,\n error: ExtendedError,\n key: string,\n stack: Exception[] = [],\n): Exception[] {\n if (!isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {\n return stack;\n }\n const exception = exceptionFromError(parser, error[key]);\n return _walkErrorTree(parser, limit, error[key], key, [exception, ...stack]);\n}\n"],"names":[],"mappings":";;;;AAOA;AACA;;AAOA;;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;;AAEA;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;;;;"}
@@ -1,236 +1,264 @@
1
- import { __assign } from "tslib";
2
- import { fill, getFunctionName, getGlobalObject, getOriginalFunction } from '@sentry/utils';
3
- import { wrap } from '../helpers';
1
+ import { getGlobalObject, fill, getFunctionName, getOriginalFunction } from '@sentry/utils';
2
+ import { wrap } from '../helpers.js';
3
+
4
4
  var DEFAULT_EVENT_TARGET = [
5
- 'EventTarget',
6
- 'Window',
7
- 'Node',
8
- 'ApplicationCache',
9
- 'AudioTrackList',
10
- 'ChannelMergerNode',
11
- 'CryptoOperation',
12
- 'EventSource',
13
- 'FileReader',
14
- 'HTMLUnknownElement',
15
- 'IDBDatabase',
16
- 'IDBRequest',
17
- 'IDBTransaction',
18
- 'KeyOperation',
19
- 'MediaController',
20
- 'MessagePort',
21
- 'ModalWindow',
22
- 'Notification',
23
- 'SVGElementInstance',
24
- 'Screen',
25
- 'TextTrack',
26
- 'TextTrackCue',
27
- 'TextTrackList',
28
- 'WebSocket',
29
- 'WebSocketWorker',
30
- 'Worker',
31
- 'XMLHttpRequest',
32
- 'XMLHttpRequestEventTarget',
33
- 'XMLHttpRequestUpload',
5
+ 'EventTarget',
6
+ 'Window',
7
+ 'Node',
8
+ 'ApplicationCache',
9
+ 'AudioTrackList',
10
+ 'ChannelMergerNode',
11
+ 'CryptoOperation',
12
+ 'EventSource',
13
+ 'FileReader',
14
+ 'HTMLUnknownElement',
15
+ 'IDBDatabase',
16
+ 'IDBRequest',
17
+ 'IDBTransaction',
18
+ 'KeyOperation',
19
+ 'MediaController',
20
+ 'MessagePort',
21
+ 'ModalWindow',
22
+ 'Notification',
23
+ 'SVGElementInstance',
24
+ 'Screen',
25
+ 'TextTrack',
26
+ 'TextTrackCue',
27
+ 'TextTrackList',
28
+ 'WebSocket',
29
+ 'WebSocketWorker',
30
+ 'Worker',
31
+ 'XMLHttpRequest',
32
+ 'XMLHttpRequestEventTarget',
33
+ 'XMLHttpRequestUpload',
34
34
  ];
35
+
35
36
  /** Wrap timer functions and event targets to catch errors and provide better meta data */
36
- var TryCatch = /** @class */ (function () {
37
- /**
38
- * @inheritDoc
39
- */
40
- function TryCatch(options) {
41
- /**
42
- * @inheritDoc
43
- */
44
- this.name = TryCatch.id;
45
- this._options = __assign({ XMLHttpRequest: true, eventTarget: true, requestAnimationFrame: true, setInterval: true, setTimeout: true }, options);
46
- }
47
- /**
48
- * Wrap timer functions and event targets to catch errors
49
- * and provide better metadata.
50
- */
51
- TryCatch.prototype.setupOnce = function () {
52
- var global = getGlobalObject();
53
- if (this._options.setTimeout) {
54
- fill(global, 'setTimeout', _wrapTimeFunction);
55
- }
56
- if (this._options.setInterval) {
57
- fill(global, 'setInterval', _wrapTimeFunction);
58
- }
59
- if (this._options.requestAnimationFrame) {
60
- fill(global, 'requestAnimationFrame', _wrapRAF);
61
- }
62
- if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {
63
- fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
64
- }
65
- var eventTargetOption = this._options.eventTarget;
66
- if (eventTargetOption) {
67
- var eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;
68
- eventTarget.forEach(_wrapEventTarget);
69
- }
37
+ class TryCatch {
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ static __initStatic() {this.id = 'TryCatch';}
42
+
43
+ /**
44
+ * @inheritDoc
45
+ */
46
+ __init() {this.name = TryCatch.id;}
47
+
48
+ /** JSDoc */
49
+
50
+
51
+ /**
52
+ * @inheritDoc
53
+ */
54
+ constructor(options) {;TryCatch.prototype.__init.call(this);
55
+ this._options = {
56
+ XMLHttpRequest: true,
57
+ eventTarget: true,
58
+ requestAnimationFrame: true,
59
+ setInterval: true,
60
+ setTimeout: true,
61
+ ...options,
70
62
  };
71
- /**
72
- * @inheritDoc
73
- */
74
- TryCatch.id = 'TryCatch';
75
- return TryCatch;
76
- }());
77
- export { TryCatch };
63
+ }
64
+
65
+ /**
66
+ * Wrap timer functions and event targets to catch errors
67
+ * and provide better metadata.
68
+ */
69
+ setupOnce() {
70
+ var global = getGlobalObject();
71
+
72
+ if (this._options.setTimeout) {
73
+ fill(global, 'setTimeout', _wrapTimeFunction);
74
+ }
75
+
76
+ if (this._options.setInterval) {
77
+ fill(global, 'setInterval', _wrapTimeFunction);
78
+ }
79
+
80
+ if (this._options.requestAnimationFrame) {
81
+ fill(global, 'requestAnimationFrame', _wrapRAF);
82
+ }
83
+
84
+ if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {
85
+ fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
86
+ }
87
+
88
+ var eventTargetOption = this._options.eventTarget;
89
+ if (eventTargetOption) {
90
+ var eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;
91
+ eventTarget.forEach(_wrapEventTarget);
92
+ }
93
+ }
94
+ } TryCatch.__initStatic();
95
+
78
96
  /** JSDoc */
79
97
  function _wrapTimeFunction(original) {
80
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
- return function () {
82
- var args = [];
83
- for (var _i = 0; _i < arguments.length; _i++) {
84
- args[_i] = arguments[_i];
85
- }
86
- var originalCallback = args[0];
87
- args[0] = wrap(originalCallback, {
88
- mechanism: {
89
- data: { function: getFunctionName(original) },
90
- handled: true,
91
- type: 'instrument',
92
- },
93
- });
94
- return original.apply(this, args);
95
- };
98
+ return function ( ...args) {
99
+ var originalCallback = args[0];
100
+ args[0] = wrap(originalCallback, {
101
+ mechanism: {
102
+ data: { function: getFunctionName(original) },
103
+ handled: true,
104
+ type: 'instrument',
105
+ },
106
+ });
107
+ return original.apply(this, args);
108
+ };
96
109
  }
110
+
97
111
  /** JSDoc */
98
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
99
112
  function _wrapRAF(original) {
100
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
- return function (callback) {
102
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
113
+ return function ( callback) {
103
114
  return original.apply(this, [
104
- wrap(callback, {
105
- mechanism: {
106
- data: {
107
- function: 'requestAnimationFrame',
108
- handler: getFunctionName(original),
109
- },
110
- handled: true,
111
- type: 'instrument',
112
- },
113
- }),
114
- ]);
115
- };
115
+ wrap(callback, {
116
+ mechanism: {
117
+ data: {
118
+ function: 'requestAnimationFrame',
119
+ handler: getFunctionName(original),
120
+ },
121
+ handled: true,
122
+ type: 'instrument',
123
+ },
124
+ }),
125
+ ]);
126
+ };
116
127
  }
128
+
117
129
  /** JSDoc */
118
130
  function _wrapXHR(originalSend) {
119
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
- return function () {
121
- var args = [];
122
- for (var _i = 0; _i < arguments.length; _i++) {
123
- args[_i] = arguments[_i];
124
- }
125
- // eslint-disable-next-line @typescript-eslint/no-this-alias
131
+ return function ( ...args) {
126
132
  var xhr = this;
127
- var xmlHttpRequestProps = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];
128
- xmlHttpRequestProps.forEach(function (prop) {
129
- if (prop in xhr && typeof xhr[prop] === 'function') {
130
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
+ var xmlHttpRequestProps = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];
134
+
135
+ xmlHttpRequestProps.forEach(prop => {
136
+ if (prop in xhr && typeof xhr[prop] === 'function') {
131
137
  fill(xhr, prop, function (original) {
132
- var wrapOptions = {
133
- mechanism: {
134
- data: {
135
- function: prop,
136
- handler: getFunctionName(original),
137
- },
138
- handled: true,
139
- type: 'instrument',
140
- },
141
- };
142
- // If Instrument integration has been called before TryCatch, get the name of original function
143
- var originalFunction = getOriginalFunction(original);
144
- if (originalFunction) {
145
- wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);
146
- }
147
- // Otherwise wrap directly
148
- return wrap(original, wrapOptions);
149
- });
150
- }
138
+ var wrapOptions = {
139
+ mechanism: {
140
+ data: {
141
+ function: prop,
142
+ handler: getFunctionName(original),
143
+ },
144
+ handled: true,
145
+ type: 'instrument',
146
+ },
147
+ };
148
+
149
+ // If Instrument integration has been called before TryCatch, get the name of original function
150
+ var originalFunction = getOriginalFunction(original);
151
+ if (originalFunction) {
152
+ wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);
153
+ }
154
+
155
+ // Otherwise wrap directly
156
+ return wrap(original, wrapOptions);
151
157
  });
152
- return originalSend.apply(this, args);
153
- };
158
+ }
159
+ });
160
+
161
+ return originalSend.apply(this, args);
162
+ };
154
163
  }
164
+
155
165
  /** JSDoc */
156
166
  function _wrapEventTarget(target) {
157
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
158
- var global = getGlobalObject();
159
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
167
+ var global = getGlobalObject() ;
160
168
  var proto = global[target] && global[target].prototype;
161
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
169
+
162
170
  if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
163
- return;
164
- }
165
- fill(proto, 'addEventListener', function (original) {
166
- return function (eventName, fn, options) {
167
- try {
168
- if (typeof fn.handleEvent === 'function') {
169
- fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
170
- mechanism: {
171
- data: {
172
- function: 'handleEvent',
173
- handler: getFunctionName(fn),
174
- target: target,
175
- },
176
- handled: true,
177
- type: 'instrument',
178
- },
179
- });
180
- }
181
- }
182
- catch (err) {
183
- // can sometimes get 'Permission denied to access property "handle Event'
184
- }
185
- return original.apply(this, [
186
- eventName,
187
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
188
- wrap(fn, {
189
- mechanism: {
190
- data: {
191
- function: 'addEventListener',
192
- handler: getFunctionName(fn),
193
- target: target,
194
- },
195
- handled: true,
196
- type: 'instrument',
197
- },
198
- }),
199
- options,
200
- ]);
201
- };
202
- });
203
- fill(proto, 'removeEventListener', function (originalRemoveEventListener) {
204
- return function (eventName, fn, options) {
205
- /**
206
- * There are 2 possible scenarios here:
207
- *
208
- * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified
209
- * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function
210
- * as a pass-through, and call original `removeEventListener` with it.
211
- *
212
- * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using
213
- * our wrapped version of `addEventListener`, which internally calls `wrap` helper.
214
- * This helper "wraps" whole callback inside a try/catch statement, and attached appropriate metadata to it,
215
- * in order for us to make a distinction between wrapped/non-wrapped functions possible.
216
- * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.
217
- *
218
- * When someone adds a handler prior to initialization, and then do it again, but after,
219
- * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible
220
- * to get rid of the initial handler and it'd stick there forever.
221
- */
222
- var wrappedEventHandler = fn;
223
- try {
224
- var originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;
225
- if (originalEventHandler) {
226
- originalRemoveEventListener.call(this, eventName, originalEventHandler, options);
227
- }
228
- }
229
- catch (e) {
230
- // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments
231
- }
232
- return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);
233
- };
234
- });
171
+ return;
172
+ }
173
+
174
+ fill(proto, 'addEventListener', function (original)
175
+
176
+ {
177
+ return function (
178
+
179
+ eventName,
180
+ fn,
181
+ options,
182
+ ) {
183
+ try {
184
+ if (typeof fn.handleEvent === 'function') {
185
+ fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
186
+ mechanism: {
187
+ data: {
188
+ function: 'handleEvent',
189
+ handler: getFunctionName(fn),
190
+ target,
191
+ },
192
+ handled: true,
193
+ type: 'instrument',
194
+ },
195
+ });
196
+ }
197
+ } catch (err) {
198
+ // can sometimes get 'Permission denied to access property "handle Event'
199
+ }
200
+
201
+ return original.apply(this, [
202
+ eventName,
203
+ wrap(fn , {
204
+ mechanism: {
205
+ data: {
206
+ function: 'addEventListener',
207
+ handler: getFunctionName(fn),
208
+ target,
209
+ },
210
+ handled: true,
211
+ type: 'instrument',
212
+ },
213
+ }),
214
+ options,
215
+ ]);
216
+ };
217
+ });
218
+
219
+ fill(
220
+ proto,
221
+ 'removeEventListener',
222
+ function (
223
+ originalRemoveEventListener,
224
+ ) {
225
+ return function (
226
+
227
+ eventName,
228
+ fn,
229
+ options,
230
+ ) {
231
+ /**
232
+ * There are 2 possible scenarios here:
233
+ *
234
+ * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified
235
+ * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function
236
+ * as a pass-through, and call original `removeEventListener` with it.
237
+ *
238
+ * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using
239
+ * our wrapped version of `addEventListener`, which internally calls `wrap` helper.
240
+ * This helper "wraps" whole callback inside a try/catch statement, and attached appropriate metadata to it,
241
+ * in order for us to make a distinction between wrapped/non-wrapped functions possible.
242
+ * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.
243
+ *
244
+ * When someone adds a handler prior to initialization, and then do it again, but after,
245
+ * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible
246
+ * to get rid of the initial handler and it'd stick there forever.
247
+ */
248
+ var wrappedEventHandler = fn ;
249
+ try {
250
+ var originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;
251
+ if (originalEventHandler) {
252
+ originalRemoveEventListener.call(this, eventName, originalEventHandler, options);
253
+ }
254
+ } catch (e) {
255
+ // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments
256
+ }
257
+ return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);
258
+ };
259
+ },
260
+ );
235
261
  }
236
- //# sourceMappingURL=trycatch.js.map
262
+
263
+ export { TryCatch };
264
+ //# sourceMappingURL=trycatch.js.map