114 lines
4.2 KiB
JavaScript
114 lines
4.2 KiB
JavaScript
// Metro module 857 (f858).
|
|
import { addNonEnumerableProperty } from "./addNonEnumerableProperty";
|
|
import { DEFAULT_ENVIRONMENT } from "./Module858";
|
|
import { extractOrgIdFromClient } from "./dsnFromString";
|
|
import { getClient } from "./Module848";
|
|
import { getRootSpan, spanToJSON, spanIsSampled } from "./spanToJSON";
|
|
import { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from "./Module839";
|
|
import { baggageHeaderToDynamicSamplingContext, dynamicSamplingContextToSentryBaggageHeader } from "./Module835";
|
|
import { hasSpansEnabled } from "./Module855";
|
|
import { getCapturedScopesOnSpan } from "./unwrapScopeFromWeakRef";
|
|
let c697_2;
|
|
const getDynamicSamplingContextFromSpan = function getDynamicSamplingContextFromSpan(a0) {
|
|
const client = getClient();
|
|
if (client) {
|
|
const rootSpan = getRootSpan(a0);
|
|
const r7 = spanToJSON(rootSpan);
|
|
const data = r7.data;
|
|
const traceState = rootSpan.spanContext().traceState;
|
|
let r6 = traceState == null ? void 0 : traceState.get("sentry.sample_rate");
|
|
if (r6 == null) {
|
|
r6 = data[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE];
|
|
}
|
|
if (r6 == null) {
|
|
r6 = data[SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE];
|
|
}
|
|
const r37 = rootSpan[c697_2];
|
|
if (r37) {
|
|
if (!(typeof r6 !== "number" ? typeof r6 !== "string" : typeof r6 !== "number")) {
|
|
r37.sample_rate = `${r6}`;
|
|
}
|
|
return r37;
|
|
}
|
|
const r16 = traceState == null ? void 0 : traceState.get("sentry.dsc");
|
|
const r41 = r16 && baggageHeaderToDynamicSamplingContext(r16);
|
|
if (r41) {
|
|
if (!(typeof r6 !== "number" ? typeof r6 !== "string" : typeof r6 !== "number")) {
|
|
r41.sample_rate = `${r6}`;
|
|
}
|
|
return r41;
|
|
}
|
|
const traceId = a0.spanContext().traceId;
|
|
const options = client.getOptions();
|
|
const r55 = {
|
|
environment: options.environment || DEFAULT_ENVIRONMENT,
|
|
release: options.release,
|
|
public_key: (client.getDsn() || {}).publicKey,
|
|
trace_id: traceId,
|
|
org_id: extractOrgIdFromClient(client)
|
|
};
|
|
client.emit("createDsc", r55);
|
|
const r66 = data[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
|
|
const description = r7.description;
|
|
if (r66 !== "url" && description) {
|
|
r55.transaction = description;
|
|
}
|
|
if (hasSpansEnabled()) {
|
|
r55.sampled = String(spanIsSampled(rootSpan));
|
|
let sample_rand = traceState == null ? void 0 : traceState.get("sentry.sample_rand");
|
|
if (sample_rand == null) {
|
|
const scope = getCapturedScopesOnSpan(rootSpan).scope;
|
|
sample_rand = scope == null ? void 0 : scope.getPropagationContext().sampleRand.toString();
|
|
}
|
|
r55.sample_rand = sample_rand;
|
|
}
|
|
if (!(typeof r6 !== "number" ? typeof r6 !== "string" : typeof r6 !== "number")) {
|
|
r55.sample_rate = `${r6}`;
|
|
}
|
|
client.emit("createDsc", r55, rootSpan);
|
|
return r55;
|
|
}
|
|
return {};
|
|
};
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
c697_2 = "_frozenDsc";
|
|
export function freezeDscOnSpan(a0, a1) {
|
|
addNonEnumerableProperty(a0, c697_2, a1);
|
|
}
|
|
export function getDynamicSamplingContextFromClient(a0, a1) {
|
|
const options = a1.getOptions();
|
|
const r22 = {
|
|
environment: options.environment || DEFAULT_ENVIRONMENT,
|
|
release: options.release,
|
|
public_key: (a1.getDsn() || {}).publicKey,
|
|
trace_id: a0,
|
|
org_id: extractOrgIdFromClient(a1)
|
|
};
|
|
a1.emit("createDsc", r22);
|
|
return r22;
|
|
}
|
|
export function getDynamicSamplingContextFromScope(a0, a1) {
|
|
const propagationContext = a1.getPropagationContext();
|
|
let dsc = propagationContext.dsc;
|
|
if (!dsc) {
|
|
const traceId = propagationContext.traceId;
|
|
const options = a0.getOptions();
|
|
const r19 = {
|
|
environment: options.environment || DEFAULT_ENVIRONMENT,
|
|
release: options.release,
|
|
public_key: (a0.getDsn() || {}).publicKey,
|
|
trace_id: traceId,
|
|
org_id: extractOrgIdFromClient(a0)
|
|
};
|
|
a0.emit("createDsc", r19);
|
|
dsc = r19;
|
|
}
|
|
return dsc;
|
|
}
|
|
export { getDynamicSamplingContextFromSpan };
|
|
export function spanToBaggageHeader(a0) {
|
|
return dynamicSamplingContextToSentryBaggageHeader(getDynamicSamplingContextFromSpan(a0));
|
|
}
|