Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
7.3 KiB
Plaintext
1 line
7.3 KiB
Plaintext
{"version":3,"file":"base.js","sources":["../../../src/transports/base.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../debug-build';\nimport type { EventDropReason } from '../types-hoist/clientreport';\nimport type { Envelope, EnvelopeItem } from '../types-hoist/envelope';\nimport type {\n InternalBaseTransportOptions,\n Transport,\n TransportMakeRequestResponse,\n TransportRequestExecutor,\n} from '../types-hoist/transport';\nimport { debug } from '../utils/debug-logger';\nimport {\n createEnvelope,\n envelopeContainsItemType,\n envelopeItemTypeToDataCategory,\n forEachEnvelopeItem,\n serializeEnvelope,\n} from '../utils/envelope';\nimport { makePromiseBuffer, type PromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from '../utils/promisebuffer';\nimport { isRateLimited, type RateLimits, updateRateLimits } from '../utils/ratelimit';\n\nexport const DEFAULT_TRANSPORT_BUFFER_SIZE = 64;\n\n/**\n * Creates an instance of a Sentry `Transport`\n *\n * @param options\n * @param makeRequest\n */\nexport function createTransport(\n options: InternalBaseTransportOptions,\n makeRequest: TransportRequestExecutor,\n buffer: PromiseBuffer<TransportMakeRequestResponse> = makePromiseBuffer(\n options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE,\n ),\n): Transport {\n let rateLimits: RateLimits = {};\n const flush = (timeout?: number): PromiseLike<boolean> => buffer.drain(timeout);\n\n function send(envelope: Envelope): PromiseLike<TransportMakeRequestResponse> {\n const filteredEnvelopeItems: EnvelopeItem[] = [];\n\n // Drop rate limited items from envelope\n forEachEnvelopeItem(envelope, (item, type) => {\n const dataCategory = envelopeItemTypeToDataCategory(type);\n if (isRateLimited(rateLimits, dataCategory)) {\n options.recordDroppedEvent('ratelimit_backoff', dataCategory);\n } else {\n filteredEnvelopeItems.push(item);\n }\n });\n\n // Skip sending if envelope is empty after filtering out rate limited events\n if (filteredEnvelopeItems.length === 0) {\n return Promise.resolve({});\n }\n\n const filteredEnvelope: Envelope = createEnvelope(envelope[0], filteredEnvelopeItems as (typeof envelope)[1]);\n\n // Creates client report for each item in an envelope\n const recordEnvelopeLoss = (reason: EventDropReason): void => {\n // Don't record outcomes for client reports - we don't want to create a feedback loop if client reports themselves fail to send\n if (envelopeContainsItemType(filteredEnvelope, ['client_report'])) {\n DEBUG_BUILD && debug.warn(`Dropping client report. Will not send outcomes (reason: ${reason}).`);\n return;\n }\n forEachEnvelopeItem(filteredEnvelope, (item, type) => {\n options.recordDroppedEvent(reason, envelopeItemTypeToDataCategory(type));\n });\n };\n\n const requestTask = (): PromiseLike<TransportMakeRequestResponse> =>\n makeRequest({ body: serializeEnvelope(filteredEnvelope) }).then(\n response => {\n // Handle 413 Content Too Large\n // Loss of envelope content is expected so we record a send_error client report\n // https://develop.sentry.dev/sdk/expected-features/#dealing-with-network-failures\n if (response.statusCode === 413) {\n DEBUG_BUILD &&\n debug.error(\n 'Sentry responded with status code 413. Envelope was discarded due to exceeding size limits.',\n );\n recordEnvelopeLoss('send_error');\n return response;\n }\n\n // We don't want to throw on NOK responses, but we want to at least log them\n if (\n DEBUG_BUILD &&\n response.statusCode !== undefined &&\n (response.statusCode < 200 || response.statusCode >= 300)\n ) {\n debug.warn(`Sentry responded with status code ${response.statusCode} to sent event.`);\n }\n\n rateLimits = updateRateLimits(rateLimits, response);\n return response;\n },\n error => {\n recordEnvelopeLoss('network_error');\n DEBUG_BUILD && debug.error('Encountered error running transport request:', error);\n throw error;\n },\n );\n\n return buffer.add(requestTask).then(\n result => result,\n error => {\n if (error === SENTRY_BUFFER_FULL_ERROR) {\n DEBUG_BUILD && debug.error('Skipped sending event because buffer is full.');\n recordEnvelopeLoss('queue_overflow');\n return Promise.resolve({});\n } else {\n throw error;\n }\n },\n );\n }\n\n return {\n send,\n flush,\n };\n}\n"],"names":["makePromiseBuffer","envelope","forEachEnvelopeItem","envelopeItemTypeToDataCategory","isRateLimited","createEnvelope","envelopeContainsItemType","DEBUG_BUILD","debug","serializeEnvelope","updateRateLimits","SENTRY_BUFFER_FULL_ERROR"],"mappings":";;;;;;;;AAoBO,MAAM,6BAAA,GAAgC;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe;AAC/B,EAAE,OAAO;AACT,EAAE,WAAW;AACb,EAAE,MAAM,GAAgDA,+BAAiB;AACzE,IAAI,OAAO,CAAC,UAAA,IAAc,6BAA6B;AACvD,GAAG;AACH,EAAa;AACb,EAAE,IAAI,UAAU,GAAe,EAAE;AACjC,EAAE,MAAM,KAAA,GAAQ,CAAC,OAAO,KAAoC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;;AAEjF,EAAE,SAAS,IAAI,CAACC,UAAQ,EAAuD;AAC/E,IAAI,MAAM,qBAAqB,GAAmB,EAAE;;AAEpD;AACA,IAAIC,4BAAmB,CAACD,UAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK;AAClD,MAAM,MAAM,YAAA,GAAeE,uCAA8B,CAAC,IAAI,CAAC;AAC/D,MAAM,IAAIC,uBAAa,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE;AACnD,QAAQ,OAAO,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,YAAY,CAAC;AACrE,MAAM,OAAO;AACb,QAAQ,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;AACxC,MAAM;AACN,IAAI,CAAC,CAAC;;AAEN;AACA,IAAI,IAAI,qBAAqB,CAAC,MAAA,KAAW,CAAC,EAAE;AAC5C,MAAM,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;AAChC,IAAI;;AAEJ,IAAI,MAAM,gBAAgB,GAAaC,uBAAc,CAACJ,UA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