Skip to main content

Documentation Index

Fetch the complete documentation index at: https://revlytics.co/docs/llms.txt

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

Identify users

Call revlytics.identify() after a user signs in:
revlytics.identify("user_123", {
  name: "Jane Doe",
  email: "jane@example.com",
  plan: "pro",
});

Parameters

ParameterTypeDescription
userIdstringYour application’s unique user identifier
traitsobjectOptional user properties (name, email, plan, etc.)

Update traits

Update user traits without re-identifying:
revlytics.setTraits({ plan: "enterprise", company: "Acme" });

Get current user

const userId = revlytics.getUserId();

Clear user

Call on sign-out to stop associating events with the user:
revlytics.clearUserId();

Persistence

The user ID is stored in localStorage under the key _rvl_uid. It persists across page reloads and browser sessions until explicitly cleared.

Example: Next.js auth flow

"use client";
import { useEffect } from "react";

export function AuthProvider({ user, children }) {
  useEffect(() => {
    if (user) {
      window.revlytics?.identify(user.id, {
        email: user.email,
        name: user.name,
      });
    } else {
      window.revlytics?.clearUserId();
    }
  }, [user]);

  return <>{children}</>;
}