> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.usebridge.com/documentation/getting-started/eligibility-sdk/analytics/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.usebridge.com/_mcp/server. The SDK emits analytics events throughout the eligibility flow. ## React Implement `AnalyticsHandler` and pass it to `BridgeSdkProvider`: ```typescript import { BridgeSdkProvider } from "@usebridge/sdk-react" import type { AnalyticsHandler, AnalyticsEvent, AnalyticsEventName } from "@usebridge/sdk-react" const myAnalyticsHandler: AnalyticsHandler = { onEvent(event: T, data: AnalyticsEvent) { // Send to your analytics service }, onError(error: Error) { // Handle fatal errors }, } ``` ## TypeScript Implement `AnalyticsHandler` and pass it to `createBridgeClient`: ```typescript import { createBridgeClient } from "@usebridge/sdk"; import type { AnalyticsHandler, AnalyticsEvent, AnalyticsEventName, } from "@usebridge/sdk-core"; const myAnalyticsHandler: AnalyticsHandler = { onEvent(event: T, data: AnalyticsEvent) { // Send to your analytics service }, onError(error: Error) { // Handle fatal errors }, }; const bridge = createBridgeClient({ publishableKey: "pk_...", analyticsHandler: myAnalyticsHandler, }); ``` ## 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.