Files
discord-decomp/_bundle/Module878.js
T
2026-11-01 12:12:55 +02:00

100 lines
3.3 KiB
JavaScript

// Metro module 878 (f879).
import { makePromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from "./Module877";
import { forEachEnvelopeItem, envelopeItemTypeToDataCategory, createEnvelope, serializeEnvelope, envelopeContainsItemType } from "./forEachEnvelopeItem";
import { isRateLimited, updateRateLimits } from "./parseRetryAfterHeader";
import { DEBUG_BUILD } from "./Module823";
import { debug } from "./consoleSandbox";
function $mk113503($env) {
return (a0, a1) => {
const r4 = $env.$parent[0];
const r2 = $env[0];
const r8 = $env.$parent.$parent;
r4.recordDroppedEvent(r2, (0, r8[0])(r8[1][1]).envelopeItemTypeToDataCategory(a1));
};
}
let env720 = {};
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
export const DEFAULT_TRANSPORT_BUFFER_SIZE = 64;
export function createTransport(a0, a1) {
let env12540 = {
$parent: env720
};
env12540[0] = a0;
env12540[1] = a1;
let r7 = arguments[2];
if (r7 === void 0) {
r7 = makePromiseBuffer(a0.bufferSize || 64);
}
env12540[2] = r7;
env12540[3] = {};
return {
send: function send(a0) {
let envelope, recordEnvelopeLoss2;
const r7 = [];
let c23893_0 = r7;
forEachEnvelopeItem(a0, (a0, a1) => {
const r8 = envelopeItemTypeToDataCategory(a1);
if (isRateLimited(env12540[3], r8)) {
env12540[0].recordDroppedEvent("ratelimit_backoff", r8);
} else {
c23893_0.push(a0);
}
});
if (r7.length === 0) {
return Promise.resolve({});
}
envelope = createEnvelope(a0[0], r7);
recordEnvelopeLoss2 = (a0) => {};
return env12540[2].add(() => (0, env12540[1])({
body: serializeEnvelope(envelope)
}).then((result) => {
if (result.statusCode !== void 0 && (result.statusCode < 200 || result.statusCode >= 300) && DEBUG_BUILD) {
debug.warn(`Sentry responded with status code ${result.statusCode} to sent event.`);
}
env12540[3] = updateRateLimits(env12540[3], result);
return result;
}, (a0) => {
let env31167;
const r13 = env31167 = {
$parent: env12540
};
env31167[0] = "network_error";
if (envelopeContainsItemType(envelope, ["client_report"])) {
if (DEBUG_BUILD) {
debug.warn(`Dropping client report. Will not send outcomes (reason: network_error).`);
}
} else {
forEachEnvelopeItem(envelope, $mk113503(r13));
}
if (DEBUG_BUILD) {
debug.error("Encountered error running transport request:", a0);
}
throw a0;
})).then((result) => result, (a0) => {
if (a0 === SENTRY_BUFFER_FULL_ERROR) {
if (DEBUG_BUILD) {
debug.error("Skipped sending event because buffer is full.");
}
let env28684;
const r26 = env28684 = {
$parent: env12540
};
env28684[0] = "queue_overflow";
if (envelopeContainsItemType(envelope, ["client_report"])) {
if (DEBUG_BUILD) {
debug.warn(`Dropping client report. Will not send outcomes (reason: queue_overflow).`);
}
} else {
forEachEnvelopeItem(envelope, $mk113503(r26));
}
return Promise.resolve({});
}
throw a0;
});
},
flush: (a0) => env12540[2].drain(a0)
};
}