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