Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
6.5 KiB
Umami Custom Events Documentation
Overview
This document lists all custom events tracked in the application using Umami Analytics. Events are tracked client-side using the window.umami.track() function.
Event Categories
🔗 Link Management Events
link-created
Fired when a user creates a new shortened link.
Properties:
short_code- The generated or custom short codehas_password- Whether the link is password protected (true/false)has_expiry- Whether the link has an expiration date (true/false)has_click_limit- Whether the link has a click limit (true/false)is_custom_code- Whether user provided a custom code (true/false)
Location: /dashboard - After successful link creation
link-edited
Fired when a user edits an existing link.
Properties:
short_code- The link's short codefields_changed- Which fields were modified
Location: Link edit modal/form
link-deleted
Fired when a user deletes a link.
Properties:
short_code- The deleted link's short code
Location: /dashboard - Delete confirmation
link-clicked
Fired when someone clicks on a shortened link from the dashboard.
Properties:
short_code- The link's short codeusername- The username in the URL path or 'direct'has_password- Whether the link requires a password (true/false)is_expiring- Whether the link has an expiration date (true/false)
Location: /dashboard - Link click tracking
link-copied
Fired when a user copies a link to clipboard.
Properties:
short_code- The copied link's short code
Location: /dashboard - Copy button clicks
link-shared
Fired when a user shares a link.
Properties:
short_code- The shared link's short codemethod- How it was shared (email, social, etc.)
Location: Share buttons/modals
📊 QR Code Events
link-qr-generated
Fired when a user generates a QR code for a link.
Properties:
short_code- The link's short code
Location: /dashboard - QR code button click
link-qr-downloaded
Fired when a user downloads a QR code.
Properties:
short_code- The link's short codeformat- Download format (png, svg, jpeg, webp)color- QR code color
Location: /dashboard - QR code download
👤 User Authentication Events
user-signup
Fired when a new user successfully registers.
Properties:
method- Registration method (email, oauth, etc.)
Location: /register - After successful registration
user-login
Fired when a user successfully logs in.
Properties:
method- Login method (email, oauth, etc.)
Location: /login - After successful authentication
user-logout
Fired when a user logs out.
Properties: None
Location: Navigation component - Logout button
user-profile-updated
Fired when a user updates their profile.
Properties:
fields_updated- Which profile fields were changed
Location: Profile/settings page
user-password-reset
Fired when a user resets their password.
Properties: None
Location: Password reset flow
📈 Analytics & Dashboard Events
dashboard-viewed
Fired when a user views their main dashboard.
Properties:
total_links- Number of links the user hastotal_clicks- Total clicks across all links
Location: /dashboard - Page load
analytics-viewed
Fired when a user views analytics for a specific link.
Properties:
short_code- The link's short codetotal_clicks- Total number of clicks
Location: /dashboard/analytics/[id] - Page load
profile-viewed
Fired when a user views their profile page.
Properties: None
Location: /profile - Page load
🔍 Search & Filter Events
search-performed
Fired when a user searches for links.
Properties:
query- Search queryresults_count- Number of results
Location: Dashboard search bar
filter-applied
Fired when a user applies filters.
Properties:
filter_type- Type of filter appliedfilter_value- Filter value
Location: Dashboard filter controls
sort-changed
Fired when a user changes sort order.
Properties:
sort_by- Sort fieldsort_order- asc or desc
Location: Dashboard sort controls
⚠️ Error Events
error-occurred
Fired when an error occurs.
Properties:
error_type- Type of errorerror_message- Error messageerror_code- Error code
Location: Throughout the application
rate-limited
Fired when a user hits a rate limit.
Properties:
action- What action was rate limitedlimit- The limit that was hit
Location: API responses
Implementation Details
Utility Functions
The application provides several helper functions for common tracking scenarios:
// Track a link click
trackLinkClick({
shortCode: 'abc123',
username: 'john',
hasPassword: false,
isExpiring: true,
});
// Track link creation
trackLinkCreated({
shortCode: 'xyz789',
hasPassword: true,
hasExpiry: false,
hasClickLimit: true,
isCustomCode: false,
});
// Track authentication
trackAuth('login', 'email');
trackAuth('signup', 'google');
trackAuth('logout');
// Track errors
trackError({
type: 'validation',
message: 'Invalid URL format',
code: 'INVALID_URL',
});
Best Practices
- Consistent Naming: All event names use lowercase with hyphens
- String Values: All property values are converted to strings (Umami requirement)
- Minimal Data: Only track essential data, avoid PII
- Error Handling: Events fail silently if Umami is not available
- Debug Mode: Events are logged to console in development
Viewing Events in Umami
- Log into your Umami dashboard
- Select your website
- Navigate to the "Events" tab
- Click on any event name to see its properties
- Use date ranges to filter event data
Adding New Events
To add a new custom event:
- Add the event name to
EVENTSconstant in/src/lib/analytics.ts - Use
trackEvent()function where the event occurs - Document the event in this file
- Test in development with console logging
Example:
// In analytics.ts
export const EVENTS = {
// ... existing events
NEW_EVENT_NAME: 'new-event-name',
};
// In your component
import { trackEvent, EVENTS } from '$lib/analytics';
trackEvent(EVENTS.NEW_EVENT_NAME, {
property1: 'value1',
property2: 'value2',
});