123 lines
3.7 KiB
JavaScript
123 lines
3.7 KiB
JavaScript
// Metro module 871 (f872).
|
|
import { merge } from "./merge";
|
|
import { getGlobalScope } from "./Module848";
|
|
import { spanToTraceContext, spanToJSON, getRootSpan } from "./spanToJSON";
|
|
import { getDynamicSamplingContextFromSpan } from "./getDynamicSamplingContextFromSpan";
|
|
const mergeScopeData = function mergeScopeData(scopeData, { extra, tags, attributes, user, contexts, level, sdkProcessingMetadata, breadcrumbs, fingerprint, eventProcessors, attachments, propagationContext, transactionName, span }) {
|
|
scopeData.extra = merge(scopeData.extra, extra, 1);
|
|
scopeData.tags = merge(scopeData.tags, tags, 1);
|
|
scopeData.attributes = merge(scopeData.attributes, attributes, 1);
|
|
scopeData.user = merge(scopeData.user, user, 1);
|
|
scopeData.contexts = merge(scopeData.contexts, contexts, 1);
|
|
scopeData.sdkProcessingMetadata = merge(scopeData.sdkProcessingMetadata, sdkProcessingMetadata, 2);
|
|
if (level) {
|
|
scopeData.level = level;
|
|
}
|
|
if (transactionName) {
|
|
scopeData.transactionName = transactionName;
|
|
}
|
|
if (span) {
|
|
scopeData.span = span;
|
|
}
|
|
if (breadcrumbs.length) {
|
|
scopeData.breadcrumbs = [...scopeData.breadcrumbs, ...breadcrumbs];
|
|
}
|
|
if (fingerprint.length) {
|
|
scopeData.fingerprint = [...scopeData.fingerprint, ...fingerprint];
|
|
}
|
|
if (eventProcessors.length) {
|
|
scopeData.eventProcessors = [...scopeData.eventProcessors, ...eventProcessors];
|
|
}
|
|
if (attachments.length) {
|
|
scopeData.attachments = [...scopeData.attachments, ...attachments];
|
|
}
|
|
scopeData.propagationContext = {
|
|
...scopeData.propagationContext,
|
|
...propagationContext
|
|
};
|
|
};
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
export function applyScopeDataToEvent(a0, { fingerprint, span, breadcrumbs, sdkProcessingMetadata, extra, tags, user, contexts, level, transactionName }) {
|
|
let fingerprint3;
|
|
if (Object.keys(extra).length) {
|
|
a0.extra = {
|
|
...extra,
|
|
...a0.extra
|
|
};
|
|
}
|
|
if (Object.keys(tags).length) {
|
|
a0.tags = {
|
|
...tags,
|
|
...a0.tags
|
|
};
|
|
}
|
|
if (Object.keys(user).length) {
|
|
a0.user = {
|
|
...user,
|
|
...a0.user
|
|
};
|
|
}
|
|
if (Object.keys(contexts).length) {
|
|
a0.contexts = {
|
|
...contexts,
|
|
...a0.contexts
|
|
};
|
|
}
|
|
if (level) {
|
|
a0.level = level;
|
|
}
|
|
if (transactionName && a0.type !== "transaction") {
|
|
a0.transaction = transactionName;
|
|
}
|
|
if (span) {
|
|
a0.contexts = {
|
|
trace: spanToTraceContext(span),
|
|
...a0.contexts
|
|
};
|
|
a0.sdkProcessingMetadata = {
|
|
dynamicSamplingContext: getDynamicSamplingContextFromSpan(span),
|
|
...a0.sdkProcessingMetadata
|
|
};
|
|
const description = spanToJSON(getRootSpan(span)).description;
|
|
if (description && !a0.transaction && a0.type === "transaction") {
|
|
a0.transaction = description;
|
|
}
|
|
}
|
|
if (a0.fingerprint) {
|
|
const isArray = Array.isArray(a0.fingerprint);
|
|
const fingerprint2 = a0.fingerprint;
|
|
fingerprint3 = isArray ? fingerprint2 : [fingerprint2];
|
|
} else {
|
|
fingerprint3 = [];
|
|
}
|
|
a0.fingerprint = fingerprint3;
|
|
if (fingerprint) {
|
|
a0.fingerprint = a0.fingerprint.concat(fingerprint);
|
|
}
|
|
if (!a0.fingerprint.length) {
|
|
delete a0["fingerprint"];
|
|
}
|
|
const r111 = [...a0.breadcrumbs || [], ...breadcrumbs];
|
|
a0.breadcrumbs = r111.length ? r111 : void 0;
|
|
a0.sdkProcessingMetadata = {
|
|
...a0.sdkProcessingMetadata,
|
|
...sdkProcessingMetadata
|
|
};
|
|
}
|
|
export function getCombinedScopeData(a0, a1) {
|
|
const scopeData = getGlobalScope().getScopeData();
|
|
if (a0) {
|
|
mergeScopeData(scopeData, a0.getScopeData());
|
|
}
|
|
if (a1) {
|
|
mergeScopeData(scopeData, a1.getScopeData());
|
|
}
|
|
return scopeData;
|
|
}
|
|
export function mergeAndOverwriteScopeData(a0, a1, a2) {
|
|
a0[a1] = merge(a0[a1], a2, 1);
|
|
}
|
|
export { mergeScopeData };
|