Revenue Guardian
Connect the SDK in minutes and start seeing telemetry flow.
This is a quickstart guide, not a landing page. Follow the steps below in order, copy the code you need, and check the dashboard once the first event lands.
Install
Add the package to your app.
Initialize
Set your API key and host.
Track
Send the first meaningful event.
Verify
Confirm the dashboard is receiving data.
What you need
- • Your Revenue Guardian API key
- • One event from your app to validate the setup
Install the SDK
Add the package to the app you want to instrument.
Code
npm install @revenueguardian/sdkIf you are integrating from a monorepo, install it in the app workspace that will emit telemetry.
Initialize the client
Create the SDK once with your API key and backend host. Keep this near app startup.
Code
import { RevenueGuardian } from "@revenueguardian/sdk";
RevenueGuardian.init({
apiKey: "pk_live_abc123...",
apiHost: "https://revenueguardian.vercel.app",
enableAutoTracking: true,
enableExitIntent: true,
enableDeAnonymization: true
});Identify Users & Sync Plans
Crucial for churn prediction! Tell the SDK who the user is, what plan they are on, and their MRR.
Code
RevenueGuardian.identify({
id: "user_123",
email: "founder@startup.com",
name: "John Doe",
plan: "Pro",
mrr: 49.99
});Call this immediately after a user logs in.
Track Custom Events & Features
Log when users perform important actions or use specific features.
Code
// Track a generic event
RevenueGuardian.track("user_signup", { source: "organic" });
// Track specific feature usage (great for identifying engagement cliffs)
RevenueGuardian.feature("export_csv", { rowCount: 500 });When to use: Use .track() for standard business events (e.g. 'invite_sent') and .feature() when they interact with a core product feature. The AI looks for sudden drops in .feature() calls to predict if they are about to churn.
Update Revenue & Billing
If a user upgrades or downgrades, update their MRR directly without re-identifying them.
Code
RevenueGuardian.revenue({
plan: "Growth",
mrr: 99.99,
interval: "monthly"
});When to use: Call this whenever a customer changes their subscription plan mid-session. It instantly updates their MRR inside the Revenue Guardian dashboard without requiring a full page reload or a new .identify() call.
Smart Webhook Sync (syncAccount)
Have a messy payload from Stripe or Paddle? Pass it to syncAccount and the SDK will auto-detect the plan and MRR.
Code
// No need to manually map properties—just pass the raw JSON!
RevenueGuardian.syncAccount(stripeWebhookPayload);How it works: We do not integrate with Stripe's servers. Instead, when YOUR server receives a messy webhook from Stripe or Paddle, simply pass that raw JSON to this function. The SDK acts as a smart parser—it loops through the JSON looking for keys like 'plan', 'tier', or 'MRR' and automatically updates the user's billing data for you.
Debugging
Having trouble? Turn on debug mode to see exactly what the SDK is doing in the console.
Code
RevenueGuardian.debug(true);Deploying to production
When the local flow works, move the same integration to your deployed environment and set the required env vars.
Add NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY, and SUPABASE_SERVICE_ROLE_KEY in Vercel.
Push your code, deploy, then open the dashboard to confirm telemetry is arriving.
Production init example
RevenueGuardian.init({
apiKey: "pk_live_abc123...",
apiHost: "https://revenueguardian.vercel.app",
environment: "production",
});