Tracking recipes

Copy a hook into your app to track a common interaction with one line in each component.

hooks/use-feature-tracking.ts
import { track } from "@databuddy/sdk";

export function useFeatureTracking(feature: string) {
  return (action: string, properties?: Record<string, unknown>) =>
    track("feature_used", { feature, action, ...properties });
}

Pick a recipe

Name events the same way everywhere

DoAvoid
snake_case names such as form_submittedformSubmitted, Form-Submitted
One event per outcome, with properties for detailA new event name per button
IDs, counts and states as propertiesEmails, addresses and message text
Track an outcome once, in the browser or on the serverThe same signup from both

track() never throws and does nothing on the server, so it needs no try around it. In development, the provider's disabled prop stops every call.

How is this guide?