Skip to main content
Userpilot SDK provides three types of callbacks to help you handle navigation, analytics, and experience lifecycle events within your app Navigation Listener is called when a deep link is triggered from an experience or notification. It holds the custom deep link URL to be handled by the client app. Parameters:
url: string

Analytics Listener

Analytics Listener is called when an event is triggered by the client app. Parameters:
analytic: string
value: string
properties: Map<string, any>

Analytics Listener

Called when an analytics event is triggered by the Userpilot SDK. Use this to mirror or log SDK-level events into your analytics system. Parameters:
analytic: "Identify" | "Screen" | "Event"

value: StringEvent value, if any.

properties: Map<String, Any>Additional metadata for the event.

Experience Listener

Called when an experience or its step changes state. Includes two callback types: onExperienceStateChanged Triggered when the overall state of an experience changes.
experienceId?: IntUnique ID of the experience (optional)

experienceType: "Flow" | "Survey" | "NPS"

experienceState: "Started" | "Completed" | "Dismissed" | "Skipped" | "Submitted"
onExperienceStepStateChanged Triggered when the state of a specific step within an experience changes.
stepId: IntUnique identifier of the step

experienceId: IntID of the parent experience

experienceType: "Flow" | "Survey" | "NPS"

stepState: "Started" | "Completed" | "Dismissed" | "Skipped" | "Submitted"

step?: IntStep index (optional)

totalSteps?: IntTotal number of steps in the experience (optional)
Note: Both callbacks are sent under the same event name: UserpilotExperienceEvent
useEffect(() => {
  const eventEmitter = new NativeEventEmitter(
    NativeModules.UserpilotReactNative
  )
  const listeners = [
    eventEmitter.addListener('UserpilotAnalyticsEvent', (event) =>
      console.log('Analytics Event:', JSON.stringify(event, null, 2))
    ),
    eventEmitter.addListener('UserpilotExperienceEvent', (event) =>
      console.log('Experience Event:', JSON.stringify(event, null, 2))
    ),
    eventEmitter.addListener('UserpilotNavigationEvent', (event) => {
      console.log('Navigation Event', JSON.stringify(event, null, 2))
      if (event?.url) handleDeepLink(event.url)
    }),
  ]
  return () => listeners.forEach((listener) => listener.remove())
}, [])