@sentry/browser 7.0.0-beta.0 → 7.0.0-rc.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 (190) hide show
  1. package/README.md +2 -3
  2. package/cjs/client.js +125 -102
  3. package/cjs/client.js.map +1 -1
  4. package/cjs/eventbuilder.js +225 -165
  5. package/cjs/eventbuilder.js.map +1 -1
  6. package/cjs/exports.js +55 -59
  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 +125 -97
  11. package/cjs/helpers.js.map +1 -1
  12. package/cjs/index.js +77 -10
  13. package/cjs/index.js.map +1 -1
  14. package/cjs/integrations/breadcrumbs.js +222 -174
  15. package/cjs/integrations/breadcrumbs.js.map +1 -1
  16. package/cjs/integrations/dedupe.js +184 -142
  17. package/cjs/integrations/dedupe.js.map +1 -1
  18. package/cjs/integrations/globalhandlers.js +211 -170
  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 +81 -50
  25. package/cjs/integrations/linkederrors.js.map +1 -1
  26. package/cjs/integrations/trycatch.js +252 -208
  27. package/cjs/integrations/trycatch.js.map +1 -1
  28. package/cjs/sdk.js +166 -125
  29. package/cjs/sdk.js.map +1 -1
  30. package/cjs/stack-parsers.js +143 -93
  31. package/cjs/stack-parsers.js.map +1 -1
  32. package/cjs/transports/fetch.js +30 -15
  33. package/cjs/transports/fetch.js.map +1 -1
  34. package/cjs/transports/index.js +10 -6
  35. package/cjs/transports/index.js.map +1 -1
  36. package/cjs/transports/utils.js +56 -52
  37. package/cjs/transports/utils.js.map +1 -1
  38. package/cjs/transports/xhr.js +40 -30
  39. package/cjs/transports/xhr.js.map +1 -1
  40. package/esm/client.js +124 -101
  41. package/esm/client.js.map +1 -1
  42. package/esm/eventbuilder.js +218 -158
  43. package/esm/eventbuilder.js.map +1 -1
  44. package/esm/exports.js +12 -8
  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 +124 -96
  49. package/esm/helpers.js.map +1 -1
  50. package/esm/index.js +27 -7
  51. package/esm/index.js.map +1 -1
  52. package/esm/integrations/breadcrumbs.js +218 -171
  53. package/esm/integrations/breadcrumbs.js.map +1 -1
  54. package/esm/integrations/dedupe.js +181 -139
  55. package/esm/integrations/dedupe.js.map +1 -1
  56. package/esm/integrations/globalhandlers.js +208 -167
  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 +77 -46
  63. package/esm/integrations/linkederrors.js.map +1 -1
  64. package/esm/integrations/trycatch.js +249 -205
  65. package/esm/integrations/trycatch.js.map +1 -1
  66. package/esm/sdk.js +163 -123
  67. package/esm/sdk.js.map +1 -1
  68. package/esm/stack-parsers.js +134 -91
  69. package/esm/stack-parsers.js.map +1 -1
  70. package/esm/transports/fetch.js +28 -13
  71. package/esm/transports/fetch.js.map +1 -1
  72. package/esm/transports/index.js +3 -3
  73. package/esm/transports/index.js.map +1 -1
  74. package/esm/transports/utils.js +55 -51
  75. package/esm/transports/utils.js.map +1 -1
  76. package/esm/transports/xhr.js +38 -28
  77. package/esm/transports/xhr.js.map +1 -1
  78. package/package.json +4 -4
  79. package/types/client.d.ts +5 -4
  80. package/types/client.d.ts.map +1 -1
  81. package/types/exports.d.ts +3 -4
  82. package/types/exports.d.ts.map +1 -1
  83. package/types/helpers.d.ts +2 -1
  84. package/types/helpers.d.ts.map +1 -1
  85. package/types/index.d.ts +1 -1
  86. package/types/integrations/{useragent.d.ts → httpcontext.d.ts} +3 -3
  87. package/types/integrations/httpcontext.d.ts.map +1 -0
  88. package/types/integrations/index.d.ts +1 -1
  89. package/types/integrations/index.d.ts.map +1 -1
  90. package/types/sdk.d.ts +2 -2
  91. package/types/sdk.d.ts.map +1 -1
  92. package/types/transports/fetch.d.ts +3 -5
  93. package/types/transports/fetch.d.ts.map +1 -1
  94. package/types/transports/types.d.ts +10 -0
  95. package/types/transports/types.d.ts.map +1 -0
  96. package/types/transports/utils.d.ts +1 -1
  97. package/types/transports/utils.d.ts.map +1 -1
  98. package/types/transports/xhr.d.ts +3 -7
  99. package/types/transports/xhr.d.ts.map +1 -1
  100. package/cjs/client.d.ts +0 -63
  101. package/cjs/client.d.ts.map +0 -1
  102. package/cjs/eventbuilder.d.ts +0 -37
  103. package/cjs/eventbuilder.d.ts.map +0 -1
  104. package/cjs/exports.d.ts +0 -11
  105. package/cjs/exports.d.ts.map +0 -1
  106. package/cjs/flags.d.ts +0 -3
  107. package/cjs/flags.d.ts.map +0 -1
  108. package/cjs/helpers.d.ts +0 -47
  109. package/cjs/helpers.d.ts.map +0 -1
  110. package/cjs/index.d.ts +0 -15
  111. package/cjs/index.d.ts.map +0 -1
  112. package/cjs/integrations/breadcrumbs.d.ts +0 -46
  113. package/cjs/integrations/breadcrumbs.d.ts.map +0 -1
  114. package/cjs/integrations/dedupe.d.ts +0 -21
  115. package/cjs/integrations/dedupe.d.ts.map +0 -1
  116. package/cjs/integrations/globalhandlers.d.ts +0 -30
  117. package/cjs/integrations/globalhandlers.d.ts.map +0 -1
  118. package/cjs/integrations/index.d.ts +0 -7
  119. package/cjs/integrations/index.d.ts.map +0 -1
  120. package/cjs/integrations/linkederrors.d.ts +0 -42
  121. package/cjs/integrations/linkederrors.d.ts.map +0 -1
  122. package/cjs/integrations/trycatch.d.ts +0 -33
  123. package/cjs/integrations/trycatch.d.ts.map +0 -1
  124. package/cjs/integrations/useragent.d.ts +0 -17
  125. package/cjs/integrations/useragent.d.ts.map +0 -1
  126. package/cjs/integrations/useragent.js +0 -40
  127. package/cjs/integrations/useragent.js.map +0 -1
  128. package/cjs/sdk.d.ts +0 -112
  129. package/cjs/sdk.d.ts.map +0 -1
  130. package/cjs/stack-parsers.d.ts +0 -9
  131. package/cjs/stack-parsers.d.ts.map +0 -1
  132. package/cjs/transports/fetch.d.ts +0 -10
  133. package/cjs/transports/fetch.d.ts.map +0 -1
  134. package/cjs/transports/index.d.ts +0 -3
  135. package/cjs/transports/index.d.ts.map +0 -1
  136. package/cjs/transports/utils.d.ts +0 -48
  137. package/cjs/transports/utils.d.ts.map +0 -1
  138. package/cjs/transports/xhr.d.ts +0 -11
  139. package/cjs/transports/xhr.d.ts.map +0 -1
  140. package/cjs/version.d.ts +0 -2
  141. package/cjs/version.d.ts.map +0 -1
  142. package/cjs/version.js +0 -4
  143. package/cjs/version.js.map +0 -1
  144. package/esm/client.d.ts +0 -63
  145. package/esm/client.d.ts.map +0 -1
  146. package/esm/eventbuilder.d.ts +0 -37
  147. package/esm/eventbuilder.d.ts.map +0 -1
  148. package/esm/exports.d.ts +0 -11
  149. package/esm/exports.d.ts.map +0 -1
  150. package/esm/flags.d.ts +0 -3
  151. package/esm/flags.d.ts.map +0 -1
  152. package/esm/helpers.d.ts +0 -47
  153. package/esm/helpers.d.ts.map +0 -1
  154. package/esm/index.d.ts +0 -15
  155. package/esm/index.d.ts.map +0 -1
  156. package/esm/integrations/breadcrumbs.d.ts +0 -46
  157. package/esm/integrations/breadcrumbs.d.ts.map +0 -1
  158. package/esm/integrations/dedupe.d.ts +0 -21
  159. package/esm/integrations/dedupe.d.ts.map +0 -1
  160. package/esm/integrations/globalhandlers.d.ts +0 -30
  161. package/esm/integrations/globalhandlers.d.ts.map +0 -1
  162. package/esm/integrations/index.d.ts +0 -7
  163. package/esm/integrations/index.d.ts.map +0 -1
  164. package/esm/integrations/linkederrors.d.ts +0 -42
  165. package/esm/integrations/linkederrors.d.ts.map +0 -1
  166. package/esm/integrations/trycatch.d.ts +0 -33
  167. package/esm/integrations/trycatch.d.ts.map +0 -1
  168. package/esm/integrations/useragent.d.ts +0 -17
  169. package/esm/integrations/useragent.d.ts.map +0 -1
  170. package/esm/integrations/useragent.js +0 -38
  171. package/esm/integrations/useragent.js.map +0 -1
  172. package/esm/sdk.d.ts +0 -112
  173. package/esm/sdk.d.ts.map +0 -1
  174. package/esm/stack-parsers.d.ts +0 -9
  175. package/esm/stack-parsers.d.ts.map +0 -1
  176. package/esm/transports/fetch.d.ts +0 -10
  177. package/esm/transports/fetch.d.ts.map +0 -1
  178. package/esm/transports/index.d.ts +0 -3
  179. package/esm/transports/index.d.ts.map +0 -1
  180. package/esm/transports/utils.d.ts +0 -48
  181. package/esm/transports/utils.d.ts.map +0 -1
  182. package/esm/transports/xhr.d.ts +0 -11
  183. package/esm/transports/xhr.d.ts.map +0 -1
  184. package/esm/version.d.ts +0 -2
  185. package/esm/version.d.ts.map +0 -1
  186. package/esm/version.js +0 -3
  187. package/esm/version.js.map +0 -1
  188. package/types/integrations/useragent.d.ts.map +0 -1
  189. package/types/version.d.ts +0 -2
  190. package/types/version.d.ts.map +0 -1
@@ -1,62 +1,93 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const core_1 = require("@sentry/core");
3
- const utils_1 = require("@sentry/utils");
4
- const eventbuilder_1 = require("../eventbuilder");
5
- const DEFAULT_KEY = 'cause';
6
- const DEFAULT_LIMIT = 5;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ var core = require('@sentry/core');
4
+ var utils = require('@sentry/utils');
5
+ var eventbuilder = require('../eventbuilder.js');
6
+
7
+ var DEFAULT_KEY = 'cause';
8
+ var DEFAULT_LIMIT = 5;
9
+
7
10
  /** Adds SDK info to an event. */
8
- class LinkedErrors {
9
- /**
10
- * @inheritDoc
11
- */
12
- constructor(options = {}) {
13
- /**
14
- * @inheritDoc
15
- */
16
- this.name = LinkedErrors.id;
17
- this._key = options.key || DEFAULT_KEY;
18
- this._limit = options.limit || DEFAULT_LIMIT;
11
+ class LinkedErrors {
12
+ /**
13
+ * @inheritDoc
14
+ */
15
+ static __initStatic() {this.id = 'LinkedErrors';}
16
+
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ __init() {this.name = LinkedErrors.id;}
21
+
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+
26
+
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+
31
+
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ constructor(options = {}) {;LinkedErrors.prototype.__init.call(this);
36
+ this._key = options.key || DEFAULT_KEY;
37
+ this._limit = options.limit || DEFAULT_LIMIT;
38
+ }
39
+
40
+ /**
41
+ * @inheritDoc
42
+ */
43
+ setupOnce() {
44
+ var client = core.getCurrentHub().getClient();
45
+ if (!client) {
46
+ return;
19
47
  }
20
- /**
21
- * @inheritDoc
22
- */
23
- setupOnce() {
24
- const client = core_1.getCurrentHub().getClient();
25
- if (!client) {
26
- return;
27
- }
28
- core_1.addGlobalEventProcessor((event, hint) => {
29
- const self = core_1.getCurrentHub().getIntegration(LinkedErrors);
30
- return self ? _handler(client.getOptions().stackParser, self._key, self._limit, event, hint) : event;
31
- });
32
- }
33
- }
34
- exports.LinkedErrors = LinkedErrors;
35
- /**
36
- * @inheritDoc
37
- */
38
- LinkedErrors.id = 'LinkedErrors';
48
+ core.addGlobalEventProcessor((event, hint) => {
49
+ var self = core.getCurrentHub().getIntegration(LinkedErrors);
50
+ return self ? _handler(client.getOptions().stackParser, self._key, self._limit, event, hint) : event;
51
+ });
52
+ }
53
+ } LinkedErrors.__initStatic();
54
+
39
55
  /**
40
56
  * @inheritDoc
41
57
  */
42
- function _handler(parser, key, limit, event, hint) {
43
- if (!event.exception || !event.exception.values || !hint || !utils_1.isInstanceOf(hint.originalException, Error)) {
44
- return event;
45
- }
46
- const linkedErrors = _walkErrorTree(parser, limit, hint.originalException, key);
47
- event.exception.values = [...linkedErrors, ...event.exception.values];
58
+ function _handler(
59
+ parser,
60
+ key,
61
+ limit,
62
+ event,
63
+ hint,
64
+ ) {
65
+ if (!event.exception || !event.exception.values || !hint || !utils.isInstanceOf(hint.originalException, Error)) {
48
66
  return event;
67
+ }
68
+ var linkedErrors = _walkErrorTree(parser, limit, hint.originalException , key);
69
+ event.exception.values = [...linkedErrors, ...event.exception.values];
70
+ return event;
49
71
  }
50
- exports._handler = _handler;
72
+
51
73
  /**
52
74
  * JSDOC
53
75
  */
54
- function _walkErrorTree(parser, limit, error, key, stack = []) {
55
- if (!utils_1.isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {
56
- return stack;
57
- }
58
- const exception = eventbuilder_1.exceptionFromError(parser, error[key]);
59
- return _walkErrorTree(parser, limit, error[key], key, [exception, ...stack]);
76
+ function _walkErrorTree(
77
+ parser,
78
+ limit,
79
+ error,
80
+ key,
81
+ stack = [],
82
+ ) {
83
+ if (!utils.isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {
84
+ return stack;
85
+ }
86
+ var exception = eventbuilder.exceptionFromError(parser, error[key]);
87
+ return _walkErrorTree(parser, limit, error[key], key, [exception, ...stack]);
60
88
  }
89
+
90
+ exports.LinkedErrors = LinkedErrors;
91
+ exports._handler = _handler;
61
92
  exports._walkErrorTree = _walkErrorTree;
62
- //# sourceMappingURL=linkederrors.js.map
93
+ //# sourceMappingURL=linkederrors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"linkederrors.js","sourceRoot":"","sources":["../../../../src/integrations/linkederrors.ts"],"names":[],"mappings":";AAAA,uCAAsE;AAEtE,yCAA6C;AAG7C,kDAAqD;AAErD,MAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,MAAM,aAAa,GAAG,CAAC,CAAC;AAOxB,iCAAiC;AACjC,MAAa,YAAY;IAqBvB;;OAEG;IACH,YAAmB,UAAwC,EAAE;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,SAAS;QACd,MAAM,MAAM,GAAG,oBAAa,EAAE,CAAC,SAAS,EAAiB,CAAC;QAC1D,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QACD,8BAAuB,CAAC,CAAC,KAAY,EAAE,IAAgB,EAAE,EAAE;YACzD,MAAM,IAAI,GAAG,oBAAa,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;YAC1D,OAAO,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACvG,CAAC,CAAC,CAAC;IACL,CAAC;;AAzCH,oCA0CC;AAzCC;;GAEG;AACW,eAAE,GAAW,cAAc,CAAC;AAwC5C;;GAEG;AACH,SAAgB,QAAQ,CACtB,MAAmB,EACnB,GAAW,EACX,KAAa,EACb,KAAY,EACZ,IAAgB;IAEhB,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,IAAI,CAAC,oBAAY,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,EAAE;QACxG,OAAO,KAAK,CAAC;KACd;IACD,MAAM,YAAY,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,iBAAkC,EAAE,GAAG,CAAC,CAAC;IACjG,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC;AACf,CAAC;AAbD,4BAaC;AAED;;GAEG;AACH,SAAgB,cAAc,CAC5B,MAAmB,EACnB,KAAa,EACb,KAAoB,EACpB,GAAW,EACX,QAAqB,EAAE;IAEvB,IAAI,CAAC,oBAAY,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,EAAE;QACjE,OAAO,KAAK,CAAC;KACd;IACD,MAAM,SAAS,GAAG,iCAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,OAAO,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;AAC/E,CAAC;AAZD,wCAYC","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"]}
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,227 +1,271 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- const utils_1 = require("@sentry/utils");
3
- const helpers_1 = require("../helpers");
4
- const 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',
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ var utils = require('@sentry/utils');
4
+ var helpers = require('../helpers.js');
5
+
6
+ var DEFAULT_EVENT_TARGET = [
7
+ 'EventTarget',
8
+ 'Window',
9
+ 'Node',
10
+ 'ApplicationCache',
11
+ 'AudioTrackList',
12
+ 'ChannelMergerNode',
13
+ 'CryptoOperation',
14
+ 'EventSource',
15
+ 'FileReader',
16
+ 'HTMLUnknownElement',
17
+ 'IDBDatabase',
18
+ 'IDBRequest',
19
+ 'IDBTransaction',
20
+ 'KeyOperation',
21
+ 'MediaController',
22
+ 'MessagePort',
23
+ 'ModalWindow',
24
+ 'Notification',
25
+ 'SVGElementInstance',
26
+ 'Screen',
27
+ 'TextTrack',
28
+ 'TextTrackCue',
29
+ 'TextTrackList',
30
+ 'WebSocket',
31
+ 'WebSocketWorker',
32
+ 'Worker',
33
+ 'XMLHttpRequest',
34
+ 'XMLHttpRequestEventTarget',
35
+ 'XMLHttpRequestUpload',
34
36
  ];
37
+
35
38
  /** Wrap timer functions and event targets to catch errors and provide better meta data */
36
- class TryCatch {
37
- /**
38
- * @inheritDoc
39
- */
40
- constructor(options) {
41
- /**
42
- * @inheritDoc
43
- */
44
- this.name = TryCatch.id;
45
- this._options = Object.assign({ XMLHttpRequest: true, eventTarget: true, requestAnimationFrame: true, setInterval: true, setTimeout: true }, options);
39
+ class TryCatch {
40
+ /**
41
+ * @inheritDoc
42
+ */
43
+ static __initStatic() {this.id = 'TryCatch';}
44
+
45
+ /**
46
+ * @inheritDoc
47
+ */
48
+ __init() {this.name = TryCatch.id;}
49
+
50
+ /** JSDoc */
51
+
52
+
53
+ /**
54
+ * @inheritDoc
55
+ */
56
+ constructor(options) {;TryCatch.prototype.__init.call(this);
57
+ this._options = {
58
+ XMLHttpRequest: true,
59
+ eventTarget: true,
60
+ requestAnimationFrame: true,
61
+ setInterval: true,
62
+ setTimeout: true,
63
+ ...options,
64
+ };
65
+ }
66
+
67
+ /**
68
+ * Wrap timer functions and event targets to catch errors
69
+ * and provide better metadata.
70
+ */
71
+ setupOnce() {
72
+ var global = utils.getGlobalObject();
73
+
74
+ if (this._options.setTimeout) {
75
+ utils.fill(global, 'setTimeout', _wrapTimeFunction);
46
76
  }
47
- /**
48
- * Wrap timer functions and event targets to catch errors
49
- * and provide better metadata.
50
- */
51
- setupOnce() {
52
- const global = utils_1.getGlobalObject();
53
- if (this._options.setTimeout) {
54
- utils_1.fill(global, 'setTimeout', _wrapTimeFunction);
55
- }
56
- if (this._options.setInterval) {
57
- utils_1.fill(global, 'setInterval', _wrapTimeFunction);
58
- }
59
- if (this._options.requestAnimationFrame) {
60
- utils_1.fill(global, 'requestAnimationFrame', _wrapRAF);
61
- }
62
- if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {
63
- utils_1.fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
64
- }
65
- const eventTargetOption = this._options.eventTarget;
66
- if (eventTargetOption) {
67
- const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;
68
- eventTarget.forEach(_wrapEventTarget);
69
- }
77
+
78
+ if (this._options.setInterval) {
79
+ utils.fill(global, 'setInterval', _wrapTimeFunction);
70
80
  }
71
- }
72
- exports.TryCatch = TryCatch;
73
- /**
74
- * @inheritDoc
75
- */
76
- TryCatch.id = 'TryCatch';
81
+
82
+ if (this._options.requestAnimationFrame) {
83
+ utils.fill(global, 'requestAnimationFrame', _wrapRAF);
84
+ }
85
+
86
+ if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {
87
+ utils.fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
88
+ }
89
+
90
+ var eventTargetOption = this._options.eventTarget;
91
+ if (eventTargetOption) {
92
+ var eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;
93
+ eventTarget.forEach(_wrapEventTarget);
94
+ }
95
+ }
96
+ } TryCatch.__initStatic();
97
+
77
98
  /** JSDoc */
78
99
  function _wrapTimeFunction(original) {
79
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
- return function (...args) {
81
- const originalCallback = args[0];
82
- args[0] = helpers_1.wrap(originalCallback, {
83
- mechanism: {
84
- data: { function: utils_1.getFunctionName(original) },
85
- handled: true,
86
- type: 'instrument',
87
- },
88
- });
89
- return original.apply(this, args);
90
- };
100
+ return function ( ...args) {
101
+ var originalCallback = args[0];
102
+ args[0] = helpers.wrap(originalCallback, {
103
+ mechanism: {
104
+ data: { function: utils.getFunctionName(original) },
105
+ handled: true,
106
+ type: 'instrument',
107
+ },
108
+ });
109
+ return original.apply(this, args);
110
+ };
91
111
  }
112
+
92
113
  /** JSDoc */
93
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
114
  function _wrapRAF(original) {
95
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
- return function (callback) {
97
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
115
+ return function ( callback) {
98
116
  return original.apply(this, [
99
- helpers_1.wrap(callback, {
100
- mechanism: {
101
- data: {
102
- function: 'requestAnimationFrame',
103
- handler: utils_1.getFunctionName(original),
104
- },
105
- handled: true,
106
- type: 'instrument',
107
- },
108
- }),
109
- ]);
110
- };
117
+ helpers.wrap(callback, {
118
+ mechanism: {
119
+ data: {
120
+ function: 'requestAnimationFrame',
121
+ handler: utils.getFunctionName(original),
122
+ },
123
+ handled: true,
124
+ type: 'instrument',
125
+ },
126
+ }),
127
+ ]);
128
+ };
111
129
  }
130
+
112
131
  /** JSDoc */
113
132
  function _wrapXHR(originalSend) {
114
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
- return function (...args) {
116
- // eslint-disable-next-line @typescript-eslint/no-this-alias
117
- const xhr = this;
118
- const xmlHttpRequestProps = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];
119
- xmlHttpRequestProps.forEach(prop => {
120
- if (prop in xhr && typeof xhr[prop] === 'function') {
121
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
122
- utils_1.fill(xhr, prop, function (original) {
123
- const wrapOptions = {
124
- mechanism: {
125
- data: {
126
- function: prop,
127
- handler: utils_1.getFunctionName(original),
128
- },
129
- handled: true,
130
- type: 'instrument',
131
- },
132
- };
133
- // If Instrument integration has been called before TryCatch, get the name of original function
134
- const originalFunction = utils_1.getOriginalFunction(original);
135
- if (originalFunction) {
136
- wrapOptions.mechanism.data.handler = utils_1.getFunctionName(originalFunction);
137
- }
138
- // Otherwise wrap directly
139
- return helpers_1.wrap(original, wrapOptions);
140
- });
141
- }
133
+ return function ( ...args) {
134
+ var xhr = this;
135
+ var xmlHttpRequestProps = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];
136
+
137
+ xmlHttpRequestProps.forEach(prop => {
138
+ if (prop in xhr && typeof xhr[prop] === 'function') {
139
+ utils.fill(xhr, prop, function (original) {
140
+ var wrapOptions = {
141
+ mechanism: {
142
+ data: {
143
+ function: prop,
144
+ handler: utils.getFunctionName(original),
145
+ },
146
+ handled: true,
147
+ type: 'instrument',
148
+ },
149
+ };
150
+
151
+ // If Instrument integration has been called before TryCatch, get the name of original function
152
+ var originalFunction = utils.getOriginalFunction(original);
153
+ if (originalFunction) {
154
+ wrapOptions.mechanism.data.handler = utils.getFunctionName(originalFunction);
155
+ }
156
+
157
+ // Otherwise wrap directly
158
+ return helpers.wrap(original, wrapOptions);
142
159
  });
143
- return originalSend.apply(this, args);
144
- };
160
+ }
161
+ });
162
+
163
+ return originalSend.apply(this, args);
164
+ };
145
165
  }
166
+
146
167
  /** JSDoc */
147
168
  function _wrapEventTarget(target) {
148
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
149
- const global = utils_1.getGlobalObject();
150
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
151
- const proto = global[target] && global[target].prototype;
152
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
169
+ var global = utils.getGlobalObject() ;
170
+ var proto = global[target] && global[target].prototype;
171
+
153
172
  if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
154
- return;
155
- }
156
- utils_1.fill(proto, 'addEventListener', function (original) {
157
- return function (eventName, fn, options) {
158
- try {
159
- if (typeof fn.handleEvent === 'function') {
160
- fn.handleEvent = helpers_1.wrap(fn.handleEvent.bind(fn), {
161
- mechanism: {
162
- data: {
163
- function: 'handleEvent',
164
- handler: utils_1.getFunctionName(fn),
165
- target,
166
- },
167
- handled: true,
168
- type: 'instrument',
169
- },
170
- });
171
- }
172
- }
173
- catch (err) {
174
- // can sometimes get 'Permission denied to access property "handle Event'
175
- }
176
- return original.apply(this, [
177
- eventName,
178
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
179
- helpers_1.wrap(fn, {
180
- mechanism: {
181
- data: {
182
- function: 'addEventListener',
183
- handler: utils_1.getFunctionName(fn),
184
- target,
185
- },
186
- handled: true,
187
- type: 'instrument',
188
- },
189
- }),
190
- options,
191
- ]);
192
- };
193
- });
194
- utils_1.fill(proto, 'removeEventListener', function (originalRemoveEventListener) {
195
- return function (eventName, fn, options) {
196
- /**
197
- * There are 2 possible scenarios here:
198
- *
199
- * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified
200
- * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function
201
- * as a pass-through, and call original `removeEventListener` with it.
202
- *
203
- * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using
204
- * our wrapped version of `addEventListener`, which internally calls `wrap` helper.
205
- * This helper "wraps" whole callback inside a try/catch statement, and attached appropriate metadata to it,
206
- * in order for us to make a distinction between wrapped/non-wrapped functions possible.
207
- * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.
208
- *
209
- * When someone adds a handler prior to initialization, and then do it again, but after,
210
- * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible
211
- * to get rid of the initial handler and it'd stick there forever.
212
- */
213
- const wrappedEventHandler = fn;
214
- try {
215
- const originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;
216
- if (originalEventHandler) {
217
- originalRemoveEventListener.call(this, eventName, originalEventHandler, options);
218
- }
219
- }
220
- catch (e) {
221
- // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments
222
- }
223
- return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);
224
- };
225
- });
173
+ return;
174
+ }
175
+
176
+ utils.fill(proto, 'addEventListener', function (original)
177
+
178
+ {
179
+ return function (
180
+
181
+ eventName,
182
+ fn,
183
+ options,
184
+ ) {
185
+ try {
186
+ if (typeof fn.handleEvent === 'function') {
187
+ // ESlint disable explanation:
188
+ // First, it is generally safe to call `wrap` with an unbound function. Furthermore, using `.bind()` would
189
+ // introduce a bug here, because bind returns a new function that doesn't have our
190
+ // flags(like __sentry_original__) attached. `wrap` checks for those flags to avoid unnecessary wrapping.
191
+ // Without those flags, every call to addEventListener wraps the function again, causing a memory leak.
192
+ fn.handleEvent = helpers.wrap(fn.handleEvent, {
193
+ mechanism: {
194
+ data: {
195
+ function: 'handleEvent',
196
+ handler: utils.getFunctionName(fn),
197
+ target,
198
+ },
199
+ handled: true,
200
+ type: 'instrument',
201
+ },
202
+ });
203
+ }
204
+ } catch (err) {
205
+ // can sometimes get 'Permission denied to access property "handle Event'
206
+ }
207
+
208
+ return original.apply(this, [
209
+ eventName,
210
+ helpers.wrap(fn , {
211
+ mechanism: {
212
+ data: {
213
+ function: 'addEventListener',
214
+ handler: utils.getFunctionName(fn),
215
+ target,
216
+ },
217
+ handled: true,
218
+ type: 'instrument',
219
+ },
220
+ }),
221
+ options,
222
+ ]);
223
+ };
224
+ });
225
+
226
+ utils.fill(
227
+ proto,
228
+ 'removeEventListener',
229
+ function (
230
+ originalRemoveEventListener,
231
+ ) {
232
+ return function (
233
+
234
+ eventName,
235
+ fn,
236
+ options,
237
+ ) {
238
+ /**
239
+ * There are 2 possible scenarios here:
240
+ *
241
+ * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified
242
+ * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function
243
+ * as a pass-through, and call original `removeEventListener` with it.
244
+ *
245
+ * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using
246
+ * our wrapped version of `addEventListener`, which internally calls `wrap` helper.
247
+ * This helper "wraps" whole callback inside a try/catch statement, and attached appropriate metadata to it,
248
+ * in order for us to make a distinction between wrapped/non-wrapped functions possible.
249
+ * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.
250
+ *
251
+ * When someone adds a handler prior to initialization, and then do it again, but after,
252
+ * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible
253
+ * to get rid of the initial handler and it'd stick there forever.
254
+ */
255
+ var wrappedEventHandler = fn ;
256
+ try {
257
+ var originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;
258
+ if (originalEventHandler) {
259
+ originalRemoveEventListener.call(this, eventName, originalEventHandler, options);
260
+ }
261
+ } catch (e) {
262
+ // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments
263
+ }
264
+ return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);
265
+ };
266
+ },
267
+ );
226
268
  }
227
- //# sourceMappingURL=trycatch.js.map
269
+
270
+ exports.TryCatch = TryCatch;
271
+ //# sourceMappingURL=trycatch.js.map