Analytics

The SDK emits analytics events throughout the eligibility flow.

React

Implement AnalyticsHandler and pass it to BridgeSdkProvider:

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 },
8 onError(error: Error) {
9 // Handle fatal errors
10 },
11}
12
13<BridgeSdkProvider
14 config={{
15 publishableKey: "pk_...",
16 analyticsHandler: myAnalyticsHandler,
17 }}
18>

TypeScript

Implement AnalyticsHandler and pass it to createBridgeClient:

1import { createBridgeClient } from "@usebridge/sdk";
2import type {
3 AnalyticsHandler,
4 AnalyticsEvent,
5 AnalyticsEventName,
6} from "@usebridge/sdk-core";
7
8const myAnalyticsHandler: AnalyticsHandler = {
9 onEvent<T extends AnalyticsEventName>(event: T, data: AnalyticsEvent<T>) {
10 // Send to your analytics service
11 },
12 onError(error: Error) {
13 // Handle fatal errors
14 },
15};
16
17const bridge = createBridgeClient({
18 publishableKey: "pk_...",
19 analyticsHandler: myAnalyticsHandler,
20});

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
hard_eligibility.session.policy
hard_eligibility.session.complete.out_of_network
hard_eligibility.session.optimistic_soft_check.error

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

Error Handling

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