trojan-analytics 0.1.4

Analytics module for trojan-rs with ClickHouse support
Documentation

Analytics module for trojan-rs.

This module provides detailed connection event collection and export to ClickHouse for traffic analysis, billing, and auditing.

Feature Gating

This crate should be used with the analytics feature in trojan-server:

[features]
analytics = ["trojan-analytics"]

Example

use trojan_analytics::{EventCollector, init};
use trojan_config::AnalyticsConfig;

// Initialize analytics
let collector = init(config).await?;

// Record connection events
let event = collector.connection(conn_id, peer)
    .user("user123")
    .target("example.com", 443, TargetType::Domain)
    .protocol(Protocol::Tcp);

// Event is automatically sent on drop