Appearance
Click Tracking
Each redirect logs a click record. Sosyabot uses these for Short Link Stats and the campaign-rollup widgets in the dashboard.
Per click
typescript
{
short_link_id: ObjectId,
ts: Date,
country: string | null, // IP-derived
referrer: string | null,
device: "mobile" | "tablet" | "desktop" | "bot" | "unknown",
user_agent_hash: string,
}Country is derived from the requester's IP at redirect time. Raw IPs are not retained; the user_agent_hash is a salted hash so distinct UAs can be counted without storing the literal string.
Counters on the link
click_count is incremented atomically per redirect; last_clicked_at is updated to the redirect timestamp. These are denormalised for fast reads on the list view.
Per-link stats
GET /api/v1/short-links/:slug/stats returns the aggregated time series for one link — clicks per day plus the country / referrer / device breakdowns.