0.0.5-Alpha • Published 5 months ago
datavault-analytics v0.0.5-Alpha
DataVault Analytics 🔍
(WORK IN PROGRESS - UNSTABLE)
Privacy-focused analytics solution with server-side logging and client-side tracking capabilities.
Features
- 🛡️ Privacy-first approach with cookie consent tracking
- 📊 Pageview and event tracking
- ⚡ Real-time performance metrics
- 📈 PostgreSQL-based storage
- 🔒 Secure middleware with rate limiting and helmet
- 📝 Comprehensive logging with Winston
- 🩺 Health check endpoints
Installation
npm install datavault-analytics
# or
yarn add datavault-analytics
Configuration
Set these environment variables in your .env
file:
DATABASE_URL=postgres://user:password@host:port/database
NODE_ENV=production
LOG_DIR=/var/log/dataforge
SERVICE_NAME=my-web-app
Usage
Server-side Setup
const express = require('express');
const DataForge = require('dataforge-analytics');
const app = express();
// Initialize DataForge analytics
DataForge(app);
app.listen(3000, () => {
console.log('Server running on port 3000');
});
Client-side Integration
Add this script to your HTML:
<script src="/dataforge/analytics/static/v1/dataforge-client.js"></script>
Event Tracking
Track events using HTML data attributes:
<button data-track-event
data-event-name="download"
data-event-category="engagement">
Download Now
</button>
Or track events programmatically:
window.trackEvent('purchase', 'ecommerce', {
product_id: '123',
value: 49.99
});
API Endpoints
Endpoint | Description |
---|---|
/dataforge/health | System health status |
/dataforge/analytics/api/v1 | Analytics data ingestion endpoint |
Logging
Logs are stored in daily rotated files:
logs/
error-2023-01-01.log
combined-2023-01-01.log
exceptions-2023-01-01.log
Environment Variables
Variable | Default | Description |
---|---|---|
DATABASE_URL | (required) | PostgreSQL connection URL |
LOG_DIR | ./logs | Log storage directory |
SERVICE_NAME | dataforge-analytics | Service identifier |
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
GNU AFFERO GENERAL PUBLIC LICENSE © Tetrachrome Studios
0.0.5-Alpha
5 months ago
0.0.4-Alpha
5 months ago
0.0.3-Alpha
5 months ago
0.0.2-Alpha
5 months ago
0.0.1-Alpha
5 months ago