Events
The core data model. What events are and how they work.
An event is a structured record of something that happened in your application.
Structure
Every event has:
- type (required): A string like
purchase,page.view,discord.command - timestamp (required): When it happened (set automatically)
- userId (optional): Who triggered it
- data (optional): Any structured data
- context (optional): Device, browser, location (set automatically)
- tags (optional): Arbitrary metadata
Event types
Event types are strings. Use a naming convention that makes sense for your app:
purchaseuser.signuppage.viewdiscord.commanderrorjob.completed
Data
The data field is a JSON object. Attach any structured information:
typescript: await vanta.track({
await vanta.track({
event: 'purchase',
data: {
product: 'Premium',
price: 19.99,
currency: 'USD'
}
})Context
Context is captured automatically by the SDK. It includes browser, OS, device type, screen size, country, city, and more. You don't need to add it manually.