@sentry/browser 6.19.3 → 6.19.4

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.
@@ -105,7 +105,7 @@ var BaseTransport = /** @class */ (function () {
105
105
  var status = utils_1.eventStatusFromHttpCode(response.status);
106
106
  this._rateLimits = utils_1.updateRateLimits(this._rateLimits, headers);
107
107
  // eslint-disable-next-line deprecation/deprecation
108
- if (this._isRateLimited(requestType) && utils_1.isDebugBuild()) {
108
+ if (this._isRateLimited(requestType)) {
109
109
  utils_1.isDebugBuild() &&
110
110
  // eslint-disable-next-line deprecation/deprecation
111
111
  utils_1.logger.warn("Too many " + requestType + " requests, backing off until: " + this._disabledUntil(requestType));
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/transports/base.ts"],"names":[],"mappings":";;AAAA,qCAOsB;AAYtB,uCAcuB;AAEvB,iCAAqC;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,uBAAe,EAAU,CAAC;AAEzC,0CAA0C;AAC1C;IAiBE,uBAA0B,OAAyB;QAAnD,iBAYC;QAZyB,YAAO,GAAP,OAAO,CAAkB;QARnD,4CAA4C;QACzB,YAAO,GAAkC,yBAAiB,CAAC,EAAE,CAAC,CAAC;QAElF,gEAAgE;QACtD,gBAAW,GAAe,EAAE,CAAC;QAE7B,cAAS,GAA8B,EAAE,CAAC;QAGlD,IAAI,CAAC,IAAI,GAAG,qBAAc,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3E,mDAAmD;QACnD,IAAI,CAAC,GAAG,GAAG,yCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC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oreEndpointWithUrlEncodedAuth,\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 isDebugBuild,\n isRateLimited,\n logger,\n makePromiseBuffer,\n PromiseBuffer,\n RateLimits,\n serializeEnvelope,\n updateRateLimits,\n} from '@sentry/utils';\n\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 isDebugBuild() && 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 isDebugBuild() && logger.log('No outcomes to flush');\n return;\n }\n\n isDebugBuild() && 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 isDebugBuild() && 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) && isDebugBuild()) {\n isDebugBuild() &&\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
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/transports/base.ts"],"names":[],"mappings":";;AAAA,qCAOsB;AAYtB,uCAcuB;AAEvB,iCAAqC;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,uBAAe,EAAU,CAAC;AAEzC,0CAA0C;AAC1C;IAiBE,uBAA0B,OAAyB;QAAnD,iBAYC;QAZyB,YAAO,GAAP,OAAO,CAAkB;QARnD,4CAA4C;QACzB,YAAO,GAAkC,yBAAiB,CAAC,EAAE,CAAC,CAAC;QAElF,gEAAgE;QACtD,gBAAW,GAAe,EAAE,CAAC;QAE7B,cAAS,GAA8B,EAAE,CAAC;QAGlD,IAAI,CAAC,IAAI,GAAG,qBAAc,CAAC,OAAO,CAAC,GAAG,EAAE,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AC;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 isDebugBuild,\n isRateLimited,\n logger,\n makePromiseBuffer,\n PromiseBuffer,\n RateLimits,\n serializeEnvelope,\n updateRateLimits,\n} from '@sentry/utils';\n\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 isDebugBuild() && 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 isDebugBuild() && logger.log('No outcomes to flush');\n return;\n }\n\n isDebugBuild() && 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 isDebugBuild() && 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 isDebugBuild() &&\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"]}
@@ -104,7 +104,7 @@ var BaseTransport = /** @class */ (function () {
104
104
  var status = eventStatusFromHttpCode(response.status);
105
105
  this._rateLimits = updateRateLimits(this._rateLimits, headers);
106
106
  // eslint-disable-next-line deprecation/deprecation
107
- if (this._isRateLimited(requestType) && isDebugBuild()) {
107
+ if (this._isRateLimited(requestType)) {
108
108
  isDebugBuild() &&
109
109
  // eslint-disable-next-line deprecation/deprecation
110
110
  logger.warn("Too many " + requestType + " requests, backing off until: " + this._disabledUntil(requestType));
@@ -1 +1 @@
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,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I,YAAY,EAAE,EAAE;YACtD,YAAY,EAAE;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 isDebugBuild,\n isRateLimited,\n logger,\n makePromiseBuffer,\n PromiseBuffer,\n RateLimits,\n serializeEnvelope,\n updateRateLimits,\n} from '@sentry/utils';\n\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 isDebugBuild() && 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 isDebugBuild() && logger.log('No outcomes to flush');\n return;\n }\n\n isDebugBuild() && 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 isDebugBuild() && 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) && isDebugBuild()) {\n isDebugBuild() &&\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
+ {"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,YAAY,EACZ,aAAa,EACb,MAAM,EACN,iBAAiB,EAGjB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,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,I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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 isDebugBuild,\n isRateLimited,\n logger,\n makePromiseBuffer,\n PromiseBuffer,\n RateLimits,\n serializeEnvelope,\n updateRateLimits,\n} from '@sentry/utils';\n\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 isDebugBuild() && 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 isDebugBuild() && logger.log('No outcomes to flush');\n return;\n }\n\n isDebugBuild() && 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 isDebugBuild() && 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 isDebugBuild() &&\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/browser",
3
- "version": "6.19.3",
3
+ "version": "6.19.4",
4
4
  "description": "Official Sentry SDK for browsers",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
@@ -11,14 +11,14 @@
11
11
  },
12
12
  "main": "dist/index.js",
13
13
  "module": "esm/index.js",
14
- "types": "dist/index.d.ts",
14
+ "types": "types/index.d.ts",
15
15
  "publishConfig": {
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "@sentry/core": "6.19.3",
20
- "@sentry/types": "6.19.3",
21
- "@sentry/utils": "6.19.3",
19
+ "@sentry/core": "6.19.4",
20
+ "@sentry/types": "6.19.4",
21
+ "@sentry/utils": "6.19.4",
22
22
  "tslib": "^1.9.3"
23
23
  },
24
24
  "devDependencies": {
@@ -63,11 +63,11 @@
63
63
  "clean": "rimraf build coverage .rpt2_cache",
64
64
  "fix": "run-s fix:eslint fix:prettier",
65
65
  "fix:eslint": "eslint . --format stylish --fix",
66
- "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
66
+ "fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
67
67
  "link:yarn": "yarn link",
68
68
  "lint": "run-s lint:prettier lint:eslint",
69
69
  "lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
70
- "lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
70
+ "lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
71
71
  "size:check": "run-p size:check:es5 size:check:es6",
72
72
  "size:check:es5": "cat build/bundles/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES5: \",$1,\"kB\";}'",
73
73
  "size:check:es6": "cat build/bundles/bundle.es6.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES6: \",$1,\"kB\";}'",