@sentry/browser 7.0.0-alpha.1 → 7.0.0-beta.2

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 (240) hide show
  1. package/README.md +2 -3
  2. package/cjs/client.js +130 -83
  3. package/cjs/client.js.map +1 -1
  4. package/cjs/eventbuilder.js +225 -167
  5. package/cjs/eventbuilder.js.map +1 -1
  6. package/cjs/exports.js +55 -47
  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 +122 -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 -192
  15. package/cjs/integrations/breadcrumbs.js.map +1 -1
  16. package/cjs/integrations/dedupe.js +183 -142
  17. package/cjs/integrations/dedupe.js.map +1 -1
  18. package/cjs/integrations/globalhandlers.js +211 -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 -51
  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 -114
  29. package/cjs/sdk.js.map +1 -1
  30. package/cjs/stack-parsers.js +134 -84
  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 -14
  35. package/cjs/transports/index.js.map +1 -1
  36. package/cjs/transports/utils.js +57 -53
  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 -82
  41. package/esm/client.js.map +1 -1
  42. package/esm/eventbuilder.js +218 -160
  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 +120 -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 -190
  53. package/esm/integrations/breadcrumbs.js.map +1 -1
  54. package/esm/integrations/dedupe.js +180 -140
  55. package/esm/integrations/dedupe.js.map +1 -1
  56. package/esm/integrations/globalhandlers.js +208 -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 +76 -49
  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 -111
  67. package/esm/sdk.js.map +1 -1
  68. package/esm/stack-parsers.js +126 -83
  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 -7
  73. package/esm/transports/index.js.map +1 -1
  74. package/esm/transports/utils.js +56 -52
  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 -4
  79. package/types/client.d.ts +24 -18
  80. package/types/client.d.ts.map +1 -1
  81. package/types/eventbuilder.d.ts +1 -1
  82. package/types/exports.d.ts +5 -5
  83. package/types/exports.d.ts.map +1 -1
  84. package/types/helpers.d.ts +0 -5
  85. package/types/helpers.d.ts.map +1 -1
  86. package/types/index.d.ts +2 -3
  87. package/types/index.d.ts.map +1 -1
  88. package/types/integrations/breadcrumbs.d.ts +6 -7
  89. package/types/integrations/breadcrumbs.d.ts.map +1 -1
  90. package/types/integrations/globalhandlers.d.ts.map +1 -1
  91. package/types/integrations/{useragent.d.ts → httpcontext.d.ts} +3 -3
  92. package/types/integrations/httpcontext.d.ts.map +1 -0
  93. package/types/integrations/index.d.ts +1 -1
  94. package/types/integrations/index.d.ts.map +1 -1
  95. package/types/integrations/linkederrors.d.ts.map +1 -1
  96. package/types/sdk.d.ts +4 -4
  97. package/types/sdk.d.ts.map +1 -1
  98. package/types/stack-parsers.d.ts +7 -6
  99. package/types/stack-parsers.d.ts.map +1 -1
  100. package/types/transports/fetch.d.ts +6 -15
  101. package/types/transports/fetch.d.ts.map +1 -1
  102. package/types/transports/index.d.ts +2 -6
  103. package/types/transports/index.d.ts.map +1 -1
  104. package/types/transports/types.d.ts +10 -0
  105. package/types/transports/types.d.ts.map +1 -0
  106. package/types/transports/utils.d.ts +1 -1
  107. package/types/transports/utils.d.ts.map +1 -1
  108. package/types/transports/xhr.d.ts +6 -10
  109. package/types/transports/xhr.d.ts.map +1 -1
  110. package/cjs/client.d.ts +0 -58
  111. package/cjs/client.d.ts.map +0 -1
  112. package/cjs/eventbuilder.d.ts +0 -37
  113. package/cjs/eventbuilder.d.ts.map +0 -1
  114. package/cjs/exports.d.ts +0 -10
  115. package/cjs/exports.d.ts.map +0 -1
  116. package/cjs/flags.d.ts +0 -3
  117. package/cjs/flags.d.ts.map +0 -1
  118. package/cjs/helpers.d.ts +0 -52
  119. package/cjs/helpers.d.ts.map +0 -1
  120. package/cjs/index.d.ts +0 -16
  121. package/cjs/index.d.ts.map +0 -1
  122. package/cjs/integrations/breadcrumbs.d.ts +0 -47
  123. package/cjs/integrations/breadcrumbs.d.ts.map +0 -1
  124. package/cjs/integrations/dedupe.d.ts +0 -21
  125. package/cjs/integrations/dedupe.d.ts.map +0 -1
  126. package/cjs/integrations/globalhandlers.d.ts +0 -30
  127. package/cjs/integrations/globalhandlers.d.ts.map +0 -1
  128. package/cjs/integrations/index.d.ts +0 -7
  129. package/cjs/integrations/index.d.ts.map +0 -1
  130. package/cjs/integrations/linkederrors.d.ts +0 -42
  131. package/cjs/integrations/linkederrors.d.ts.map +0 -1
  132. package/cjs/integrations/trycatch.d.ts +0 -33
  133. package/cjs/integrations/trycatch.d.ts.map +0 -1
  134. package/cjs/integrations/useragent.d.ts +0 -17
  135. package/cjs/integrations/useragent.d.ts.map +0 -1
  136. package/cjs/integrations/useragent.js +0 -42
  137. package/cjs/integrations/useragent.js.map +0 -1
  138. package/cjs/sdk.d.ts +0 -112
  139. package/cjs/sdk.d.ts.map +0 -1
  140. package/cjs/stack-parsers.d.ts +0 -8
  141. package/cjs/stack-parsers.d.ts.map +0 -1
  142. package/cjs/transports/base.d.ts +0 -65
  143. package/cjs/transports/base.d.ts.map +0 -1
  144. package/cjs/transports/base.js +0 -141
  145. package/cjs/transports/base.js.map +0 -1
  146. package/cjs/transports/fetch.d.ts +0 -17
  147. package/cjs/transports/fetch.d.ts.map +0 -1
  148. package/cjs/transports/index.d.ts +0 -7
  149. package/cjs/transports/index.d.ts.map +0 -1
  150. package/cjs/transports/new-fetch.d.ts +0 -10
  151. package/cjs/transports/new-fetch.d.ts.map +0 -1
  152. package/cjs/transports/new-fetch.js +0 -27
  153. package/cjs/transports/new-fetch.js.map +0 -1
  154. package/cjs/transports/new-xhr.d.ts +0 -11
  155. package/cjs/transports/new-xhr.d.ts.map +0 -1
  156. package/cjs/transports/new-xhr.js +0 -46
  157. package/cjs/transports/new-xhr.js.map +0 -1
  158. package/cjs/transports/setup.d.ts +0 -22
  159. package/cjs/transports/setup.d.ts.map +0 -1
  160. package/cjs/transports/setup.js +0 -44
  161. package/cjs/transports/setup.js.map +0 -1
  162. package/cjs/transports/utils.d.ts +0 -48
  163. package/cjs/transports/utils.d.ts.map +0 -1
  164. package/cjs/transports/xhr.d.ts +0 -11
  165. package/cjs/transports/xhr.d.ts.map +0 -1
  166. package/cjs/version.d.ts +0 -2
  167. package/cjs/version.d.ts.map +0 -1
  168. package/cjs/version.js +0 -4
  169. package/cjs/version.js.map +0 -1
  170. package/esm/client.d.ts +0 -58
  171. package/esm/client.d.ts.map +0 -1
  172. package/esm/eventbuilder.d.ts +0 -37
  173. package/esm/eventbuilder.d.ts.map +0 -1
  174. package/esm/exports.d.ts +0 -10
  175. package/esm/exports.d.ts.map +0 -1
  176. package/esm/flags.d.ts +0 -3
  177. package/esm/flags.d.ts.map +0 -1
  178. package/esm/helpers.d.ts +0 -52
  179. package/esm/helpers.d.ts.map +0 -1
  180. package/esm/index.d.ts +0 -16
  181. package/esm/index.d.ts.map +0 -1
  182. package/esm/integrations/breadcrumbs.d.ts +0 -47
  183. package/esm/integrations/breadcrumbs.d.ts.map +0 -1
  184. package/esm/integrations/dedupe.d.ts +0 -21
  185. package/esm/integrations/dedupe.d.ts.map +0 -1
  186. package/esm/integrations/globalhandlers.d.ts +0 -30
  187. package/esm/integrations/globalhandlers.d.ts.map +0 -1
  188. package/esm/integrations/index.d.ts +0 -7
  189. package/esm/integrations/index.d.ts.map +0 -1
  190. package/esm/integrations/linkederrors.d.ts +0 -42
  191. package/esm/integrations/linkederrors.d.ts.map +0 -1
  192. package/esm/integrations/trycatch.d.ts +0 -33
  193. package/esm/integrations/trycatch.d.ts.map +0 -1
  194. package/esm/integrations/useragent.d.ts +0 -17
  195. package/esm/integrations/useragent.d.ts.map +0 -1
  196. package/esm/integrations/useragent.js +0 -41
  197. package/esm/integrations/useragent.js.map +0 -1
  198. package/esm/sdk.d.ts +0 -112
  199. package/esm/sdk.d.ts.map +0 -1
  200. package/esm/stack-parsers.d.ts +0 -8
  201. package/esm/stack-parsers.d.ts.map +0 -1
  202. package/esm/transports/base.d.ts +0 -65
  203. package/esm/transports/base.d.ts.map +0 -1
  204. package/esm/transports/base.js +0 -140
  205. package/esm/transports/base.js.map +0 -1
  206. package/esm/transports/fetch.d.ts +0 -17
  207. package/esm/transports/fetch.d.ts.map +0 -1
  208. package/esm/transports/index.d.ts +0 -7
  209. package/esm/transports/index.d.ts.map +0 -1
  210. package/esm/transports/new-fetch.d.ts +0 -10
  211. package/esm/transports/new-fetch.d.ts.map +0 -1
  212. package/esm/transports/new-fetch.js +0 -25
  213. package/esm/transports/new-fetch.js.map +0 -1
  214. package/esm/transports/new-xhr.d.ts +0 -11
  215. package/esm/transports/new-xhr.d.ts.map +0 -1
  216. package/esm/transports/new-xhr.js +0 -44
  217. package/esm/transports/new-xhr.js.map +0 -1
  218. package/esm/transports/setup.d.ts +0 -22
  219. package/esm/transports/setup.d.ts.map +0 -1
  220. package/esm/transports/setup.js +0 -42
  221. package/esm/transports/setup.js.map +0 -1
  222. package/esm/transports/utils.d.ts +0 -48
  223. package/esm/transports/utils.d.ts.map +0 -1
  224. package/esm/transports/xhr.d.ts +0 -11
  225. package/esm/transports/xhr.d.ts.map +0 -1
  226. package/esm/version.d.ts +0 -2
  227. package/esm/version.d.ts.map +0 -1
  228. package/esm/version.js +0 -3
  229. package/esm/version.js.map +0 -1
  230. package/types/integrations/useragent.d.ts.map +0 -1
  231. package/types/transports/base.d.ts +0 -65
  232. package/types/transports/base.d.ts.map +0 -1
  233. package/types/transports/new-fetch.d.ts +0 -10
  234. package/types/transports/new-fetch.d.ts.map +0 -1
  235. package/types/transports/new-xhr.d.ts +0 -11
  236. package/types/transports/new-xhr.d.ts.map +0 -1
  237. package/types/transports/setup.d.ts +0 -22
  238. package/types/transports/setup.d.ts.map +0 -1
  239. package/types/version.d.ts +0 -2
  240. package/types/version.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"trycatch.js","sourceRoot":"","sources":["../../../../src/integrations/trycatch.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE5F,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEl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gBACF,OAAO;aACR,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CACF,KAAK,EACL,qBAAqB,EACrB,UACE,2BAAuC;QAGvC,OAAO,UAGL,SAAiB,EACjB,EAAuB,EACvB,OAAwC;YAExC;;;;;;;;;;;;;;;;eAgBG;YACH,IAAM,mBAAmB,GAAG,EAAgC,CAAC;YAC7D,IAAI;gBACF,IAAM,oBAAoB,GAAG,mBAAmB,IAAI,mBAAmB,CAAC,kBAAkB,CAAC;gBAC3F,IAAI,oBAAoB,EAAE;oBACxB,2BAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAC;iBAClF;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,gFAAgF;aACjF;YACD,OAAO,2BAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;QACzF,CAAC,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { Integration, WrappedFunction } from '@sentry/types';\nimport { fill, getFunctionName, getGlobalObject, getOriginalFunction } from '@sentry/utils';\n\nimport { wrap } from '../helpers';\n\nconst DEFAULT_EVENT_TARGET = [\n 'EventTarget',\n 'Window',\n 'Node',\n 'ApplicationCache',\n 'AudioTrackList',\n 'ChannelMergerNode',\n 'CryptoOperation',\n 'EventSource',\n 'FileReader',\n 'HTMLUnknownElement',\n 'IDBDatabase',\n 'IDBRequest',\n 'IDBTransaction',\n 'KeyOperation',\n 'MediaController',\n 'MessagePort',\n 'ModalWindow',\n 'Notification',\n 'SVGElementInstance',\n 'Screen',\n 'TextTrack',\n 'TextTrackCue',\n 'TextTrackList',\n 'WebSocket',\n 'WebSocketWorker',\n 'Worker',\n 'XMLHttpRequest',\n 'XMLHttpRequestEventTarget',\n 'XMLHttpRequestUpload',\n];\n\ntype XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' | 'onreadystatechange';\n\n/** JSDoc */\ninterface TryCatchOptions {\n setTimeout: boolean;\n setInterval: boolean;\n requestAnimationFrame: boolean;\n XMLHttpRequest: boolean;\n eventTarget: boolean | string[];\n}\n\n/** Wrap timer functions and event targets to catch errors and provide better meta data */\nexport class TryCatch implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'TryCatch';\n\n /**\n * @inheritDoc\n */\n public name: string = TryCatch.id;\n\n /** JSDoc */\n private readonly _options: TryCatchOptions;\n\n /**\n * @inheritDoc\n */\n public constructor(options?: Partial<TryCatchOptions>) {\n this._options = {\n XMLHttpRequest: true,\n eventTarget: true,\n requestAnimationFrame: true,\n setInterval: true,\n setTimeout: true,\n ...options,\n };\n }\n\n /**\n * Wrap timer functions and event targets to catch errors\n * and provide better metadata.\n */\n public setupOnce(): void {\n const global = getGlobalObject();\n\n if (this._options.setTimeout) {\n fill(global, 'setTimeout', _wrapTimeFunction);\n }\n\n if (this._options.setInterval) {\n fill(global, 'setInterval', _wrapTimeFunction);\n }\n\n if (this._options.requestAnimationFrame) {\n fill(global, 'requestAnimationFrame', _wrapRAF);\n }\n\n if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {\n fill(XMLHttpRequest.prototype, 'send', _wrapXHR);\n }\n\n const eventTargetOption = this._options.eventTarget;\n if (eventTargetOption) {\n const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;\n eventTarget.forEach(_wrapEventTarget);\n }\n }\n}\n\n/** JSDoc */\nfunction _wrapTimeFunction(original: () => void): () => number {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (this: any, ...args: any[]): number {\n const originalCallback = args[0];\n args[0] = wrap(originalCallback, {\n mechanism: {\n data: { function: getFunctionName(original) },\n handled: true,\n type: 'instrument',\n },\n });\n return original.apply(this, args);\n };\n}\n\n/** JSDoc */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _wrapRAF(original: any): (callback: () => void) => any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (this: any, callback: () => void): () => void {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return original.apply(this, [\n wrap(callback, {\n mechanism: {\n data: {\n function: 'requestAnimationFrame',\n handler: getFunctionName(original),\n },\n handled: true,\n type: 'instrument',\n },\n }),\n ]);\n };\n}\n\n/** JSDoc */\nfunction _wrapXHR(originalSend: () => void): () => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (this: XMLHttpRequest, ...args: any[]): void {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const xhr = this;\n const xmlHttpRequestProps: XMLHttpRequestProp[] = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];\n\n xmlHttpRequestProps.forEach(prop => {\n if (prop in xhr && typeof xhr[prop] === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fill(xhr, prop, function (original: WrappedFunction): () => any {\n const wrapOptions = {\n mechanism: {\n data: {\n function: prop,\n handler: getFunctionName(original),\n },\n handled: true,\n type: 'instrument',\n },\n };\n\n // If Instrument integration has been called before TryCatch, get the name of original function\n const originalFunction = getOriginalFunction(original);\n if (originalFunction) {\n wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);\n }\n\n // Otherwise wrap directly\n return wrap(original, wrapOptions);\n });\n }\n });\n\n return originalSend.apply(this, args);\n };\n}\n\n/** JSDoc */\nfunction _wrapEventTarget(target: string): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const global = getGlobalObject() as { [key: string]: any };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const proto = global[target] && global[target].prototype;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins\n if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {\n return;\n }\n\n fill(proto, 'addEventListener', function (original: () => void): (\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ) => void {\n return function (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this: any,\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): (eventName: string, fn: EventListenerObject, capture?: boolean, secure?: boolean) => void {\n try {\n if (typeof fn.handleEvent === 'function') {\n fn.handleEvent = wrap(fn.handleEvent.bind(fn), {\n mechanism: {\n data: {\n function: 'handleEvent',\n handler: getFunctionName(fn),\n target,\n },\n handled: true,\n type: 'instrument',\n },\n });\n }\n } catch (err) {\n // can sometimes get 'Permission denied to access property \"handle Event'\n }\n\n return original.apply(this, [\n eventName,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrap(fn as any as WrappedFunction, {\n mechanism: {\n data: {\n function: 'addEventListener',\n handler: getFunctionName(fn),\n target,\n },\n handled: true,\n type: 'instrument',\n },\n }),\n options,\n ]);\n };\n });\n\n fill(\n proto,\n 'removeEventListener',\n function (\n originalRemoveEventListener: () => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): (this: any, eventName: string, fn: EventListenerObject, options?: boolean | EventListenerOptions) => () => void {\n return function (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this: any,\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | EventListenerOptions,\n ): () => void {\n /**\n * There are 2 possible scenarios here:\n *\n * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified\n * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function\n * as a pass-through, and call original `removeEventListener` with it.\n *\n * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using\n * our wrapped version of `addEventListener`, which internally calls `wrap` helper.\n * This helper \"wraps\" whole callback inside a try/catch statement, and attached appropriate metadata to it,\n * in order for us to make a distinction between wrapped/non-wrapped functions possible.\n * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.\n *\n * When someone adds a handler prior to initialization, and then do it again, but after,\n * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible\n * to get rid of the initial handler and it'd stick there forever.\n */\n const wrappedEventHandler = fn as unknown as WrappedFunction;\n try {\n const originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;\n if (originalEventHandler) {\n originalRemoveEventListener.call(this, eventName, originalEventHandler, options);\n }\n } catch (e) {\n // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments\n }\n return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);\n };\n },\n );\n}\n"]}
1
+ {"version":3,"file":"trycatch.js","sources":["../../../../src/integrations/trycatch.ts"],"sourcesContent":["import { Integration, WrappedFunction } from '@sentry/types';\nimport { fill, getFunctionName, getGlobalObject, getOriginalFunction } from '@sentry/utils';\n\nimport { wrap } from '../helpers';\n\nconst DEFAULT_EVENT_TARGET = [\n 'EventTarget',\n 'Window',\n 'Node',\n 'ApplicationCache',\n 'AudioTrackList',\n 'ChannelMergerNode',\n 'CryptoOperation',\n 'EventSource',\n 'FileReader',\n 'HTMLUnknownElement',\n 'IDBDatabase',\n 'IDBRequest',\n 'IDBTransaction',\n 'KeyOperation',\n 'MediaController',\n 'MessagePort',\n 'ModalWindow',\n 'Notification',\n 'SVGElementInstance',\n 'Screen',\n 'TextTrack',\n 'TextTrackCue',\n 'TextTrackList',\n 'WebSocket',\n 'WebSocketWorker',\n 'Worker',\n 'XMLHttpRequest',\n 'XMLHttpRequestEventTarget',\n 'XMLHttpRequestUpload',\n];\n\ntype XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' | 'onreadystatechange';\n\n/** JSDoc */\ninterface TryCatchOptions {\n setTimeout: boolean;\n setInterval: boolean;\n requestAnimationFrame: boolean;\n XMLHttpRequest: boolean;\n eventTarget: boolean | string[];\n}\n\n/** Wrap timer functions and event targets to catch errors and provide better meta data */\nexport class TryCatch implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'TryCatch';\n\n /**\n * @inheritDoc\n */\n public name: string = TryCatch.id;\n\n /** JSDoc */\n private readonly _options: TryCatchOptions;\n\n /**\n * @inheritDoc\n */\n public constructor(options?: Partial<TryCatchOptions>) {\n this._options = {\n XMLHttpRequest: true,\n eventTarget: true,\n requestAnimationFrame: true,\n setInterval: true,\n setTimeout: true,\n ...options,\n };\n }\n\n /**\n * Wrap timer functions and event targets to catch errors\n * and provide better metadata.\n */\n public setupOnce(): void {\n const global = getGlobalObject();\n\n if (this._options.setTimeout) {\n fill(global, 'setTimeout', _wrapTimeFunction);\n }\n\n if (this._options.setInterval) {\n fill(global, 'setInterval', _wrapTimeFunction);\n }\n\n if (this._options.requestAnimationFrame) {\n fill(global, 'requestAnimationFrame', _wrapRAF);\n }\n\n if (this._options.XMLHttpRequest && 'XMLHttpRequest' in global) {\n fill(XMLHttpRequest.prototype, 'send', _wrapXHR);\n }\n\n const eventTargetOption = this._options.eventTarget;\n if (eventTargetOption) {\n const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;\n eventTarget.forEach(_wrapEventTarget);\n }\n }\n}\n\n/** JSDoc */\nfunction _wrapTimeFunction(original: () => void): () => number {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (this: any, ...args: any[]): number {\n const originalCallback = args[0];\n args[0] = wrap(originalCallback, {\n mechanism: {\n data: { function: getFunctionName(original) },\n handled: true,\n type: 'instrument',\n },\n });\n return original.apply(this, args);\n };\n}\n\n/** JSDoc */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _wrapRAF(original: any): (callback: () => void) => any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (this: any, callback: () => void): () => void {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return original.apply(this, [\n wrap(callback, {\n mechanism: {\n data: {\n function: 'requestAnimationFrame',\n handler: getFunctionName(original),\n },\n handled: true,\n type: 'instrument',\n },\n }),\n ]);\n };\n}\n\n/** JSDoc */\nfunction _wrapXHR(originalSend: () => void): () => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (this: XMLHttpRequest, ...args: any[]): void {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const xhr = this;\n const xmlHttpRequestProps: XMLHttpRequestProp[] = ['onload', 'onerror', 'onprogress', 'onreadystatechange'];\n\n xmlHttpRequestProps.forEach(prop => {\n if (prop in xhr && typeof xhr[prop] === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fill(xhr, prop, function (original: WrappedFunction): () => any {\n const wrapOptions = {\n mechanism: {\n data: {\n function: prop,\n handler: getFunctionName(original),\n },\n handled: true,\n type: 'instrument',\n },\n };\n\n // If Instrument integration has been called before TryCatch, get the name of original function\n const originalFunction = getOriginalFunction(original);\n if (originalFunction) {\n wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);\n }\n\n // Otherwise wrap directly\n return wrap(original, wrapOptions);\n });\n }\n });\n\n return originalSend.apply(this, args);\n };\n}\n\n/** JSDoc */\nfunction _wrapEventTarget(target: string): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const global = getGlobalObject() as { [key: string]: any };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const proto = global[target] && global[target].prototype;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins\n if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {\n return;\n }\n\n fill(proto, 'addEventListener', function (original: () => void): (\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ) => void {\n return function (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this: any,\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): (eventName: string, fn: EventListenerObject, capture?: boolean, secure?: boolean) => void {\n try {\n if (typeof fn.handleEvent === 'function') {\n fn.handleEvent = wrap(fn.handleEvent.bind(fn), {\n mechanism: {\n data: {\n function: 'handleEvent',\n handler: getFunctionName(fn),\n target,\n },\n handled: true,\n type: 'instrument',\n },\n });\n }\n } catch (err) {\n // can sometimes get 'Permission denied to access property \"handle Event'\n }\n\n return original.apply(this, [\n eventName,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrap(fn as any as WrappedFunction, {\n mechanism: {\n data: {\n function: 'addEventListener',\n handler: getFunctionName(fn),\n target,\n },\n handled: true,\n type: 'instrument',\n },\n }),\n options,\n ]);\n };\n });\n\n fill(\n proto,\n 'removeEventListener',\n function (\n originalRemoveEventListener: () => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): (this: any, eventName: string, fn: EventListenerObject, options?: boolean | EventListenerOptions) => () => void {\n return function (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this: any,\n eventName: string,\n fn: EventListenerObject,\n options?: boolean | EventListenerOptions,\n ): () => void {\n /**\n * There are 2 possible scenarios here:\n *\n * 1. Someone passes a callback, which was attached prior to Sentry initialization, or by using unmodified\n * method, eg. `document.addEventListener.call(el, name, handler). In this case, we treat this function\n * as a pass-through, and call original `removeEventListener` with it.\n *\n * 2. Someone passes a callback, which was attached after Sentry was initialized, which means that it was using\n * our wrapped version of `addEventListener`, which internally calls `wrap` helper.\n * This helper \"wraps\" whole callback inside a try/catch statement, and attached appropriate metadata to it,\n * in order for us to make a distinction between wrapped/non-wrapped functions possible.\n * If a function was wrapped, it has additional property of `__sentry_wrapped__`, holding the handler.\n *\n * When someone adds a handler prior to initialization, and then do it again, but after,\n * then we have to detach both of them. Otherwise, if we'd detach only wrapped one, it'd be impossible\n * to get rid of the initial handler and it'd stick there forever.\n */\n const wrappedEventHandler = fn as unknown as WrappedFunction;\n try {\n const originalEventHandler = wrappedEventHandler && wrappedEventHandler.__sentry_wrapped__;\n if (originalEventHandler) {\n originalRemoveEventListener.call(this, eventName, originalEventHandler, options);\n }\n } catch (e) {\n // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments\n }\n return originalRemoveEventListener.call(this, eventName, wrappedEventHandler, options);\n };\n },\n );\n}\n"],"names":[],"mappings":";;;AAKA;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;;AAaA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AACA;;AAIA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
package/esm/sdk.js CHANGED
@@ -1,22 +1,31 @@
1
- import { __assign } from "tslib";
2
- import { getCurrentHub, initAndBind, Integrations as CoreIntegrations } from '@sentry/core';
3
- import { addInstrumentationHandler, getGlobalObject, logger, resolvedSyncPromise } from '@sentry/utils';
4
- import { BrowserClient } from './client';
5
- import { IS_DEBUG_BUILD } from './flags';
6
- import { wrap as internalWrap } from './helpers';
7
- import { Breadcrumbs, Dedupe, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';
8
- import { defaultStackParsers } from './stack-parsers';
9
- import { setupBrowserTransport } from './transports/setup';
10
- export var defaultIntegrations = [
11
- new CoreIntegrations.InboundFilters(),
12
- new CoreIntegrations.FunctionToString(),
13
- new TryCatch(),
14
- new Breadcrumbs(),
15
- new GlobalHandlers(),
16
- new LinkedErrors(),
17
- new Dedupe(),
18
- new UserAgent(),
1
+ import { Integrations, getIntegrationsToSetup, initAndBind, getCurrentHub, getReportDialogEndpoint } from '@sentry/core';
2
+ import { getGlobalObject, stackParserFromStackParserOptions, supportsFetch, logger, resolvedSyncPromise, addInstrumentationHandler } from '@sentry/utils';
3
+ import { BrowserClient } from './client.js';
4
+ import { IS_DEBUG_BUILD } from './flags.js';
5
+ import { wrap as wrap$1 } from './helpers.js';
6
+ import './integrations/index.js';
7
+ import { defaultStackParser } from './stack-parsers.js';
8
+ import './transports/index.js';
9
+ import { TryCatch } from './integrations/trycatch.js';
10
+ import { Breadcrumbs } from './integrations/breadcrumbs.js';
11
+ import { GlobalHandlers } from './integrations/globalhandlers.js';
12
+ import { LinkedErrors } from './integrations/linkederrors.js';
13
+ import { Dedupe } from './integrations/dedupe.js';
14
+ import { HttpContext } from './integrations/httpcontext.js';
15
+ import { makeFetchTransport } from './transports/fetch.js';
16
+ import { makeXHRTransport } from './transports/xhr.js';
17
+
18
+ var defaultIntegrations = [
19
+ new Integrations.InboundFilters(),
20
+ new Integrations.FunctionToString(),
21
+ new TryCatch(),
22
+ new Breadcrumbs(),
23
+ new GlobalHandlers(),
24
+ new LinkedErrors(),
25
+ new Dedupe(),
26
+ new HttpContext(),
19
27
  ];
28
+
20
29
  /**
21
30
  * The Sentry Browser SDK Client.
22
31
  *
@@ -74,75 +83,110 @@ export var defaultIntegrations = [
74
83
  *
75
84
  * @see {@link BrowserOptions} for documentation on configuration options.
76
85
  */
77
- export function init(options) {
78
- if (options === void 0) { options = {}; }
79
- if (options.defaultIntegrations === undefined) {
80
- options.defaultIntegrations = defaultIntegrations;
81
- }
82
- if (options.release === undefined) {
83
- var window_1 = getGlobalObject();
84
- // This supports the variable that sentry-webpack-plugin injects
85
- if (window_1.SENTRY_RELEASE && window_1.SENTRY_RELEASE.id) {
86
- options.release = window_1.SENTRY_RELEASE.id;
87
- }
88
- }
89
- if (options.autoSessionTracking === undefined) {
90
- options.autoSessionTracking = true;
91
- }
92
- if (options.sendClientReports === undefined) {
93
- options.sendClientReports = true;
94
- }
95
- if (options.stackParser === undefined) {
96
- options.stackParser = defaultStackParsers;
97
- }
98
- var _a = setupBrowserTransport(options), transport = _a.transport, newTransport = _a.newTransport;
99
- initAndBind(BrowserClient, options, transport, newTransport);
100
- if (options.autoSessionTracking) {
101
- startSessionTracking();
86
+ function init(options = {}) {
87
+ if (options.defaultIntegrations === undefined) {
88
+ options.defaultIntegrations = defaultIntegrations;
89
+ }
90
+ if (options.release === undefined) {
91
+ var window = getGlobalObject();
92
+ // This supports the variable that sentry-webpack-plugin injects
93
+ if (window.SENTRY_RELEASE && window.SENTRY_RELEASE.id) {
94
+ options.release = window.SENTRY_RELEASE.id;
102
95
  }
96
+ }
97
+ if (options.autoSessionTracking === undefined) {
98
+ options.autoSessionTracking = true;
99
+ }
100
+ if (options.sendClientReports === undefined) {
101
+ options.sendClientReports = true;
102
+ }
103
+
104
+ var clientOptions = {
105
+ ...options,
106
+ stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),
107
+ integrations: getIntegrationsToSetup(options),
108
+ transport: options.transport || (supportsFetch() ? makeFetchTransport : makeXHRTransport),
109
+ };
110
+
111
+ initAndBind(BrowserClient, clientOptions);
112
+
113
+ if (options.autoSessionTracking) {
114
+ startSessionTracking();
115
+ }
103
116
  }
117
+
104
118
  /**
105
119
  * Present the user with a report dialog.
106
120
  *
107
121
  * @param options Everything is optional, we try to fetch all info need from the global scope.
108
122
  */
109
- export function showReportDialog(options) {
110
- if (options === void 0) { options = {}; }
111
- var hub = getCurrentHub();
112
- var scope = hub.getScope();
113
- if (scope) {
114
- options.user = __assign(__assign({}, scope.getUser()), options.user);
115
- }
116
- if (!options.eventId) {
117
- options.eventId = hub.lastEventId();
118
- }
119
- var client = hub.getClient();
120
- if (client) {
121
- client.showReportDialog(options);
122
- }
123
+ function showReportDialog(options = {}, hub = getCurrentHub()) {
124
+ // doesn't work without a document (React Native)
125
+ var global = getGlobalObject();
126
+ if (!global.document) {
127
+ IS_DEBUG_BUILD && logger.error('Global document not defined in showReportDialog call');
128
+ return;
129
+ }
130
+
131
+ const { client, scope } = hub.getStackTop();
132
+ var dsn = options.dsn || (client && client.getDsn());
133
+ if (!dsn) {
134
+ IS_DEBUG_BUILD && logger.error('DSN not configured for showReportDialog call');
135
+ return;
136
+ }
137
+
138
+ if (scope) {
139
+ options.user = {
140
+ ...scope.getUser(),
141
+ ...options.user,
142
+ };
143
+ }
144
+
145
+ if (!options.eventId) {
146
+ options.eventId = hub.lastEventId();
147
+ }
148
+
149
+ var script = global.document.createElement('script');
150
+ script.async = true;
151
+ script.src = getReportDialogEndpoint(dsn, options);
152
+
153
+ if (options.onLoad) {
154
+ script.onload = options.onLoad;
155
+ }
156
+
157
+ var injectionPoint = global.document.head || global.document.body;
158
+ if (injectionPoint) {
159
+ injectionPoint.appendChild(script);
160
+ } else {
161
+ IS_DEBUG_BUILD && logger.error('Not injecting report dialog. No injection point found in HTML');
162
+ }
123
163
  }
164
+
124
165
  /**
125
166
  * This is the getter for lastEventId.
126
167
  *
127
168
  * @returns The last event id of a captured event.
128
169
  */
129
- export function lastEventId() {
130
- return getCurrentHub().lastEventId();
170
+ function lastEventId() {
171
+ return getCurrentHub().lastEventId();
131
172
  }
173
+
132
174
  /**
133
175
  * This function is here to be API compatible with the loader.
134
176
  * @hidden
135
177
  */
136
- export function forceLoad() {
137
- // Noop
178
+ function forceLoad() {
179
+ // Noop
138
180
  }
181
+
139
182
  /**
140
183
  * This function is here to be API compatible with the loader.
141
184
  * @hidden
142
185
  */
143
- export function onLoad(callback) {
144
- callback();
186
+ function onLoad(callback) {
187
+ callback();
145
188
  }
189
+
146
190
  /**
147
191
  * Call `flush()` on the current client, if there is one. See {@link Client.flush}.
148
192
  *
@@ -151,14 +195,15 @@ export function onLoad(callback) {
151
195
  * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
152
196
  * doesn't (or if there's no client defined).
153
197
  */
154
- export function flush(timeout) {
155
- var client = getCurrentHub().getClient();
156
- if (client) {
157
- return client.flush(timeout);
158
- }
159
- IS_DEBUG_BUILD && logger.warn('Cannot flush events. No client defined.');
160
- return resolvedSyncPromise(false);
198
+ function flush(timeout) {
199
+ var client = getCurrentHub().getClient();
200
+ if (client) {
201
+ return client.flush(timeout);
202
+ }
203
+ IS_DEBUG_BUILD && logger.warn('Cannot flush events. No client defined.');
204
+ return resolvedSyncPromise(false);
161
205
  }
206
+
162
207
  /**
163
208
  * Call `close()` on the current client, if there is one. See {@link Client.close}.
164
209
  *
@@ -167,14 +212,15 @@ export function flush(timeout) {
167
212
  * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
168
213
  * doesn't (or if there's no client defined).
169
214
  */
170
- export function close(timeout) {
171
- var client = getCurrentHub().getClient();
172
- if (client) {
173
- return client.close(timeout);
174
- }
175
- IS_DEBUG_BUILD && logger.warn('Cannot flush events and disable SDK. No client defined.');
176
- return resolvedSyncPromise(false);
215
+ function close(timeout) {
216
+ var client = getCurrentHub().getClient();
217
+ if (client) {
218
+ return client.close(timeout);
219
+ }
220
+ IS_DEBUG_BUILD && logger.warn('Cannot flush events and disable SDK. No client defined.');
221
+ return resolvedSyncPromise(false);
177
222
  }
223
+
178
224
  /**
179
225
  * Wrap code within a try/catch block so the SDK is able to capture errors.
180
226
  *
@@ -182,46 +228,53 @@ export function close(timeout) {
182
228
  *
183
229
  * @returns The result of wrapped function call.
184
230
  */
185
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
- export function wrap(fn) {
187
- return internalWrap(fn)();
231
+ function wrap(fn) {
232
+ return wrap$1(fn)();
188
233
  }
234
+
189
235
  function startSessionOnHub(hub) {
190
- hub.startSession({ ignoreDuration: true });
191
- hub.captureSession();
236
+ hub.startSession({ ignoreDuration: true });
237
+ hub.captureSession();
192
238
  }
239
+
193
240
  /**
194
241
  * Enable automatic Session Tracking for the initial page load.
195
242
  */
196
243
  function startSessionTracking() {
197
- var window = getGlobalObject();
198
- var document = window.document;
199
- if (typeof document === 'undefined') {
200
- IS_DEBUG_BUILD && logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
201
- return;
202
- }
203
- var hub = getCurrentHub();
204
- // The only way for this to be false is for there to be a version mismatch between @sentry/browser (>= 6.0.0) and
205
- // @sentry/hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are
206
- // pinned at the same version in package.json, but there are edge cases where it's possible. See
207
- // https://github.com/getsentry/sentry-javascript/issues/3207 and
208
- // https://github.com/getsentry/sentry-javascript/issues/3234 and
209
- // https://github.com/getsentry/sentry-javascript/issues/3278.
210
- if (!hub.captureSession) {
211
- return;
244
+ var window = getGlobalObject();
245
+ var document = window.document;
246
+
247
+ if (typeof document === 'undefined') {
248
+ IS_DEBUG_BUILD && logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');
249
+ return;
250
+ }
251
+
252
+ var hub = getCurrentHub();
253
+
254
+ // The only way for this to be false is for there to be a version mismatch between @sentry/browser (>= 6.0.0) and
255
+ // @sentry/hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are
256
+ // pinned at the same version in package.json, but there are edge cases where it's possible. See
257
+ // https://github.com/getsentry/sentry-javascript/issues/3207 and
258
+ // https://github.com/getsentry/sentry-javascript/issues/3234 and
259
+ // https://github.com/getsentry/sentry-javascript/issues/3278.
260
+ if (!hub.captureSession) {
261
+ return;
262
+ }
263
+
264
+ // The session duration for browser sessions does not track a meaningful
265
+ // concept that can be used as a metric.
266
+ // Automatically captured sessions are akin to page views, and thus we
267
+ // discard their duration.
268
+ startSessionOnHub(hub);
269
+
270
+ // We want to create a session for every navigation as well
271
+ addInstrumentationHandler('history', ({ from, to }) => {
272
+ // Don't create an additional session for the initial route or if the location did not change
273
+ if (!(from === undefined || from === to)) {
274
+ startSessionOnHub(getCurrentHub());
212
275
  }
213
- // The session duration for browser sessions does not track a meaningful
214
- // concept that can be used as a metric.
215
- // Automatically captured sessions are akin to page views, and thus we
216
- // discard their duration.
217
- startSessionOnHub(hub);
218
- // We want to create a session for every navigation as well
219
- addInstrumentationHandler('history', function (_a) {
220
- var from = _a.from, to = _a.to;
221
- // Don't create an additional session for the initial route or if the location did not change
222
- if (!(from === undefined || from === to)) {
223
- startSessionOnHub(getCurrentHub());
224
- }
225
- });
276
+ });
226
277
  }
227
- //# sourceMappingURL=sdk.js.map
278
+
279
+ export { close, defaultIntegrations, flush, forceLoad, init, lastEventId, onLoad, showReportDialog, wrap };
280
+ //# sourceMappingURL=sdk.js.map
package/esm/sdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE5F,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAExG,OAAO,EAAE,aAAa,EAAkB,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAuB,IAAI,IAAI,YAAY,EAAE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xE,wCAAwC;IACxC,sEAAsE;IACtE,0BAA0B;IAC1B,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAEvB,2DAA2D;IAC3D,yBAAyB,CAAC,SAAS,EAAE,UAAC,EAAY;YAAV,cAAI,EAAE,UAAE;QAC9C,6FAA6F;QAC7F,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,CAAC,EAAE;YACxC,iBAAiB,CAAC,aAAa,EAAE,CAAC,CAAC;SACpC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { getCurrentHub, initAndBind, Integrations as CoreIntegrations } from '@sentry/core';\nimport { Hub } from '@sentry/types';\nimport { addInstrumentationHandler, getGlobalObject, logger, resolvedSyncPromise } from '@sentry/utils';\n\nimport { BrowserClient, BrowserOptions } from './client';\nimport { IS_DEBUG_BUILD } from './flags';\nimport { ReportDialogOptions, wrap as internalWrap } from './helpers';\nimport { Breadcrumbs, Dedupe, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';\nimport { defaultStackParsers } from './stack-parsers';\nimport { setupBrowserTransport } from './transports/setup';\n\nexport const defaultIntegrations = [\n new CoreIntegrations.InboundFilters(),\n new CoreIntegrations.FunctionToString(),\n new TryCatch(),\n new Breadcrumbs(),\n new GlobalHandlers(),\n new LinkedErrors(),\n new Dedupe(),\n new UserAgent(),\n];\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { configureScope } from '@sentry/browser';\n * configureScope((scope: Scope) => {\n * scope.setExtra({ battery: 0.7 });\n * scope.setTag({ user_mode: 'admin' });\n * scope.setUser({ id: '4711' });\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(options: BrowserOptions = {}): void {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = defaultIntegrations;\n }\n if (options.release === undefined) {\n const window = getGlobalObject<Window>();\n // This supports the variable that sentry-webpack-plugin injects\n if (window.SENTRY_RELEASE && window.SENTRY_RELEASE.id) {\n options.release = window.SENTRY_RELEASE.id;\n }\n }\n if (options.autoSessionTracking === undefined) {\n options.autoSessionTracking = true;\n }\n if (options.sendClientReports === undefined) {\n options.sendClientReports = true;\n }\n if (options.stackParser === undefined) {\n options.stackParser = defaultStackParsers;\n }\n\n const { transport, newTransport } = setupBrowserTransport(options);\n initAndBind(BrowserClient, options, transport, newTransport);\n\n if (options.autoSessionTracking) {\n startSessionTracking();\n }\n}\n\n/**\n * Present the user with a report dialog.\n *\n * @param options Everything is optional, we try to fetch all info need from the global scope.\n */\nexport function showReportDialog(options: ReportDialogOptions = {}): void {\n const hub = getCurrentHub();\n const scope = hub.getScope();\n if (scope) {\n options.user = {\n ...scope.getUser(),\n ...options.user,\n };\n }\n\n if (!options.eventId) {\n options.eventId = hub.lastEventId();\n }\n const client = hub.getClient<BrowserClient>();\n if (client) {\n client.showReportDialog(options);\n }\n}\n\n/**\n * This is the getter for lastEventId.\n *\n * @returns The last event id of a captured event.\n */\nexport function lastEventId(): string | undefined {\n return getCurrentHub().lastEventId();\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n\n/**\n * Call `flush()` on the current client, if there is one. See {@link Client.flush}.\n *\n * @param timeout Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause\n * the client to wait until all events are sent before resolving the promise.\n * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it\n * doesn't (or if there's no client defined).\n */\nexport function flush(timeout?: number): PromiseLike<boolean> {\n const client = getCurrentHub().getClient<BrowserClient>();\n if (client) {\n return client.flush(timeout);\n }\n IS_DEBUG_BUILD && logger.warn('Cannot flush events. No client defined.');\n return resolvedSyncPromise(false);\n}\n\n/**\n * Call `close()` on the current client, if there is one. See {@link Client.close}.\n *\n * @param timeout Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this\n * parameter will cause the client to wait until all events are sent before disabling itself.\n * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it\n * doesn't (or if there's no client defined).\n */\nexport function close(timeout?: number): PromiseLike<boolean> {\n const client = getCurrentHub().getClient<BrowserClient>();\n if (client) {\n return client.close(timeout);\n }\n IS_DEBUG_BUILD && logger.warn('Cannot flush events and disable SDK. No client defined.');\n return resolvedSyncPromise(false);\n}\n\n/**\n * Wrap code within a try/catch block so the SDK is able to capture errors.\n *\n * @param fn A function to wrap.\n *\n * @returns The result of wrapped function call.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrap(fn: (...args: any) => any): any {\n return internalWrap(fn)();\n}\n\nfunction startSessionOnHub(hub: Hub): void {\n hub.startSession({ ignoreDuration: true });\n hub.captureSession();\n}\n\n/**\n * Enable automatic Session Tracking for the initial page load.\n */\nfunction startSessionTracking(): void {\n const window = getGlobalObject<Window>();\n const document = window.document;\n\n if (typeof document === 'undefined') {\n IS_DEBUG_BUILD && logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');\n return;\n }\n\n const hub = getCurrentHub();\n\n // The only way for this to be false is for there to be a version mismatch between @sentry/browser (>= 6.0.0) and\n // @sentry/hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are\n // pinned at the same version in package.json, but there are edge cases where it's possible. See\n // https://github.com/getsentry/sentry-javascript/issues/3207 and\n // https://github.com/getsentry/sentry-javascript/issues/3234 and\n // https://github.com/getsentry/sentry-javascript/issues/3278.\n if (!hub.captureSession) {\n return;\n }\n\n // The session duration for browser sessions does not track a meaningful\n // concept that can be used as a metric.\n // Automatically captured sessions are akin to page views, and thus we\n // discard their duration.\n startSessionOnHub(hub);\n\n // We want to create a session for every navigation as well\n addInstrumentationHandler('history', ({ from, to }) => {\n // Don't create an additional session for the initial route or if the location did not change\n if (!(from === undefined || from === to)) {\n startSessionOnHub(getCurrentHub());\n }\n });\n}\n"]}
1
+ {"version":3,"file":"sdk.js","sources":["../../../src/sdk.ts"],"sourcesContent":["import {\n getCurrentHub,\n getIntegrationsToSetup,\n getReportDialogEndpoint,\n Hub,\n initAndBind,\n Integrations as CoreIntegrations,\n} from '@sentry/core';\nimport {\n addInstrumentationHandler,\n getGlobalObject,\n logger,\n resolvedSyncPromise,\n stackParserFromStackParserOptions,\n supportsFetch,\n} from '@sentry/utils';\n\nimport { BrowserClient, BrowserClientOptions, BrowserOptions } from './client';\nimport { IS_DEBUG_BUILD } from './flags';\nimport { ReportDialogOptions, wrap as internalWrap } from './helpers';\nimport { Breadcrumbs, Dedupe, GlobalHandlers, HttpContext, LinkedErrors, TryCatch } from './integrations';\nimport { defaultStackParser } from './stack-parsers';\nimport { makeFetchTransport, makeXHRTransport } from './transports';\n\nexport const defaultIntegrations = [\n new CoreIntegrations.InboundFilters(),\n new CoreIntegrations.FunctionToString(),\n new TryCatch(),\n new Breadcrumbs(),\n new GlobalHandlers(),\n new LinkedErrors(),\n new Dedupe(),\n new HttpContext(),\n];\n\n/**\n * The Sentry Browser SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the web page. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/browser';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { configureScope } from '@sentry/browser';\n * configureScope((scope: Scope) => {\n * scope.setExtra({ battery: 0.7 });\n * scope.setTag({ user_mode: 'admin' });\n * scope.setUser({ id: '4711' });\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/browser';\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/browser';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link BrowserOptions} for documentation on configuration options.\n */\nexport function init(options: BrowserOptions = {}): void {\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = defaultIntegrations;\n }\n if (options.release === undefined) {\n const window = getGlobalObject<Window>();\n // This supports the variable that sentry-webpack-plugin injects\n if (window.SENTRY_RELEASE && window.SENTRY_RELEASE.id) {\n options.release = window.SENTRY_RELEASE.id;\n }\n }\n if (options.autoSessionTracking === undefined) {\n options.autoSessionTracking = true;\n }\n if (options.sendClientReports === undefined) {\n options.sendClientReports = true;\n }\n\n const clientOptions: BrowserClientOptions = {\n ...options,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n integrations: getIntegrationsToSetup(options),\n transport: options.transport || (supportsFetch() ? makeFetchTransport : makeXHRTransport),\n };\n\n initAndBind(BrowserClient, clientOptions);\n\n if (options.autoSessionTracking) {\n startSessionTracking();\n }\n}\n\n/**\n * Present the user with a report dialog.\n *\n * @param options Everything is optional, we try to fetch all info need from the global scope.\n */\nexport function showReportDialog(options: ReportDialogOptions = {}, hub: Hub = getCurrentHub()): void {\n // doesn't work without a document (React Native)\n const global = getGlobalObject<Window>();\n if (!global.document) {\n IS_DEBUG_BUILD && logger.error('Global document not defined in showReportDialog call');\n return;\n }\n\n const { client, scope } = hub.getStackTop();\n const dsn = options.dsn || (client && client.getDsn());\n if (!dsn) {\n IS_DEBUG_BUILD && logger.error('DSN not configured for showReportDialog call');\n return;\n }\n\n if (scope) {\n options.user = {\n ...scope.getUser(),\n ...options.user,\n };\n }\n\n if (!options.eventId) {\n options.eventId = hub.lastEventId();\n }\n\n const script = global.document.createElement('script');\n script.async = true;\n script.src = getReportDialogEndpoint(dsn, options);\n\n if (options.onLoad) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n script.onload = options.onLoad;\n }\n\n const injectionPoint = global.document.head || global.document.body;\n if (injectionPoint) {\n injectionPoint.appendChild(script);\n } else {\n IS_DEBUG_BUILD && logger.error('Not injecting report dialog. No injection point found in HTML');\n }\n}\n\n/**\n * This is the getter for lastEventId.\n *\n * @returns The last event id of a captured event.\n */\nexport function lastEventId(): string | undefined {\n return getCurrentHub().lastEventId();\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function forceLoad(): void {\n // Noop\n}\n\n/**\n * This function is here to be API compatible with the loader.\n * @hidden\n */\nexport function onLoad(callback: () => void): void {\n callback();\n}\n\n/**\n * Call `flush()` on the current client, if there is one. See {@link Client.flush}.\n *\n * @param timeout Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause\n * the client to wait until all events are sent before resolving the promise.\n * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it\n * doesn't (or if there's no client defined).\n */\nexport function flush(timeout?: number): PromiseLike<boolean> {\n const client = getCurrentHub().getClient<BrowserClient>();\n if (client) {\n return client.flush(timeout);\n }\n IS_DEBUG_BUILD && logger.warn('Cannot flush events. No client defined.');\n return resolvedSyncPromise(false);\n}\n\n/**\n * Call `close()` on the current client, if there is one. See {@link Client.close}.\n *\n * @param timeout Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this\n * parameter will cause the client to wait until all events are sent before disabling itself.\n * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it\n * doesn't (or if there's no client defined).\n */\nexport function close(timeout?: number): PromiseLike<boolean> {\n const client = getCurrentHub().getClient<BrowserClient>();\n if (client) {\n return client.close(timeout);\n }\n IS_DEBUG_BUILD && logger.warn('Cannot flush events and disable SDK. No client defined.');\n return resolvedSyncPromise(false);\n}\n\n/**\n * Wrap code within a try/catch block so the SDK is able to capture errors.\n *\n * @param fn A function to wrap.\n *\n * @returns The result of wrapped function call.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrap(fn: (...args: any) => any): any {\n return internalWrap(fn)();\n}\n\nfunction startSessionOnHub(hub: Hub): void {\n hub.startSession({ ignoreDuration: true });\n hub.captureSession();\n}\n\n/**\n * Enable automatic Session Tracking for the initial page load.\n */\nfunction startSessionTracking(): void {\n const window = getGlobalObject<Window>();\n const document = window.document;\n\n if (typeof document === 'undefined') {\n IS_DEBUG_BUILD && logger.warn('Session tracking in non-browser environment with @sentry/browser is not supported.');\n return;\n }\n\n const hub = getCurrentHub();\n\n // The only way for this to be false is for there to be a version mismatch between @sentry/browser (>= 6.0.0) and\n // @sentry/hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are\n // pinned at the same version in package.json, but there are edge cases where it's possible. See\n // https://github.com/getsentry/sentry-javascript/issues/3207 and\n // https://github.com/getsentry/sentry-javascript/issues/3234 and\n // https://github.com/getsentry/sentry-javascript/issues/3278.\n if (!hub.captureSession) {\n return;\n }\n\n // The session duration for browser sessions does not track a meaningful\n // concept that can be used as a metric.\n // Automatically captured sessions are akin to page views, and thus we\n // discard their duration.\n startSessionOnHub(hub);\n\n // We want to create a session for every navigation as well\n addInstrumentationHandler('history', ({ from, to }) => {\n // Don't create an additional session for the initial route or if the location did not change\n if (!(from === undefined || from === to)) {\n startSessionOnHub(getCurrentHub());\n }\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;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;;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;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;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;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;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;;;;"}