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

237 lines
8.1 KiB
JavaScript

// Metro module 1077 (f1078).
import { defineIntegration, addConsoleInstrumentationHandler, getClient, severityLevelFromString, safeJoin, addBreadcrumb, debug, htmlTreeAsString, getComponentName, getBreadcrumbLogLevelFromHttpStatusCode, addFetchInstrumentationHandler, parseUrl, getEventDescription } from "./Module817";
import { addClickKeypressInstrumentationHandler, addXhrInstrumentationHandler, SENTRY_XHR_DATA_KEY, addHistoryInstrumentationHandler } from "./Module1033";
import { DEBUG_BUILD } from "./Module1072";
import { WINDOW } from "./ignoreNextOnError";
Object.defineProperty(exports, Symbol.toStringTag, {
value: "Module"
});
const maxStringLength = 1024;
export const breadcrumbsIntegration = defineIntegration(function(r3 = {}) {
let c12708_0 = {
console: true,
dom: true,
fetch: true,
history: true,
sentry: true,
xhr: true,
...r3
};
return {
name: "Breadcrumbs",
setup: (a0) => {
if (c12708_0.console) {
let c24032_0 = a0;
addConsoleInstrumentationHandler(function _consoleBreadcrumb(a0) {
if (getClient() === c24032_0) {
const r18 = {
category: "console",
data: {
arguments: a0.args,
logger: "console"
},
level: severityLevelFromString(a0.level),
message: safeJoin(a0.args, " ")
};
if (a0.level === "assert") {
if (a0.args[0] !== false) {
return void 0;
}
r18.message = `Assertion failed: ${safeJoin(a0.args.slice(1), " ") || "console.assert"}`;
r18.data.arguments = a0.args.slice(1);
}
addBreadcrumb(r18, {
input: a0.args,
level: a0.level
});
}
});
}
if (c12708_0.dom) {
const dom2 = c12708_0.dom;
let c24033_0 = a0;
const dom = dom2;
addClickKeypressInstrumentationHandler(function _innerDomBreadcrumb(a0) {
let message;
let r6 = void 0;
if (getClient() === c24033_0) {
const r19 = typeof dom === "object" ? dom.serializeAttribute : void 0;
const r14 = typeof dom === "object" ? typeof dom.maxStringLength === "number" ? dom.maxStringLength : void 0 : void 0;
const r21 = r14 ? r14 > maxStringLength : r14;
let maxStringLength2 = r14;
if (r21) {
if (DEBUG_BUILD) {
debug.warn(`\`dom.maxStringLength\` cannot exceed 1024, but a value of ${r14} was configured. Sentry will use 1024 instead.`);
}
maxStringLength2 = maxStringLength;
}
let keyAttrs = r19;
if (typeof keyAttrs === "string") {
keyAttrs = [r19];
}
try {
const event = a0.event;
const r41 = (function _isEvent(a0) {
return !!a0 && !!a0.target;
})(event) ? event.target : event;
message = htmlTreeAsString(r41, {
keyAttrs,
maxStringLength: maxStringLength2
});
r6 = getComponentName(r41);
} catch ($e) {
message = "<unknown>";
}
if (message.length !== 0) {
const r60 = {
category: `ui.${a0.name}`,
message
};
if (r6) {
r60.data = {
"ui.component_name": r6
};
}
addBreadcrumb(r60, {
event: a0.event,
name: a0.name,
global: a0.global
});
}
}
});
}
if (c12708_0.xhr) {
let c24034_0 = a0;
addXhrInstrumentationHandler(function _xhrBreadcrumb(a0) {
const client = getClient();
if (client === c24034_0) {
const { startTimestamp, endTimestamp } = a0;
const r20 = a0.xhr[SENTRY_XHR_DATA_KEY];
if (startTimestamp && endTimestamp && r20) {
const { method, url, status_code, body } = r20;
const data = {
method,
url,
status_code
};
const r24 = {
xhr: a0.xhr,
input: body,
startTimestamp,
endTimestamp
};
const r25 = {
category: "xhr",
data,
type: "http",
level: getBreadcrumbLogLevelFromHttpStatusCode(status_code)
};
c24034_0.emit("beforeOutgoingRequestBreadcrumb", r25, r24);
addBreadcrumb(r25, r24);
}
}
});
}
if (c12708_0.fetch) {
let c24035_0 = a0;
addFetchInstrumentationHandler(function _fetchBreadcrumb(a0) {
L9: {
const client = getClient();
if (client === c24035_0) {
const { startTimestamp, endTimestamp } = a0;
if (endTimestamp) {
if (a0.fetchData.url.match(/sentry_key/) && a0.fetchData.method === "POST") {
break L9;
}
a0.fetchData.method;
a0.fetchData.url;
if (a0.error) {
const fetchData = a0.fetchData;
const r57 = {
data: a0.error,
input: a0.args,
startTimestamp,
endTimestamp
};
const r58 = {
category: "fetch",
data: fetchData,
level: "error",
type: "http"
};
c24035_0.emit("beforeOutgoingRequestBreadcrumb", r58, r57);
addBreadcrumb(r58, r57);
} else {
const response = a0.response;
const data = {
...a0.fetchData,
status_code: response?.status
};
a0.fetchData.request_body_size;
a0.fetchData.response_body_size;
const r11 = {
input: a0.args,
response,
startTimestamp,
endTimestamp
};
const r42 = {
category: "fetch",
data,
type: "http",
level: getBreadcrumbLogLevelFromHttpStatusCode(data.status_code)
};
c24035_0.emit("beforeOutgoingRequestBreadcrumb", r42, r11);
addBreadcrumb(r42, r11);
}
}
}
}
});
}
if (c12708_0.history) {
let c24036_0 = a0;
addHistoryInstrumentationHandler(function _historyBreadcrumb(a0) {
if (getClient() === c24036_0) {
const from = a0.from;
let to = a0.to;
const r25 = parseUrl(WINDOW.location.href);
let r26 = from ? parseUrl(from) : void 0;
const r32 = parseUrl(to);
if (!r26?.path) {
r26 = r25;
}
if (r25.protocol === r32.protocol && r25.host === r32.host) {
to = r32.relative;
}
addBreadcrumb({
category: "navigation",
data: {
from: r25.protocol === r26.protocol && r25.host === r26.host ? r26.relative : from,
to
}
});
}
});
}
if (c12708_0.sentry) {
const on = a0.on;
let c24037_0 = a0;
on.call(a0, "beforeSendEvent", function addSentryBreadcrumb(a0) {
if (getClient() === c24037_0) {
addBreadcrumb({
category: "sentry." + (a0.type === "transaction" ? "transaction" : "event"),
event_id: a0.event_id,
level: a0.level,
message: getEventDescription(a0)
}, {
event: a0
});
}
});
}
}
};
});