62 lines
3.0 KiB
JavaScript
62 lines
3.0 KiB
JavaScript
// Metro module 1165 (f1166).
|
|
import { getClient, getActiveSpan, debug, spanToJSON, getCurrentScope, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from "./Module817";
|
|
import { getCurrentReactNativeTracingIntegration } from "./Module1166";
|
|
import { isSentryInteractionSpan, clearActiveSpanFromScope, startIdleSpan } from "./startIdleSpan";
|
|
import { SPAN_ORIGIN_MANUAL_INTERACTION } from "./Module1158";
|
|
import { onlySampleIfChildSpans } from "./Module1161";
|
|
const name = "UserInteraction";
|
|
export const userInteractionIntegration = () => ({
|
|
name
|
|
});
|
|
export const startUserInteractionSpan = (a0) => {
|
|
L19: {
|
|
const client = getClient();
|
|
if (client) {
|
|
const currentReactNativeTracingIntegration = getCurrentReactNativeTracingIntegration();
|
|
if (currentReactNativeTracingIntegration) {
|
|
const options = client.getOptions();
|
|
const { elementId, op } = a0;
|
|
if (options.enableUserInteractionTracing) {
|
|
if (elementId) {
|
|
if (currentReactNativeTracingIntegration.state.currentRoute) {
|
|
const activeSpan = getActiveSpan();
|
|
const r83 = activeSpan && !isSentryInteractionSpan(activeSpan);
|
|
if (activeSpan && r83) {
|
|
debug.warn(`[${name}] Did not create ${op} transaction because active transaction ${spanToJSON(activeSpan).description} exists on the scope.`);
|
|
break L19;
|
|
}
|
|
const name2 = `${currentReactNativeTracingIntegration.state.currentRoute}.${elementId}`;
|
|
if (activeSpan && spanToJSON(activeSpan).description === name2 && spanToJSON(activeSpan).op === op) {
|
|
debug.warn(`[${name}] Did not create ${op} transaction because it the same transaction ${spanToJSON(activeSpan).description} already exists on the scope.`);
|
|
break L19;
|
|
}
|
|
const currentScope = getCurrentScope();
|
|
const r120 = {
|
|
name: name2,
|
|
op,
|
|
scope: currentScope
|
|
};
|
|
clearActiveSpanFromScope(currentScope);
|
|
const r133 = startIdleSpan(r120, {
|
|
idleTimeout: currentReactNativeTracingIntegration.options.idleTimeoutMs,
|
|
finalTimeout: currentReactNativeTracingIntegration.options.finalTimeoutMs
|
|
});
|
|
r133.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_MANUAL_INTERACTION);
|
|
onlySampleIfChildSpans(client, r133);
|
|
debug.log(`[${name}] User Interaction Tracing Created ${op} transaction ${name2}.`);
|
|
return r133;
|
|
}
|
|
debug.log(`[${name}] User Interaction Tracing can not create transaction without a current route.`);
|
|
} else {
|
|
debug.log(`[${name}] User Interaction Tracing can not create transaction with undefined elementId.`);
|
|
}
|
|
} else {
|
|
debug.log(`[${name}] User Interaction Tracing is disabled.`);
|
|
}
|
|
} else {
|
|
debug.log(`[${name}] Tracing integration is not available. Can not start user interaction span.`);
|
|
}
|
|
}
|
|
}
|
|
};
|