@sentry/browser 7.0.0-alpha.1 → 7.0.0-beta.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 (185) hide show
  1. package/cjs/client.d.ts +23 -18
  2. package/cjs/client.d.ts.map +1 -1
  3. package/cjs/client.js +75 -51
  4. package/cjs/client.js.map +1 -1
  5. package/cjs/eventbuilder.d.ts +1 -1
  6. package/cjs/eventbuilder.js +31 -33
  7. package/cjs/eventbuilder.js.map +1 -1
  8. package/cjs/exports.d.ts +5 -4
  9. package/cjs/exports.d.ts.map +1 -1
  10. package/cjs/exports.js +20 -8
  11. package/cjs/exports.js.map +1 -1
  12. package/cjs/helpers.d.ts +0 -5
  13. package/cjs/helpers.d.ts.map +1 -1
  14. package/cjs/helpers.js +15 -49
  15. package/cjs/helpers.js.map +1 -1
  16. package/cjs/index.d.ts +1 -2
  17. package/cjs/index.d.ts.map +1 -1
  18. package/cjs/index.js +7 -9
  19. package/cjs/index.js.map +1 -1
  20. package/cjs/integrations/breadcrumbs.d.ts +6 -7
  21. package/cjs/integrations/breadcrumbs.d.ts.map +1 -1
  22. package/cjs/integrations/breadcrumbs.js +37 -54
  23. package/cjs/integrations/breadcrumbs.js.map +1 -1
  24. package/cjs/integrations/dedupe.js +25 -26
  25. package/cjs/integrations/dedupe.js.map +1 -1
  26. package/cjs/integrations/globalhandlers.d.ts.map +1 -1
  27. package/cjs/integrations/globalhandlers.js +52 -53
  28. package/cjs/integrations/globalhandlers.js.map +1 -1
  29. package/cjs/integrations/linkederrors.d.ts.map +1 -1
  30. package/cjs/integrations/linkederrors.js +26 -29
  31. package/cjs/integrations/linkederrors.js.map +1 -1
  32. package/cjs/integrations/trycatch.js +30 -40
  33. package/cjs/integrations/trycatch.js.map +1 -1
  34. package/cjs/integrations/useragent.js +19 -21
  35. package/cjs/integrations/useragent.js.map +1 -1
  36. package/cjs/sdk.d.ts +2 -2
  37. package/cjs/sdk.d.ts.map +1 -1
  38. package/cjs/sdk.js +47 -34
  39. package/cjs/sdk.js.map +1 -1
  40. package/cjs/stack-parsers.d.ts +7 -6
  41. package/cjs/stack-parsers.d.ts.map +1 -1
  42. package/cjs/stack-parsers.js +45 -45
  43. package/cjs/stack-parsers.js.map +1 -1
  44. package/cjs/transports/fetch.d.ts +7 -14
  45. package/cjs/transports/fetch.d.ts.map +1 -1
  46. package/cjs/transports/fetch.js +17 -78
  47. package/cjs/transports/fetch.js.map +1 -1
  48. package/cjs/transports/index.d.ts +2 -6
  49. package/cjs/transports/index.d.ts.map +1 -1
  50. package/cjs/transports/index.js +2 -10
  51. package/cjs/transports/index.js.map +1 -1
  52. package/cjs/transports/utils.d.ts.map +1 -1
  53. package/cjs/transports/utils.js +17 -17
  54. package/cjs/transports/utils.js.map +1 -1
  55. package/cjs/transports/xhr.d.ts +9 -9
  56. package/cjs/transports/xhr.d.ts.map +1 -1
  57. package/cjs/transports/xhr.js +39 -59
  58. package/cjs/transports/xhr.js.map +1 -1
  59. package/esm/client.d.ts +23 -18
  60. package/esm/client.d.ts.map +1 -1
  61. package/esm/client.js +73 -50
  62. package/esm/client.js.map +1 -1
  63. package/esm/eventbuilder.d.ts +1 -1
  64. package/esm/eventbuilder.js +30 -32
  65. package/esm/eventbuilder.js.map +1 -1
  66. package/esm/exports.d.ts +5 -4
  67. package/esm/exports.d.ts.map +1 -1
  68. package/esm/exports.js +4 -3
  69. package/esm/exports.js.map +1 -1
  70. package/esm/flags.js +1 -1
  71. package/esm/flags.js.map +1 -1
  72. package/esm/helpers.d.ts +0 -5
  73. package/esm/helpers.d.ts.map +1 -1
  74. package/esm/helpers.js +15 -48
  75. package/esm/helpers.js.map +1 -1
  76. package/esm/index.d.ts +1 -2
  77. package/esm/index.d.ts.map +1 -1
  78. package/esm/index.js +4 -6
  79. package/esm/index.js.map +1 -1
  80. package/esm/integrations/breadcrumbs.d.ts +6 -7
  81. package/esm/integrations/breadcrumbs.d.ts.map +1 -1
  82. package/esm/integrations/breadcrumbs.js +36 -54
  83. package/esm/integrations/breadcrumbs.js.map +1 -1
  84. package/esm/integrations/dedupe.js +23 -25
  85. package/esm/integrations/dedupe.js.map +1 -1
  86. package/esm/integrations/globalhandlers.d.ts.map +1 -1
  87. package/esm/integrations/globalhandlers.js +48 -50
  88. package/esm/integrations/globalhandlers.js.map +1 -1
  89. package/esm/integrations/linkederrors.d.ts.map +1 -1
  90. package/esm/integrations/linkederrors.js +24 -28
  91. package/esm/integrations/linkederrors.js.map +1 -1
  92. package/esm/integrations/trycatch.js +28 -39
  93. package/esm/integrations/trycatch.js.map +1 -1
  94. package/esm/integrations/useragent.js +17 -20
  95. package/esm/integrations/useragent.js.map +1 -1
  96. package/esm/sdk.d.ts +2 -2
  97. package/esm/sdk.d.ts.map +1 -1
  98. package/esm/sdk.js +44 -31
  99. package/esm/sdk.js.map +1 -1
  100. package/esm/stack-parsers.d.ts +7 -6
  101. package/esm/stack-parsers.d.ts.map +1 -1
  102. package/esm/stack-parsers.js +45 -45
  103. package/esm/stack-parsers.js.map +1 -1
  104. package/esm/transports/fetch.d.ts +7 -14
  105. package/esm/transports/fetch.d.ts.map +1 -1
  106. package/esm/transports/fetch.js +15 -77
  107. package/esm/transports/fetch.js.map +1 -1
  108. package/esm/transports/index.d.ts +2 -6
  109. package/esm/transports/index.d.ts.map +1 -1
  110. package/esm/transports/index.js +2 -6
  111. package/esm/transports/index.js.map +1 -1
  112. package/esm/transports/utils.d.ts.map +1 -1
  113. package/esm/transports/utils.js +16 -16
  114. package/esm/transports/utils.js.map +1 -1
  115. package/esm/transports/xhr.d.ts +9 -9
  116. package/esm/transports/xhr.d.ts.map +1 -1
  117. package/esm/transports/xhr.js +38 -59
  118. package/esm/transports/xhr.js.map +1 -1
  119. package/esm/version.js +1 -1
  120. package/esm/version.js.map +1 -1
  121. package/package.json +4 -4
  122. package/types/client.d.ts +23 -18
  123. package/types/client.d.ts.map +1 -1
  124. package/types/eventbuilder.d.ts +1 -1
  125. package/types/exports.d.ts +5 -4
  126. package/types/exports.d.ts.map +1 -1
  127. package/types/helpers.d.ts +0 -5
  128. package/types/helpers.d.ts.map +1 -1
  129. package/types/index.d.ts +1 -2
  130. package/types/index.d.ts.map +1 -1
  131. package/types/integrations/breadcrumbs.d.ts +6 -7
  132. package/types/integrations/breadcrumbs.d.ts.map +1 -1
  133. package/types/integrations/globalhandlers.d.ts.map +1 -1
  134. package/types/integrations/linkederrors.d.ts.map +1 -1
  135. package/types/sdk.d.ts +2 -2
  136. package/types/sdk.d.ts.map +1 -1
  137. package/types/stack-parsers.d.ts +7 -6
  138. package/types/stack-parsers.d.ts.map +1 -1
  139. package/types/transports/fetch.d.ts +7 -14
  140. package/types/transports/fetch.d.ts.map +1 -1
  141. package/types/transports/index.d.ts +2 -6
  142. package/types/transports/index.d.ts.map +1 -1
  143. package/types/transports/utils.d.ts.map +1 -1
  144. package/types/transports/xhr.d.ts +9 -9
  145. package/types/transports/xhr.d.ts.map +1 -1
  146. package/cjs/transports/base.d.ts +0 -65
  147. package/cjs/transports/base.d.ts.map +0 -1
  148. package/cjs/transports/base.js +0 -141
  149. package/cjs/transports/base.js.map +0 -1
  150. package/cjs/transports/new-fetch.d.ts +0 -10
  151. package/cjs/transports/new-fetch.d.ts.map +0 -1
  152. package/cjs/transports/new-fetch.js +0 -27
  153. package/cjs/transports/new-fetch.js.map +0 -1
  154. package/cjs/transports/new-xhr.d.ts +0 -11
  155. package/cjs/transports/new-xhr.d.ts.map +0 -1
  156. package/cjs/transports/new-xhr.js +0 -46
  157. package/cjs/transports/new-xhr.js.map +0 -1
  158. package/cjs/transports/setup.d.ts +0 -22
  159. package/cjs/transports/setup.d.ts.map +0 -1
  160. package/cjs/transports/setup.js +0 -44
  161. package/cjs/transports/setup.js.map +0 -1
  162. package/esm/transports/base.d.ts +0 -65
  163. package/esm/transports/base.d.ts.map +0 -1
  164. package/esm/transports/base.js +0 -140
  165. package/esm/transports/base.js.map +0 -1
  166. package/esm/transports/new-fetch.d.ts +0 -10
  167. package/esm/transports/new-fetch.d.ts.map +0 -1
  168. package/esm/transports/new-fetch.js +0 -25
  169. package/esm/transports/new-fetch.js.map +0 -1
  170. package/esm/transports/new-xhr.d.ts +0 -11
  171. package/esm/transports/new-xhr.d.ts.map +0 -1
  172. package/esm/transports/new-xhr.js +0 -44
  173. package/esm/transports/new-xhr.js.map +0 -1
  174. package/esm/transports/setup.d.ts +0 -22
  175. package/esm/transports/setup.d.ts.map +0 -1
  176. package/esm/transports/setup.js +0 -42
  177. package/esm/transports/setup.js.map +0 -1
  178. package/types/transports/base.d.ts +0 -65
  179. package/types/transports/base.d.ts.map +0 -1
  180. package/types/transports/new-fetch.d.ts +0 -10
  181. package/types/transports/new-fetch.d.ts.map +0 -1
  182. package/types/transports/new-xhr.d.ts +0 -11
  183. package/types/transports/new-xhr.d.ts.map +0 -1
  184. package/types/transports/setup.d.ts +0 -22
  185. package/types/transports/setup.d.ts.map +0 -1
@@ -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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CAAG,CAAC,CAAC;SAC3G;QAED,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,OAAO,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,CAAC;YACpB,OAAO;SACR;QAED,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACO,sCAAc,GAAxB,UAAyB,WAA8B;QACrD,IAAM,QAAQ,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;QACpD,OAAO,IAAI,IAAI,CAAC,qBAAa,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACO,sCAAc,GAAxB,UAAyB,WAA8B;QACrD,IAAM,QAAQ,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;QACpD,OAAO,qBAAa,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC;IAMH,oBAAC;AAAD,CAAC,AAtKD,IAsKC;AAtKqB,sCAAa","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,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,m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\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,22 +0,0 @@
1
- import { BaseTransportOptions, NewTransport } from '@sentry/core';
2
- import { Transport } from '@sentry/types';
3
- import { BrowserOptions } from '../client';
4
- export interface BrowserTransportOptions extends BaseTransportOptions {
5
- fetchParams: Record<string, string>;
6
- headers?: Record<string, string>;
7
- sendClientReports?: boolean;
8
- }
9
- /**
10
- * Sets up Browser transports based on the passed `options`. If available, the returned
11
- * transport will use the fetch API. In case fetch is not supported, an XMLHttpRequest
12
- * based transport is created.
13
- *
14
- * @returns an object currently still containing both, the old `Transport` and
15
- * `NewTransport` which will eventually replace `Transport`. Once this is replaced,
16
- * this function will return a ready to use `NewTransport`.
17
- */
18
- export declare function setupBrowserTransport(options: BrowserOptions): {
19
- transport: Transport;
20
- newTransport?: NewTransport;
21
- };
22
- //# sourceMappingURL=setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../../src/transports/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAGpB,YAAY,EAEb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAoB,MAAM,eAAe,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAM3C,MAAM,WAAW,uBAAwB,SAAQ,oBAAoB;IAEnE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;GAQG;AAEH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,cAAc,GAAG;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,YAAY,CAAC,EAAE,YAAY,CAAA;CAAE,CAkCpH"}
@@ -1,44 +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 fetch_1 = require("./fetch");
6
- var new_fetch_1 = require("./new-fetch");
7
- var new_xhr_1 = require("./new-xhr");
8
- var xhr_1 = require("./xhr");
9
- /**
10
- * Sets up Browser transports based on the passed `options`. If available, the returned
11
- * transport will use the fetch API. In case fetch is not supported, an XMLHttpRequest
12
- * based transport is created.
13
- *
14
- * @returns an object currently still containing both, the old `Transport` and
15
- * `NewTransport` which will eventually replace `Transport`. Once this is replaced,
16
- * this function will return a ready to use `NewTransport`.
17
- */
18
- // TODO(v7): Adjust return value when NewTransport is the default
19
- function setupBrowserTransport(options) {
20
- if (!options.dsn) {
21
- // We return the noop transport here in case there is no Dsn.
22
- return { transport: new core_1.NoopTransport() };
23
- }
24
- var transportOptions = tslib_1.__assign(tslib_1.__assign({}, options.transportOptions), { dsn: options.dsn, tunnel: options.tunnel, sendClientReports: options.sendClientReports, _metadata: options._metadata });
25
- var api = core_1.initAPIDetails(transportOptions.dsn, transportOptions._metadata, transportOptions.tunnel);
26
- var url = core_1.getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel);
27
- if (options.transport) {
28
- return { transport: new options.transport(transportOptions) };
29
- }
30
- if (utils_1.supportsFetch()) {
31
- var requestOptions = tslib_1.__assign({}, transportOptions.fetchParameters);
32
- var newTransport_1 = new_fetch_1.makeNewFetchTransport({ requestOptions: requestOptions, url: url });
33
- var fetchTransport = new fetch_1.FetchTransport(transportOptions);
34
- return { transport: fetchTransport, newTransport: newTransport_1 };
35
- }
36
- var newTransport = new_xhr_1.makeNewXHRTransport({
37
- url: url,
38
- headers: transportOptions.headers,
39
- });
40
- var transport = new xhr_1.XHRTransport(transportOptions);
41
- return { transport: transport, newTransport: newTransport };
42
- }
43
- exports.setupBrowserTransport = setupBrowserTransport;
44
- //# sourceMappingURL=setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../../src/transports/setup.ts"],"names":[],"mappings":";;AAAA,qCAMsB;AAEtB,uCAA8C;AAG9C,iCAAyC;AACzC,yCAAoD;AACpD,qCAAgD;AAChD,6BAAqC;AASrC;;;;;;;;GAQG;AACH,iEAAiE;AACjE,SAAgB,qBAAqB,CAAC,OAAuB;IAC3D,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QAChB,6DAA6D;QAC7D,OAAO,EAAE,SAAS,EAAE,IAAI,oBAAa,EAAE,EAAE,CAAC;KAC3C;IAED,IAA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entry/core';\nimport { Transport, TransportOptions } from '@sentry/types';\nimport { supportsFetch } from '@sentry/utils';\n\nimport { BrowserOptions } from '../client';\nimport { FetchTransport } from './fetch';\nimport { makeNewFetchTransport } from './new-fetch';\nimport { makeNewXHRTransport } from './new-xhr';\nimport { XHRTransport } from './xhr';\n\nexport interface BrowserTransportOptions extends BaseTransportOptions {\n // options to pass into fetch request\n fetchParams: Record<string, string>;\n headers?: Record<string, string>;\n sendClientReports?: boolean;\n}\n\n/**\n * Sets up Browser transports based on the passed `options`. If available, the returned\n * transport will use the fetch API. In case fetch is not supported, an XMLHttpRequest\n * based transport is created.\n *\n * @returns an object currently still containing both, the old `Transport` and\n * `NewTransport` which will eventually replace `Transport`. Once this is replaced,\n * this function will return a ready to use `NewTransport`.\n */\n// TODO(v7): Adjust return value when NewTransport is the default\nexport function setupBrowserTransport(options: BrowserOptions): { transport: Transport; newTransport?: NewTransport } {\n if (!options.dsn) {\n // We return the noop transport here in case there is no Dsn.\n return { transport: new NoopTransport() };\n }\n\n const transportOptions: TransportOptions = {\n ...options.transportOptions,\n dsn: options.dsn,\n tunnel: options.tunnel,\n sendClientReports: options.sendClientReports,\n _metadata: options._metadata,\n };\n\n const api = initAPIDetails(transportOptions.dsn, transportOptions._metadata, transportOptions.tunnel);\n const url = getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel);\n\n if (options.transport) {\n return { transport: new options.transport(transportOptions) };\n }\n\n if (supportsFetch()) {\n const requestOptions: RequestInit = { ...transportOptions.fetchParameters };\n const newTransport = makeNewFetchTransport({ requestOptions, url });\n const fetchTransport = new FetchTransport(transportOptions);\n return { transport: fetchTransport, newTransport };\n }\n\n const newTransport = makeNewXHRTransport({\n url,\n headers: transportOptions.headers,\n });\n const transport = new XHRTransport(transportOptions);\n return { transport, newTransport };\n}\n"]}
@@ -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
@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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,140 +0,0 @@
1
- import { __read } from "tslib";
2
- import { eventToSentryRequest, getEnvelopeEndpointWithUrlEncodedAuth, getStoreEndpointWithUrlEncodedAuth, initAPIDetails, sessionToSentryRequest, } from '@sentry/core';
3
- import { createClientReportEnvelope, disabledUntil, dsnToString, eventStatusFromHttpCode, getGlobalObject, isRateLimited, logger, makePromiseBuffer, serializeEnvelope, updateRateLimits, } from '@sentry/utils';
4
- import { IS_DEBUG_BUILD } from '../flags';
5
- import { sendReport } from './utils';
6
- function requestTypeToCategory(ty) {
7
- var tyStr = ty;
8
- return tyStr === 'event' ? 'error' : tyStr;
9
- }
10
- var global = getGlobalObject();
11
- /** Base Transport class implementation */
12
- var BaseTransport = /** @class */ (function () {
13
- function BaseTransport(options) {
14
- var _this = this;
15
- this.options = options;
16
- /** A simple buffer holding all requests. */
17
- this._buffer = makePromiseBuffer(30);
18
- /** Locks transport after receiving rate limits in a response */
19
- this._rateLimits = {};
20
- this._outcomes = {};
21
- this._api = initAPIDetails(options.dsn, options._metadata, options.tunnel);
22
- // eslint-disable-next-line deprecation/deprecation
23
- this.url = getStoreEndpointWithUrlEncodedAuth(this._api.dsn);
24
- if (this.options.sendClientReports && global.document) {
25
- global.document.addEventListener('visibilitychange', function () {
26
- if (global.document.visibilityState === 'hidden') {
27
- _this._flushOutcomes();
28
- }
29
- });
30
- }
31
- }
32
- /**
33
- * @inheritDoc
34
- */
35
- BaseTransport.prototype.sendEvent = function (event) {
36
- return this._sendRequest(eventToSentryRequest(event, this._api), event);
37
- };
38
- /**
39
- * @inheritDoc
40
- */
41
- BaseTransport.prototype.sendSession = function (session) {
42
- return this._sendRequest(sessionToSentryRequest(session, this._api), session);
43
- };
44
- /**
45
- * @inheritDoc
46
- */
47
- BaseTransport.prototype.close = function (timeout) {
48
- return this._buffer.drain(timeout);
49
- };
50
- /**
51
- * @inheritDoc
52
- */
53
- BaseTransport.prototype.recordLostEvent = function (reason, category) {
54
- var _a;
55
- if (!this.options.sendClientReports) {
56
- return;
57
- }
58
- // We want to track each category (event, transaction, session) separately
59
- // but still keep the distinction between different type of outcomes.
60
- // We could use nested maps, but it's much easier to read and type this way.
61
- // A correct type for map-based implementation if we want to go that route
62
- // would be `Partial<Record<SentryRequestType, Partial<Record<Outcome, number>>>>`
63
- var key = requestTypeToCategory(category) + ":" + reason;
64
- IS_DEBUG_BUILD && logger.log("Adding outcome: " + key);
65
- this._outcomes[key] = ((_a = this._outcomes[key]) !== null && _a !== void 0 ? _a : 0) + 1;
66
- };
67
- /**
68
- * Send outcomes as an envelope
69
- */
70
- BaseTransport.prototype._flushOutcomes = function () {
71
- if (!this.options.sendClientReports) {
72
- return;
73
- }
74
- var outcomes = this._outcomes;
75
- this._outcomes = {};
76
- // Nothing to send
77
- if (!Object.keys(outcomes).length) {
78
- IS_DEBUG_BUILD && logger.log('No outcomes to flush');
79
- return;
80
- }
81
- IS_DEBUG_BUILD && logger.log("Flushing outcomes:\n" + JSON.stringify(outcomes, null, 2));
82
- var url = getEnvelopeEndpointWithUrlEncodedAuth(this._api.dsn, this._api.tunnel);
83
- var discardedEvents = Object.keys(outcomes).map(function (key) {
84
- var _a = __read(key.split(':'), 2), category = _a[0], reason = _a[1];
85
- return {
86
- reason: reason,
87
- category: category,
88
- quantity: outcomes[key],
89
- };
90
- // TODO: Improve types on discarded_events to get rid of cast
91
- });
92
- var envelope = createClientReportEnvelope(discardedEvents, this._api.tunnel && dsnToString(this._api.dsn));
93
- try {
94
- sendReport(url, serializeEnvelope(envelope));
95
- }
96
- catch (e) {
97
- IS_DEBUG_BUILD && logger.error(e);
98
- }
99
- };
100
- /**
101
- * Handle Sentry repsonse for promise-based transports.
102
- */
103
- BaseTransport.prototype._handleResponse = function (_a) {
104
- var requestType = _a.requestType, response = _a.response, headers = _a.headers, resolve = _a.resolve, reject = _a.reject;
105
- var status = eventStatusFromHttpCode(response.status);
106
- this._rateLimits = updateRateLimits(this._rateLimits, headers);
107
- // eslint-disable-next-line deprecation/deprecation
108
- if (this._isRateLimited(requestType)) {
109
- IS_DEBUG_BUILD &&
110
- // eslint-disable-next-line deprecation/deprecation
111
- logger.warn("Too many " + requestType + " requests, backing off until: " + this._disabledUntil(requestType));
112
- }
113
- if (status === 'success') {
114
- resolve({ status: status });
115
- return;
116
- }
117
- reject(response);
118
- };
119
- /**
120
- * Gets the time that given category is disabled until for rate limiting
121
- *
122
- * @deprecated Please use `disabledUntil` from @sentry/utils
123
- */
124
- BaseTransport.prototype._disabledUntil = function (requestType) {
125
- var category = requestTypeToCategory(requestType);
126
- return new Date(disabledUntil(this._rateLimits, category));
127
- };
128
- /**
129
- * Checks if a category is rate limited
130
- *
131
- * @deprecated Please use `isRateLimited` from @sentry/utils
132
- */
133
- BaseTransport.prototype._isRateLimited = function (requestType) {
134
- var category = requestTypeToCategory(requestType);
135
- return isRateLimited(this._rateLimits, category);
136
- };
137
- return BaseTransport;
138
- }());
139
- export { BaseTransport };
140
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/transports/base.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,oBAAoB,EACpB,qCAAqC,EACrC,kCAAkC,EAClC,cAAc,EACd,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAYtB,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,WAAW,EACX,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,MAAM,EACN,iBAAiB,EAGjB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,SAAS,qBAAqB,CAAC,EAAqB;IAClD,IAAM,KAAK,GAAG,EAAY,CAAC;IAC3B,OAAO,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7C,CAAC;AAED,IAAM,MAAM,GAAG,eAAe,EAAU,CAAC;AAEzC,0CAA0C;AAC1C;IAiBE,uBAA0B,OAAyB;QAAnD,iBAYC;QAZyB,YAAO,GAAP,OAAO,CAAkB;QARnD,4CAA4C;QACzB,YAAO,GAAkC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QAElF,gEAAgE;QACtD,gBAAW,GAAe,EAAE,CAAC;QAE7B,cAAS,GAA8B,EAAE,CAAC;QAGlD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3E,mDAAmD;QACnD,IAAI,CAAC,GAAG,GAAG,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE7D,IAAI,IAAI,CAAC,OAA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,GAAzB,UAA0B,EAYzB;YAXC,4BAAW,EACX,sBAAQ,EACR,oBAAO,EACP,oBAAO,EACP,kBAAM;QAQN,IAAM,MAAM,GAAG,uBAAuB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAExD,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC/D,mDAAmD;QACnD,IAAI,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;YACpC,cAAc;gBACZ,mDAAmD;gBACnD,MAAM,CAAC,IAAI,CAAC,cAAY,WAAW,sCAAiC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAG,CAAC,CAAC;SAC3G;QAED,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,OAAO,CAAC,EAAE,MAAM,QAAA,EAAE,CAAC,CAAC;YACpB,OAAO;SACR;QAED,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACO,sCAAc,GAAxB,UAAyB,WAA8B;QACrD,IAAM,QAAQ,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;QACpD,OAAO,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;;;OAIG;IACO,sCAAc,GAAxB,UAAyB,WAA8B;QACrD,IAAM,QAAQ,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;QACpD,OAAO,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC;IAMH,oBAAC;AAAD,CAAC,AAtKD,IAsKC","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,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"}