Skip to content

App Start data lost when first transaction is unsampled #5757

@antonis

Description

@antonis

Environment

  • @sentry/react-native (all versions with appStartIntegration)
  • Any tracesSampleRate less than 1.0

Steps to Reproduce

  1. Configure Sentry with tracesSampleRate less than 1.0 (e.g., 0.5)
  2. Launch the app so that a Cold/Warm Start is measured by the native layer
  3. The first root span (navigation transaction) happens to be unsampled

Expected Result

App start data (Cold/Warm Start spans and measurements) is attached to the next sampled transaction.

Actual Result

App start data is permanently lost for that session. No sampled transaction ever receives it.

Root Cause

In appStartIntegration, recordFirstStartedActiveRootSpanId locks firstStartedActiveRootSpanId to the first root span that starts, regardless of whether it is sampled. Since processEvent only runs for sampled events, the span ID match check at:

if (firstStartedActiveRootSpanId !== event.contexts.trace.span_id) {
  return;
}

will always fail for every subsequent sampled transaction, because the stored ID belongs to the unsampled span that was never sent.

At lower sample rates this is statistically very likely. For example at tracesSampleRate: 0.1, there's a 90% chance the first transaction is unsampled, meaning 90% of sessions lose app start data entirely.

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions