React (coming soon)
Provider

Provider

⚠️

Not available yet. TracePath does not publish a React package, so nothing on this page can be imported or run today. It documents the planned component. See OpenTelemetry for the integration path that works now.

The provider is the single setup point for a React app: it initializes the SDK, supplies context to the hooks below it, and acts as an error boundary for the tree it wraps.

Props

PropTypeRequiredDescription
connectionStringstringYesProject token and ingest endpoint
optionsobjectNoSDK configuration, see below
childrenReactNodeYesThe tree to wrap

Options

OptionTypeDefaultDescription
debugbooleanfalseLog SDK problems to the console: failed uploads, a beforeCapture that threw, and errors dropped by ignoreErrors / beforeCapture. Captured events themselves are not logged
debounceMsnumber1500Batch delay in milliseconds
retryDelayMsnumber10000Retry delay for failed uploads
versionstringundefinedYour application version
ignoreErrorsArray<string | RegExp>built-in defaultsError patterns to suppress. An empty array captures everything. See Error Filtering
beforeCapture(exception) => booleanundefinedReturn false to suppress an error
sessionRecordingbooleantrueEnable the rrweb session recorder
sessionRecordingSegmentDurationnumber30000Segment length in ms
recordAllSessionsbooleanfalseAlways-on session recording. See Sessions
captureLogsbooleantrueMirror console.* calls into the rolling log buffer
captureNetworkbooleantrueRecord fetch / XHR calls as network actions
captureNavigationbooleantrueRecord History API push / replace / pop transitions
eventsWindowMsnumber10000 (30000 with recordAllSessions)Rolling log/action buffer window
eventsMaxCountnumber200 (600 with recordAllSessions)Hard cap on log/action buffer entries
captureHttpServerErrorsbooleanfalseReport every fetch response with status >= 500 as a synthetic exception. 4xx is never included, and it is wired into the fetch wrapper only, so XMLHttpRequest (including browser Axios) does not trigger it

Placement

The provider goes as high in the tree as you can put it — the root App component or the entry file — because it only captures render errors thrown below itself, and because the SDK should be initialized before any other code has a chance to throw.

Each environment should use its own TracePath project and therefore its own connection string, selected from an environment variable at build time.

A note on StrictMode

The provider initializes the SDK in its constructor, and React's StrictMode double-invokes constructors in development. Two clients get created, so every uncaught error is reported twice and two batches are uploaded. Production builds do not double-invoke, so live counts are correct. If the doubled counts get in the way while you develop, mount the provider outside <StrictMode> rather than inside it.

Custom attributes

App-level identifiers — userId, tenant, feature flags — will be bindable two ways:

  • Declaratively, as a component or a hook taking a map of attributes. Each render diffs against the previous map and pushes only the deltas; on unmount, every key it owns is removed. null and undefined are accepted as "empty map", which is the useful state while user data is loading or after logout.
  • Imperatively, as plain functions for code outside a component tree: background workers, auth listeners, init scripts.

Treat a key as owned by whichever mechanism set it. Setting the same key from both means the declarative cleanup on unmount removes a value the imperative side still expects.

Layering on each event is defaults < global scope < per-call. See Sessions for the full attribute model.

Context access

The context the provider supplies is exported directly for class components and other advanced cases, but the hook is the intended interface.