86 lines
3.0 KiB
JavaScript
86 lines
3.0 KiB
JavaScript
// Metro module 6431 (f6432).
|
|
import { makePromiseBuffer } from "./Module6432";
|
|
import { forEachEnvelopeItem, envelopeItemTypeToDataCategory, createEnvelope, serializeEnvelope } from "./forEachEnvelopeItem_6412";
|
|
import { isRateLimited, updateRateLimits } from "./parseRetryAfterHeader_6433";
|
|
import { resolvedSyncPromise } from "./SyncPromise_6392";
|
|
import { DEBUG_BUILD } from "./Module6396";
|
|
import { logger } from "./consoleSandbox_6368";
|
|
import { SentryError } from "./SentryError_6425";
|
|
function $mk114972($env) {
|
|
return (a0, a1) => {
|
|
const r5 = a1 !== "event" ? a1 === "transaction" ? Array.isArray(a0) ? a0[1] : void 0 : void 0 : Array.isArray(a0) ? a0[1] : void 0;
|
|
const r13 = $env;
|
|
const r4 = $env.$parent[0];
|
|
const r16 = r13[0];
|
|
const r17 = $env.$parent.$parent;
|
|
r4.recordDroppedEvent(r16, (0, r17[0])(r17[1][1]).envelopeItemTypeToDataCategory(a1), r5);
|
|
};
|
|
}
|
|
let env4132 = {};
|
|
export const DEFAULT_TRANSPORT_BUFFER_SIZE = 64;
|
|
export function createTransport(a0, a1) {
|
|
let env15729 = {
|
|
$parent: env4132
|
|
};
|
|
env15729[0] = a0;
|
|
env15729[1] = a1;
|
|
let r7 = arguments[2];
|
|
if (r7 === void 0) {
|
|
r7 = makePromiseBuffer(a0.bufferSize || 64);
|
|
}
|
|
env15729[2] = r7;
|
|
env15729[3] = {};
|
|
return {
|
|
send: function send(a0) {
|
|
let envelope, recordEnvelopeLoss2;
|
|
const r9 = [];
|
|
let c25877_0 = r9;
|
|
forEachEnvelopeItem(a0, (a0, a1) => {
|
|
const r10 = envelopeItemTypeToDataCategory(a1);
|
|
if (isRateLimited(env15729[3], r10)) {
|
|
env15729[0].recordDroppedEvent("ratelimit_backoff", r10, a1 !== "event" ? a1 === "transaction" ? Array.isArray(a0) ? a0[1] : void 0 : void 0 : Array.isArray(a0) ? a0[1] : void 0);
|
|
} else {
|
|
c25877_0.push(a0);
|
|
}
|
|
});
|
|
if (r9.length === 0) {
|
|
return resolvedSyncPromise({});
|
|
}
|
|
envelope = createEnvelope(a0[0], r9);
|
|
recordEnvelopeLoss2 = (a0) => {};
|
|
return env15729[2].add(() => (0, env15729[1])({
|
|
body: serializeEnvelope(envelope)
|
|
}).then((result) => {
|
|
if (result.statusCode !== void 0 && (result.statusCode < 200 || result.statusCode >= 300) && DEBUG_BUILD) {
|
|
logger.warn(`Sentry responded with status code ${result.statusCode} to sent event.`);
|
|
}
|
|
env15729[3] = updateRateLimits(env15729[3], result);
|
|
return result;
|
|
}, (a0) => {
|
|
let env31421;
|
|
const r10 = env31421 = {
|
|
$parent: env15729
|
|
};
|
|
env31421[0] = "network_error";
|
|
forEachEnvelopeItem(envelope, $mk114972(r10));
|
|
throw a0;
|
|
})).then((result) => result, (a0) => {
|
|
if (a0 instanceof SentryError) {
|
|
if (DEBUG_BUILD) {
|
|
logger.error("Skipped sending event because buffer is full.");
|
|
}
|
|
let env29771;
|
|
const r25 = env29771 = {
|
|
$parent: env15729
|
|
};
|
|
env29771[0] = "queue_overflow";
|
|
forEachEnvelopeItem(envelope, $mk114972(r25));
|
|
return resolvedSyncPromise({});
|
|
}
|
|
throw a0;
|
|
});
|
|
},
|
|
flush: (a0) => env15729[2].drain(a0)
|
|
};
|
|
}
|