Integrate sniffurl

Track events, identify visitors, and attribute deep links. Use the React Native SDK for mobile, or call the REST API from any other stack.

@kalporg/sniffurl

Installation

Install the SDK and its peer dependency.

terminal
npm install @kalporg/sniffurl @react-native-async-storage/async-storage

On iOS, install the pods:

terminal
cd ios && pod install && cd ..

Quick start

Initialize once on app start. Presence tracking begins automatically.

App.tsx
import { SniffURL } from "@kalporg/sniffurl";

await SniffURL.init({
  projectKey: "your_project_key",
  apiKey: "sk_live_your_api_key",
});

await SniffURL.trackEvent("app_open");

Configuration

Use configure for auto-tracking and debug logs.

config.ts
SniffURL.configure({
  projectKey: "your_project_key",
  apiKey: "sk_live_your_api_key",
  enableAutoTracking: true,
  debug: __DEV__,
});

Tracking events

Track any event with optional properties.

checkout.ts
SniffURL.trackEvent("signup", { plan: "basic" });
SniffURL.trackEvent("purchase", { amount: 1499, currency: "INR" });
SniffURL.trackScreen("Product Details", { product_id: "123" });

User identification

Call after login. Details ride on every later event.

auth.ts
await SniffURL.identify({
  userId: "user123",
  email: "user@example.com",
  name: "John Doe",
});

Real-time presence

A 30s heartbeat powers the live-users widget. Pause it while backgrounded.

App.tsx
AppState.addEventListener("change", (s) => {
  if (s === "active") SniffURL.startPresenceTracking();
  else SniffURL.stopPresenceTracking();
});

Deep links carry sn_vid for attribution, handled automatically.

links.ts
// yourapp://promo?sn_vid=visitor_hash_123
SniffURL.handleUrl("yourapp://promo?sn_vid=abc123");

Reference

SniffURL.init(options)

Initialize. Requires projectKey and apiKey.

SniffURL.configure(options)

Adds enableAutoTracking and debug.

SniffURL.trackEvent(event, data?)

Track a named event.

SniffURL.trackScreen(name, data?)

Track a screen view.

SniffURL.identify(userData)

Identify a user.

SniffURL.startPresenceTracking()

Resume presence heartbeat.

SniffURL.stopPresenceTracking()

Pause presence heartbeat.

SniffURL.handleUrl(url)

Process a deep link's sn_vid.