init-consoleiq
v1.0.3
Published
CLI to initialize ConsoleIQ logging in a React app
Maintainers
Readme
ConsoleIQ Setup CLI
🧠 Intelligent Logging for Developers - Streamline your JavaScript/TypeScript project setup with ConsoleIQ's powerful logging and monitoring capabilities.
🚀 Quick Start
Get up and running with ConsoleIQ in your project with just one command:
npx init-consoleiqThis interactive setup will guide you through configuring ConsoleIQ for your project, handling authentication, and automatically integrating the SDK into your codebase.
📋 Table of Contents
- Features
- Installation
- Usage
- Command Line Options
- Examples
- Authentication
- Project Integration
- Configuration
- Troubleshooting
- Links
✨ Features
- 🎯 One-Command Setup - Initialize ConsoleIQ in any JavaScript/TypeScript project
- 🔐 Integrated Authentication - Built-in account creation and login flows
- 🔍 Smart Detection - Automatically detects project structure and entry files
- ⚙️ Flexible Configuration - Customize log levels, environment, and app settings
- 📦 Auto-Installation - Installs required dependencies automatically
- 🎨 Interactive & Silent Modes - Choose between guided setup or automated configuration
- 🌐 Multi-Environment - Supports both browser and Node.js environments
- 📝 TypeScript Ready - Automatic TypeScript detection and configuration
💻 Installation
No installation required! Run directly with npx:
npx init-consoleiqOr install globally for repeated use:
npm install -g init-consoleiq
init-consoleiq🎮 Usage
Interactive Mode (Recommended)
Run the setup wizard that guides you through the entire process:
npx init-consoleiqThe interactive mode will:
- Check if you have an existing API key or need to create an account
- Handle authentication (login/registration with OTP verification)
- Configure your app settings (name, log levels, environment)
- Auto-detect your project structure
- Install dependencies and integrate ConsoleIQ
Silent Mode
For automated setups or CI/CD pipelines:
npx init-consoleiq --apiKey your_api_key --appName "MyApp" --silent🛠 Command Line Options
| Option | Short | Description | Default |
|--------|-------|-------------|---------|
| --apiKey | -k | Your ConsoleIQ API key | - |
| --appName | -n | Application name for logs | Interactive prompt |
| --levels | -l | Comma-separated log levels | log,error,warn,info |
| --environment | -e | Target environment (browser/node) | browser |
| --email | - | Email for account creation/login | - |
| --password | - | Password for account creation/login | - |
| --register | - | Force account registration flow | - |
| --login | - | Force login flow | - |
| --silent | -s | Run without prompts, use defaults | false |
| --help | -h | Show help message | - |
Log Levels
Customize which console methods are captured:
log- Standard console.log outputerror- Error messages and stack traceswarn- Warning messagesinfo- Informational messagesdebug- Debug-level loggingtrace- Detailed trace information
📚 Examples
Basic Setup with API Key
npx init-consoleiq --apiKey abc123xyz --appName "My Awesome App"Full Configuration
npx init-consoleiq \
--apiKey abc123xyz \
--appName "ProductionApp" \
--levels "error,warn,info" \
--environment node \
--silentAccount Registration
npx init-consoleiq \
--email [email protected] \
--password mySecurePassword123 \
--appName "MyApp" \
--registerAccount Login
npx init-consoleiq \
--email [email protected] \
--password mySecurePassword123 \
--loginNode.js Environment Setup
npx init-consoleiq \
--apiKey abc123xyz \
--appName "BackendAPI" \
--environment node \
--levels "error,warn,info"🔐 Authentication
ConsoleIQ Setup CLI supports multiple authentication methods:
1. Existing API Key
If you already have an API key from the ConsoleIQ dashboard:
npx init-consoleiq --apiKey your_existing_key2. Account Login
Log in with existing ConsoleIQ credentials:
npx init-consoleiq --email [email protected] --password yourpassword --login3. New Account Registration
Create a new account with OTP verification:
npx init-consoleiq --email [email protected] --password yourpassword --registerNote: Registration requires email verification via OTP (One-Time Password) sent to your email address.
🏗 Project Integration
The CLI automatically handles project integration:
File Detection
Automatically detects and integrates with common entry files:
main.tsx/ts/jsx/jsindex.tsx/ts/jsx/jsapp.ts/jsserver.js/tsapi.js
Module System Detection
- ES Modules: Uses
importstatements - CommonJS: Uses
require()statements - TypeScript: Creates
.tsfiles whentsconfig.jsonis detected
Generated Files
The CLI creates a consoleiq.js or consoleiq.ts file in your project:
// Example generated file (consoleiq.js)
import { createConsoleIQ } from 'consoleiq';
createConsoleIQ({
apiKey: 'your_api_key',
name: 'MyApp',
allowedLevels: ['log', 'error', 'warn', 'info'],
environment: 'browser'
});⚙️ Configuration
Environment Types
Browser Environment (--environment browser)
- Captures frontend console output
- Tracks client-side errors and logs
- Ideal for React, Vue, Angular, vanilla JS apps
Node.js Environment (--environment node)
- Captures server-side console output
- Monitors backend application logs
- Perfect for Express, Fastify, NestJS, and other Node.js frameworks
Directory Structure
The CLI intelligently places files based on your project structure:
your-project/
├── src/ # If src/ exists, files go here
│ ├── consoleiq.ts # Generated config file
│ └── main.ts # Auto-injected import
├── package.json
└── tsconfig.json # Triggers TypeScript mode🔧 Manual Integration
If automatic integration fails, you can manually add ConsoleIQ to your project:
ES Modules (TypeScript/Modern JS)
import './consoleiq.js'; // Add to your entry fileCommonJS (Node.js)
require('./consoleiq.js'); // Add to your entry file🐛 Troubleshooting
Common Issues
🔴 "API Key Invalid"
- Verify your API key is correct
- Check if your account is properly verified
- Try logging in again with
--loginflag
🔴 "Entry File Not Found"
- Manually specify entry file when prompted
- Add the import statement manually to your main file
🔴 "Installation Failed"
- Run
npm install consoleiq axios prompt-sync --savemanually - Check your npm configuration and permissions
🔴 "OTP Not Received"
- Check your spam/junk folder
- Ensure email address is correct
- Wait a few minutes and try again
Getting Help
If you encounter issues:
- Run with
--helpto see all available options - Check the ConsoleIQ documentation
- Contact support through the ConsoleIQ dashboard
📖 What Happens After Setup?
Once setup is complete:
- 🔄 Restart your development server - This ensures ConsoleIQ is loaded
- 📊 Check your dashboard - Visit consoleiq.io to see incoming logs
- 🧪 Test logging - Add some
console.log()statements to verify capture - ⚡ Start monitoring - ConsoleIQ will now capture and analyze your application logs
🔗 Links
- 🌐 ConsoleIQ Website: https://consoleiq.io
- 📚 Documentation: https://consoleiq.io/docs
- 📊 Dashboard: https://consoleiq.io
📝 Advanced Usage
Custom Entry File Integration
If you have a non-standard project structure:
npx init-consoleiq --apiKey abc123 --appName MyApp
# When prompted for entry file, provide your custom path
# Example: ./app/bootstrap.jsCI/CD Integration
For automated deployments:
npx init-consoleiq \
--apiKey $CONSOLEIQ_API_KEY \
--appName $APP_NAME \
--environment $NODE_ENV \
--silentMultiple Environment Setup
Set up different configurations for different environments:
# Development
npx init-consoleiq --apiKey dev_key --appName "MyApp-Dev" --levels "log,error,warn,info,debug"
# Production
npx init-consoleiq --apiKey prod_key --appName "MyApp-Prod" --levels "error,warn"🤝 Contributing
This is a setup utility for the ConsoleIQ logging service. For feature requests or bug reports related to the ConsoleIQ platform itself, please visit the main ConsoleIQ website.
Ready to supercharge your logging? Get started with npx init-consoleiq today! 🚀
