Analytics

The Bridge React SDK emits analytics events throughout the eligibility flow, allowing you to track user interactions and monitor the performance of your integration.

Implementation

To receive analytics events, implement the AnalyticsHandler interface and pass it to the BridgeSdkProvider config:

1import { BridgeSdkProvider } from "@usebridge/sdk-react"
2import type { AnalyticsHandler, AnalyticsEvent, AnalyticsEventName } from "@usebridge/sdk-react"
3
4const myAnalyticsHandler: AnalyticsHandler = {
5 onEvent<T extends AnalyticsEventName>(event: T, data: AnalyticsEvent<T>) {
6 // Send to your analytics service
7 console.log(event, data)
8 },
9 onError(error: Error) {
10 // Handle fatal errors
11 console.error(error)
12 },
13}
14
15export const BridgeLayoutProvider = ({ children }) => {
16 return (
17 <BridgeSdkProvider
18 config={{
19 publishableKey: "pk_...",
20 analyticsHandler: myAnalyticsHandler,
21 }}
22 >
23 {children}
24 </BridgeSdkProvider>
25 )
26}

Event Types

The SDK emits events at key points in the eligibility flow, to the onEvent callback.

SDK Events

Event Name
sdk.initialized
sdk.error

Input Events

Event Name
input.payer.search
input.state.updated

Soft Eligibility Events

Event Name
soft_eligibility.session.created
soft_eligibility.session.submit
soft_eligibility.session.updated
soft_eligibility.session.complete.eligible
soft_eligibility.session.complete.ineligible

Hard Eligibility Events

Event Name
hard_eligibility.session.created
hard_eligibility.session.submit
hard_eligibility.session.updated
hard_eligibility.session.complete.eligible
hard_eligibility.session.complete.ineligible

Each event includes relevant context data, such as session identifiers, input values, status information, and error details. For specific payload definitions of each event, explore the types exported from the package.

Error Handling

The onError callback is invoked when errors are throw from within the SDK.