CLI

Command-line interface for Entrolytics

Entrolytics CLI

The @entro314labs/entro-cli package provides a command-line interface for managing websites, viewing analytics, and generating tracking snippets.

Installation

# Global installation
pnpm add -g @entro314labs/entro-cli

# Or use with npx
npx @entro314labs/entro-cli --help

Quick Start

Initialize Project

The fastest way to get started is with the init command:

cd your-project
npx @entro314labs/entro-cli init

This will:

  • Authenticate you (if needed)
  • Detect your framework (Next.js, React, Vue, etc.)
  • Create or find your website
  • Add credentials to .env.local
  • Optionally install the appropriate package

Verify Setup

entro verify

This checks your configuration and sends a test event.

View Analytics

entro stats <website-id> --period 7d

Legacy Setup

If you prefer manual setup:

Login

entro login

This opens your browser for OAuth authentication.

List Websites

entro sites list

View Stats

entro stats <website-id> --period 7d

Commands

Setup & Initialization

# Initialize Entrolytics in your project (recommended)
entro init

# With options
entro init --framework nextjs
entro init --domain example.com
entro init --website-id abc-123-def
entro init --skip-install

# Verify tracking is working
entro verify
entro verify --website-id abc-123

# Update configuration
entro update
entro update --website-id new-id
entro update --host https://custom.entrolytics.click

Authentication

# Login
entro login

# Logout
entro logout

# Show current user
entro whoami

# Switch organization
entro switch <org-id>

Website Management

# List websites
entro sites list

# Add website
entro sites add example.com

# Remove website
entro sites remove <website-id>

# Get website info
entro sites info <website-id>

# Verify tracking script
entro sites verify <website-id>

Analytics

# Get website stats
entro stats <website-id> --period 7d

# View realtime visitors
entro realtime <website-id>

# Top pages
entro top pages <website-id> --limit 10

# Top referrers
entro top referrers <website-id>

# Top countries
entro top countries <website-id>
# List links
entro links list

# Create short link
entro links create https://example.com/page --alias my-link

# Get link stats
entro links stats <link-id>

# Delete link
entro links delete <link-id>

Snippets

# Generate tracking snippet
entro snippet <website-id> --framework nextjs
entro snippet <website-id> --framework react
entro snippet <website-id> --framework html

Testing

# Send test event
entro test-event <website-id>

Configuration

# Show config
entro config

# Set API URL
entro config set apiUrl https://your-domain.com

# Set default website
entro config set defaultWebsite <website-id>

Options

Global Options

--help, -h      Show help
--version, -v   Show version
--json          Output as JSON
--no-color      Disable colors

Period Options

--period, -p    Time period
  today         Today only
  yesterday     Yesterday only
  7d            Last 7 days (default)
  30d           Last 30 days
  90d           Last 90 days

Examples

Quick Project Setup

# In your Next.js project
cd my-nextjs-app
entro init

# Output:
# 🚀 Entrolytics Setup
#
# ✓ Detected NEXTJS project: my-nextjs-app
# ✓ Created website: my-nextjs-app
# ✓ Updated .env.local
# ✓ Installed @entro314labs/entro-nextjs
#
# ✅ Entrolytics configured successfully!
#
# Next steps:
#
# 1. Add to app/layout.tsx:
#    import { EntrolyticsProvider } from '@entro314labs/entro-nextjs';
#    // ... usage example

Verify Tracking

entro verify

# Output:
# 🔍 Verifying Entrolytics Setup
#
# ✓ Found website: my-nextjs-app
# ✓ Test event sent successfully
# ✓ Recent activity detected: 42 pageviews, 12 visitors
#
# ✅ Configuration:
#   Website: my-nextjs-app
#   Domain:  example.com
#   ID:      abc-123-def

Update Configuration

# Switch to a different website
entro update --website-id new-website-id

# Change API host
entro update --host https://analytics.mycompany.com

View Weekly Stats

entro stats abc-123-def --period 7d

Output:

📊 Website Stats (Last 7 Days)

Total Pageviews:      12,345
Unique Visitors:       3,456
Bounce Rate:             45%
Avg. Session Duration: 2m 34s

Top Pages:
1. /               4,567 views
2. /about          1,234 views
3. /pricing          987 views
# Create link
entro links create https://example.com/landing --alias promo

# View stats
entro links stats link-abc-123

Generate Snippet

entro snippet abc-123-def --framework nextjs

Output:

// Add to your app/layout.tsx
import { EntrolyticsProvider } from '@entro314labs/entro-nextjs';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <EntrolyticsProvider
          websiteId="abc-123-def"
          host="https://cloud.entrolytics.click"
        >
          {children}
        </EntrolyticsProvider>
      </body>
    </html>
  );
}

Environment Variables

ENTROLYTICS_API_URL      # API base URL
ENTROLYTICS_API_KEY      # API key (alternative to OAuth)
ENTROLYTICS_DEFAULT_SITE # Default website ID

Configuration File

The CLI stores configuration in:

  • macOS: ~/Library/Application Support/entro-cli/
  • Linux: ~/.config/entro-cli/
  • Windows: %APPDATA%\entro-cli\

CI/CD Usage

For automated workflows, use API key authentication:

export ENTROLYTICS_API_KEY=your-api-key

entro stats abc-123-def --json | jq '.pageviews'

Features

  • One-command setup - entro init configures everything
  • Auto framework detection - Detects Next.js, React, Vue, Svelte, Astro
  • Safe environment management - Preserves existing .env variables
  • Verification tools - Test tracking without leaving terminal
  • Configuration updates - Easy credential refresh
  • ✅ OAuth authentication with secure token storage
  • ✅ Full website management
  • ✅ Real-time analytics viewing
  • ✅ Link shortener management
  • ✅ Code snippet generation
  • ✅ JSON output for scripting
  • ✅ Colored, formatted output
  • ✅ Cross-platform support

Workflows

New Project Setup

# Start a new Next.js project
npx create-next-app@latest my-app
cd my-app

# Set up Entrolytics (one command does it all!)
npx @entro314labs/entro-cli init

# Start your dev server
npm run dev

# Verify tracking is working
npx @entro314labs/entro-cli verify

Existing Project

# Navigate to your project
cd existing-project

# Initialize Entrolytics
entro init

# If you already have a website ID
entro init --website-id abc-123-def --skip-install

# Verify it's working
entro verify

Team Collaboration

# Team member clones repo
git clone https://github.com/company/project.git
cd project

# They just need to login (credentials already in .env.local)
entro login

# Verify their setup works
entro verify

# View shared analytics
entro stats

Switching Websites

# Update to use a different website
entro update --website-id production-site-id

# Verify the change
entro verify

# View analytics for the new site
entro stats

Features

  • ✅ OAuth authentication with secure token storage
  • ✅ Full website management
  • ✅ Real-time analytics viewing
  • ✅ Link shortener management
  • ✅ Code snippet generation
  • ✅ JSON output for scripting
  • ✅ Colored, formatted output
  • ✅ Cross-platform support

Support