63 lines
2.4 KiB
JavaScript
63 lines
2.4 KiB
JavaScript
// Metro module 1128 (f1129).
|
|
import { debug, serializeEnvelope } from "./Module817";
|
|
import { createStealthXhr, XHR_READYSTATE_DONE } from "./Module815";
|
|
import { ReactNativeLibraries } from "./Module997";
|
|
let c936_2;
|
|
const getDefaultSidecarUrl = function getDefaultSidecarUrl() {
|
|
let r22;
|
|
try {
|
|
const Devtools = ReactNativeLibraries.Devtools;
|
|
const r13 = Devtools !== null ? Devtools !== void 0 ? Devtools.getDevServer() : void 0 : void 0;
|
|
const url = (r13 !== null && r13 !== void 0 ? r13 : {}).url;
|
|
r22 = url ? `http://${(function getHostnameFromString(a0) {
|
|
const r4 = a0.match(/^(?:\w+:)?\/\/([^/:]+)(:\d+)?(.*)$/);
|
|
return (r4 == null ? void 0 : r4[1]) ? r4[1] : null;
|
|
})(url)}:8969/stream` : c936_2;
|
|
} catch ($e) {
|
|
return c936_2;
|
|
}
|
|
return r22;
|
|
};
|
|
c936_2 = "http://localhost:8969/stream";
|
|
export function spotlightIntegration(r2 = {}) {
|
|
let sidecarUrl = r2.sidecarUrl;
|
|
if (sidecarUrl === void 0) {
|
|
sidecarUrl = getDefaultSidecarUrl();
|
|
}
|
|
const defaultSidecarUrl = sidecarUrl;
|
|
debug.log("[Spotlight] Using Sidecar URL", defaultSidecarUrl);
|
|
return {
|
|
name: "Spotlight",
|
|
setupOnce: () => {},
|
|
setup: (a0) => {
|
|
let c24226_0 = defaultSidecarUrl;
|
|
if (a0.on) {
|
|
a0.on("beforeEnvelope", (a0) => {
|
|
let stealthXhr;
|
|
const r8 = [...a0, [...a0[1]].filter((item) => {
|
|
const content_type = item[0].content_type;
|
|
return typeof content_type === "string" ? !item[0].content_type.startsWith("image") : typeof content_type !== "string";
|
|
})];
|
|
stealthXhr = createStealthXhr();
|
|
if (stealthXhr) {
|
|
stealthXhr.open("POST", c24226_0, true);
|
|
stealthXhr.setRequestHeader("Content-Type", "application/x-sentry-envelope");
|
|
stealthXhr.onreadystatechange = function() {
|
|
if (stealthXhr.readyState === XHR_READYSTATE_DONE) {
|
|
const status = stealthXhr.status;
|
|
if (!(status === 0 || status >= 200 && status < 400)) {
|
|
debug.error("[Spotlight] Sentry SDK can't connect to Spotlight is it running? See https://spotlightjs.com to download it.", new Error(stealthXhr.statusText));
|
|
}
|
|
}
|
|
};
|
|
stealthXhr.send(serializeEnvelope(r8));
|
|
} else {
|
|
debug.error("[Spotlight] Sentry SDK can not create XHR object");
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
}
|
|
export { getDefaultSidecarUrl };
|