Static web publishing CLI tool for deploying web applications to a CDN with a single command
—
Analytics and monitoring capabilities for tracking traffic, performance, and usage metrics of deployed projects on the Surge platform.
View comprehensive analytics data for deployed projects including traffic, performance, and user behavior metrics.
/**
* View comprehensive analytics for project
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function analytics(hooks?: HookConfig): CommandFunction;CLI Usage:
# View comprehensive analytics for domain
surge analytics example.surge.sh
# Interactive domain selection
surge analyticsAnalytics Data Includes:
Library Usage:
surge.analytics({})(process.argv.slice(2));View detailed traffic analytics for deployed projects.
/**
* View traffic analytics for project
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function traffic(hooks?: HookConfig): CommandFunction;CLI Usage:
# View traffic for domain
surge traffic example.surge.sh
# Interactive domain selection
surge trafficTraffic Metrics:
Library Usage:
surge.traffic({})(process.argv.slice(2));Monitor global network load and performance metrics.
/**
* View global network load analytics
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function load(hooks?: HookConfig): CommandFunction;CLI Usage:
# View global load metrics
surge loadLoad Metrics:
Library Usage:
surge.load({})(process.argv.slice(2));Analyze visitor demographics and device information.
/**
* View audience device and demographic analytics
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function audience(hooks?: HookConfig): CommandFunction;CLI Usage:
# View audience analytics for domain
surge audience example.surge.sh
# Interactive domain selection
surge audienceAudience Metrics:
Library Usage:
surge.audience({})(process.argv.slice(2));Monitor bandwidth usage and resource consumption.
/**
* View bandwidth usage and resource analytics
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function usage(hooks?: HookConfig): CommandFunction;CLI Usage:
# View usage analytics for domain
surge usage example.surge.sh
# Interactive domain selection
surge usageUsage Metrics:
Library Usage:
surge.usage({})(process.argv.slice(2));Audit edge node state and system health.
/**
* Audit edge node state and system health
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function audit(hooks?: HookConfig): CommandFunction;CLI Usage:
# Audit system for domain
surge audit example.surge.sh
# Global system audit
surge auditAudit Information:
Library Usage:
surge.audit({})(process.argv.slice(2));Bust cache across all edge nodes to force content refresh.
/**
* Bust cache on all edge nodes for immediate content refresh
* @param hooks - Optional lifecycle hooks
* @returns Command function
*/
function bust(hooks?: HookConfig): CommandFunction;CLI Usage:
# Bust cache for domain
surge bust example.surge.sh
# Interactive domain selection
surge bustCache Busting:
Library Usage:
surge.bust({})(process.argv.slice(2));Analytics commands display data using ASCII charts and formatted tables:
Traffic Analytics - example.surge.sh
=====================================
Page Views (Last 30 Days)
1000 | *
800 | * * *
600 | * * * *
400 |* *
200 | *
0 +-------------
1 5 10 15 20 25 30
Bandwidth Usage: 2.4 GB
Unique Visitors: 1,247
Top Countries:
1. United States 45%
2. United Kingdom 22%
3. Canada 15%Export analytics data for external analysis:
# Export traffic data to JSON
surge traffic example.surge.sh --format json > traffic.json
# Export usage data to CSV
surge usage example.surge.sh --format csv > usage.csvMonitor key performance indicators:
Track performance trends over time:
Set up monitoring alerts:
# Configure performance alerts
surge config example.surge.sh --alerts enabled
# Set thresholds
surge config example.surge.sh --alert-threshold response-time 500ms
surge config example.surge.sh --alert-threshold error-rate 5%Integrate Surge analytics with Google Analytics:
<!-- Add to your HTML -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID');
</script>Implement custom analytics tracking:
// Custom event tracking
function trackEvent(event, data) {
fetch('/analytics', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ event, data, timestamp: Date.now() })
});
}
// Page view tracking
trackEvent('page_view', {
page: window.location.pathname,
referrer: document.referrer
});Access analytics data programmatically:
// Fetch analytics via Surge API
const analytics = await fetch('https://surge.surge.sh/api/analytics', {
headers: { 'Authorization': `Bearer ${surgeToken}` }
});Surge analytics respect user privacy:
Analytics data retention policies:
Common Causes:
Resolution:
# Force cache refresh
surge bust example.surge.sh
# Verify DNS configuration
surge dns example.surge.sh
# Check system status
surge audit example.surge.shCommon Issues:
Filtering Options:
# Filter bot traffic
surge traffic example.surge.sh --filter-bots
# Exclude specific IPs
surge traffic example.surge.sh --exclude-ips 192.168.1.0/24Diagnostic Commands:
# Check edge node performance
surge load --region us-east-1
# Audit specific domain
surge audit example.surge.sh --verbose
# Test from multiple locations
surge traffic example.surge.sh --geo-breakdownInstall with Tessl CLI
npx tessl i tessl/npm-surge