sjursen-digital-watchtower
v1.0.2
Published
A TypeScript Node.js SDK for Watchtower, an Intelligence as a Service (IaaS) platform that uses Google's Gemini AI model to transform traditional logging into an active intelligence system with predictive analytics and automated decision-making capabiliti
Maintainers
Readme
Watchtower Node.js SDK
A TypeScript Node.js SDK for interacting with Watchtower, an Intelligence as a Service (IaaS) platform that transforms traditional logging into an active intelligence system. Watchtower leverages Google's Gemini AI model to provide intelligent insights, predictive analytics, and automated decision-making capabilities.
Features
AI-Powered Intelligence
- Real-time log analysis using Google's Gemini AI model
- Pattern detection and anomaly identification
- Predictive analytics and trend forecasting
- Automated decision-making based on log data
Comprehensive Logging
- Structured log collection and storage
- Multi-tenant support
- Flexible log querying and filtering
- Context-aware logging with metadata support
Advanced Analytics
- Real-time metrics and monitoring
- Historical data analysis
- Custom metric aggregation
- Performance trend analysis
Intelligent Decision Making
- AI-driven recommendations
- Automated response suggestions
- Risk assessment and prioritization
- Actionable insights generation
Developer Experience
- Full TypeScript support with comprehensive type definitions
- Built-in error handling with custom error types
- Simple and intuitive API
- Complete coverage of Watchtower API endpoints
Installation
npm install sjursen-digital-watchtowerQuick Start
import { WatchtowerSDK } from 'sjursen-digital-watchtower';
// Initialize the SDK with your API base URL
const sdk = new WatchtowerSDK('YOUR_API_BASE_URL');
// Create a new log entry
await sdk.logs.createLog({
organization_apikey: 'YOUR_ORG_API_KEY',
app_apikey: 'YOUR_APP_API_KEY',
item_id: 'item123',
timestamp: new Date().toISOString(),
level: 'info',
message: 'User logged in',
context: { userId: 'user456' }
});
// Get AI-powered analysis for an item
const analysis = await sdk.analyze.getLatest({
organization_apikey: 'YOUR_ORG_API_KEY',
app_apikey: 'YOUR_APP_API_KEY',
item_id: 'item123'
});
// Get AI predictions for potential issues
const prediction = await sdk.intelligence.predict({
organization_apikey: 'YOUR_ORG_API_KEY',
app_apikey: 'YOUR_APP_API_KEY',
item_id: 'item123',
prediction_type: 'anomaly',
timeframe: '24h'
});
// Get AI-driven decision recommendations
const decision = await sdk.intelligence.decide({
organization_apikey: 'YOUR_ORG_API_KEY',
app_apikey: 'YOUR_APP_API_KEY',
log_data: {
metrics: [{ name: 'cpu_usage', value: 90 }],
context: 'high_load',
item_name: 'server1'
},
allowed_actions: { restart: 'Restart the server' }
});Documentation
For detailed documentation, please visit our documentation page.
Error Handling
The SDK provides custom error types for better error handling:
import { InvalidRequestError, AuthenticationError, ServerError } from 'sjursen-digital-watchtower/errors';
try {
// SDK call
} catch (error) {
if (error instanceof InvalidRequestError) {
console.error('Invalid Request:', error.message);
} else if (error instanceof AuthenticationError) {
console.error('Authentication Failed:', error.message);
} else if (error instanceof ServerError) {
console.error('Server Error:', error.message);
}
}Development
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Run linter
npm run lintLicense
MIT © Sjursen Digital
