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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/README.md +2 -3
  2. package/cjs/client.js +130 -68
  3. package/cjs/client.js.map +1 -1
  4. package/cjs/eventbuilder.js +227 -168
  5. package/cjs/eventbuilder.js.map +1 -1
  6. package/cjs/exports.js +55 -42
  7. package/cjs/exports.js.map +1 -1
  8. package/cjs/flags.js +7 -3
  9. package/cjs/flags.js.map +1 -1
  10. package/cjs/helpers.js +123 -130
  11. package/cjs/helpers.js.map +1 -1
  12. package/cjs/index.js +78 -13
  13. package/cjs/index.js.map +1 -1
  14. package/cjs/integrations/breadcrumbs.js +223 -193
  15. package/cjs/integrations/breadcrumbs.js.map +1 -1
  16. package/cjs/integrations/dedupe.js +183 -143
  17. package/cjs/integrations/dedupe.js.map +1 -1
  18. package/cjs/integrations/globalhandlers.js +212 -171
  19. package/cjs/integrations/globalhandlers.js.map +1 -1
  20. package/cjs/integrations/httpcontext.js +51 -0
  21. package/cjs/integrations/httpcontext.js.map +1 -0
  22. package/cjs/integrations/index.js +18 -14
  23. package/cjs/integrations/index.js.map +1 -1
  24. package/cjs/integrations/linkederrors.js +79 -48
  25. package/cjs/integrations/linkederrors.js.map +1 -1
  26. package/cjs/integrations/trycatch.js +245 -216
  27. package/cjs/integrations/trycatch.js.map +1 -1
  28. package/cjs/sdk.js +168 -108
  29. package/cjs/sdk.js.map +1 -1
  30. package/cjs/stack-parsers.js +134 -83
  31. package/cjs/stack-parsers.js.map +1 -1
  32. package/cjs/transports/fetch.js +34 -80
  33. package/cjs/transports/fetch.js.map +1 -1
  34. package/cjs/transports/index.js +10 -12
  35. package/cjs/transports/index.js.map +1 -1
  36. package/cjs/transports/utils.js +57 -52
  37. package/cjs/transports/utils.js.map +1 -1
  38. package/cjs/transports/xhr.js +53 -63
  39. package/cjs/transports/xhr.js.map +1 -1
  40. package/esm/client.js +128 -67
  41. package/esm/client.js.map +1 -1
  42. package/esm/eventbuilder.js +218 -159
  43. package/esm/eventbuilder.js.map +1 -1
  44. package/esm/exports.js +12 -7
  45. package/esm/exports.js.map +1 -1
  46. package/esm/flags.js +5 -2
  47. package/esm/flags.js.map +1 -1
  48. package/esm/helpers.js +121 -127
  49. package/esm/helpers.js.map +1 -1
  50. package/esm/index.js +28 -10
  51. package/esm/index.js.map +1 -1
  52. package/esm/integrations/breadcrumbs.js +219 -191
  53. package/esm/integrations/breadcrumbs.js.map +1 -1
  54. package/esm/integrations/dedupe.js +180 -141
  55. package/esm/integrations/dedupe.js.map +1 -1
  56. package/esm/integrations/globalhandlers.js +209 -169
  57. package/esm/integrations/globalhandlers.js.map +1 -1
  58. package/esm/integrations/httpcontext.js +49 -0
  59. package/esm/integrations/httpcontext.js.map +1 -0
  60. package/esm/integrations/index.js +7 -7
  61. package/esm/integrations/index.js.map +1 -1
  62. package/esm/integrations/linkederrors.js +75 -45
  63. package/esm/integrations/linkederrors.js.map +1 -1
  64. package/esm/integrations/trycatch.js +242 -214
  65. package/esm/integrations/trycatch.js.map +1 -1
  66. package/esm/sdk.js +164 -105
  67. package/esm/sdk.js.map +1 -1
  68. package/esm/stack-parsers.js +126 -82
  69. package/esm/stack-parsers.js.map +1 -1
  70. package/esm/transports/fetch.js +32 -79
  71. package/esm/transports/fetch.js.map +1 -1
  72. package/esm/transports/index.js +3 -6
  73. package/esm/transports/index.js.map +1 -1
  74. package/esm/transports/utils.js +56 -51
  75. package/esm/transports/utils.js.map +1 -1
  76. package/esm/transports/xhr.js +51 -62
  77. package/esm/transports/xhr.js.map +1 -1
  78. package/package.json +4 -5
  79. package/types/client.d.ts +42 -11
  80. package/types/client.d.ts.map +1 -1
  81. package/types/eventbuilder.d.ts +10 -12
  82. package/types/eventbuilder.d.ts.map +1 -1
  83. package/types/exports.d.ts +7 -6
  84. package/types/exports.d.ts.map +1 -1
  85. package/types/helpers.d.ts +0 -5
  86. package/types/helpers.d.ts.map +1 -1
  87. package/types/index.d.ts +2 -3
  88. package/types/index.d.ts.map +1 -1
  89. package/types/integrations/breadcrumbs.d.ts +6 -7
  90. package/types/integrations/breadcrumbs.d.ts.map +1 -1
  91. package/types/integrations/dedupe.d.ts.map +1 -1
  92. package/types/integrations/globalhandlers.d.ts.map +1 -1
  93. package/types/integrations/{useragent.d.ts → httpcontext.d.ts} +3 -3
  94. package/types/integrations/httpcontext.d.ts.map +1 -0
  95. package/types/integrations/index.d.ts +1 -1
  96. package/types/integrations/index.d.ts.map +1 -1
  97. package/types/integrations/linkederrors.d.ts +3 -3
  98. package/types/integrations/linkederrors.d.ts.map +1 -1
  99. package/types/sdk.d.ts +5 -5
  100. package/types/sdk.d.ts.map +1 -1
  101. package/types/stack-parsers.d.ts +8 -6
  102. package/types/stack-parsers.d.ts.map +1 -1
  103. package/types/transports/fetch.d.ts +6 -15
  104. package/types/transports/fetch.d.ts.map +1 -1
  105. package/types/transports/index.d.ts +2 -5
  106. package/types/transports/index.d.ts.map +1 -1
  107. package/types/transports/types.d.ts +10 -0
  108. package/types/transports/types.d.ts.map +1 -0
  109. package/types/transports/utils.d.ts.map +1 -1
  110. package/types/transports/xhr.d.ts +6 -10
  111. package/types/transports/xhr.d.ts.map +1 -1
  112. package/cjs/backend.d.ts +0 -39
  113. package/cjs/backend.d.ts.map +0 -1
  114. package/cjs/backend.js +0 -58
  115. package/cjs/backend.js.map +0 -1
  116. package/cjs/client.d.ts +0 -33
  117. package/cjs/client.d.ts.map +0 -1
  118. package/cjs/eventbuilder.d.ts +0 -39
  119. package/cjs/eventbuilder.d.ts.map +0 -1
  120. package/cjs/exports.d.ts +0 -9
  121. package/cjs/exports.d.ts.map +0 -1
  122. package/cjs/flags.d.ts +0 -3
  123. package/cjs/flags.d.ts.map +0 -1
  124. package/cjs/helpers.d.ts +0 -52
  125. package/cjs/helpers.d.ts.map +0 -1
  126. package/cjs/index.d.ts +0 -16
  127. package/cjs/index.d.ts.map +0 -1
  128. package/cjs/integrations/breadcrumbs.d.ts +0 -47
  129. package/cjs/integrations/breadcrumbs.d.ts.map +0 -1
  130. package/cjs/integrations/dedupe.d.ts +0 -21
  131. package/cjs/integrations/dedupe.d.ts.map +0 -1
  132. package/cjs/integrations/globalhandlers.d.ts +0 -30
  133. package/cjs/integrations/globalhandlers.d.ts.map +0 -1
  134. package/cjs/integrations/index.d.ts +0 -7
  135. package/cjs/integrations/index.d.ts.map +0 -1
  136. package/cjs/integrations/linkederrors.d.ts +0 -42
  137. package/cjs/integrations/linkederrors.d.ts.map +0 -1
  138. package/cjs/integrations/trycatch.d.ts +0 -33
  139. package/cjs/integrations/trycatch.d.ts.map +0 -1
  140. package/cjs/integrations/useragent.d.ts +0 -17
  141. package/cjs/integrations/useragent.d.ts.map +0 -1
  142. package/cjs/integrations/useragent.js +0 -42
  143. package/cjs/integrations/useragent.js.map +0 -1
  144. package/cjs/sdk.d.ts +0 -112
  145. package/cjs/sdk.d.ts.map +0 -1
  146. package/cjs/stack-parsers.d.ts +0 -7
  147. package/cjs/stack-parsers.d.ts.map +0 -1
  148. package/cjs/transports/base.d.ts +0 -65
  149. package/cjs/transports/base.d.ts.map +0 -1
  150. package/cjs/transports/base.js +0 -141
  151. package/cjs/transports/base.js.map +0 -1
  152. package/cjs/transports/fetch.d.ts +0 -17
  153. package/cjs/transports/fetch.d.ts.map +0 -1
  154. package/cjs/transports/index.d.ts +0 -6
  155. package/cjs/transports/index.d.ts.map +0 -1
  156. package/cjs/transports/new-fetch.d.ts +0 -10
  157. package/cjs/transports/new-fetch.d.ts.map +0 -1
  158. package/cjs/transports/new-fetch.js +0 -27
  159. package/cjs/transports/new-fetch.js.map +0 -1
  160. package/cjs/transports/new-xhr.d.ts +0 -11
  161. package/cjs/transports/new-xhr.d.ts.map +0 -1
  162. package/cjs/transports/new-xhr.js +0 -46
  163. package/cjs/transports/new-xhr.js.map +0 -1
  164. package/cjs/transports/utils.d.ts +0 -48
  165. package/cjs/transports/utils.d.ts.map +0 -1
  166. package/cjs/transports/xhr.d.ts +0 -11
  167. package/cjs/transports/xhr.d.ts.map +0 -1
  168. package/cjs/version.d.ts +0 -2
  169. package/cjs/version.d.ts.map +0 -1
  170. package/cjs/version.js +0 -4
  171. package/cjs/version.js.map +0 -1
  172. package/esm/backend.d.ts +0 -39
  173. package/esm/backend.d.ts.map +0 -1
  174. package/esm/backend.js +0 -57
  175. package/esm/backend.js.map +0 -1
  176. package/esm/client.d.ts +0 -33
  177. package/esm/client.d.ts.map +0 -1
  178. package/esm/eventbuilder.d.ts +0 -39
  179. package/esm/eventbuilder.d.ts.map +0 -1
  180. package/esm/exports.d.ts +0 -9
  181. package/esm/exports.d.ts.map +0 -1
  182. package/esm/flags.d.ts +0 -3
  183. package/esm/flags.d.ts.map +0 -1
  184. package/esm/helpers.d.ts +0 -52
  185. package/esm/helpers.d.ts.map +0 -1
  186. package/esm/index.d.ts +0 -16
  187. package/esm/index.d.ts.map +0 -1
  188. package/esm/integrations/breadcrumbs.d.ts +0 -47
  189. package/esm/integrations/breadcrumbs.d.ts.map +0 -1
  190. package/esm/integrations/dedupe.d.ts +0 -21
  191. package/esm/integrations/dedupe.d.ts.map +0 -1
  192. package/esm/integrations/globalhandlers.d.ts +0 -30
  193. package/esm/integrations/globalhandlers.d.ts.map +0 -1
  194. package/esm/integrations/index.d.ts +0 -7
  195. package/esm/integrations/index.d.ts.map +0 -1
  196. package/esm/integrations/linkederrors.d.ts +0 -42
  197. package/esm/integrations/linkederrors.d.ts.map +0 -1
  198. package/esm/integrations/trycatch.d.ts +0 -33
  199. package/esm/integrations/trycatch.d.ts.map +0 -1
  200. package/esm/integrations/useragent.d.ts +0 -17
  201. package/esm/integrations/useragent.d.ts.map +0 -1
  202. package/esm/integrations/useragent.js +0 -41
  203. package/esm/integrations/useragent.js.map +0 -1
  204. package/esm/sdk.d.ts +0 -112
  205. package/esm/sdk.d.ts.map +0 -1
  206. package/esm/stack-parsers.d.ts +0 -7
  207. package/esm/stack-parsers.d.ts.map +0 -1
  208. package/esm/transports/base.d.ts +0 -65
  209. package/esm/transports/base.d.ts.map +0 -1
  210. package/esm/transports/base.js +0 -140
  211. package/esm/transports/base.js.map +0 -1
  212. package/esm/transports/fetch.d.ts +0 -17
  213. package/esm/transports/fetch.d.ts.map +0 -1
  214. package/esm/transports/index.d.ts +0 -6
  215. package/esm/transports/index.d.ts.map +0 -1
  216. package/esm/transports/new-fetch.d.ts +0 -10
  217. package/esm/transports/new-fetch.d.ts.map +0 -1
  218. package/esm/transports/new-fetch.js +0 -25
  219. package/esm/transports/new-fetch.js.map +0 -1
  220. package/esm/transports/new-xhr.d.ts +0 -11
  221. package/esm/transports/new-xhr.d.ts.map +0 -1
  222. package/esm/transports/new-xhr.js +0 -44
  223. package/esm/transports/new-xhr.js.map +0 -1
  224. package/esm/transports/utils.d.ts +0 -48
  225. package/esm/transports/utils.d.ts.map +0 -1
  226. package/esm/transports/xhr.d.ts +0 -11
  227. package/esm/transports/xhr.d.ts.map +0 -1
  228. package/esm/version.d.ts +0 -2
  229. package/esm/version.d.ts.map +0 -1
  230. package/esm/version.js +0 -3
  231. package/esm/version.js.map +0 -1
  232. package/types/backend.d.ts +0 -39
  233. package/types/backend.d.ts.map +0 -1
  234. package/types/integrations/useragent.d.ts.map +0 -1
  235. package/types/transports/base.d.ts +0 -65
  236. package/types/transports/base.d.ts.map +0 -1
  237. package/types/transports/new-fetch.d.ts +0 -10
  238. package/types/transports/new-fetch.d.ts.map +0 -1
  239. package/types/transports/new-xhr.d.ts +0 -11
  240. package/types/transports/new-xhr.d.ts.map +0 -1
  241. package/types/version.d.ts +0 -2
  242. package/types/version.d.ts.map +0 -1
package/cjs/sdk.d.ts DELETED
@@ -1,112 +0,0 @@
1
- import { Integrations as CoreIntegrations } from '@sentry/core';
2
- import { BrowserOptions } from './backend';
3
- import { ReportDialogOptions } from './helpers';
4
- import { Breadcrumbs, Dedupe, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';
5
- export declare const defaultIntegrations: (CoreIntegrations.FunctionToString | CoreIntegrations.InboundFilters | GlobalHandlers | TryCatch | Breadcrumbs | LinkedErrors | UserAgent | Dedupe)[];
6
- /**
7
- * The Sentry Browser SDK Client.
8
- *
9
- * To use this SDK, call the {@link init} function as early as possible when
10
- * loading the web page. To set context information or send manual events, use
11
- * the provided methods.
12
- *
13
- * @example
14
- *
15
- * ```
16
- *
17
- * import { init } from '@sentry/browser';
18
- *
19
- * init({
20
- * dsn: '__DSN__',
21
- * // ...
22
- * });
23
- * ```
24
- *
25
- * @example
26
- * ```
27
- *
28
- * import { configureScope } from '@sentry/browser';
29
- * configureScope((scope: Scope) => {
30
- * scope.setExtra({ battery: 0.7 });
31
- * scope.setTag({ user_mode: 'admin' });
32
- * scope.setUser({ id: '4711' });
33
- * });
34
- * ```
35
- *
36
- * @example
37
- * ```
38
- *
39
- * import { addBreadcrumb } from '@sentry/browser';
40
- * addBreadcrumb({
41
- * message: 'My Breadcrumb',
42
- * // ...
43
- * });
44
- * ```
45
- *
46
- * @example
47
- *
48
- * ```
49
- *
50
- * import * as Sentry from '@sentry/browser';
51
- * Sentry.captureMessage('Hello, world!');
52
- * Sentry.captureException(new Error('Good bye'));
53
- * Sentry.captureEvent({
54
- * message: 'Manual',
55
- * stacktrace: [
56
- * // ...
57
- * ],
58
- * });
59
- * ```
60
- *
61
- * @see {@link BrowserOptions} for documentation on configuration options.
62
- */
63
- export declare function init(options?: BrowserOptions): void;
64
- /**
65
- * Present the user with a report dialog.
66
- *
67
- * @param options Everything is optional, we try to fetch all info need from the global scope.
68
- */
69
- export declare function showReportDialog(options?: ReportDialogOptions): void;
70
- /**
71
- * This is the getter for lastEventId.
72
- *
73
- * @returns The last event id of a captured event.
74
- */
75
- export declare function lastEventId(): string | undefined;
76
- /**
77
- * This function is here to be API compatible with the loader.
78
- * @hidden
79
- */
80
- export declare function forceLoad(): void;
81
- /**
82
- * This function is here to be API compatible with the loader.
83
- * @hidden
84
- */
85
- export declare function onLoad(callback: () => void): void;
86
- /**
87
- * Call `flush()` on the current client, if there is one. See {@link Client.flush}.
88
- *
89
- * @param timeout Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause
90
- * the client to wait until all events are sent before resolving the promise.
91
- * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
92
- * doesn't (or if there's no client defined).
93
- */
94
- export declare function flush(timeout?: number): PromiseLike<boolean>;
95
- /**
96
- * Call `close()` on the current client, if there is one. See {@link Client.close}.
97
- *
98
- * @param timeout Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this
99
- * parameter will cause the client to wait until all events are sent before disabling itself.
100
- * @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
101
- * doesn't (or if there's no client defined).
102
- */
103
- export declare function close(timeout?: number): PromiseLike<boolean>;
104
- /**
105
- * Wrap code within a try/catch block so the SDK is able to capture errors.
106
- *
107
- * @param fn A function to wrap.
108
- *
109
- * @returns The result of wrapped function call.
110
- */
111
- export declare function wrap(fn: (...args: any) => any): any;
112
- //# sourceMappingURL=sdk.d.ts.map
package/cjs/sdk.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,YAAY,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAI5F,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,EAAE,mBAAmB,EAAwB,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAExG,eAAO,MAAM,mBAAmB,uJAS/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,cAAmB,GAAG,IAAI,CAuBvD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,mBAAwB,GAAG,IAAI,CAiBxE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,GAAG,SAAS,CAEhD;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAEjD;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAO5D;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAO5D;AAED;;;;;;GAMG;AAEH,wBAAgB,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,CAEnD"}
@@ -1,7 +0,0 @@
1
- import { StackLineParser } from '@sentry/utils';
2
- export declare const chromeStackParser: StackLineParser;
3
- export declare const geckoStackParser: StackLineParser;
4
- export declare const winjsStackParser: StackLineParser;
5
- export declare const opera10StackParser: StackLineParser;
6
- export declare const opera11StackParser: StackLineParser;
7
- //# sourceMappingURL=stack-parsers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stack-parsers.d.ts","sourceRoot":"","sources":["../../../src/stack-parsers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAqB,MAAM,eAAe,CAAC;AA8DnE,eAAO,MAAM,iBAAiB,EAAE,eAA2C,CAAC;AAoC5E,eAAO,MAAM,gBAAgB,EAAE,eAAyC,CAAC;AAazE,eAAO,MAAM,gBAAgB,EAAE,eAAyC,CAAC;AASzE,eAAO,MAAM,kBAAkB,EAAE,eAA6C,CAAC;AAU/E,eAAO,MAAM,kBAAkB,EAAE,eAA6C,CAAC"}
@@ -1,65 +0,0 @@
1
- import { APIDetails } from '@sentry/core';
2
- import { Event, Outcome, Response as SentryResponse, SentryRequest, SentryRequestType, Session, Transport, TransportOptions } from '@sentry/types';
3
- import { PromiseBuffer, RateLimits } from '@sentry/utils';
4
- /** Base Transport class implementation */
5
- export declare abstract class BaseTransport implements Transport {
6
- options: TransportOptions;
7
- /**
8
- * @deprecated
9
- */
10
- url: string;
11
- /** Helper to get Sentry API endpoints. */
12
- protected readonly _api: APIDetails;
13
- /** A simple buffer holding all requests. */
14
- protected readonly _buffer: PromiseBuffer<SentryResponse>;
15
- /** Locks transport after receiving rate limits in a response */
16
- protected _rateLimits: RateLimits;
17
- protected _outcomes: {
18
- [key: string]: number;
19
- };
20
- constructor(options: TransportOptions);
21
- /**
22
- * @inheritDoc
23
- */
24
- sendEvent(event: Event): PromiseLike<SentryResponse>;
25
- /**
26
- * @inheritDoc
27
- */
28
- sendSession(session: Session): PromiseLike<SentryResponse>;
29
- /**
30
- * @inheritDoc
31
- */
32
- close(timeout?: number): PromiseLike<boolean>;
33
- /**
34
- * @inheritDoc
35
- */
36
- recordLostEvent(reason: Outcome, category: SentryRequestType): void;
37
- /**
38
- * Send outcomes as an envelope
39
- */
40
- protected _flushOutcomes(): void;
41
- /**
42
- * Handle Sentry repsonse for promise-based transports.
43
- */
44
- protected _handleResponse({ requestType, response, headers, resolve, reject, }: {
45
- requestType: SentryRequestType;
46
- response: Response | XMLHttpRequest;
47
- headers: Record<string, string | null>;
48
- resolve: (value?: SentryResponse | PromiseLike<SentryResponse> | null | undefined) => void;
49
- reject: (reason?: unknown) => void;
50
- }): void;
51
- /**
52
- * Gets the time that given category is disabled until for rate limiting
53
- *
54
- * @deprecated Please use `disabledUntil` from @sentry/utils
55
- */
56
- protected _disabledUntil(requestType: SentryRequestType): Date;
57
- /**
58
- * Checks if a category is rate limited
59
- *
60
- * @deprecated Please use `isRateLimited` from @sentry/utils
61
- */
62
- protected _isRateLimited(requestType: SentryRequestType): boolean;
63
- protected abstract _sendRequest(sentryRequest: SentryRequest, originalPayload: Event | Session): PromiseLike<SentryResponse>;
64
- }
65
- //# sourceMappingURL=base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/transports/base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAMX,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,EACL,OAAO,EACP,QAAQ,IAAI,cAAc,EAC1B,aAAa,EACb,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EASL,aAAa,EACb,UAAU,EAGX,MAAM,eAAe,CAAC;AAYvB,0CAA0C;AAC1C,8BAAsB,aAAc,YAAW,SAAS;IAiB5B,OAAO,EAAE,gBAAgB;IAhBnD;;OAEG;IACI,GAAG,EAAE,MAAM,CAAC;IAEnB,0CAA0C;IAC1C,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAEpC,4CAA4C;IAC5C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAyB;IAElF,gEAAgE;IAChE,SAAS,CAAC,WAAW,EAAE,UAAU,CAAM;IAEvC,SAAS,CAAC,SAAS,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAM;gBAE1B,OAAO,EAAE,gBAAgB;IAcnD;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAAC,cAAc,CAAC;IAI3D;;OAEG;IACI,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAAC,cAAc,CAAC;IAIjE;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC;IAIpD;;OAEG;IACI,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAc1E;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;IAoChC;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,EACxB,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,MAAM,GACP,EAAE;QACD,WAAW,EAAE,iBAAiB,CAAC;QAC/B,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAAC;QACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;QACvC,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;QAC3F,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;KACpC,GAAG,IAAI;IAmBR;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI;IAK9D;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO;IAKjE,SAAS,CAAC,QAAQ,CAAC,YAAY,CAC7B,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,KAAK,GAAG,OAAO,GAC/B,WAAW,CAAC,cAAc,CAAC;CAC/B"}
@@ -1,141 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- var tslib_1 = require("tslib");
3
- var core_1 = require("@sentry/core");
4
- var utils_1 = require("@sentry/utils");
5
- var flags_1 = require("../flags");
6
- var utils_2 = require("./utils");
7
- function requestTypeToCategory(ty) {
8
- var tyStr = ty;
9
- return tyStr === 'event' ? 'error' : tyStr;
10
- }
11
- var global = utils_1.getGlobalObject();
12
- /** Base Transport class implementation */
13
- var BaseTransport = /** @class */ (function () {
14
- function BaseTransport(options) {
15
- var _this = this;
16
- this.options = options;
17
- /** A simple buffer holding all requests. */
18
- this._buffer = utils_1.makePromiseBuffer(30);
19
- /** Locks transport after receiving rate limits in a response */
20
- this._rateLimits = {};
21
- this._outcomes = {};
22
- this._api = core_1.initAPIDetails(options.dsn, options._metadata, options.tunnel);
23
- // eslint-disable-next-line deprecation/deprecation
24
- this.url = core_1.getStoreEndpointWithUrlEncodedAuth(this._api.dsn);
25
- if (this.options.sendClientReports && global.document) {
26
- global.document.addEventListener('visibilitychange', function () {
27
- if (global.document.visibilityState === 'hidden') {
28
- _this._flushOutcomes();
29
- }
30
- });
31
- }
32
- }
33
- /**
34
- * @inheritDoc
35
- */
36
- BaseTransport.prototype.sendEvent = function (event) {
37
- return this._sendRequest(core_1.eventToSentryRequest(event, this._api), event);
38
- };
39
- /**
40
- * @inheritDoc
41
- */
42
- BaseTransport.prototype.sendSession = function (session) {
43
- return this._sendRequest(core_1.sessionToSentryRequest(session, this._api), session);
44
- };
45
- /**
46
- * @inheritDoc
47
- */
48
- BaseTransport.prototype.close = function (timeout) {
49
- return this._buffer.drain(timeout);
50
- };
51
- /**
52
- * @inheritDoc
53
- */
54
- BaseTransport.prototype.recordLostEvent = function (reason, category) {
55
- var _a;
56
- if (!this.options.sendClientReports) {
57
- return;
58
- }
59
- // We want to track each category (event, transaction, session) separately
60
- // but still keep the distinction between different type of outcomes.
61
- // We could use nested maps, but it's much easier to read and type this way.
62
- // A correct type for map-based implementation if we want to go that route
63
- // would be `Partial<Record<SentryRequestType, Partial<Record<Outcome, number>>>>`
64
- var key = requestTypeToCategory(category) + ":" + reason;
65
- flags_1.IS_DEBUG_BUILD && utils_1.logger.log("Adding outcome: " + key);
66
- this._outcomes[key] = ((_a = this._outcomes[key]) !== null && _a !== void 0 ? _a : 0) + 1;
67
- };
68
- /**
69
- * Send outcomes as an envelope
70
- */
71
- BaseTransport.prototype._flushOutcomes = function () {
72
- if (!this.options.sendClientReports) {
73
- return;
74
- }
75
- var outcomes = this._outcomes;
76
- this._outcomes = {};
77
- // Nothing to send
78
- if (!Object.keys(outcomes).length) {
79
- flags_1.IS_DEBUG_BUILD && utils_1.logger.log('No outcomes to flush');
80
- return;
81
- }
82
- flags_1.IS_DEBUG_BUILD && utils_1.logger.log("Flushing outcomes:\n" + JSON.stringify(outcomes, null, 2));
83
- var url = core_1.getEnvelopeEndpointWithUrlEncodedAuth(this._api.dsn, this._api.tunnel);
84
- var discardedEvents = Object.keys(outcomes).map(function (key) {
85
- var _a = tslib_1.__read(key.split(':'), 2), category = _a[0], reason = _a[1];
86
- return {
87
- reason: reason,
88
- category: category,
89
- quantity: outcomes[key],
90
- };
91
- // TODO: Improve types on discarded_events to get rid of cast
92
- });
93
- var envelope = utils_1.createClientReportEnvelope(discardedEvents, this._api.tunnel && utils_1.dsnToString(this._api.dsn));
94
- try {
95
- utils_2.sendReport(url, utils_1.serializeEnvelope(envelope));
96
- }
97
- catch (e) {
98
- flags_1.IS_DEBUG_BUILD && utils_1.logger.error(e);
99
- }
100
- };
101
- /**
102
- * Handle Sentry repsonse for promise-based transports.
103
- */
104
- BaseTransport.prototype._handleResponse = function (_a) {
105
- var requestType = _a.requestType, response = _a.response, headers = _a.headers, resolve = _a.resolve, reject = _a.reject;
106
- var status = utils_1.eventStatusFromHttpCode(response.status);
107
- this._rateLimits = utils_1.updateRateLimits(this._rateLimits, headers);
108
- // eslint-disable-next-line deprecation/deprecation
109
- if (this._isRateLimited(requestType)) {
110
- flags_1.IS_DEBUG_BUILD &&
111
- // eslint-disable-next-line deprecation/deprecation
112
- utils_1.logger.warn("Too many " + requestType + " requests, backing off until: " + this._disabledUntil(requestType));
113
- }
114
- if (status === 'success') {
115
- resolve({ status: status });
116
- return;
117
- }
118
- reject(response);
119
- };
120
- /**
121
- * Gets the time that given category is disabled until for rate limiting
122
- *
123
- * @deprecated Please use `disabledUntil` from @sentry/utils
124
- */
125
- BaseTransport.prototype._disabledUntil = function (requestType) {
126
- var category = requestTypeToCategory(requestType);
127
- return new Date(utils_1.disabledUntil(this._rateLimits, category));
128
- };
129
- /**
130
- * Checks if a category is rate limited
131
- *
132
- * @deprecated Please use `isRateLimited` from @sentry/utils
133
- */
134
- BaseTransport.prototype._isRateLimited = function (requestType) {
135
- var category = requestTypeToCategory(requestType);
136
- return utils_1.isRateLimited(this._rateLimits, category);
137
- };
138
- return BaseTransport;
139
- }());
140
- exports.BaseTransport = BaseTransport;
141
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/transports/base.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n APIDetails,\n eventToSentryRequest,\n getEnvelopeEndpointWithUrlEncodedAuth,\n getStoreEndpointWithUrlEncodedAuth,\n initAPIDetails,\n sessionToSentryRequest,\n} from '@sentry/core';\nimport {\n ClientReport,\n Event,\n Outcome,\n Response as SentryResponse,\n SentryRequest,\n SentryRequestType,\n Session,\n Transport,\n TransportOptions,\n} from '@sentry/types';\nimport {\n createClientReportEnvelope,\n disabledUntil,\n dsnToString,\n eventStatusFromHttpCode,\n getGlobalObject,\n isRateLimited,\n logger,\n makePromiseBuffer,\n PromiseBuffer,\n RateLimits,\n serializeEnvelope,\n updateRateLimits,\n} from '@sentry/utils';\n\nimport { IS_DEBUG_BUILD } from '../flags';\nimport { sendReport } from './utils';\n\nfunction requestTypeToCategory(ty: SentryRequestType): string {\n const tyStr = ty as string;\n return tyStr === 'event' ? 'error' : tyStr;\n}\n\nconst global = getGlobalObject<Window>();\n\n/** Base Transport class implementation */\nexport abstract class BaseTransport implements Transport {\n /**\n * @deprecated\n */\n public url: string;\n\n /** Helper to get Sentry API endpoints. */\n protected readonly _api: APIDetails;\n\n /** A simple buffer holding all requests. */\n protected readonly _buffer: PromiseBuffer<SentryResponse> = makePromiseBuffer(30);\n\n /** Locks transport after receiving rate limits in a response */\n protected _rateLimits: RateLimits = {};\n\n protected _outcomes: { [key: string]: number } = {};\n\n public constructor(public options: TransportOptions) {\n this._api = initAPIDetails(options.dsn, options._metadata, options.tunnel);\n // eslint-disable-next-line deprecation/deprecation\n this.url = getStoreEndpointWithUrlEncodedAuth(this._api.dsn);\n\n if (this.options.sendClientReports && global.document) {\n global.document.addEventListener('visibilitychange', () => {\n if (global.document.visibilityState === 'hidden') {\n this._flushOutcomes();\n }\n });\n }\n }\n\n /**\n * @inheritDoc\n */\n public sendEvent(event: Event): PromiseLike<SentryResponse> {\n return this._sendRequest(eventToSentryRequest(event, this._api), event);\n }\n\n /**\n * @inheritDoc\n */\n public sendSession(session: Session): PromiseLike<SentryResponse> {\n return this._sendRequest(sessionToSentryRequest(session, this._api), session);\n }\n\n /**\n * @inheritDoc\n */\n public close(timeout?: number): PromiseLike<boolean> {\n return this._buffer.drain(timeout);\n }\n\n /**\n * @inheritDoc\n */\n public recordLostEvent(reason: Outcome, category: SentryRequestType): void {\n if (!this.options.sendClientReports) {\n return;\n }\n // We want to track each category (event, transaction, session) separately\n // but still keep the distinction between different type of outcomes.\n // We could use nested maps, but it's much easier to read and type this way.\n // A correct type for map-based implementation if we want to go that route\n // would be `Partial<Record<SentryRequestType, Partial<Record<Outcome, number>>>>`\n const key = `${requestTypeToCategory(category)}:${reason}`;\n IS_DEBUG_BUILD && logger.log(`Adding outcome: ${key}`);\n this._outcomes[key] = (this._outcomes[key] ?? 0) + 1;\n }\n\n /**\n * Send outcomes as an envelope\n */\n protected _flushOutcomes(): void {\n if (!this.options.sendClientReports) {\n return;\n }\n\n const outcomes = this._outcomes;\n this._outcomes = {};\n\n // Nothing to send\n if (!Object.keys(outcomes).length) {\n IS_DEBUG_BUILD && logger.log('No outcomes to flush');\n return;\n }\n\n IS_DEBUG_BUILD && logger.log(`Flushing outcomes:\\n${JSON.stringify(outcomes, null, 2)}`);\n\n const url = getEnvelopeEndpointWithUrlEncodedAuth(this._api.dsn, this._api.tunnel);\n\n const discardedEvents = Object.keys(outcomes).map(key => {\n const [category, reason] = key.split(':');\n return {\n reason,\n category,\n quantity: outcomes[key],\n };\n // TODO: Improve types on discarded_events to get rid of cast\n }) as ClientReport['discarded_events'];\n const envelope = createClientReportEnvelope(discardedEvents, this._api.tunnel && dsnToString(this._api.dsn));\n\n try {\n sendReport(url, serializeEnvelope(envelope));\n } catch (e) {\n IS_DEBUG_BUILD && logger.error(e);\n }\n }\n\n /**\n * Handle Sentry repsonse for promise-based transports.\n */\n protected _handleResponse({\n requestType,\n response,\n headers,\n resolve,\n reject,\n }: {\n requestType: SentryRequestType;\n response: Response | XMLHttpRequest;\n headers: Record<string, string | null>;\n resolve: (value?: SentryResponse | PromiseLike<SentryResponse> | null | undefined) => void;\n reject: (reason?: unknown) => void;\n }): void {\n const status = eventStatusFromHttpCode(response.status);\n\n this._rateLimits = updateRateLimits(this._rateLimits, headers);\n // eslint-disable-next-line deprecation/deprecation\n if (this._isRateLimited(requestType)) {\n IS_DEBUG_BUILD &&\n // eslint-disable-next-line deprecation/deprecation\n logger.warn(`Too many ${requestType} requests, backing off until: ${this._disabledUntil(requestType)}`);\n }\n\n if (status === 'success') {\n resolve({ status });\n return;\n }\n\n reject(response);\n }\n\n /**\n * Gets the time that given category is disabled until for rate limiting\n *\n * @deprecated Please use `disabledUntil` from @sentry/utils\n */\n protected _disabledUntil(requestType: SentryRequestType): Date {\n const category = requestTypeToCategory(requestType);\n return new Date(disabledUntil(this._rateLimits, category));\n }\n\n /**\n * Checks if a category is rate limited\n *\n * @deprecated Please use `isRateLimited` from @sentry/utils\n */\n protected _isRateLimited(requestType: SentryRequestType): boolean {\n const category = requestTypeToCategory(requestType);\n return isRateLimited(this._rateLimits, category);\n }\n\n protected abstract _sendRequest(\n sentryRequest: SentryRequest,\n originalPayload: Event | Session,\n ): PromiseLike<SentryResponse>;\n}\n"]}
@@ -1,17 +0,0 @@
1
- import { Event, Response, SentryRequest, Session, TransportOptions } from '@sentry/types';
2
- import { BaseTransport } from './base';
3
- import { FetchImpl } from './utils';
4
- /** `fetch` based transport */
5
- export declare class FetchTransport extends BaseTransport {
6
- /**
7
- * Fetch API reference which always points to native browser implementation.
8
- */
9
- private _fetch;
10
- constructor(options: TransportOptions, fetchImpl?: FetchImpl);
11
- /**
12
- * @param sentryRequest Prepared SentryRequest to be delivered
13
- * @param originalPayload Original payload used to create SentryRequest
14
- */
15
- protected _sendRequest(sentryRequest: SentryRequest, originalPayload: Event | Session): PromiseLike<Response>;
16
- }
17
- //# sourceMappingURL=fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/transports/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG1F,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,EAAgC,MAAM,SAAS,CAAC;AAElE,8BAA8B;AAC9B,qBAAa,cAAe,SAAQ,aAAa;IAC/C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAe;gBAEV,OAAO,EAAE,gBAAgB,EAAE,SAAS,GAAE,SAA0C;IAKnG;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,GAAG,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC;CA+D9G"}
@@ -1,6 +0,0 @@
1
- export { BaseTransport } from './base';
2
- export { FetchTransport } from './fetch';
3
- export { XHRTransport } from './xhr';
4
- export { makeNewFetchTransport } from './new-fetch';
5
- export { makeNewXHRTransport } from './new-xhr';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC"}
@@ -1,10 +0,0 @@
1
- import { BaseTransportOptions, NewTransport } from '@sentry/core';
2
- import { FetchImpl } from './utils';
3
- export interface FetchTransportOptions extends BaseTransportOptions {
4
- requestOptions?: RequestInit;
5
- }
6
- /**
7
- * Creates a Transport that uses the Fetch API to send events to Sentry.
8
- */
9
- export declare function makeNewFetchTransport(options: FetchTransportOptions, nativeFetch?: FetchImpl): NewTransport;
10
- //# sourceMappingURL=new-fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-fetch.d.ts","sourceRoot":"","sources":["../../../../src/transports/new-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAEpB,YAAY,EAGb,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAgC,MAAM,SAAS,CAAC;AAElE,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,cAAc,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,qBAAqB,EAC9B,WAAW,GAAE,SAA0C,GACtD,YAAY,CAuBd"}
@@ -1,27 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- var tslib_1 = require("tslib");
3
- var core_1 = require("@sentry/core");
4
- var utils_1 = require("./utils");
5
- /**
6
- * Creates a Transport that uses the Fetch API to send events to Sentry.
7
- */
8
- function makeNewFetchTransport(options, nativeFetch) {
9
- if (nativeFetch === void 0) { nativeFetch = utils_1.getNativeFetchImplementation(); }
10
- function makeRequest(request) {
11
- var requestOptions = tslib_1.__assign({ body: request.body, method: 'POST', referrerPolicy: 'origin' }, options.requestOptions);
12
- return nativeFetch(options.url, requestOptions).then(function (response) {
13
- return response.text().then(function (body) { return ({
14
- body: body,
15
- headers: {
16
- 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),
17
- 'retry-after': response.headers.get('Retry-After'),
18
- },
19
- reason: response.statusText,
20
- statusCode: response.status,
21
- }); });
22
- });
23
- }
24
- return core_1.createTransport({ bufferSize: options.bufferSize }, makeRequest);
25
- }
26
- exports.makeNewFetchTransport = makeNewFetchTransport;
27
- //# sourceMappingURL=new-fetch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-fetch.js","sourceRoot":"","sources":["../../../../src/transports/new-fetch.ts"],"names":[],"mappings":";;AAAA,qCAMsB;AAEtB,iCAAkE;AAMlE;;GAEG;AACH,SAAgB,qBAAqB,CACnC,OAA8B,EAC9B,WAAuD;IAAvD,4BAAA,EAAA,cAAyB,oCAA4B,EAAE;IAEvD,SAAS,WAAW,CAAC,OAAyB;QAC5C,IAAM,cAAc,sBAClB,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,QAAQ,IACrB,OAAO,CAAC,cAAc,CAC1B,CAAC;QAEF,OAAO,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,UAAA,QAAQ;YAC3D,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,UAAA,IAAI,IAAI,OAAA,CAAC;gBACnC,IAAI,MAAA;gBACJ,OAAO,EAAE;oBACP,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;oBACpE,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;iBACnD;gBACD,MAAM,EAAE,QAAQ,CAAC,UAAU;gBAC3B,UAAU,EAAE,QAAQ,CAAC,MAAM;aAC5B,CAAC,EARkC,CAQlC,CAAC,CAAC;QACN,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,sBAAe,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,WAAW,CAAC,CAAC;AAC1E,CAAC;AA1BD,sDA0BC","sourcesContent":["import {\n BaseTransportOptions,\n createTransport,\n NewTransport,\n TransportMakeRequestResponse,\n TransportRequest,\n} from '@sentry/core';\n\nimport { FetchImpl, getNativeFetchImplementation } from './utils';\n\nexport interface FetchTransportOptions extends BaseTransportOptions {\n requestOptions?: RequestInit;\n}\n\n/**\n * Creates a Transport that uses the Fetch API to send events to Sentry.\n */\nexport function makeNewFetchTransport(\n options: FetchTransportOptions,\n nativeFetch: FetchImpl = getNativeFetchImplementation(),\n): NewTransport {\n function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n const requestOptions: RequestInit = {\n body: request.body,\n method: 'POST',\n referrerPolicy: 'origin',\n ...options.requestOptions,\n };\n\n return nativeFetch(options.url, requestOptions).then(response => {\n return response.text().then(body => ({\n body,\n headers: {\n 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),\n 'retry-after': response.headers.get('Retry-After'),\n },\n reason: response.statusText,\n statusCode: response.status,\n }));\n });\n }\n\n return createTransport({ bufferSize: options.bufferSize }, makeRequest);\n}\n"]}
@@ -1,11 +0,0 @@
1
- import { BaseTransportOptions, NewTransport } from '@sentry/core';
2
- export interface XHRTransportOptions extends BaseTransportOptions {
3
- headers?: {
4
- [key: string]: string;
5
- };
6
- }
7
- /**
8
- * Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.
9
- */
10
- export declare function makeNewXHRTransport(options: XHRTransportOptions): NewTransport;
11
- //# sourceMappingURL=new-xhr.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-xhr.d.ts","sourceRoot":"","sources":["../../../../src/transports/new-xhr.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAEpB,YAAY,EAGb,MAAM,cAAc,CAAC;AAatB,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACrC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAiC9E"}
@@ -1,46 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- var core_1 = require("@sentry/core");
3
- var utils_1 = require("@sentry/utils");
4
- /**
5
- * The DONE ready state for XmlHttpRequest
6
- *
7
- * Defining it here as a constant b/c XMLHttpRequest.DONE is not always defined
8
- * (e.g. during testing, it is `undefined`)
9
- *
10
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState}
11
- */
12
- var XHR_READYSTATE_DONE = 4;
13
- /**
14
- * Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.
15
- */
16
- function makeNewXHRTransport(options) {
17
- function makeRequest(request) {
18
- return new utils_1.SyncPromise(function (resolve, _reject) {
19
- var xhr = new XMLHttpRequest();
20
- xhr.onreadystatechange = function () {
21
- if (xhr.readyState === XHR_READYSTATE_DONE) {
22
- var response = {
23
- body: xhr.response,
24
- headers: {
25
- 'x-sentry-rate-limits': xhr.getResponseHeader('X-Sentry-Rate-Limits'),
26
- 'retry-after': xhr.getResponseHeader('Retry-After'),
27
- },
28
- reason: xhr.statusText,
29
- statusCode: xhr.status,
30
- };
31
- resolve(response);
32
- }
33
- };
34
- xhr.open('POST', options.url);
35
- for (var header in options.headers) {
36
- if (Object.prototype.hasOwnProperty.call(options.headers, header)) {
37
- xhr.setRequestHeader(header, options.headers[header]);
38
- }
39
- }
40
- xhr.send(request.body);
41
- });
42
- }
43
- return core_1.createTransport({ bufferSize: options.bufferSize }, makeRequest);
44
- }
45
- exports.makeNewXHRTransport = makeNewXHRTransport;
46
- //# sourceMappingURL=new-xhr.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-xhr.js","sourceRoot":"","sources":["../../../../src/transports/new-xhr.ts"],"names":[],"mappings":";AAAA,qCAMsB;AACtB,uCAA4C;AAE5C;;;;;;;GAOG;AACH,IAAM,mBAAmB,GAAG,CAAC,CAAC;AAM9B;;GAEG;AACH,SAAgB,mBAAmB,CAAC,OAA4B;IAC9D,SAAS,WAAW,CAAC,OAAyB;QAC5C,OAAO,IAAI,mBAAW,CAA+B,UAAC,OAAO,EAAE,OAAO;YACpE,IAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;YAEjC,GAAG,CAAC,kBAAkB,GAAG;gBACvB,IAAI,GAAG,CAAC,UAAU,KAAK,mBAAmB,EAAE;oBAC1C,IAAM,QAAQ,GAAG;wBACf,IAAI,EAAE,GAAG,CAAC,QAAQ;wBAClB,OAAO,EAAE;4BACP,sBAAsB,EAAE,GAAG,CAAC,iBAAiB,CAAC,sBAAsB,CAAC;4BACrE,aAAa,EAAE,GAAG,CAAC,iBAAiB,CAAC,aAAa,CAAC;yBACpD;wBACD,MAAM,EAAE,GAAG,CAAC,UAAU;wBACtB,UAAU,EAAE,GAAG,CAAC,MAAM;qBACvB,CAAC;oBACF,OAAO,CAAC,QAAQ,CAAC,CAAC;iBACnB;YACH,CAAC,CAAC;YAEF,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YAE9B,KAAK,IAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE;gBACpC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;oBACjE,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;iBACvD;aACF;YAED,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,sBAAe,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,WAAW,CAAC,CAAC;AAC1E,CAAC;AAjCD,kDAiCC","sourcesContent":["import {\n BaseTransportOptions,\n createTransport,\n NewTransport,\n TransportMakeRequestResponse,\n TransportRequest,\n} from '@sentry/core';\nimport { SyncPromise } from '@sentry/utils';\n\n/**\n * The DONE ready state for XmlHttpRequest\n *\n * Defining it here as a constant b/c XMLHttpRequest.DONE is not always defined\n * (e.g. during testing, it is `undefined`)\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState}\n */\nconst XHR_READYSTATE_DONE = 4;\n\nexport interface XHRTransportOptions extends BaseTransportOptions {\n headers?: { [key: string]: string };\n}\n\n/**\n * Creates a Transport that uses the XMLHttpRequest API to send events to Sentry.\n */\nexport function makeNewXHRTransport(options: XHRTransportOptions): NewTransport {\n function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n return new SyncPromise<TransportMakeRequestResponse>((resolve, _reject) => {\n const xhr = new XMLHttpRequest();\n\n xhr.onreadystatechange = (): void => {\n if (xhr.readyState === XHR_READYSTATE_DONE) {\n const response = {\n body: xhr.response,\n headers: {\n 'x-sentry-rate-limits': xhr.getResponseHeader('X-Sentry-Rate-Limits'),\n 'retry-after': xhr.getResponseHeader('Retry-After'),\n },\n reason: xhr.statusText,\n statusCode: xhr.status,\n };\n resolve(response);\n }\n };\n\n xhr.open('POST', options.url);\n\n for (const header in options.headers) {\n if (Object.prototype.hasOwnProperty.call(options.headers, header)) {\n xhr.setRequestHeader(header, options.headers[header]);\n }\n }\n\n xhr.send(request.body);\n });\n }\n\n return createTransport({ bufferSize: options.bufferSize }, makeRequest);\n}\n"]}
@@ -1,48 +0,0 @@
1
- export declare type FetchImpl = typeof fetch;
2
- /**
3
- * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
4
- * Whenever someone wraps the Fetch API and returns the wrong promise chain,
5
- * this chain becomes orphaned and there is no possible way to capture it's rejections
6
- * other than allowing it bubble up to this very handler. eg.
7
- *
8
- * const f = window.fetch;
9
- * window.fetch = function () {
10
- * const p = f.apply(this, arguments);
11
- *
12
- * p.then(function() {
13
- * console.log('hi.');
14
- * });
15
- *
16
- * return p;
17
- * }
18
- *
19
- * `p.then(function () { ... })` is producing a completely separate promise chain,
20
- * however, what's returned is `p` - the result of original `fetch` call.
21
- *
22
- * This mean, that whenever we use the Fetch API to send our own requests, _and_
23
- * some ad-blocker blocks it, this orphaned chain will _always_ reject,
24
- * effectively causing another event to be captured.
25
- * This makes a whole process become an infinite loop, which we need to somehow
26
- * deal with, and break it in one way or another.
27
- *
28
- * To deal with this issue, we are making sure that we _always_ use the real
29
- * browser Fetch API, instead of relying on what `window.fetch` exposes.
30
- * The only downside to this would be missing our own requests as breadcrumbs,
31
- * but because we are already not doing this, it should be just fine.
32
- *
33
- * Possible failed fetch error messages per-browser:
34
- *
35
- * Chrome: Failed to fetch
36
- * Edge: Failed to Fetch
37
- * Firefox: NetworkError when attempting to fetch resource
38
- * Safari: resource blocked by content blocker
39
- */
40
- export declare function getNativeFetchImplementation(): FetchImpl;
41
- /**
42
- * Sends sdk client report using sendBeacon or fetch as a fallback if available
43
- *
44
- * @param url report endpoint
45
- * @param body report payload
46
- */
47
- export declare function sendReport(url: string, body: string): void;
48
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/transports/utils.ts"],"names":[],"mappings":"AAOA,oBAAY,SAAS,GAAG,OAAO,KAAK,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,4BAA4B,IAAI,SAAS,CAiCxD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAqB1D"}
@@ -1,11 +0,0 @@
1
- import { Event, Response, SentryRequest, Session } from '@sentry/types';
2
- import { BaseTransport } from './base';
3
- /** `XHR` based transport */
4
- export declare class XHRTransport extends BaseTransport {
5
- /**
6
- * @param sentryRequest Prepared SentryRequest to be delivered
7
- * @param originalPayload Original payload used to create SentryRequest
8
- */
9
- protected _sendRequest(sentryRequest: SentryRequest, originalPayload: Event | Session): PromiseLike<Response>;
10
- }
11
- //# sourceMappingURL=xhr.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../../../src/transports/xhr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,4BAA4B;AAC5B,qBAAa,YAAa,SAAQ,aAAa;IAC7C;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,GAAG,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC;CAmD9G"}
package/cjs/version.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const SDK_NAME = "sentry.javascript.browser";
2
- //# sourceMappingURL=version.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,QAAQ,8BAA8B,CAAC"}
package/cjs/version.js DELETED
@@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- // TODO: Remove in the next major release and rely only on @sentry/core SDK_VERSION and SdkInfo metadata
3
- exports.SDK_NAME = 'sentry.javascript.browser';
4
- //# sourceMappingURL=version.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/version.ts"],"names":[],"mappings":";AAAA,wGAAwG;AAC3F,QAAA,QAAQ,GAAG,2BAA2B,CAAC","sourcesContent":["// TODO: Remove in the next major release and rely only on @sentry/core SDK_VERSION and SdkInfo metadata\nexport const SDK_NAME = 'sentry.javascript.browser';\n"]}