Skip to main content

Events

An Event represents a single interaction or occurrence of a specific event type. It could be a scroll action, button click, user registration, error occurrence, or any other trackable activity in your application.

Data Structure

Each event contains the following data:

PropertyDescription
IDUnique identifier for the event
Event Type IDIdentifier of the event type it belongs to
App IDIdentifier of the app it belongs to
Created AtThe timestamp when the event was created
PayloadCustom data sent by the application

The Event Payload

The payload is the most powerful and flexible part of an event. It allows you to store any relevant data as a JSON object.

Payload Best Practices
  • Structure your data: Use consistent field names across similar events
  • Include context: Add relevant identifiers like user ID, session ID, page URL
  • Be specific: Include detailed information that will be useful for analysis
  • Stay consistent: Use the same data format for the same event type

Example Payloads

Here are some real-world examples of well-structured event payloads:

E-commerce Button Click

Event Type: 'add_to_cart'
{
"userId": "user_12345",
"sessionId": "sess_abcdef",
"productId": "prod_sneakers_01",
"productName": "Running Sneakers",
"price": 89.99,
"currency": "USD",
"quantity": 1,
"page": "product-detail",
"timestamp": "2023-10-24T14:30:00Z"
}

User Authentication

Event Type: 'user_login'
{
"userId": "user_67890",
"email": "user@example.com",
"loginMethod": "google_oauth",
"userAgent": "Mozilla/5.0...",
"ipAddress": "192.168.1.100",
"deviceType": "desktop",
"location": {
"country": "US",
"city": "San Francisco"
}
}

Application Error

Event Type: 'error_occurred'
{
"errorType": "validation_error",
"errorMessage": "Invalid email format",
"errorCode": "VAL_001",
"userId": "user_11111",
"page": "/signup",
"formData": {
"email": "invalid-email",
"step": "registration"
},
"stack": "Error at line 45..."
}

Creating Events via API

Events are created by sending POST requests to the SEDL API endpoint. Here's what you need:

Required Information

  • Event Logging Token: Found in your app's dashboard
  • Event Type ID: The category this event belongs to
  • Payload: Your custom JSON data

API Endpoint

POST https://api.sedl.dev/public/create_event

Request Format

Request Body
{
"loggingToken": "your-app-logging-token",
"typeId": "your-event-type-id",
"payload": {
"your": "custom",
"data": "here"
}
}
JSON Validation

The payload must be valid JSON. Invalid JSON will result in a 400 Bad Request error.

Event Analysis

Once events are logged, you can:

  • View time-series data in your app dashboard
  • Filter by date ranges to analyze specific periods
  • Export data for further analysis
  • Share insights with team members

Next Steps

Ready to start logging events? Check out: