@sentry/browser 8.39.0-dev.0 → 8.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/build/npm/cjs/client.js +2 -3
  2. package/build/npm/cjs/client.js.map +1 -1
  3. package/build/npm/cjs/eventbuilder.js +18 -19
  4. package/build/npm/cjs/eventbuilder.js.map +1 -1
  5. package/build/npm/cjs/helpers.js +6 -7
  6. package/build/npm/cjs/helpers.js.map +1 -1
  7. package/build/npm/cjs/integrations/breadcrumbs.js +14 -15
  8. package/build/npm/cjs/integrations/breadcrumbs.js.map +1 -1
  9. package/build/npm/cjs/integrations/browserapierrors.js +14 -15
  10. package/build/npm/cjs/integrations/browserapierrors.js.map +1 -1
  11. package/build/npm/cjs/integrations/contextlines.js +3 -4
  12. package/build/npm/cjs/integrations/contextlines.js.map +1 -1
  13. package/build/npm/cjs/integrations/globalhandlers.js +7 -8
  14. package/build/npm/cjs/integrations/globalhandlers.js.map +1 -1
  15. package/build/npm/cjs/integrations/httpclient.js +8 -9
  16. package/build/npm/cjs/integrations/httpclient.js.map +1 -1
  17. package/build/npm/cjs/integrations/linkederrors.js +1 -2
  18. package/build/npm/cjs/integrations/linkederrors.js.map +1 -1
  19. package/build/npm/cjs/integrations/reportingobserver.js +2 -3
  20. package/build/npm/cjs/integrations/reportingobserver.js.map +1 -1
  21. package/build/npm/cjs/integrations/spotlight.js +4 -5
  22. package/build/npm/cjs/integrations/spotlight.js.map +1 -1
  23. package/build/npm/cjs/profiling/integration.js +3 -4
  24. package/build/npm/cjs/profiling/integration.js.map +1 -1
  25. package/build/npm/cjs/profiling/startProfileForSpan.js +7 -8
  26. package/build/npm/cjs/profiling/startProfileForSpan.js.map +1 -1
  27. package/build/npm/cjs/profiling/utils.js +21 -22
  28. package/build/npm/cjs/profiling/utils.js.map +1 -1
  29. package/build/npm/cjs/sdk.js +8 -9
  30. package/build/npm/cjs/sdk.js.map +1 -1
  31. package/build/npm/cjs/stack-parsers.js +17 -10
  32. package/build/npm/cjs/stack-parsers.js.map +1 -1
  33. package/build/npm/cjs/tracing/backgroundtab.js +2 -3
  34. package/build/npm/cjs/tracing/backgroundtab.js.map +1 -1
  35. package/build/npm/cjs/tracing/browserTracingIntegration.js +10 -11
  36. package/build/npm/cjs/tracing/browserTracingIntegration.js.map +1 -1
  37. package/build/npm/cjs/tracing/request.js +12 -13
  38. package/build/npm/cjs/tracing/request.js.map +1 -1
  39. package/build/npm/cjs/transports/fetch.js +2 -3
  40. package/build/npm/cjs/transports/fetch.js.map +1 -1
  41. package/build/npm/cjs/transports/offline.js +3 -4
  42. package/build/npm/cjs/transports/offline.js.map +1 -1
  43. package/build/npm/cjs/userfeedback.js +3 -3
  44. package/build/npm/cjs/userfeedback.js.map +1 -1
  45. package/build/npm/esm/client.js +1 -2
  46. package/build/npm/esm/client.js.map +1 -1
  47. package/build/npm/esm/eventbuilder.js +1 -2
  48. package/build/npm/esm/eventbuilder.js.map +1 -1
  49. package/build/npm/esm/helpers.js +1 -2
  50. package/build/npm/esm/helpers.js.map +1 -1
  51. package/build/npm/esm/integrations/breadcrumbs.js +1 -2
  52. package/build/npm/esm/integrations/breadcrumbs.js.map +1 -1
  53. package/build/npm/esm/integrations/browserapierrors.js +1 -2
  54. package/build/npm/esm/integrations/browserapierrors.js.map +1 -1
  55. package/build/npm/esm/integrations/contextlines.js +1 -2
  56. package/build/npm/esm/integrations/contextlines.js.map +1 -1
  57. package/build/npm/esm/integrations/globalhandlers.js +1 -2
  58. package/build/npm/esm/integrations/globalhandlers.js.map +1 -1
  59. package/build/npm/esm/integrations/httpclient.js +1 -2
  60. package/build/npm/esm/integrations/httpclient.js.map +1 -1
  61. package/build/npm/esm/integrations/linkederrors.js +1 -2
  62. package/build/npm/esm/integrations/linkederrors.js.map +1 -1
  63. package/build/npm/esm/integrations/reportingobserver.js +1 -2
  64. package/build/npm/esm/integrations/reportingobserver.js.map +1 -1
  65. package/build/npm/esm/integrations/spotlight.js +1 -2
  66. package/build/npm/esm/integrations/spotlight.js.map +1 -1
  67. package/build/npm/esm/package.json +1 -1
  68. package/build/npm/esm/profiling/integration.js +1 -2
  69. package/build/npm/esm/profiling/integration.js.map +1 -1
  70. package/build/npm/esm/profiling/startProfileForSpan.js +1 -2
  71. package/build/npm/esm/profiling/startProfileForSpan.js.map +1 -1
  72. package/build/npm/esm/profiling/utils.js +1 -2
  73. package/build/npm/esm/profiling/utils.js.map +1 -1
  74. package/build/npm/esm/sdk.js +1 -2
  75. package/build/npm/esm/sdk.js.map +1 -1
  76. package/build/npm/esm/stack-parsers.js +8 -1
  77. package/build/npm/esm/stack-parsers.js.map +1 -1
  78. package/build/npm/esm/tracing/backgroundtab.js +1 -2
  79. package/build/npm/esm/tracing/backgroundtab.js.map +1 -1
  80. package/build/npm/esm/tracing/browserTracingIntegration.js +1 -2
  81. package/build/npm/esm/tracing/browserTracingIntegration.js.map +1 -1
  82. package/build/npm/esm/tracing/request.js +1 -2
  83. package/build/npm/esm/tracing/request.js.map +1 -1
  84. package/build/npm/esm/transports/fetch.js +1 -2
  85. package/build/npm/esm/transports/fetch.js.map +1 -1
  86. package/build/npm/esm/transports/offline.js +1 -2
  87. package/build/npm/esm/transports/offline.js.map +1 -1
  88. package/build/npm/esm/userfeedback.js +1 -1
  89. package/build/npm/esm/userfeedback.js.map +1 -1
  90. package/build/npm/types/client.d.ts.map +1 -1
  91. package/build/npm/types/eventbuilder.d.ts.map +1 -1
  92. package/build/npm/types/exports.d.ts +1 -1
  93. package/build/npm/types/exports.d.ts.map +1 -1
  94. package/build/npm/types/helpers.d.ts +1 -1
  95. package/build/npm/types/helpers.d.ts.map +1 -1
  96. package/build/npm/types/index.d.ts.map +1 -1
  97. package/build/npm/types/integrations/contextlines.d.ts.map +1 -1
  98. package/build/npm/types/integrations/spotlight.d.ts.map +1 -1
  99. package/build/npm/types/integrations-bundle/index.debug.d.ts.map +1 -1
  100. package/build/npm/types/integrations-bundle/index.sessiontiming.d.ts.map +1 -1
  101. package/build/npm/types/profiling/startProfileForSpan.d.ts.map +1 -1
  102. package/build/npm/types/profiling/utils.d.ts.map +1 -1
  103. package/build/npm/types/sdk.d.ts.map +1 -1
  104. package/build/npm/types/stack-parsers.d.ts.map +1 -1
  105. package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
  106. package/build/npm/types/tracing/request.d.ts.map +1 -1
  107. package/build/npm/types/transports/fetch.d.ts.map +1 -1
  108. package/build/npm/types/transports/offline.d.ts.map +1 -1
  109. package/build/npm/types/userfeedback.d.ts.map +1 -1
  110. package/build/npm/types-ts3.8/exports.d.ts +1 -1
  111. package/build/npm/types-ts3.8/helpers.d.ts +1 -1
  112. package/package.json +8 -9
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  const core = require('@sentry/core');
4
- const utils = require('@sentry/utils');
5
4
  const helpers = require('../helpers.js');
6
5
 
7
6
  const DEFAULT_EVENT_TARGET = [
@@ -56,19 +55,19 @@ const _browserApiErrorsIntegration = ((options = {}) => {
56
55
  // We may want to adjust this to check for client etc.
57
56
  setupOnce() {
58
57
  if (_options.setTimeout) {
59
- utils.fill(helpers.WINDOW, 'setTimeout', _wrapTimeFunction);
58
+ core.fill(helpers.WINDOW, 'setTimeout', _wrapTimeFunction);
60
59
  }
61
60
 
62
61
  if (_options.setInterval) {
63
- utils.fill(helpers.WINDOW, 'setInterval', _wrapTimeFunction);
62
+ core.fill(helpers.WINDOW, 'setInterval', _wrapTimeFunction);
64
63
  }
65
64
 
66
65
  if (_options.requestAnimationFrame) {
67
- utils.fill(helpers.WINDOW, 'requestAnimationFrame', _wrapRAF);
66
+ core.fill(helpers.WINDOW, 'requestAnimationFrame', _wrapRAF);
68
67
  }
69
68
 
70
69
  if (_options.XMLHttpRequest && 'XMLHttpRequest' in helpers.WINDOW) {
71
- utils.fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
70
+ core.fill(XMLHttpRequest.prototype, 'send', _wrapXHR);
72
71
  }
73
72
 
74
73
  const eventTargetOption = _options.eventTarget;
@@ -91,7 +90,7 @@ function _wrapTimeFunction(original) {
91
90
  const originalCallback = args[0];
92
91
  args[0] = helpers.wrap(originalCallback, {
93
92
  mechanism: {
94
- data: { function: utils.getFunctionName(original) },
93
+ data: { function: core.getFunctionName(original) },
95
94
  handled: false,
96
95
  type: 'instrument',
97
96
  },
@@ -110,7 +109,7 @@ function _wrapRAF(original) {
110
109
  mechanism: {
111
110
  data: {
112
111
  function: 'requestAnimationFrame',
113
- handler: utils.getFunctionName(original),
112
+ handler: core.getFunctionName(original),
114
113
  },
115
114
  handled: false,
116
115
  type: 'instrument',
@@ -130,12 +129,12 @@ function _wrapXHR(originalSend) {
130
129
  xmlHttpRequestProps.forEach(prop => {
131
130
  if (prop in xhr && typeof xhr[prop] === 'function') {
132
131
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
- utils.fill(xhr, prop, function (original) {
132
+ core.fill(xhr, prop, function (original) {
134
133
  const wrapOptions = {
135
134
  mechanism: {
136
135
  data: {
137
136
  function: prop,
138
- handler: utils.getFunctionName(original),
137
+ handler: core.getFunctionName(original),
139
138
  },
140
139
  handled: false,
141
140
  type: 'instrument',
@@ -143,9 +142,9 @@ function _wrapXHR(originalSend) {
143
142
  };
144
143
 
145
144
  // If Instrument integration has been called before BrowserApiErrors, get the name of original function
146
- const originalFunction = utils.getOriginalFunction(original);
145
+ const originalFunction = core.getOriginalFunction(original);
147
146
  if (originalFunction) {
148
- wrapOptions.mechanism.data.handler = utils.getFunctionName(originalFunction);
147
+ wrapOptions.mechanism.data.handler = core.getFunctionName(originalFunction);
149
148
  }
150
149
 
151
150
  // Otherwise wrap directly
@@ -169,7 +168,7 @@ function _wrapEventTarget(target) {
169
168
  return;
170
169
  }
171
170
 
172
- utils.fill(proto, 'addEventListener', function (original,)
171
+ core.fill(proto, 'addEventListener', function (original,)
173
172
 
174
173
  {
175
174
  return function (
@@ -191,7 +190,7 @@ function _wrapEventTarget(target) {
191
190
  mechanism: {
192
191
  data: {
193
192
  function: 'handleEvent',
194
- handler: utils.getFunctionName(fn),
193
+ handler: core.getFunctionName(fn),
195
194
  target,
196
195
  },
197
196
  handled: false,
@@ -210,7 +209,7 @@ function _wrapEventTarget(target) {
210
209
  mechanism: {
211
210
  data: {
212
211
  function: 'addEventListener',
213
- handler: utils.getFunctionName(fn),
212
+ handler: core.getFunctionName(fn),
214
213
  target,
215
214
  },
216
215
  handled: false,
@@ -222,7 +221,7 @@ function _wrapEventTarget(target) {
222
221
  };
223
222
  });
224
223
 
225
- utils.fill(
224
+ core.fill(
226
225
  proto,
227
226
  'removeEventListener',
228
227
  function (
@@ -1 +1 @@
1
- {"version":3,"file":"browserapierrors.js","sources":["../../../../src/integrations/browserapierrors.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport type { IntegrationFn, WrappedFunction } from '@sentry/types';\nimport { fill, getFunctionName, getOriginalFunction } from '@sentry/utils';\n\nimport { WINDOW, wrap } from '../helpers';\n\nconst DEFAULT_EVENT_TARGET = [\n 'EventTarget',\n 'Window',\n 'Node',\n 'ApplicationCache',\n 'AudioTrackList',\n 'BroadcastChannel',\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 'SharedWorker',\n 'TextTrack',\n 'TextTrackCue',\n 'TextTrackList',\n 'WebSocket',\n 'WebSocketWorker',\n 'Worker',\n 'XMLHttpRequest',\n 'XMLHttpRequestEventTarget',\n 'XMLHttpRequestUpload',\n];\n\nconst INTEGRATION_NAME = 'BrowserApiErrors';\n\ntype XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' | 'onreadystatechange';\n\ninterface BrowserApiErrorsOptions {\n setTimeout: boolean;\n setInterval: boolean;\n requestAnimationFrame: boolean;\n XMLHttpRequest: boolean;\n eventTarget: boolean | string[];\n}\n\nconst _browserApiErrorsIntegration = ((options: Partial<BrowserApiErrorsOptions> = {}) => {\n const _options = {\n XMLHttpRequest: true,\n eventTarget: true,\n requestAnimationFrame: true,\n setInterval: true,\n setTimeout: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n // TODO: This currently only works for the first client this is setup\n // We may want to adjust this to check for client etc.\n setupOnce() {\n if (_options.setTimeout) {\n fill(WINDOW, 'setTimeout', _wrapTimeFunction);\n }\n\n if (_options.setInterval) {\n fill(WINDOW, 'setInterval', _wrapTimeFunction);\n }\n\n if (_options.requestAnimationFrame) {\n fill(WINDOW, 'requestAnimationFrame', _wrapRAF);\n }\n\n if (_options.XMLHttpRequest && 'XMLHttpRequest' in WINDOW) {\n fill(XMLHttpRequest.prototype, 'send', _wrapXHR);\n }\n\n const eventTargetOption = _options.eventTarget;\n if (eventTargetOption) {\n const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;\n eventTarget.forEach(_wrapEventTarget);\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Wrap timer functions and event targets to catch errors and provide better meta data.\n */\nexport const browserApiErrorsIntegration = defineIntegration(_browserApiErrorsIntegration);\n\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: false,\n type: 'instrument',\n },\n });\n return original.apply(this, args);\n };\n}\n\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: false,\n type: 'instrument',\n },\n }),\n ]);\n };\n}\n\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: false,\n type: 'instrument',\n },\n };\n\n // If Instrument integration has been called before BrowserApiErrors, 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\nfunction _wrapEventTarget(target: string): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const globalObject = WINDOW as { [key: string]: any };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const proto = globalObject[target] && globalObject[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: VoidFunction,): (\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 // ESlint disable explanation:\n // First, it is generally safe to call `wrap` with an unbound function. Furthermore, using `.bind()` would\n // introduce a bug here, because bind returns a new function that doesn't have our\n // flags(like __sentry_original__) attached. `wrap` checks for those flags to avoid unnecessary wrapping.\n // Without those flags, every call to addEventListener wraps the function again, causing a memory leak.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n fn.handleEvent = wrap(fn.handleEvent, {\n mechanism: {\n data: {\n function: 'handleEvent',\n handler: getFunctionName(fn),\n target,\n },\n handled: false,\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: false,\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":["fill","WINDOW","defineIntegration","wrap","getFunctionName","getOriginalFunction"],"mappings":";;;;;;AAMA,MAAM,uBAAuB;AAC7B,EAAE,aAAa;AACf,EAAE,QAAQ;AACV,EAAE,MAAM;AACR,EAAE,kBAAkB;AACpB,EAAE,gBAAgB;AAClB,EAAE,kBAAkB;AACpB,EAAE,mBAAmB;AACrB,EAAE,iBAAiB;AACnB,EAAE,aAAa;AACf,EAAE,YAAY;AACd,EAAE,oBAAoB;AACtB,EAAE,aAAa;AACf,EAAE,YAAY;AACd,EAAE,gBAAgB;AAClB,EAAE,cAAc;AAChB,EAAE,iBAAiB;AACnB,EAAE,aAAa;AACf,EAAE,aAAa;AACf,EAAE,cAAc;AAChB,EAAE,oBAAoB;AACtB,EAAE,QAAQ;AACV,EAAE,cAAc;AAChB,EAAE,WAAW;AACb,EAAE,cAAc;AAChB,EAAE,eAAe;AACjB,EAAE,WAAW;AACb,EAAE,iBAAiB;AACnB,EAAE,QAAQ;AACV,EAAE,gBAAgB;AAClB,EAAE,2BAA2B;AAC7B,EAAE,sBAAsB;AACxB,CAAC;;AAED,MAAM,gBAAA,GAAmB,kBAAkB;;AAY3C,MAAM,4BAAA,IAAgC,CAAC,OAAO,GAAqC,EAAE,KAAK;AAC1F,EAAE,MAAM,WAAW;AACnB,IAAI,cAAc,EAAE,IAAI;AACxB,IAAI,WAAW,EAAE,IAAI;AACrB,IAAI,qBAAqB,EAAE,IAAI;AAC/B,IAAI,W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AC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,oBAAoB,EAAE,OAAO,CAAC;AAC5F;AACA,SAAU,CAAA,OAAO,CAAC,EAAE;AACpB;AACA;AACA,QAAQ,OAAO,2BAA2B,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC;AAC9F,OAAO;AACP,KAAK;AACL,GAAG;AACH;;;;"}
1
+ {"version":3,"file":"browserapierrors.js","sources":["../../../../src/integrations/browserapierrors.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport { fill, getFunctionName, getOriginalFunction } from '@sentry/core';\nimport type { IntegrationFn, WrappedFunction } from '@sentry/types';\n\nimport { WINDOW, wrap } from '../helpers';\n\nconst DEFAULT_EVENT_TARGET = [\n 'EventTarget',\n 'Window',\n 'Node',\n 'ApplicationCache',\n 'AudioTrackList',\n 'BroadcastChannel',\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 'SharedWorker',\n 'TextTrack',\n 'TextTrackCue',\n 'TextTrackList',\n 'WebSocket',\n 'WebSocketWorker',\n 'Worker',\n 'XMLHttpRequest',\n 'XMLHttpRequestEventTarget',\n 'XMLHttpRequestUpload',\n];\n\nconst INTEGRATION_NAME = 'BrowserApiErrors';\n\ntype XMLHttpRequestProp = 'onload' | 'onerror' | 'onprogress' | 'onreadystatechange';\n\ninterface BrowserApiErrorsOptions {\n setTimeout: boolean;\n setInterval: boolean;\n requestAnimationFrame: boolean;\n XMLHttpRequest: boolean;\n eventTarget: boolean | string[];\n}\n\nconst _browserApiErrorsIntegration = ((options: Partial<BrowserApiErrorsOptions> = {}) => {\n const _options = {\n XMLHttpRequest: true,\n eventTarget: true,\n requestAnimationFrame: true,\n setInterval: true,\n setTimeout: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n // TODO: This currently only works for the first client this is setup\n // We may want to adjust this to check for client etc.\n setupOnce() {\n if (_options.setTimeout) {\n fill(WINDOW, 'setTimeout', _wrapTimeFunction);\n }\n\n if (_options.setInterval) {\n fill(WINDOW, 'setInterval', _wrapTimeFunction);\n }\n\n if (_options.requestAnimationFrame) {\n fill(WINDOW, 'requestAnimationFrame', _wrapRAF);\n }\n\n if (_options.XMLHttpRequest && 'XMLHttpRequest' in WINDOW) {\n fill(XMLHttpRequest.prototype, 'send', _wrapXHR);\n }\n\n const eventTargetOption = _options.eventTarget;\n if (eventTargetOption) {\n const eventTarget = Array.isArray(eventTargetOption) ? eventTargetOption : DEFAULT_EVENT_TARGET;\n eventTarget.forEach(_wrapEventTarget);\n }\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Wrap timer functions and event targets to catch errors and provide better meta data.\n */\nexport const browserApiErrorsIntegration = defineIntegration(_browserApiErrorsIntegration);\n\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: false,\n type: 'instrument',\n },\n });\n return original.apply(this, args);\n };\n}\n\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: false,\n type: 'instrument',\n },\n }),\n ]);\n };\n}\n\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: false,\n type: 'instrument',\n },\n };\n\n // If Instrument integration has been called before BrowserApiErrors, 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\nfunction _wrapEventTarget(target: string): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const globalObject = WINDOW as { [key: string]: any };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const proto = globalObject[target] && globalObject[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: VoidFunction,): (\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 // ESlint disable explanation:\n // First, it is generally safe to call `wrap` with an unbound function. Furthermore, using `.bind()` would\n // introduce a bug here, because bind returns a new function that doesn't have our\n // flags(like __sentry_original__) attached. `wrap` checks for those flags to avoid unnecessary wrapping.\n // Without those flags, every call to addEventListener wraps the function again, causing a memory leak.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n fn.handleEvent = wrap(fn.handleEvent, {\n mechanism: {\n data: {\n function: 'handleEvent',\n handler: getFunctionName(fn),\n target,\n },\n handled: false,\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: false,\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":["fill","WINDOW","defineIntegration","wrap","getFunctionName","getOriginalFunction"],"mappings":";;;;;AAMA,MAAM,uBAAuB;AAC7B,EAAE,aAAa;AACf,EAAE,QAAQ;AACV,EAAE,MAAM;AACR,EAAE,kBAAkB;AACpB,EAAE,gBAAgB;AAClB,EAAE,kBAAkB;AACpB,EAAE,mBAAmB;AACrB,EAAE,iBAAiB;AACnB,EAAE,aAAa;AACf,EAAE,YAAY;AACd,EAAE,oBAAoB;AACtB,EAAE,aAAa;AACf,EAAE,YAAY;AACd,EAAE,gBAAgB;AAClB,EAAE,cAAc;AAChB,EAAE,iBAAiB;AACnB,EAAE,aAAa;AACf,EAAE,aAAa;AACf,EAAE,cAAc;AAChB,EAAE,oBAAoB;AACtB,EAAE,QAAQ;AACV,EAAE,cAAc;AAChB,EAAE,WAAW;AACb,EAAE,cAAc;AAChB,EAAE,eAAe;AACjB,EAAE,WAAW;AACb,EAAE,iBAAiB;AACnB,EAAE,QAAQ;AACV,EAAE,gBAAgB;AAClB,EAAE,2BAA2B;AAC7B,EAAE,sBAAsB;AACxB,CAAC;;AAED,MAAM,gBAAA,GAAmB,kBAAkB;;AAY3C,MAAM,4BAAA,IAAgC,CAAC,OAAO,GAAqC,EAAE,KAAK;AAC1F,EAAE,MAAM,WAAW;AACnB,IAAI,cAAc,EAAE,IAAI;AACxB,IAAI,WAAW,EAAE,IAAI;AACrB,IAAI,qBAAqB,EAAE,IAAI;AAC/B,IAAI,WAAW,EAAE,IAAI;AACrB,IAAI,UAAU,EAAE,IAAI;AACpB,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B;AACA;AACA,IAAI,SAAS,GAAG;AAChB,MAAM,IAAI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AE,mBAAmB,EAAE,OAAO,CAAC;AAC9F,OAAO;AACP,KAAK;AACL,GAAG;AACH;;;;"}
@@ -1,9 +1,8 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  const core = require('@sentry/core');
4
- const utils = require('@sentry/utils');
5
4
 
6
- const WINDOW = utils.GLOBAL_OBJ ;
5
+ const WINDOW = core.GLOBAL_OBJ ;
7
6
 
8
7
  const DEFAULT_LINES_OF_CONTEXT = 7;
9
8
 
@@ -38,7 +37,7 @@ const contextLinesIntegration = core.defineIntegration(_contextLinesIntegration)
38
37
  */
39
38
  function addSourceContext(event, contextLines) {
40
39
  const doc = WINDOW.document;
41
- const htmlFilename = WINDOW.location && utils.stripUrlQueryAndFragment(WINDOW.location.href);
40
+ const htmlFilename = WINDOW.location && core.stripUrlQueryAndFragment(WINDOW.location.href);
42
41
  if (!doc || !htmlFilename) {
43
42
  return event;
44
43
  }
@@ -80,7 +79,7 @@ function applySourceContextToFrame(
80
79
  return frame;
81
80
  }
82
81
 
83
- utils.addContextToFrame(htmlLines, frame, linesOfContext);
82
+ core.addContextToFrame(htmlLines, frame, linesOfContext);
84
83
 
85
84
  return frame;
86
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"contextlines.js","sources":["../../../../src/integrations/contextlines.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport type { Event, IntegrationFn, StackFrame } from '@sentry/types';\nimport { GLOBAL_OBJ, addContextToFrame, stripUrlQueryAndFragment } from '@sentry/utils';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst DEFAULT_LINES_OF_CONTEXT = 7;\n\nconst INTEGRATION_NAME = 'ContextLines';\n\ninterface ContextLinesOptions {\n /**\n * Sets the number of context lines for each frame when loading a file.\n * Defaults to 7.\n *\n * Set to 0 to disable loading and inclusion of source files.\n **/\n frameContextLines?: number;\n}\n\nconst _contextLinesIntegration = ((options: ContextLinesOptions = {}) => {\n const contextLines = options.frameContextLines != null ? options.frameContextLines : DEFAULT_LINES_OF_CONTEXT;\n\n return {\n name: INTEGRATION_NAME,\n processEvent(event) {\n return addSourceContext(event, contextLines);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Collects source context lines around the lines of stackframes pointing to JS embedded in\n * the current page's HTML.\n *\n * This integration DOES NOT work for stack frames pointing to JS files that are loaded by the browser.\n * For frames pointing to files, context lines are added during ingestion and symbolication\n * by attempting to download the JS files to the Sentry backend.\n *\n * Use this integration if you have inline JS code in HTML pages that can't be accessed\n * by our backend (e.g. due to a login-protected page).\n */\nexport const contextLinesIntegration = defineIntegration(_contextLinesIntegration);\n\n/**\n * Processes an event and adds context lines.\n */\nfunction addSourceContext(event: Event, contextLines: number): Event {\n const doc = WINDOW.document;\n const htmlFilename = WINDOW.location && stripUrlQueryAndFragment(WINDOW.location.href);\n if (!doc || !htmlFilename) {\n return event;\n }\n\n const exceptions = event.exception && event.exception.values;\n if (!exceptions || !exceptions.length) {\n return event;\n }\n\n const html = doc.documentElement.innerHTML;\n if (!html) {\n return event;\n }\n\n const htmlLines = ['<!DOCTYPE html>', '<html>', ...html.split('\\n'), '</html>'];\n\n exceptions.forEach(exception => {\n const stacktrace = exception.stacktrace;\n if (stacktrace && stacktrace.frames) {\n stacktrace.frames = stacktrace.frames.map(frame =>\n applySourceContextToFrame(frame, htmlLines, htmlFilename, contextLines),\n );\n }\n });\n\n return event;\n}\n\n/**\n * Only exported for testing\n */\nexport function applySourceContextToFrame(\n frame: StackFrame,\n htmlLines: string[],\n htmlFilename: string,\n linesOfContext: number,\n): StackFrame {\n if (frame.filename !== htmlFilename || !frame.lineno || !htmlLines.length) {\n return frame;\n }\n\n addContextToFrame(htmlLines, frame, linesOfContext);\n\n return frame;\n}\n"],"names":["GLOBAL_OBJ","defineIntegration","stripUrlQueryAndFragment","addContextToFrame"],"mappings":";;;;;AAIA,MAAM,MAAA,GAASA,gBAAW;;AAE1B,MAAM,wBAAA,GAA2B,CAAC;;AAElC,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AU,CAAC,OAAO,CAAC,aAAa;AAClC,IAAI,MAAM,UAAA,GAAa,SAAS,CAAC,UAAU;AAC3C,IAAI,IAAI,UAAA,IAAc,UAAU,CAAC,MAAM,EAAE;AACzC,MAAM,UAAU,CAAC,MAAA,GAAS,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAM;AACtD,QAAQ,yBAAyB,CAAC,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,CAAC;AAC/E,OAAO;AACP;AACA,GAAG,CAAC;;AAEJ,EAAE,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACO,SAAS,yBAAyB;AACzC,EAAE,KAAK;AACP,EAAE,SAAS;AACX,EAAE,YAAY;AACd,EAAE,cAAc;AAChB,EAAc;AACd,EAAE,IAAI,KAAK,CAAC,QAAA,KAAa,YAAa,IAAG,CAAC,KAAK,CAAC,MAAO,IAAG,CAAC,SAAS,CAAC,MAAM,EAAE;AAC7E,IAAI,OAAO,KAAK;AAChB;;AAEA,EAAEC,uBAAiB,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,CAAC;;AAErD,EAAE,OAAO,KAAK;AACd;;;;;"}
1
+ {"version":3,"file":"contextlines.js","sources":["../../../../src/integrations/contextlines.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport { GLOBAL_OBJ, addContextToFrame, stripUrlQueryAndFragment } from '@sentry/core';\nimport type { Event, IntegrationFn, StackFrame } from '@sentry/types';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst DEFAULT_LINES_OF_CONTEXT = 7;\n\nconst INTEGRATION_NAME = 'ContextLines';\n\ninterface ContextLinesOptions {\n /**\n * Sets the number of context lines for each frame when loading a file.\n * Defaults to 7.\n *\n * Set to 0 to disable loading and inclusion of source files.\n **/\n frameContextLines?: number;\n}\n\nconst _contextLinesIntegration = ((options: ContextLinesOptions = {}) => {\n const contextLines = options.frameContextLines != null ? options.frameContextLines : DEFAULT_LINES_OF_CONTEXT;\n\n return {\n name: INTEGRATION_NAME,\n processEvent(event) {\n return addSourceContext(event, contextLines);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Collects source context lines around the lines of stackframes pointing to JS embedded in\n * the current page's HTML.\n *\n * This integration DOES NOT work for stack frames pointing to JS files that are loaded by the browser.\n * For frames pointing to files, context lines are added during ingestion and symbolication\n * by attempting to download the JS files to the Sentry backend.\n *\n * Use this integration if you have inline JS code in HTML pages that can't be accessed\n * by our backend (e.g. due to a login-protected page).\n */\nexport const contextLinesIntegration = defineIntegration(_contextLinesIntegration);\n\n/**\n * Processes an event and adds context lines.\n */\nfunction addSourceContext(event: Event, contextLines: number): Event {\n const doc = WINDOW.document;\n const htmlFilename = WINDOW.location && stripUrlQueryAndFragment(WINDOW.location.href);\n if (!doc || !htmlFilename) {\n return event;\n }\n\n const exceptions = event.exception && event.exception.values;\n if (!exceptions || !exceptions.length) {\n return event;\n }\n\n const html = doc.documentElement.innerHTML;\n if (!html) {\n return event;\n }\n\n const htmlLines = ['<!DOCTYPE html>', '<html>', ...html.split('\\n'), '</html>'];\n\n exceptions.forEach(exception => {\n const stacktrace = exception.stacktrace;\n if (stacktrace && stacktrace.frames) {\n stacktrace.frames = stacktrace.frames.map(frame =>\n applySourceContextToFrame(frame, htmlLines, htmlFilename, contextLines),\n );\n }\n });\n\n return event;\n}\n\n/**\n * Only exported for testing\n */\nexport function applySourceContextToFrame(\n frame: StackFrame,\n htmlLines: string[],\n htmlFilename: string,\n linesOfContext: number,\n): StackFrame {\n if (frame.filename !== htmlFilename || !frame.lineno || !htmlLines.length) {\n return frame;\n }\n\n addContextToFrame(htmlLines, frame, linesOfContext);\n\n return frame;\n}\n"],"names":["GLOBAL_OBJ","defineIntegration","stripUrlQueryAndFragment","addContextToFrame"],"mappings":";;;;AAIA,MAAM,MAAA,GAASA,eAAW;;AAE1B,MAAM,wBAAA,GAA2B,CAAC;;AAElC,MAAM,gBAAA,GAAmB,cAAc;;AAYvC,MAAM,wB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M,UAAA,GAAa,SAAS,CAAC,UAAU;AAC3C,IAAI,IAAI,UAAA,IAAc,UAAU,CAAC,MAAM,EAAE;AACzC,MAAM,UAAU,CAAC,MAAA,GAAS,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,KAAM;AACtD,QAAQ,yBAAyB,CAAC,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,CAAC;AAC/E,OAAO;AACP;AACA,GAAG,CAAC;;AAEJ,EAAE,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACO,SAAS,yBAAyB;AACzC,EAAE,KAAK;AACP,EAAE,SAAS;AACX,EAAE,YAAY;AACd,EAAE,cAAc;AAChB,EAAc;AACd,EAAE,IAAI,KAAK,CAAC,QAAA,KAAa,YAAa,IAAG,CAAC,KAAK,CAAC,MAAO,IAAG,CAAC,SAAS,CAAC,MAAM,EAAE;AAC7E,IAAI,OAAO,KAAK;AAChB;;AAEA,EAAEC,sBAAiB,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,CAAC;;AAErD,EAAE,OAAO,KAAK;AACd;;;;;"}
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  const core = require('@sentry/core');
4
- const utils = require('@sentry/utils');
5
4
  const debugBuild = require('../debug-build.js');
6
5
  const eventbuilder = require('../eventbuilder.js');
7
6
  const helpers = require('../helpers.js');
@@ -36,7 +35,7 @@ const _globalHandlersIntegration = ((options = {}) => {
36
35
  const globalHandlersIntegration = core.defineIntegration(_globalHandlersIntegration);
37
36
 
38
37
  function _installGlobalOnErrorHandler(client) {
39
- utils.addGlobalErrorInstrumentationHandler(data => {
38
+ core.addGlobalErrorInstrumentationHandler(data => {
40
39
  const { stackParser, attachStacktrace } = getOptions();
41
40
 
42
41
  if (core.getClient() !== client || helpers.shouldIgnoreOnError()) {
@@ -65,7 +64,7 @@ function _installGlobalOnErrorHandler(client) {
65
64
  }
66
65
 
67
66
  function _installGlobalOnUnhandledRejectionHandler(client) {
68
- utils.addGlobalUnhandledRejectionInstrumentationHandler(e => {
67
+ core.addGlobalUnhandledRejectionInstrumentationHandler(e => {
69
68
  const { stackParser, attachStacktrace } = getOptions();
70
69
 
71
70
  if (core.getClient() !== client || helpers.shouldIgnoreOnError()) {
@@ -74,7 +73,7 @@ function _installGlobalOnUnhandledRejectionHandler(client) {
74
73
 
75
74
  const error = _getUnhandledRejectionError(e );
76
75
 
77
- const event = utils.isPrimitive(error)
76
+ const event = core.isPrimitive(error)
78
77
  ? _eventFromRejectionWithPrimitive(error)
79
78
  : eventbuilder.eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);
80
79
 
@@ -91,7 +90,7 @@ function _installGlobalOnUnhandledRejectionHandler(client) {
91
90
  }
92
91
 
93
92
  function _getUnhandledRejectionError(error) {
94
- if (utils.isPrimitive(error)) {
93
+ if (core.isPrimitive(error)) {
95
94
  return error;
96
95
  }
97
96
 
@@ -152,14 +151,14 @@ function _enhanceEventWithInitialFrame(event, url, line, column) {
152
151
 
153
152
  const colno = isNaN(parseInt(column, 10)) ? undefined : column;
154
153
  const lineno = isNaN(parseInt(line, 10)) ? undefined : line;
155
- const filename = utils.isString(url) && url.length > 0 ? url : utils.getLocationHref();
154
+ const filename = core.isString(url) && url.length > 0 ? url : core.getLocationHref();
156
155
 
157
156
  // event.exception.values[0].stacktrace.frames
158
157
  if (ev0sf.length === 0) {
159
158
  ev0sf.push({
160
159
  colno,
161
160
  filename,
162
- function: utils.UNKNOWN_FUNCTION,
161
+ function: core.UNKNOWN_FUNCTION,
163
162
  in_app: true,
164
163
  lineno,
165
164
  });
@@ -169,7 +168,7 @@ function _enhanceEventWithInitialFrame(event, url, line, column) {
169
168
  }
170
169
 
171
170
  function globalHandlerLog(type) {
172
- debugBuild.DEBUG_BUILD && utils.logger.log(`Global Handler attached: ${type}`);
171
+ debugBuild.DEBUG_BUILD && core.logger.log(`Global Handler attached: ${type}`);
173
172
  }
174
173
 
175
174
  function getOptions() {
@@ -1 +1 @@
1
- {"version":3,"file":"globalhandlers.js","sources":["../../../../src/integrations/globalhandlers.ts"],"sourcesContent":["import { captureEvent, defineIntegration, getClient } from '@sentry/core';\nimport type { Client, Event, IntegrationFn, Primitive, StackParser } from '@sentry/types';\nimport {\n UNKNOWN_FUNCTION,\n addGlobalErrorInstrumentationHandler,\n addGlobalUnhandledRejectionInstrumentationHandler,\n getLocationHref,\n isPrimitive,\n isString,\n logger,\n} from '@sentry/utils';\n\nimport type { BrowserClient } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { eventFromUnknownInput } from '../eventbuilder';\nimport { shouldIgnoreOnError } from '../helpers';\n\ntype GlobalHandlersIntegrationsOptionKeys = 'onerror' | 'onunhandledrejection';\n\ntype GlobalHandlersIntegrations = Record<GlobalHandlersIntegrationsOptionKeys, boolean>;\n\nconst INTEGRATION_NAME = 'GlobalHandlers';\n\nconst _globalHandlersIntegration = ((options: Partial<GlobalHandlersIntegrations> = {}) => {\n const _options = {\n onerror: true,\n onunhandledrejection: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n Error.stackTraceLimit = 50;\n },\n setup(client) {\n if (_options.onerror) {\n _installGlobalOnErrorHandler(client);\n globalHandlerLog('onerror');\n }\n if (_options.onunhandledrejection) {\n _installGlobalOnUnhandledRejectionHandler(client);\n globalHandlerLog('onunhandledrejection');\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const globalHandlersIntegration = defineIntegration(_globalHandlersIntegration);\n\nfunction _installGlobalOnErrorHandler(client: Client): void {\n addGlobalErrorInstrumentationHandler(data => {\n const { stackParser, attachStacktrace } = getOptions();\n\n if (getClient() !== client || shouldIgnoreOnError()) {\n return;\n }\n\n const { msg, url, line, column, error } = data;\n\n const event = _enhanceEventWithInitialFrame(\n eventFromUnknownInput(stackParser, error || msg, undefined, attachStacktrace, false),\n url,\n line,\n column,\n );\n\n event.level = 'error';\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'onerror',\n },\n });\n });\n}\n\nfunction _installGlobalOnUnhandledRejectionHandler(client: Client): void {\n addGlobalUnhandledRejectionInstrumentationHandler(e => {\n const { stackParser, attachStacktrace } = getOptions();\n\n if (getClient() !== client || shouldIgnoreOnError()) {\n return;\n }\n\n const error = _getUnhandledRejectionError(e as unknown);\n\n const event = isPrimitive(error)\n ? _eventFromRejectionWithPrimitive(error)\n : eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);\n\n event.level = 'error';\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'onunhandledrejection',\n },\n });\n });\n}\n\nfunction _getUnhandledRejectionError(error: unknown): unknown {\n if (isPrimitive(error)) {\n return error;\n }\n\n // dig the object of the rejection out of known event types\n try {\n type ErrorWithReason = { reason: unknown };\n // PromiseRejectionEvents store the object of the rejection under 'reason'\n // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent\n if ('reason' in (error as ErrorWithReason)) {\n return (error as ErrorWithReason).reason;\n }\n\n type CustomEventWithDetail = { detail: { reason: unknown } };\n // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents\n // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into\n // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec\n // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and\n // https://github.com/getsentry/sentry-javascript/issues/2380\n if ('detail' in (error as CustomEventWithDetail) && 'reason' in (error as CustomEventWithDetail).detail) {\n return (error as CustomEventWithDetail).detail.reason;\n }\n } catch {} // eslint-disable-line no-empty\n\n return error;\n}\n\n/**\n * Create an event from a promise rejection where the `reason` is a primitive.\n *\n * @param reason: The `reason` property of the promise rejection\n * @returns An Event object with an appropriate `exception` value\n */\nfunction _eventFromRejectionWithPrimitive(reason: Primitive): Event {\n return {\n exception: {\n values: [\n {\n type: 'UnhandledRejection',\n // String() is needed because the Primitive type includes symbols (which can't be automatically stringified)\n value: `Non-Error promise rejection captured with value: ${String(reason)}`,\n },\n ],\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column: any): Event {\n // event.exception\n const e = (event.exception = event.exception || {});\n // event.exception.values\n const ev = (e.values = e.values || []);\n // event.exception.values[0]\n const ev0 = (ev[0] = ev[0] || {});\n // event.exception.values[0].stacktrace\n const ev0s = (ev0.stacktrace = ev0.stacktrace || {});\n // event.exception.values[0].stacktrace.frames\n const ev0sf = (ev0s.frames = ev0s.frames || []);\n\n const colno = isNaN(parseInt(column, 10)) ? undefined : column;\n const lineno = isNaN(parseInt(line, 10)) ? undefined : line;\n const filename = isString(url) && url.length > 0 ? url : getLocationHref();\n\n // event.exception.values[0].stacktrace.frames\n if (ev0sf.length === 0) {\n ev0sf.push({\n colno,\n filename,\n function: UNKNOWN_FUNCTION,\n in_app: true,\n lineno,\n });\n }\n\n return event;\n}\n\nfunction globalHandlerLog(type: string): void {\n DEBUG_BUILD && logger.log(`Global Handler attached: ${type}`);\n}\n\nfunction getOptions(): { stackParser: StackParser; attachStacktrace?: boolean } {\n const client = getClient<BrowserClient>();\n const options = (client && client.getOptions()) || {\n stackParser: () => [],\n attachStacktrace: false,\n };\n return options;\n}\n"],"names":["defineIntegration","addGlobalErrorInstrumentationHandler","getClient","shouldIgnoreOnError","eventFromUnknownInput","captureEvent","addGlobalUnhandledRejectionInstrumentationHandler","isPrimitive","isString","getLocationHref","UNKNOWN_FUNCTION","DEBUG_BUILD","logger"],"mappings":";;;;;;;;AAqBA,MAAM,gBAAA,GAAmB,gBAAgB;;AAEzC,MAAM,0BAAA,IAA8B,CAAC,OAAO,GAAwC,EAAE,KAAK;AAC3F,EAAE,MAAM,WAAW;AACnB,IAAI,OAAO,EAAE,IAAI;AACjB,IAAI,oBAAoB,EAAE,IAAI;AAC9B,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAA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,EAAA,IAAA,KAAA,CAAA,MAAA,KAAA,CAAA,EAAA;AACA,IAAA,KAAA,CAAA,IAAA,CAAA;AACA,MAAA,KAAA;AACA,MAAA,QAAA;AACA,MAAA,QAAA,EAAAC,sBAAA;AACA,MAAA,MAAA,EAAA,IAAA;AACA,MAAA,MAAA;AACA,KAAA,CAAA;AACA;;AAEA,EAAA,OAAA,KAAA;AACA;;AAEA,SAAA,gBAAA,CAAA,IAAA,EAAA;AACA,EAAAC,sBAAA,IAAAC,YAAA,CAAA,GAAA,CAAA,CAAA,yBAAA,EAAA,IAAA,CAAA,CAAA,CAAA;AACA;;AAEA,SAAA,UAAA,GAAA;AACA,EAAA,MAAA,MAAA,GAAAV,cAAA,EAAA;AACA,EAAA,MAAA,OAAA,GAAA,CAAA,MAAA,IAAA,MAAA,CAAA,UAAA,EAAA,KAAA;AACA,IAAA,WAAA,EAAA,MAAA,EAAA;AACA,IAAA,gBAAA,EAAA,KAAA;AACA,GAAA;AACA,EAAA,OAAA,OAAA;AACA;;;;"}
1
+ {"version":3,"file":"globalhandlers.js","sources":["../../../../src/integrations/globalhandlers.ts"],"sourcesContent":["import { captureEvent, defineIntegration, getClient } from '@sentry/core';\nimport {\n UNKNOWN_FUNCTION,\n addGlobalErrorInstrumentationHandler,\n addGlobalUnhandledRejectionInstrumentationHandler,\n getLocationHref,\n isPrimitive,\n isString,\n logger,\n} from '@sentry/core';\nimport type { Client, Event, IntegrationFn, Primitive, StackParser } from '@sentry/types';\n\nimport type { BrowserClient } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { eventFromUnknownInput } from '../eventbuilder';\nimport { shouldIgnoreOnError } from '../helpers';\n\ntype GlobalHandlersIntegrationsOptionKeys = 'onerror' | 'onunhandledrejection';\n\ntype GlobalHandlersIntegrations = Record<GlobalHandlersIntegrationsOptionKeys, boolean>;\n\nconst INTEGRATION_NAME = 'GlobalHandlers';\n\nconst _globalHandlersIntegration = ((options: Partial<GlobalHandlersIntegrations> = {}) => {\n const _options = {\n onerror: true,\n onunhandledrejection: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n Error.stackTraceLimit = 50;\n },\n setup(client) {\n if (_options.onerror) {\n _installGlobalOnErrorHandler(client);\n globalHandlerLog('onerror');\n }\n if (_options.onunhandledrejection) {\n _installGlobalOnUnhandledRejectionHandler(client);\n globalHandlerLog('onunhandledrejection');\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const globalHandlersIntegration = defineIntegration(_globalHandlersIntegration);\n\nfunction _installGlobalOnErrorHandler(client: Client): void {\n addGlobalErrorInstrumentationHandler(data => {\n const { stackParser, attachStacktrace } = getOptions();\n\n if (getClient() !== client || shouldIgnoreOnError()) {\n return;\n }\n\n const { msg, url, line, column, error } = data;\n\n const event = _enhanceEventWithInitialFrame(\n eventFromUnknownInput(stackParser, error || msg, undefined, attachStacktrace, false),\n url,\n line,\n column,\n );\n\n event.level = 'error';\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'onerror',\n },\n });\n });\n}\n\nfunction _installGlobalOnUnhandledRejectionHandler(client: Client): void {\n addGlobalUnhandledRejectionInstrumentationHandler(e => {\n const { stackParser, attachStacktrace } = getOptions();\n\n if (getClient() !== client || shouldIgnoreOnError()) {\n return;\n }\n\n const error = _getUnhandledRejectionError(e as unknown);\n\n const event = isPrimitive(error)\n ? _eventFromRejectionWithPrimitive(error)\n : eventFromUnknownInput(stackParser, error, undefined, attachStacktrace, true);\n\n event.level = 'error';\n\n captureEvent(event, {\n originalException: error,\n mechanism: {\n handled: false,\n type: 'onunhandledrejection',\n },\n });\n });\n}\n\nfunction _getUnhandledRejectionError(error: unknown): unknown {\n if (isPrimitive(error)) {\n return error;\n }\n\n // dig the object of the rejection out of known event types\n try {\n type ErrorWithReason = { reason: unknown };\n // PromiseRejectionEvents store the object of the rejection under 'reason'\n // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent\n if ('reason' in (error as ErrorWithReason)) {\n return (error as ErrorWithReason).reason;\n }\n\n type CustomEventWithDetail = { detail: { reason: unknown } };\n // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents\n // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into\n // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec\n // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and\n // https://github.com/getsentry/sentry-javascript/issues/2380\n if ('detail' in (error as CustomEventWithDetail) && 'reason' in (error as CustomEventWithDetail).detail) {\n return (error as CustomEventWithDetail).detail.reason;\n }\n } catch {} // eslint-disable-line no-empty\n\n return error;\n}\n\n/**\n * Create an event from a promise rejection where the `reason` is a primitive.\n *\n * @param reason: The `reason` property of the promise rejection\n * @returns An Event object with an appropriate `exception` value\n */\nfunction _eventFromRejectionWithPrimitive(reason: Primitive): Event {\n return {\n exception: {\n values: [\n {\n type: 'UnhandledRejection',\n // String() is needed because the Primitive type includes symbols (which can't be automatically stringified)\n value: `Non-Error promise rejection captured with value: ${String(reason)}`,\n },\n ],\n },\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column: any): Event {\n // event.exception\n const e = (event.exception = event.exception || {});\n // event.exception.values\n const ev = (e.values = e.values || []);\n // event.exception.values[0]\n const ev0 = (ev[0] = ev[0] || {});\n // event.exception.values[0].stacktrace\n const ev0s = (ev0.stacktrace = ev0.stacktrace || {});\n // event.exception.values[0].stacktrace.frames\n const ev0sf = (ev0s.frames = ev0s.frames || []);\n\n const colno = isNaN(parseInt(column, 10)) ? undefined : column;\n const lineno = isNaN(parseInt(line, 10)) ? undefined : line;\n const filename = isString(url) && url.length > 0 ? url : getLocationHref();\n\n // event.exception.values[0].stacktrace.frames\n if (ev0sf.length === 0) {\n ev0sf.push({\n colno,\n filename,\n function: UNKNOWN_FUNCTION,\n in_app: true,\n lineno,\n });\n }\n\n return event;\n}\n\nfunction globalHandlerLog(type: string): void {\n DEBUG_BUILD && logger.log(`Global Handler attached: ${type}`);\n}\n\nfunction getOptions(): { stackParser: StackParser; attachStacktrace?: boolean } {\n const client = getClient<BrowserClient>();\n const options = (client && client.getOptions()) || {\n stackParser: () => [],\n attachStacktrace: false,\n };\n return options;\n}\n"],"names":["defineIntegration","addGlobalErrorInstrumentationHandler","getClient","shouldIgnoreOnError","eventFromUnknownInput","captureEvent","addGlobalUnhandledRejectionInstrumentationHandler","isPrimitive","isString","getLocationHref","UNKNOWN_FUNCTION","DEBUG_BUILD","logger"],"mappings":";;;;;;;AAqBA,MAAM,gBAAA,GAAmB,gBAAgB;;AAEzC,MAAM,0BAAA,IAA8B,CAAC,OAAO,GAAwC,EAAE,KAAK;AAC3F,EAAE,MAAM,WAAW;AACnB,IAAI,OAAO,EAAE,IAAI;AACjB,IAAI,oBAAoB,EAAE,IAAI;AAC9B,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,KAAK,CAAC,eAAgB,GAAE,EAAE;AAChC,KAAK;AACL,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE;AAC5B,QAAQ,4BAA4B,CAAC,MAAM,CAAC;AAC5C,QAAQ,gBAAgB,CAAC,SAAS,CAAC;AACnC;AACA,MAAM,IAAI,QAAQ,CAAC,oBAAoB,EAAE;AACzC,QAAQ,yCAAyC,CAAC,MAAM,CAAC;AACzD,QAAQ,gBAAgB,CAAC,sBAAsB,CAAC;AAChD;AACA,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;MAEU,yBAA0B,GAAEA,sBAAiB,CAAC,0BAA0B;;AAErF,SAAS,4BAA4B,CAAC,MAAM,EAAgB;AAC5D,EAAEC,yCAAoC,CAAC,IAAA,IAAQ;AAC/C,IAAI,MAAM,EAAE,WAAW,EAAE,kBAAmB,GAAE,UAAU,EAAE;;A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A;AACA,EAAA,OAAA,OAAA;AACA;;;;"}
@@ -2,7 +2,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  const browserUtils = require('@sentry-internal/browser-utils');
4
4
  const core = require('@sentry/core');
5
- const utils = require('@sentry/utils');
6
5
  const debugBuild = require('../debug-build.js');
7
6
 
8
7
  const INTEGRATION_NAME = 'HttpClient';
@@ -79,7 +78,7 @@ function _parseCookieHeaders(
79
78
  cookies = _parseCookieString(cookieString);
80
79
  }
81
80
  } catch (e) {
82
- debugBuild.DEBUG_BUILD && utils.logger.log(`Could not extract cookies from header ${cookieHeader}`);
81
+ debugBuild.DEBUG_BUILD && core.logger.log(`Could not extract cookies from header ${cookieHeader}`);
83
82
  }
84
83
 
85
84
  return [headers, cookies];
@@ -109,13 +108,13 @@ function _xhrResponseHandler(
109
108
  responseCookies = _parseCookieString(cookieString);
110
109
  }
111
110
  } catch (e) {
112
- debugBuild.DEBUG_BUILD && utils.logger.log('Could not extract cookies from response headers');
111
+ debugBuild.DEBUG_BUILD && core.logger.log('Could not extract cookies from response headers');
113
112
  }
114
113
 
115
114
  try {
116
115
  responseHeaders = _getXHRResponseHeaders(xhr);
117
116
  } catch (e) {
118
- debugBuild.DEBUG_BUILD && utils.logger.log('Could not extract headers from response');
117
+ debugBuild.DEBUG_BUILD && core.logger.log('Could not extract headers from response');
119
118
  }
120
119
 
121
120
  requestHeaders = headers;
@@ -249,11 +248,11 @@ function _isInGivenStatusRanges(
249
248
  * Wraps `fetch` function to capture request and response data
250
249
  */
251
250
  function _wrapFetch(client, options) {
252
- if (!utils.supportsNativeFetch()) {
251
+ if (!core.supportsNativeFetch()) {
253
252
  return;
254
253
  }
255
254
 
256
- utils.addFetchInstrumentationHandler(handlerData => {
255
+ core.addFetchInstrumentationHandler(handlerData => {
257
256
  if (core.getClient() !== client) {
258
257
  return;
259
258
  }
@@ -273,7 +272,7 @@ function _wrapFetch(client, options) {
273
272
  * Wraps XMLHttpRequest to capture request and response data
274
273
  */
275
274
  function _wrapXHR(client, options) {
276
- if (!('XMLHttpRequest' in utils.GLOBAL_OBJ)) {
275
+ if (!('XMLHttpRequest' in core.GLOBAL_OBJ)) {
277
276
  return;
278
277
  }
279
278
 
@@ -295,7 +294,7 @@ function _wrapXHR(client, options) {
295
294
  try {
296
295
  _xhrResponseHandler(options, xhr, method, headers);
297
296
  } catch (e) {
298
- debugBuild.DEBUG_BUILD && utils.logger.warn('Error while extracting response event form XHR response', e);
297
+ debugBuild.DEBUG_BUILD && core.logger.warn('Error while extracting response event form XHR response', e);
299
298
  }
300
299
  });
301
300
  }
@@ -351,7 +350,7 @@ function _createEvent(data
351
350
  },
352
351
  };
353
352
 
354
- utils.addExceptionMechanism(event, {
353
+ core.addExceptionMechanism(event, {
355
354
  type: 'http.client',
356
355
  handled: false,
357
356
  });
@@ -1 +1 @@
1
- {"version":3,"file":"httpclient.js","sources":["../../../../src/integrations/httpclient.ts"],"sourcesContent":["import { SENTRY_XHR_DATA_KEY, addXhrInstrumentationHandler } from '@sentry-internal/browser-utils';\nimport { captureEvent, defineIntegration, getClient, isSentryRequestUrl } from '@sentry/core';\nimport type { Client, Event as SentryEvent, IntegrationFn, SentryWrappedXMLHttpRequest } from '@sentry/types';\nimport {\n GLOBAL_OBJ,\n addExceptionMechanism,\n addFetchInstrumentationHandler,\n logger,\n supportsNativeFetch,\n} from '@sentry/utils';\n\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport type HttpStatusCodeRange = [number, number] | number;\nexport type HttpRequestTarget = string | RegExp;\n\nconst INTEGRATION_NAME = 'HttpClient';\n\ninterface HttpClientOptions {\n /**\n * HTTP status codes that should be considered failed.\n * This array can contain tuples of `[begin, end]` (both inclusive),\n * single status codes, or a combinations of both\n *\n * Example: [[500, 505], 507]\n * Default: [[500, 599]]\n */\n failedRequestStatusCodes: HttpStatusCodeRange[];\n\n /**\n * Targets to track for failed requests.\n * This array can contain strings or regular expressions.\n *\n * Example: ['http://localhost', /api\\/.*\\/]\n * Default: [/.*\\/]\n */\n failedRequestTargets: HttpRequestTarget[];\n}\n\nconst _httpClientIntegration = ((options: Partial<HttpClientOptions> = {}) => {\n const _options: HttpClientOptions = {\n failedRequestStatusCodes: [[500, 599]],\n failedRequestTargets: [/.*/],\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client): void {\n _wrapFetch(client, _options);\n _wrapXHR(client, _options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Create events for failed client side HTTP requests.\n */\nexport const httpClientIntegration = defineIntegration(_httpClientIntegration);\n\n/**\n * Interceptor function for fetch requests\n *\n * @param requestInfo The Fetch API request info\n * @param response The Fetch API response\n * @param requestInit The request init object\n */\nfunction _fetchResponseHandler(\n options: HttpClientOptions,\n requestInfo: RequestInfo,\n response: Response,\n requestInit?: RequestInit,\n): void {\n if (_shouldCaptureResponse(options, response.status, response.url)) {\n const request = _getRequest(requestInfo, requestInit);\n\n let requestHeaders, responseHeaders, requestCookies, responseCookies;\n\n if (_shouldSendDefaultPii()) {\n [requestHeaders, requestCookies] = _parseCookieHeaders('Cookie', request);\n [responseHeaders, responseCookies] = _parseCookieHeaders('Set-Cookie', response);\n }\n\n const event = _createEvent({\n url: request.url,\n method: request.method,\n status: response.status,\n requestHeaders,\n responseHeaders,\n requestCookies,\n responseCookies,\n });\n\n captureEvent(event);\n }\n}\n\nfunction _parseCookieHeaders(\n cookieHeader: string,\n obj: Request | Response,\n): [Record<string, string>, Record<string, string> | undefined] {\n const headers = _extractFetchHeaders(obj.headers);\n let cookies;\n\n try {\n const cookieString = headers[cookieHeader] || headers[cookieHeader.toLowerCase()] || undefined;\n\n if (cookieString) {\n cookies = _parseCookieString(cookieString);\n }\n } catch (e) {\n DEBUG_BUILD && logger.log(`Could not extract cookies from header ${cookieHeader}`);\n }\n\n return [headers, cookies];\n}\n\n/**\n * Interceptor function for XHR requests\n *\n * @param xhr The XHR request\n * @param method The HTTP method\n * @param headers The HTTP headers\n */\nfunction _xhrResponseHandler(\n options: HttpClientOptions,\n xhr: XMLHttpRequest,\n method: string,\n headers: Record<string, string>,\n): void {\n if (_shouldCaptureResponse(options, xhr.status, xhr.responseURL)) {\n let requestHeaders, responseCookies, responseHeaders;\n\n if (_shouldSendDefaultPii()) {\n try {\n const cookieString = xhr.getResponseHeader('Set-Cookie') || xhr.getResponseHeader('set-cookie') || undefined;\n\n if (cookieString) {\n responseCookies = _parseCookieString(cookieString);\n }\n } catch (e) {\n DEBUG_BUILD && logger.log('Could not extract cookies from response headers');\n }\n\n try {\n responseHeaders = _getXHRResponseHeaders(xhr);\n } catch (e) {\n DEBUG_BUILD && logger.log('Could not extract headers from response');\n }\n\n requestHeaders = headers;\n }\n\n const event = _createEvent({\n url: xhr.responseURL,\n method,\n status: xhr.status,\n requestHeaders,\n // Can't access request cookies from XHR\n responseHeaders,\n responseCookies,\n });\n\n captureEvent(event);\n }\n}\n\n/**\n * Extracts response size from `Content-Length` header when possible\n *\n * @param headers\n * @returns The response size in bytes or undefined\n */\nfunction _getResponseSizeFromHeaders(headers?: Record<string, string>): number | undefined {\n if (headers) {\n const contentLength = headers['Content-Length'] || headers['content-length'];\n\n if (contentLength) {\n return parseInt(contentLength, 10);\n }\n }\n\n return undefined;\n}\n\n/**\n * Creates an object containing cookies from the given cookie string\n *\n * @param cookieString The cookie string to parse\n * @returns The parsed cookies\n */\nfunction _parseCookieString(cookieString: string): Record<string, string> {\n return cookieString.split('; ').reduce((acc: Record<string, string>, cookie: string) => {\n const [key, value] = cookie.split('=');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Extracts the headers as an object from the given Fetch API request or response object\n *\n * @param headers The headers to extract\n * @returns The extracted headers as an object\n */\nfunction _extractFetchHeaders(headers: Headers): Record<string, string> {\n const result: Record<string, string> = {};\n\n headers.forEach((value, key) => {\n result[key] = value;\n });\n\n return result;\n}\n\n/**\n * Extracts the response headers as an object from the given XHR object\n *\n * @param xhr The XHR object to extract the response headers from\n * @returns The response headers as an object\n */\nfunction _getXHRResponseHeaders(xhr: XMLHttpRequest): Record<string, string> {\n const headers = xhr.getAllResponseHeaders();\n\n if (!headers) {\n return {};\n }\n\n return headers.split('\\r\\n').reduce((acc: Record<string, string>, line: string) => {\n const [key, value] = line.split(': ');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Checks if the given target url is in the given list of targets\n *\n * @param target The target url to check\n * @returns true if the target url is in the given list of targets, false otherwise\n */\nfunction _isInGivenRequestTargets(\n failedRequestTargets: HttpClientOptions['failedRequestTargets'],\n target: string,\n): boolean {\n return failedRequestTargets.some((givenRequestTarget: HttpRequestTarget) => {\n if (typeof givenRequestTarget === 'string') {\n return target.includes(givenRequestTarget);\n }\n\n return givenRequestTarget.test(target);\n });\n}\n\n/**\n * Checks if the given status code is in the given range\n *\n * @param status The status code to check\n * @returns true if the status code is in the given range, false otherwise\n */\nfunction _isInGivenStatusRanges(\n failedRequestStatusCodes: HttpClientOptions['failedRequestStatusCodes'],\n status: number,\n): boolean {\n return failedRequestStatusCodes.some((range: HttpStatusCodeRange) => {\n if (typeof range === 'number') {\n return range === status;\n }\n\n return status >= range[0] && status <= range[1];\n });\n}\n\n/**\n * Wraps `fetch` function to capture request and response data\n */\nfunction _wrapFetch(client: Client, options: HttpClientOptions): void {\n if (!supportsNativeFetch()) {\n return;\n }\n\n addFetchInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const { response, args } = handlerData;\n const [requestInfo, requestInit] = args as [RequestInfo, RequestInit | undefined];\n\n if (!response) {\n return;\n }\n\n _fetchResponseHandler(options, requestInfo, response as Response, requestInit);\n });\n}\n\n/**\n * Wraps XMLHttpRequest to capture request and response data\n */\nfunction _wrapXHR(client: Client, options: HttpClientOptions): void {\n if (!('XMLHttpRequest' in GLOBAL_OBJ)) {\n return;\n }\n\n addXhrInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const xhr = handlerData.xhr as SentryWrappedXMLHttpRequest & XMLHttpRequest;\n\n const sentryXhrData = xhr[SENTRY_XHR_DATA_KEY];\n\n if (!sentryXhrData) {\n return;\n }\n\n const { method, request_headers: headers } = sentryXhrData;\n\n try {\n _xhrResponseHandler(options, xhr, method, headers);\n } catch (e) {\n DEBUG_BUILD && logger.warn('Error while extracting response event form XHR response', e);\n }\n });\n}\n\n/**\n * Checks whether to capture given response as an event\n *\n * @param status response status code\n * @param url response url\n */\nfunction _shouldCaptureResponse(options: HttpClientOptions, status: number, url: string): boolean {\n return (\n _isInGivenStatusRanges(options.failedRequestStatusCodes, status) &&\n _isInGivenRequestTargets(options.failedRequestTargets, url) &&\n !isSentryRequestUrl(url, getClient())\n );\n}\n\n/**\n * Creates a synthetic Sentry event from given response data\n *\n * @param data response data\n * @returns event\n */\nfunction _createEvent(data: {\n url: string;\n method: string;\n status: number;\n responseHeaders?: Record<string, string>;\n responseCookies?: Record<string, string>;\n requestHeaders?: Record<string, string>;\n requestCookies?: Record<string, string>;\n}): SentryEvent {\n const message = `HTTP Client Error with status code: ${data.status}`;\n\n const event: SentryEvent = {\n message,\n exception: {\n values: [\n {\n type: 'Error',\n value: message,\n },\n ],\n },\n request: {\n url: data.url,\n method: data.method,\n headers: data.requestHeaders,\n cookies: data.requestCookies,\n },\n contexts: {\n response: {\n status_code: data.status,\n headers: data.responseHeaders,\n cookies: data.responseCookies,\n body_size: _getResponseSizeFromHeaders(data.responseHeaders),\n },\n },\n };\n\n addExceptionMechanism(event, {\n type: 'http.client',\n handled: false,\n });\n\n return event;\n}\n\nfunction _getRequest(requestInfo: RequestInfo, requestInit?: RequestInit): Request {\n if (!requestInit && requestInfo instanceof Request) {\n return requestInfo;\n }\n\n // If both are set, we try to construct a new Request with the given arguments\n // However, if e.g. the original request has a `body`, this will throw an error because it was already accessed\n // In this case, as a fallback, we just use the original request - using both is rather an edge case\n if (requestInfo instanceof Request && requestInfo.bodyUsed) {\n return requestInfo;\n }\n\n return new Request(requestInfo, requestInit);\n}\n\nfunction _shouldSendDefaultPii(): boolean {\n const client = getClient();\n return client ? Boolean(client.getOptions().sendDefaultPii) : false;\n}\n"],"names":["defineIntegration","captureEvent","DEBUG_BUILD","logger","supportsNativeFetch","addFetchInstrumentationHandler","getClient","GLOBAL_OBJ","addXhrInstrumentationHandler","SENTRY_XHR_DATA_KEY","isSentryRequestUrl","addExceptionMechanism"],"mappings":";;;;;;;AAgBA,MAAM,gBAAA,GAAmB,YAAY;;AAuBrC,MAAM,sBAAA,IAA0B,CAAC,OAAO,GAA+B,EAAE,KAAK;AAC9E,EAAE,MAAM,QAAQ,GAAsB;AACtC,IAAI,wBAAwB,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1C,IAAI,oBAAoB,EAAE,CAAC,IAAI,CAAC;AAChC,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAQ;AACxB,MAAM,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC;AAClC,MAAM,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;AAChC,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;MACa,qBAAsB,GAAEA,sBAAiB,CAAC,sBAAsB;;AAE7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,qBAAqB;AAC9B,EAAE,OAAO;AACT,EAAE,WAAW;AACb,EAAE,QAAQ;AACV,EAAE,WAAW;AACb,EAAQ;AACR,EAAE,IAAI,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE;AACtE,IAAI,MAAM,UAAU,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC;;AAEzD,IAAI,IAAI,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe;;AAExE,IAAI,IAAI,qBAAqB,EAAE,EAAE;AACjC,MAAM,CAAC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AA;AACA,SAAA;AACA,OAAA;AACA,KAAA;AACA,IAAA,OAAA,EAAA;AACA,MAAA,GAAA,EAAA,IAAA,CAAA,GAAA;AACA,MAAA,MAAA,EAAA,IAAA,CAAA,MAAA;AACA,MAAA,OAAA,EAAA,IAAA,CAAA,cAAA;AACA,MAAA,OAAA,EAAA,IAAA,CAAA,cAAA;AACA,KAAA;AACA,IAAA,QAAA,EAAA;AACA,MAAA,QAAA,EAAA;AACA,QAAA,WAAA,EAAA,IAAA,CAAA,MAAA;AACA,QAAA,OAAA,EAAA,IAAA,CAAA,eAAA;AACA,QAAA,OAAA,EAAA,IAAA,CAAA,eAAA;AACA,QAAA,SAAA,EAAA,2BAAA,CAAA,IAAA,CAAA,eAAA,CAAA;AACA,OAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAAK,2BAAA,CAAA,KAAA,EAAA;AACA,IAAA,IAAA,EAAA,aAAA;AACA,IAAA,OAAA,EAAA,KAAA;AACA,GAAA,CAAA;;AAEA,EAAA,OAAA,KAAA;AACA;;AAEA,SAAA,WAAA,CAAA,WAAA,EAAA,WAAA,EAAA;AACA,EAAA,IAAA,CAAA,WAAA,IAAA,WAAA,YAAA,OAAA,EAAA;AACA,IAAA,OAAA,WAAA;AACA;;AAEA;AACA;AACA;AACA,EAAA,IAAA,WAAA,YAAA,OAAA,IAAA,WAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,WAAA;AACA;;AAEA,EAAA,OAAA,IAAA,OAAA,CAAA,WAAA,EAAA,WAAA,CAAA;AACA;;AAEA,SAAA,qBAAA,GAAA;AACA,EAAA,MAAA,MAAA,GAAAL,cAAA,EAAA;AACA,EAAA,OAAA,MAAA,GAAA,OAAA,CAAA,MAAA,CAAA,UAAA,EAAA,CAAA,cAAA,CAAA,GAAA,KAAA;AACA;;;;"}
1
+ {"version":3,"file":"httpclient.js","sources":["../../../../src/integrations/httpclient.ts"],"sourcesContent":["import { SENTRY_XHR_DATA_KEY, addXhrInstrumentationHandler } from '@sentry-internal/browser-utils';\nimport { captureEvent, defineIntegration, getClient, isSentryRequestUrl } from '@sentry/core';\nimport {\n GLOBAL_OBJ,\n addExceptionMechanism,\n addFetchInstrumentationHandler,\n logger,\n supportsNativeFetch,\n} from '@sentry/core';\nimport type { Client, Event as SentryEvent, IntegrationFn, SentryWrappedXMLHttpRequest } from '@sentry/types';\n\nimport { DEBUG_BUILD } from '../debug-build';\n\nexport type HttpStatusCodeRange = [number, number] | number;\nexport type HttpRequestTarget = string | RegExp;\n\nconst INTEGRATION_NAME = 'HttpClient';\n\ninterface HttpClientOptions {\n /**\n * HTTP status codes that should be considered failed.\n * This array can contain tuples of `[begin, end]` (both inclusive),\n * single status codes, or a combinations of both\n *\n * Example: [[500, 505], 507]\n * Default: [[500, 599]]\n */\n failedRequestStatusCodes: HttpStatusCodeRange[];\n\n /**\n * Targets to track for failed requests.\n * This array can contain strings or regular expressions.\n *\n * Example: ['http://localhost', /api\\/.*\\/]\n * Default: [/.*\\/]\n */\n failedRequestTargets: HttpRequestTarget[];\n}\n\nconst _httpClientIntegration = ((options: Partial<HttpClientOptions> = {}) => {\n const _options: HttpClientOptions = {\n failedRequestStatusCodes: [[500, 599]],\n failedRequestTargets: [/.*/],\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client): void {\n _wrapFetch(client, _options);\n _wrapXHR(client, _options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Create events for failed client side HTTP requests.\n */\nexport const httpClientIntegration = defineIntegration(_httpClientIntegration);\n\n/**\n * Interceptor function for fetch requests\n *\n * @param requestInfo The Fetch API request info\n * @param response The Fetch API response\n * @param requestInit The request init object\n */\nfunction _fetchResponseHandler(\n options: HttpClientOptions,\n requestInfo: RequestInfo,\n response: Response,\n requestInit?: RequestInit,\n): void {\n if (_shouldCaptureResponse(options, response.status, response.url)) {\n const request = _getRequest(requestInfo, requestInit);\n\n let requestHeaders, responseHeaders, requestCookies, responseCookies;\n\n if (_shouldSendDefaultPii()) {\n [requestHeaders, requestCookies] = _parseCookieHeaders('Cookie', request);\n [responseHeaders, responseCookies] = _parseCookieHeaders('Set-Cookie', response);\n }\n\n const event = _createEvent({\n url: request.url,\n method: request.method,\n status: response.status,\n requestHeaders,\n responseHeaders,\n requestCookies,\n responseCookies,\n });\n\n captureEvent(event);\n }\n}\n\nfunction _parseCookieHeaders(\n cookieHeader: string,\n obj: Request | Response,\n): [Record<string, string>, Record<string, string> | undefined] {\n const headers = _extractFetchHeaders(obj.headers);\n let cookies;\n\n try {\n const cookieString = headers[cookieHeader] || headers[cookieHeader.toLowerCase()] || undefined;\n\n if (cookieString) {\n cookies = _parseCookieString(cookieString);\n }\n } catch (e) {\n DEBUG_BUILD && logger.log(`Could not extract cookies from header ${cookieHeader}`);\n }\n\n return [headers, cookies];\n}\n\n/**\n * Interceptor function for XHR requests\n *\n * @param xhr The XHR request\n * @param method The HTTP method\n * @param headers The HTTP headers\n */\nfunction _xhrResponseHandler(\n options: HttpClientOptions,\n xhr: XMLHttpRequest,\n method: string,\n headers: Record<string, string>,\n): void {\n if (_shouldCaptureResponse(options, xhr.status, xhr.responseURL)) {\n let requestHeaders, responseCookies, responseHeaders;\n\n if (_shouldSendDefaultPii()) {\n try {\n const cookieString = xhr.getResponseHeader('Set-Cookie') || xhr.getResponseHeader('set-cookie') || undefined;\n\n if (cookieString) {\n responseCookies = _parseCookieString(cookieString);\n }\n } catch (e) {\n DEBUG_BUILD && logger.log('Could not extract cookies from response headers');\n }\n\n try {\n responseHeaders = _getXHRResponseHeaders(xhr);\n } catch (e) {\n DEBUG_BUILD && logger.log('Could not extract headers from response');\n }\n\n requestHeaders = headers;\n }\n\n const event = _createEvent({\n url: xhr.responseURL,\n method,\n status: xhr.status,\n requestHeaders,\n // Can't access request cookies from XHR\n responseHeaders,\n responseCookies,\n });\n\n captureEvent(event);\n }\n}\n\n/**\n * Extracts response size from `Content-Length` header when possible\n *\n * @param headers\n * @returns The response size in bytes or undefined\n */\nfunction _getResponseSizeFromHeaders(headers?: Record<string, string>): number | undefined {\n if (headers) {\n const contentLength = headers['Content-Length'] || headers['content-length'];\n\n if (contentLength) {\n return parseInt(contentLength, 10);\n }\n }\n\n return undefined;\n}\n\n/**\n * Creates an object containing cookies from the given cookie string\n *\n * @param cookieString The cookie string to parse\n * @returns The parsed cookies\n */\nfunction _parseCookieString(cookieString: string): Record<string, string> {\n return cookieString.split('; ').reduce((acc: Record<string, string>, cookie: string) => {\n const [key, value] = cookie.split('=');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Extracts the headers as an object from the given Fetch API request or response object\n *\n * @param headers The headers to extract\n * @returns The extracted headers as an object\n */\nfunction _extractFetchHeaders(headers: Headers): Record<string, string> {\n const result: Record<string, string> = {};\n\n headers.forEach((value, key) => {\n result[key] = value;\n });\n\n return result;\n}\n\n/**\n * Extracts the response headers as an object from the given XHR object\n *\n * @param xhr The XHR object to extract the response headers from\n * @returns The response headers as an object\n */\nfunction _getXHRResponseHeaders(xhr: XMLHttpRequest): Record<string, string> {\n const headers = xhr.getAllResponseHeaders();\n\n if (!headers) {\n return {};\n }\n\n return headers.split('\\r\\n').reduce((acc: Record<string, string>, line: string) => {\n const [key, value] = line.split(': ');\n if (key && value) {\n acc[key] = value;\n }\n return acc;\n }, {});\n}\n\n/**\n * Checks if the given target url is in the given list of targets\n *\n * @param target The target url to check\n * @returns true if the target url is in the given list of targets, false otherwise\n */\nfunction _isInGivenRequestTargets(\n failedRequestTargets: HttpClientOptions['failedRequestTargets'],\n target: string,\n): boolean {\n return failedRequestTargets.some((givenRequestTarget: HttpRequestTarget) => {\n if (typeof givenRequestTarget === 'string') {\n return target.includes(givenRequestTarget);\n }\n\n return givenRequestTarget.test(target);\n });\n}\n\n/**\n * Checks if the given status code is in the given range\n *\n * @param status The status code to check\n * @returns true if the status code is in the given range, false otherwise\n */\nfunction _isInGivenStatusRanges(\n failedRequestStatusCodes: HttpClientOptions['failedRequestStatusCodes'],\n status: number,\n): boolean {\n return failedRequestStatusCodes.some((range: HttpStatusCodeRange) => {\n if (typeof range === 'number') {\n return range === status;\n }\n\n return status >= range[0] && status <= range[1];\n });\n}\n\n/**\n * Wraps `fetch` function to capture request and response data\n */\nfunction _wrapFetch(client: Client, options: HttpClientOptions): void {\n if (!supportsNativeFetch()) {\n return;\n }\n\n addFetchInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const { response, args } = handlerData;\n const [requestInfo, requestInit] = args as [RequestInfo, RequestInit | undefined];\n\n if (!response) {\n return;\n }\n\n _fetchResponseHandler(options, requestInfo, response as Response, requestInit);\n });\n}\n\n/**\n * Wraps XMLHttpRequest to capture request and response data\n */\nfunction _wrapXHR(client: Client, options: HttpClientOptions): void {\n if (!('XMLHttpRequest' in GLOBAL_OBJ)) {\n return;\n }\n\n addXhrInstrumentationHandler(handlerData => {\n if (getClient() !== client) {\n return;\n }\n\n const xhr = handlerData.xhr as SentryWrappedXMLHttpRequest & XMLHttpRequest;\n\n const sentryXhrData = xhr[SENTRY_XHR_DATA_KEY];\n\n if (!sentryXhrData) {\n return;\n }\n\n const { method, request_headers: headers } = sentryXhrData;\n\n try {\n _xhrResponseHandler(options, xhr, method, headers);\n } catch (e) {\n DEBUG_BUILD && logger.warn('Error while extracting response event form XHR response', e);\n }\n });\n}\n\n/**\n * Checks whether to capture given response as an event\n *\n * @param status response status code\n * @param url response url\n */\nfunction _shouldCaptureResponse(options: HttpClientOptions, status: number, url: string): boolean {\n return (\n _isInGivenStatusRanges(options.failedRequestStatusCodes, status) &&\n _isInGivenRequestTargets(options.failedRequestTargets, url) &&\n !isSentryRequestUrl(url, getClient())\n );\n}\n\n/**\n * Creates a synthetic Sentry event from given response data\n *\n * @param data response data\n * @returns event\n */\nfunction _createEvent(data: {\n url: string;\n method: string;\n status: number;\n responseHeaders?: Record<string, string>;\n responseCookies?: Record<string, string>;\n requestHeaders?: Record<string, string>;\n requestCookies?: Record<string, string>;\n}): SentryEvent {\n const message = `HTTP Client Error with status code: ${data.status}`;\n\n const event: SentryEvent = {\n message,\n exception: {\n values: [\n {\n type: 'Error',\n value: message,\n },\n ],\n },\n request: {\n url: data.url,\n method: data.method,\n headers: data.requestHeaders,\n cookies: data.requestCookies,\n },\n contexts: {\n response: {\n status_code: data.status,\n headers: data.responseHeaders,\n cookies: data.responseCookies,\n body_size: _getResponseSizeFromHeaders(data.responseHeaders),\n },\n },\n };\n\n addExceptionMechanism(event, {\n type: 'http.client',\n handled: false,\n });\n\n return event;\n}\n\nfunction _getRequest(requestInfo: RequestInfo, requestInit?: RequestInit): Request {\n if (!requestInit && requestInfo instanceof Request) {\n return requestInfo;\n }\n\n // If both are set, we try to construct a new Request with the given arguments\n // However, if e.g. the original request has a `body`, this will throw an error because it was already accessed\n // In this case, as a fallback, we just use the original request - using both is rather an edge case\n if (requestInfo instanceof Request && requestInfo.bodyUsed) {\n return requestInfo;\n }\n\n return new Request(requestInfo, requestInit);\n}\n\nfunction _shouldSendDefaultPii(): boolean {\n const client = getClient();\n return client ? Boolean(client.getOptions().sendDefaultPii) : false;\n}\n"],"names":["defineIntegration","captureEvent","DEBUG_BUILD","logger","supportsNativeFetch","addFetchInstrumentationHandler","getClient","GLOBAL_OBJ","addXhrInstrumentationHandler","SENTRY_XHR_DATA_KEY","isSentryRequestUrl","addExceptionMechanism"],"mappings":";;;;;;AAgBA,MAAM,gBAAA,GAAmB,YAAY;;AAuBrC,MAAM,sBAAA,IAA0B,CAAC,OAAO,GAA+B,EAAE,KAAK;AAC9E,EAAE,MAAM,QAAQ,GAAsB;AACtC,IAAI,wBAAwB,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1C,IAAI,oBAAoB,EAAE,CAAC,IAAI,CAAC;AAChC,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAQ;AACxB,MAAM,UAAU,CAAC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;;AAEA,SAAA,WAAA,CAAA,WAAA,EAAA,WAAA,EAAA;AACA,EAAA,IAAA,CAAA,WAAA,IAAA,WAAA,YAAA,OAAA,EAAA;AACA,IAAA,OAAA,WAAA;AACA;;AAEA;AACA;AACA;AACA,EAAA,IAAA,WAAA,YAAA,OAAA,IAAA,WAAA,CAAA,QAAA,EAAA;AACA,IAAA,OAAA,WAAA;AACA;;AAEA,EAAA,OAAA,IAAA,OAAA,CAAA,WAAA,EAAA,WAAA,CAAA;AACA;;AAEA,SAAA,qBAAA,GAAA;AACA,EAAA,MAAA,MAAA,GAAAL,cAAA,EAAA;AACA,EAAA,OAAA,MAAA,GAAA,OAAA,CAAA,MAAA,CAAA,UAAA,EAAA,CAAA,cAAA,CAAA,GAAA,KAAA;AACA;;;;"}
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  const core = require('@sentry/core');
4
- const utils = require('@sentry/utils');
5
4
  const eventbuilder = require('../eventbuilder.js');
6
5
 
7
6
  const DEFAULT_KEY = 'cause';
@@ -18,7 +17,7 @@ const _linkedErrorsIntegration = ((options = {}) => {
18
17
  preprocessEvent(event, hint, client) {
19
18
  const options = client.getOptions();
20
19
 
21
- utils.applyAggregateErrorsToEvent(
20
+ core.applyAggregateErrorsToEvent(
22
21
  // This differs from the LinkedErrors integration in core by using a different exceptionFromError function
23
22
  eventbuilder.exceptionFromError,
24
23
  options.stackParser,
@@ -1 +1 @@
1
- {"version":3,"file":"linkederrors.js","sources":["../../../../src/integrations/linkederrors.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport type { IntegrationFn } from '@sentry/types';\nimport { applyAggregateErrorsToEvent } from '@sentry/utils';\nimport { exceptionFromError } from '../eventbuilder';\n\ninterface LinkedErrorsOptions {\n key?: string;\n limit?: number;\n}\n\nconst DEFAULT_KEY = 'cause';\nconst DEFAULT_LIMIT = 5;\n\nconst INTEGRATION_NAME = 'LinkedErrors';\n\nconst _linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {\n const limit = options.limit || DEFAULT_LIMIT;\n const key = options.key || DEFAULT_KEY;\n\n return {\n name: INTEGRATION_NAME,\n preprocessEvent(event, hint, client) {\n const options = client.getOptions();\n\n applyAggregateErrorsToEvent(\n // This differs from the LinkedErrors integration in core by using a different exceptionFromError function\n exceptionFromError,\n options.stackParser,\n options.maxValueLength,\n key,\n limit,\n event,\n hint,\n );\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Aggregrate linked errors in an event.\n */\nexport const linkedErrorsIntegration = defineIntegration(_linkedErrorsIntegration);\n"],"names":["applyAggregateErrorsToEvent","exceptionFromError","defineIntegration"],"mappings":";;;;;;AAUA,MAAM,WAAA,GAAc,OAAO;AAC3B,MAAM,aAAA,GAAgB,CAAC;;AAEvB,MAAM,gBAAA,GAAmB,cAAc;;AAEvC,MAAM,wBAAA,IAA4B,CAAC,OAAO,GAAwB,EAAE,KAAK;AACzE,EAAE,MAAM,KAAM,GAAE,OAAO,CAAC,KAAA,IAAS,aAAa;AAC9C,EAAE,MAAM,GAAI,GAAE,OAAO,CAAC,GAAA,IAAO,WAAW;;AAExC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;AACzC,MAAM,MAAM,OAAQ,GAAE,MAAM,CAAC,UAAU,EAAE;;AAEzC,MAAMA,iCAA2B;AACjC;AACA,QAAQC,+BAAkB;AAC1B,QAAQ,OAAO,CAAC,WAAW;AAC3B,QAAQ,OAAO,CAAC,cAAc;AAC9B,QAAQ,GAAG;AACX,QAAQ,KAAK;AACb,QAAQ,KAAK;AACb,QAAQ,IAAI;AACZ,OAAO;AACP,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;MACa,uBAAwB,GAAEC,sBAAiB,CAAC,wBAAwB;;;;"}
1
+ {"version":3,"file":"linkederrors.js","sources":["../../../../src/integrations/linkederrors.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport { applyAggregateErrorsToEvent } from '@sentry/core';\nimport type { IntegrationFn } from '@sentry/types';\nimport { exceptionFromError } from '../eventbuilder';\n\ninterface LinkedErrorsOptions {\n key?: string;\n limit?: number;\n}\n\nconst DEFAULT_KEY = 'cause';\nconst DEFAULT_LIMIT = 5;\n\nconst INTEGRATION_NAME = 'LinkedErrors';\n\nconst _linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {\n const limit = options.limit || DEFAULT_LIMIT;\n const key = options.key || DEFAULT_KEY;\n\n return {\n name: INTEGRATION_NAME,\n preprocessEvent(event, hint, client) {\n const options = client.getOptions();\n\n applyAggregateErrorsToEvent(\n // This differs from the LinkedErrors integration in core by using a different exceptionFromError function\n exceptionFromError,\n options.stackParser,\n options.maxValueLength,\n key,\n limit,\n event,\n hint,\n );\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Aggregrate linked errors in an event.\n */\nexport const linkedErrorsIntegration = defineIntegration(_linkedErrorsIntegration);\n"],"names":["applyAggregateErrorsToEvent","exceptionFromError","defineIntegration"],"mappings":";;;;;AAUA,MAAM,WAAA,GAAc,OAAO;AAC3B,MAAM,aAAA,GAAgB,CAAC;;AAEvB,MAAM,gBAAA,GAAmB,cAAc;;AAEvC,MAAM,wBAAA,IAA4B,CAAC,OAAO,GAAwB,EAAE,KAAK;AACzE,EAAE,MAAM,KAAM,GAAE,OAAO,CAAC,KAAA,IAAS,aAAa;AAC9C,EAAE,MAAM,GAAI,GAAE,OAAO,CAAC,GAAA,IAAO,WAAW;;AAExC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;AACzC,MAAM,MAAM,OAAQ,GAAE,MAAM,CAAC,UAAU,EAAE;;AAEzC,MAAMA,gCAA2B;AACjC;AACA,QAAQC,+BAAkB;AAC1B,QAAQ,OAAO,CAAC,WAAW;AAC3B,QAAQ,OAAO,CAAC,cAAc;AAC9B,QAAQ,GAAG;AACX,QAAQ,KAAK;AACb,QAAQ,KAAK;AACb,QAAQ,IAAI;AACZ,OAAO;AACP,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;MACa,uBAAwB,GAAEC,sBAAiB,CAAC,wBAAwB;;;;"}
@@ -1,9 +1,8 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  const core = require('@sentry/core');
4
- const utils = require('@sentry/utils');
5
4
 
6
- const WINDOW = utils.GLOBAL_OBJ ;
5
+ const WINDOW = core.GLOBAL_OBJ ;
7
6
 
8
7
  const INTEGRATION_NAME = 'ReportingObserver';
9
8
 
@@ -56,7 +55,7 @@ const _reportingObserverIntegration = ((options = {}) => {
56
55
  return {
57
56
  name: INTEGRATION_NAME,
58
57
  setupOnce() {
59
- if (!utils.supportsReportingObserver()) {
58
+ if (!core.supportsReportingObserver()) {
60
59
  return;
61
60
  }
62
61
 
@@ -1 +1 @@
1
- {"version":3,"file":"reportingobserver.js","sources":["../../../../src/integrations/reportingobserver.ts"],"sourcesContent":["import { captureMessage, defineIntegration, getClient, withScope } from '@sentry/core';\nimport type { Client, IntegrationFn } from '@sentry/types';\nimport { GLOBAL_OBJ, supportsReportingObserver } from '@sentry/utils';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst INTEGRATION_NAME = 'ReportingObserver';\n\ninterface Report {\n [key: string]: unknown;\n type: ReportTypes;\n url: string;\n body?: ReportBody;\n}\n\ntype ReportTypes = 'crash' | 'deprecation' | 'intervention';\n\ntype ReportBody = CrashReportBody | DeprecationReportBody | InterventionReportBody;\n\ninterface CrashReportBody {\n [key: string]: unknown;\n crashId: string;\n reason?: string;\n}\n\ninterface DeprecationReportBody {\n [key: string]: unknown;\n id: string;\n anticipatedRemoval?: Date;\n message: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\ninterface InterventionReportBody {\n [key: string]: unknown;\n id: string;\n message: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\ninterface ReportingObserverOptions {\n types?: ReportTypes[];\n}\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _reportingObserverIntegration = ((options: ReportingObserverOptions = {}) => {\n const types = options.types || ['crash', 'deprecation', 'intervention'];\n\n /** Handler for the reporting observer. */\n function handler(reports: Report[]): void {\n if (!SETUP_CLIENTS.has(getClient() as Client)) {\n return;\n }\n\n for (const report of reports) {\n withScope(scope => {\n scope.setExtra('url', report.url);\n\n const label = `ReportingObserver [${report.type}]`;\n let details = 'No details available';\n\n if (report.body) {\n // Object.keys doesn't work on ReportBody, as all properties are inherited\n const plainBody: {\n [key: string]: unknown;\n } = {};\n\n // eslint-disable-next-line guard-for-in\n for (const prop in report.body) {\n plainBody[prop] = report.body[prop];\n }\n\n scope.setExtra('body', plainBody);\n\n if (report.type === 'crash') {\n const body = report.body as CrashReportBody;\n // A fancy way to create a message out of crashId OR reason OR both OR fallback\n details = [body.crashId || '', body.reason || ''].join(' ').trim() || details;\n } else {\n const body = report.body as DeprecationReportBody | InterventionReportBody;\n details = body.message || details;\n }\n }\n\n captureMessage(`${label}: ${details}`);\n });\n }\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!supportsReportingObserver()) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const observer = new (WINDOW as any).ReportingObserver(handler, {\n buffered: true,\n types,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n observer.observe();\n },\n\n setup(client): void {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Reporting API integration - https://w3c.github.io/reporting/\n */\nexport const reportingObserverIntegration = defineIntegration(_reportingObserverIntegration);\n"],"names":["GLOBAL_OBJ","getClient","withScope","captureMessage","supportsReportingObserver","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E,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAG,IAAG,OAAO;AACzF,iBAAiB;AACjB,YAAY,MAAM,IAAA,GAAO,MAAM,CAAC,IAAK;AACrC,YAAY,UAAU,IAAI,CAAC,OAAA,IAAW,OAAO;AAC7C;AACA;;AAEA,QAAQC,mBAAc,CAAC,CAAC,EAAA,KAAA,CAAA,EAAA,EAAA,OAAA,CAAA,CAAA,CAAA;AACA,OAAA,CAAA;AACA;AACA;;AAEA,EAAA,OAAA;AACA,IAAA,IAAA,EAAA,gBAAA;AACA,IAAA,SAAA,GAAA;AACA,MAAA,IAAA,CAAAC,+BAAA,EAAA,EAAA;AACA,QAAA;AACA;;AAEA;AACA,MAAA,MAAA,QAAA,GAAA,IAAA,CAAA,MAAA,GAAA,iBAAA,CAAA,OAAA,EAAA;AACA,QAAA,QAAA,EAAA,IAAA;AACA,QAAA,KAAA;AACA,OAAA,CAAA;;AAEA;AACA,MAAA,QAAA,CAAA,OAAA,EAAA;AACA,KAAA;;AAEA,IAAA,KAAA,CAAA,MAAA,EAAA;AACA,MAAA,aAAA,CAAA,GAAA,CAAA,MAAA,EAAA,IAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA,MAAA,4BAAA,GAAAC,sBAAA,CAAA,6BAAA;;;;"}
1
+ {"version":3,"file":"reportingobserver.js","sources":["../../../../src/integrations/reportingobserver.ts"],"sourcesContent":["import { captureMessage, defineIntegration, getClient, withScope } from '@sentry/core';\nimport { GLOBAL_OBJ, supportsReportingObserver } from '@sentry/core';\nimport type { Client, IntegrationFn } from '@sentry/types';\n\nconst WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst INTEGRATION_NAME = 'ReportingObserver';\n\ninterface Report {\n [key: string]: unknown;\n type: ReportTypes;\n url: string;\n body?: ReportBody;\n}\n\ntype ReportTypes = 'crash' | 'deprecation' | 'intervention';\n\ntype ReportBody = CrashReportBody | DeprecationReportBody | InterventionReportBody;\n\ninterface CrashReportBody {\n [key: string]: unknown;\n crashId: string;\n reason?: string;\n}\n\ninterface DeprecationReportBody {\n [key: string]: unknown;\n id: string;\n anticipatedRemoval?: Date;\n message: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\ninterface InterventionReportBody {\n [key: string]: unknown;\n id: string;\n message: string;\n sourceFile?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\ninterface ReportingObserverOptions {\n types?: ReportTypes[];\n}\n\nconst SETUP_CLIENTS = new WeakMap<Client, boolean>();\n\nconst _reportingObserverIntegration = ((options: ReportingObserverOptions = {}) => {\n const types = options.types || ['crash', 'deprecation', 'intervention'];\n\n /** Handler for the reporting observer. */\n function handler(reports: Report[]): void {\n if (!SETUP_CLIENTS.has(getClient() as Client)) {\n return;\n }\n\n for (const report of reports) {\n withScope(scope => {\n scope.setExtra('url', report.url);\n\n const label = `ReportingObserver [${report.type}]`;\n let details = 'No details available';\n\n if (report.body) {\n // Object.keys doesn't work on ReportBody, as all properties are inherited\n const plainBody: {\n [key: string]: unknown;\n } = {};\n\n // eslint-disable-next-line guard-for-in\n for (const prop in report.body) {\n plainBody[prop] = report.body[prop];\n }\n\n scope.setExtra('body', plainBody);\n\n if (report.type === 'crash') {\n const body = report.body as CrashReportBody;\n // A fancy way to create a message out of crashId OR reason OR both OR fallback\n details = [body.crashId || '', body.reason || ''].join(' ').trim() || details;\n } else {\n const body = report.body as DeprecationReportBody | InterventionReportBody;\n details = body.message || details;\n }\n }\n\n captureMessage(`${label}: ${details}`);\n });\n }\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n if (!supportsReportingObserver()) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const observer = new (WINDOW as any).ReportingObserver(handler, {\n buffered: true,\n types,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n observer.observe();\n },\n\n setup(client): void {\n SETUP_CLIENTS.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Reporting API integration - https://w3c.github.io/reporting/\n */\nexport const reportingObserverIntegration = defineIntegration(_reportingObserverIntegration);\n"],"names":["GLOBAL_OBJ","getClient","withScope","captureMessage","supportsReportingObserver","defineIntegration"],"mappings":";;;;AAIA,MAAM,MAAA,GAASA,eAAW;;AAE1B,MAAM,gBAAA,GAAmB,mBAAmB;;AA0C5C,MAAM,aAAc,GAAE,IAAI,OAAO,EAAmB;;AAEpD,MAAM,6BAAA,IAAiC,CAAC,OAAO,GAA6B,EAAE,KAAK;AACnF,EAAE,MAAM,KAAA,GAAQ,OAAO,CAAC,KAAA,IAAS,CAAC,OAAO,EAAE,aAAa,EAAE,cAAc,CAAC;;AAEzE;AACA,EAAE,SAAS,OAAO,CAAC,OAAO,EAAkB;AAC5C,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAACC,cAAS,EAAG,EAAU,EAAE;AACnD,MAAM;AACN;;AAEA,IAAI,KAAK,MAAM,MAAO,IAAG,OAAO,EAAE;AAClC,MAAMC,cAAS,CAAC,KAAA,IAAS;AACzB,QAAQ,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC;;AAEzC,QAAQ,MAAM,KAAM,GAAE,CAAC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1D,QAAQ,IAAI,OAAQ,GAAE,sBAAsB;;AAE5C,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE;AACzB;AACA,UAAU,MAAM;;AAEN,GAAI,EAAE;;AAEhB;AACA,UAAU,KAAK,MAAM,IAAA,IAAQ,MAAM,CAAC,IAAI,EAAE;AAC1C,YAAY,SAAS,CAAC,IAAI,CAAE,GAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/C;;AAEA,UAAU,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;;AA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