172 lines
6.5 KiB
JavaScript
172 lines
6.5 KiB
JavaScript
// Metro module 880 (f881).
|
|
import { getCurrentScope, getClient, getIsolationScope } from "./Module848";
|
|
import { DEBUG_BUILD } from "./Module823";
|
|
import { consoleSandbox, debug } from "./consoleSandbox";
|
|
import { _getTraceInfoFromScope } from "./Module881";
|
|
import { getCombinedScopeData } from "./mergeScopeData";
|
|
import { isParameterizedString } from "./isInstanceOf";
|
|
import { _getSpanForScope } from "./Module844";
|
|
import { timestampInSeconds } from "./dateTimestampInSeconds";
|
|
import { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from "./Module882";
|
|
import { serializeAttributes } from "./isAttributeObject";
|
|
import { createLogEnvelope } from "./Module884";
|
|
import { getGlobalSingleton } from "./Module825";
|
|
function $mk67280() {
|
|
return () => new WeakMap();
|
|
}
|
|
let _INTERNAL_flushLogsBuffer;
|
|
const _INTERNAL_captureSerializedLog = function _INTERNAL_captureSerializedLog(a0, a1) {
|
|
const globalSingleton = getGlobalSingleton("clientToLogBufferMap", $mk67280());
|
|
const r23 = getGlobalSingleton("clientToLogBufferMap", $mk67280()).get(a0);
|
|
if (r23 === void 0) {
|
|
globalSingleton.set(a0, [a1]);
|
|
} else if (r23.length >= 100) {
|
|
_INTERNAL_flushLogsBuffer(a0, r23);
|
|
globalSingleton.set(a0, [a1]);
|
|
} else {
|
|
globalSingleton.set(a0, [...r23, a1]);
|
|
}
|
|
};
|
|
_INTERNAL_flushLogsBuffer = function _INTERNAL_flushLogsBuffer(a0, a1) {
|
|
let r11 = a1 == null ? getGlobalSingleton("clientToLogBufferMap", $mk67280()).get(a0) : a1;
|
|
if (r11 == null) {
|
|
r11 = [];
|
|
}
|
|
if (r11.length !== 0) {
|
|
const options = a0.getOptions();
|
|
const logEnvelope = createLogEnvelope(r11, options._metadata, options.tunnel, a0.getDsn());
|
|
getGlobalSingleton("clientToLogBufferMap", $mk67280()).set(a0, []);
|
|
a0.emit("flushLogs");
|
|
a0.sendEnvelope(logEnvelope);
|
|
}
|
|
};
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
export function _INTERNAL_captureLog(a0, r16 = getCurrentScope(), r28 = _INTERNAL_captureSerializedLog) {
|
|
let beforeSendLog, c12541_1, c12541_2;
|
|
beforeSendLog = void 0;
|
|
c12541_1 = void 0;
|
|
c12541_2 = void 0;
|
|
let r7 = r16 == null ? void 0 : r16.getClient();
|
|
if (r7 == null) {
|
|
r7 = getClient();
|
|
}
|
|
if (r7) {
|
|
const options = r7.getOptions();
|
|
const { release, environment, enableLogs = false } = options;
|
|
beforeSendLog = options.beforeSendLog;
|
|
if (enableLogs) {
|
|
const [, r64] = _getTraceInfoFromScope(r7, r16);
|
|
const attributes3 = {
|
|
...a0.attributes
|
|
};
|
|
c12541_1 = attributes3;
|
|
const combinedScopeData = getCombinedScopeData(getIsolationScope(), r16);
|
|
const user = combinedScopeData.user;
|
|
const { id, email, username } = user;
|
|
let attributes = combinedScopeData.attributes;
|
|
if (attributes === void 0) {
|
|
attributes = {};
|
|
}
|
|
if (!(id ? attributes3["user.id"] && true : !id)) {
|
|
attributes3["user.id"] = id;
|
|
}
|
|
if (!(email ? attributes3["user.email"] && true : !email)) {
|
|
attributes3["user.email"] = email;
|
|
}
|
|
if (!(username ? attributes3["user.name"] && true : !username)) {
|
|
attributes3["user.name"] = username;
|
|
}
|
|
if (!(release ? attributes3["sentry.release"] && false : !release)) {
|
|
attributes3["sentry.release"] = release;
|
|
}
|
|
if (!(environment ? attributes3["sentry.environment"] && false : !environment)) {
|
|
attributes3["sentry.environment"] = environment;
|
|
}
|
|
let r88 = r7.getSdkMetadata()?.sdk;
|
|
if (r88 == null) {
|
|
r88 = {};
|
|
}
|
|
const { name, version } = r88;
|
|
if (!(name ? attributes3["sentry.sdk.name"] && false : !name)) {
|
|
attributes3["sentry.sdk.name"] = name;
|
|
}
|
|
if (!(version ? attributes3["sentry.sdk.version"] && false : !version)) {
|
|
attributes3["sentry.sdk.version"] = version;
|
|
}
|
|
const integrationByName = r7.getIntegrationByName("Replay");
|
|
let r99 = integrationByName == null ? void 0 : integrationByName.getReplayId(true);
|
|
if (!(r99 ? attributes3["sentry.replay_id"] && false : !r99)) {
|
|
attributes3["sentry.replay_id"] = r99;
|
|
}
|
|
if (r99) {
|
|
r99 = (integrationByName == null ? void 0 : integrationByName.getRecordingMode()) === "buffer";
|
|
}
|
|
if (r99 && !(attributes3["sentry._internal.replay_is_buffering"] && false)) {
|
|
attributes3["sentry._internal.replay_is_buffering"] = true;
|
|
}
|
|
const message = a0.message;
|
|
if (isParameterizedString(message)) {
|
|
const { __sentry_template_string__, __sentry_template_values__ = [] } = message;
|
|
if (__sentry_template_values__?.length) {
|
|
attributes3["sentry.message.template"] = __sentry_template_string__;
|
|
}
|
|
__sentry_template_values__.forEach((item, index) => {
|
|
c12541_1[`sentry.message.parameter.${index}`] = item;
|
|
});
|
|
}
|
|
const r125 = _getSpanForScope(r16);
|
|
const r127 = r125 == null ? void 0 : r125.spanContext().spanId;
|
|
if (!(r127 ? attributes3["sentry.trace.parent_span_id"] && false : !r127)) {
|
|
attributes3["sentry.trace.parent_span_id"] = r127;
|
|
}
|
|
let r132 = {
|
|
...a0,
|
|
attributes: attributes3
|
|
};
|
|
c12541_2 = r132;
|
|
r7.emit("beforeCaptureLog", r132);
|
|
if (beforeSendLog) {
|
|
r132 = consoleSandbox(() => beforeSendLog(c12541_2));
|
|
}
|
|
if (!r132) {
|
|
r7.recordDroppedEvent("before_send", "log_item", 1);
|
|
if (DEBUG_BUILD) {
|
|
debug.warn("beforeSendLog returned null, log will not be captured.");
|
|
}
|
|
return void 0;
|
|
}
|
|
const { level, message: message2, attributes: attributes2 = {} } = r132;
|
|
let severityNumber = r132.severityNumber;
|
|
const r166 = {
|
|
timestamp: timestampInSeconds(),
|
|
level,
|
|
body: message2,
|
|
trace_id: r64?.trace_id,
|
|
severity_number: null,
|
|
attributes: null
|
|
};
|
|
if (severityNumber == null) {
|
|
severityNumber = SEVERITY_TEXT_TO_SEVERITY_NUMBER[level];
|
|
}
|
|
r166.severity_number = severityNumber;
|
|
r166.attributes = {
|
|
...serializeAttributes(attributes),
|
|
...serializeAttributes(attributes2, true)
|
|
};
|
|
r28(r7, r166);
|
|
r7.emit("afterCaptureLog", r132);
|
|
} else if (DEBUG_BUILD) {
|
|
debug.warn("logging option not enabled, log will not be captured.");
|
|
}
|
|
} else if (DEBUG_BUILD) {
|
|
debug.warn("No client available to capture log.");
|
|
}
|
|
}
|
|
export { _INTERNAL_captureSerializedLog };
|
|
export { _INTERNAL_flushLogsBuffer };
|
|
export function _INTERNAL_getLogBuffer(a0) {
|
|
return getGlobalSingleton("clientToLogBufferMap", $mk67280()).get(a0);
|
|
}
|