Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.getmilana.ai/llms.txt

Use this file to discover all available pages before exploring further.

The Milana SDK records user sessions and provides methods to initialize recording, identify users, update session metadata, track custom events, and stop recording.

Installation

npm install milana-js
Import from milana-js/react for React bindings — MilanaProvider, useMilana, useMilanaOptional.See React Setup for the full setup guide.

API surface

import { MilanaProvider, useMilana, useMilanaOptional } from "milana-js/react";

// Wrap your app to auto-initialize recording
<MilanaProvider
  productId="prd_..."
  clientKey="key_..."
  sessionInfo={{ environment: "production", version: "1.0.0" }}
>
  <App />
</MilanaProvider>

// Access SDK methods from any component
const {
  initialize,
  isInitialized,
  identify,
  updateUser,
  updateSession,
  trackEvent,
  stopRecording,
} = useMilana();
PropertyTypeDescription
initialize() => Promise<{ success: boolean }>Trigger initialization manually (for deferred init).
isInitializedbooleantrue after init has completed successfully.
identify(input: IdentifyInput) => Promise<{ success: boolean }>Associate the session with a known user (requires userId + email).
updateUser(user: UserUpdate) => Promise<{ success: boolean }>Refresh user identity (email optional).
updateSession(session: SessionUpdate) => Promise<{ success: boolean }>Update session metadata.
trackEvent(eventName: string, attributes?: TrackEventAttributes) => voidTrack a custom event.
stopRecording() => Promise<{ success: boolean }>End the current session; next init() starts a fresh one.
update(payload: UpdatePayload) => Promise<{ success: boolean }>Deprecated — prefer identify / updateUser / updateSession.

Method pages

Initialize

Start recording with your product ID, client key, and session info.

Identify

Associate sessions with known users using identify().

Update User

Refresh user identity mid-session with updateUser().

Update Session

Attach session-level context with updateSession().

Track events

Mark important user actions with named events and attributes.

Stop Recording

End the current session immediately with stopRecording().

Privacy controls

Block, mask, or ignore sensitive elements before they are recorded.

Update (deprecated)

Legacy entry point — kept for backward compatibility.