npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

milana-js

v1.0.3

Published

Milana SDK — session recording and analytics for web applications

Downloads

1,983

Readme

Milana

Session recording and analytics SDK for web applications. Milana captures user sessions using rrweb and sends them to the Milana ingest API for replay and analysis.

Installation

npm install milana-js

React (Recommended)

Wrap your application with MilanaProvider near the root of the component tree:

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

function App() {
  return (
    <MilanaProvider
      productId="prd_YOUR_PRODUCT_ID"
      clientKey="key_YOUR_CLIENT_KEY"
      sessionInfo={{
        environment: "production",
        version: "1.2.0",
      }}
    >
      <YourApp />
    </MilanaProvider>
  );
}

Use the useMilana() hook to access the SDK from any component. Call update to identify the user — typically after login or when auth state resolves:

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

function Dashboard() {
  const { user } = useAuth(); // Clerk, Better Auth, Auth0, etc.
  const { update, trackEvent } = useMilana();

  useEffect(() => {
    if (user) {
      void update({
        user: { userId: user.id, email: user.email, name: user.name },
      });
    }
  }, [user, update]);

  return (
    <button onClick={() => trackEvent("export_clicked", { format: "csv" })}>
      Export
    </button>
  );
}

useMilana

| Property | Type | Description | |---|---|---| | update | (input: UpdateInput) => Promise<{ success: boolean }> | Update session metadata or user identity. See UpdateInput. | | trackEvent | (eventName: string, attributes?: TrackEventAttributes) => void | Track a custom event. Calls are queued until initialization completes. See TrackEventAttributes. | | isInitialized | boolean | true after init() has completed successfully |

Vanilla JS (ESM)

import { init, update, trackEvent } from "milana-js";

await init("prd_YOUR_PRODUCT_ID", "key_YOUR_CLIENT_KEY", {
  environment: "production",
  version: "1.2.0",
});

await update({
  user: { userId: "usr_12345", email: "[email protected]" },
});

trackEvent("feature_used", { featureName: "export", format: "csv" });

Script Tag / CDN

For applications that do not use a bundler:

<script>
  window._milanaQueue = window._milanaQueue || [];
  function Milana() { window._milanaQueue.push([].slice.call(arguments)); }
</script>
<script async src="https://cdn.getmilana.ai/milana.js"></script>

<script>
  Milana("init", "prd_YOUR_PRODUCT_ID", "key_YOUR_CLIENT_KEY", {
    environment: "production",
    version: "1.2.0",
  });
</script>

After the SDK loads, call the API via the queue syntax or the direct API:

Milana("update", { user: { userId: "usr_12345", email: "[email protected]" } });
Milana("trackEvent", "button_clicked", { buttonId: "signup" });

User Identity

Call update() with user information as soon as authentication resolves:

await update({
  user: {
    userId: "usr_12345",           // Required: stable unique identifier
    email: "[email protected]",     // Strongly recommended
    name: "Jane Smith",            // Optional
    metadata: {
      plan: "enterprise",          // Optional
      createdAt: "2024-01-15",     // Strongly recommended
    },
  },
});

Event Tracking

trackEvent("signup_completed");
trackEvent("item_purchased", { itemId: "sku_789", price: 29.99 });

Attribute values can be string, number, boolean, or null.

Privacy

CSS class-based privacy controls:

| Class | Effect | |---|---| | milana-block | Element and children replaced with a placeholder | | milana-mask | Text and input values replaced with asterisks | | milana-ignore | User interactions not recorded (visual appearance still captured) |

password and tel inputs are always masked. Override class names via options.privacy.

Debug Mode

Enable debug mode to log init, update, identify, and trackEvent calls to the browser console. Open the browser console and run:

Milana.setDebugMode(true)

Then reload the page. API calls will be logged as Milana [debug]: ... messages in the console. The setting persists in localStorage across page reloads.

To disable:

Milana.setDebugMode(false)

For ESM users without window.Milana, you can set it directly in the browser console:

localStorage.setItem("milana_debug_mode", "true")

Configuration Reference

init(productId, clientKey, sessionInfo, options?)

| Parameter | Type | Description | |---|---|---| | productId | string | Your Milana product ID (format: prd_...) | | clientKey | string | Your Milana client key (format: key_...) | | sessionInfo | SessionInfo | Session context — see SessionInfo | | options | PublicInitOptions | Optional SDK configuration |

PublicInitOptions

| Option | Type | Default | Description | |---|---|---|---| | endpoint | string | "https://in.getmilana.ai" | Ingest API base URL | | shouldRecordCanvas | boolean | false | Record canvas element contents | | shouldRecordCrossOriginIframes | boolean | false | Record cross-origin iframe contents | | privacy | Partial<InitPrivacyOptions> | See source | Privacy controls |

SessionInfo

| Field | Type | Description | |---|---|---| | environment | string | Deployment environment (e.g. "production", "staging") | | version | string | Application version | | metadata | Record<string, unknown> | Arbitrary key-value pairs (optional) |

UpdateInput

| Field | Type | Description | |---|---|---| | session | object | Session metadata to merge (optional) | | session.metadata | Record<string, unknown> | Arbitrary key-value pairs attached to the session | | user | object | User identity (optional) | | user.userId | string | Stable unique identifier (required when user is provided) | | user.email | string | User email (optional) | | user.name | string | Display name (optional) | | user.metadata | Record<string, unknown> | Arbitrary key-value pairs attached to the user (optional) |

TrackEventAttributes

Record<string, string | number | boolean | null>

A flat object of attribute values to attach to a custom event. Keys are strings; values can be string, number, boolean, or null.

License

MIT