verdaccio-stats
v0.4.4
Published
The stats plugin for Verdaccio
Readme
Verdaccio Stats Plugin
This plugin adds detailed statistics functionality to your Verdaccio private npm registry.
Features
- Track package download statistics
- Track manifest view counts
- ISO week format support
- Admin interface to view statistics
Installation
Install Globally
npm install -g verdaccio-statsOr install to verdaccio plugin folder:
mkdir -p ./install-here/
npm install --global-style \
--bin-links=false --save=false --package-lock=false \
--omit=dev --omit=peer --prefix ./install-here/ \
verdaccio-stats@latest
mv ./install-here/node_modules/verdaccio-stats/ /path/to/verdaccio/plugins/Note: Do not use
--omit=optionalflag, as this plugin requires optional dependencies (e.g., platform-specific binaries for rollup) to function correctly at runtime.
Configuration
Add the plugin to your Verdaccio config file:
middlewares:
stats:
enabled: true
dialect: sqlite # Optional: sqlite, mysql, postgres, mariadb, mssql, db2, snowflake, oracle (default: sqlite)
database: stats.db # For SQLite: path to database file
# For other databases, use object configuration:
# database:
# name: verdaccio_stats
# username: user # Or use VERDACCIO_STATS_USERNAME env var
# password: pass # Or use VERDACCIO_STATS_PASSWORD env var
# host: localhost
# port: 5432
iso-week: false # Optional, whether to use ISO week format
count-downloads: true # Optional, whether to count downloads
count-manifest-views: true # Optional, whether to count manifest views
flush-interval: 5s # Optional: flush interval (number ms or duration string). 0 means realtime flush.
max-pending-entries: 10000 # Optional: flush when pending entry keys reach this sizeNote: SQLite is the default database type, but for performance reason, it is not recommended for production use. For production, consider using MySQL, PostgreSQL, MariaDB, or MSSQL.
You'll also need to ensure that the appropriate database driver is installed. For example, if you're using MySQL, you would need to install mysql2:
npm install -g mysql2For other databases, install the corresponding driver:
- PostgreSQL:
pgandpg-hstore - MariaDB:
mariadb - MSSQL:
tedious - SQLite:
sqlite3(not recommended for production) - Oracle:
oracledb - DB2:
ibm_db - Snowflake:
snowflake-sdk
Configuration Options
| Option | Type | Default | Description |
| ---------------------- | ---------------- | ----------------- | ------------------------------------------------------------------------------------------------ |
| enabled | boolean | true | Whether the plugin is enabled |
| dialect | string | sqlite | Database type (sqlite, mysql, postgres, mariadb, mssql, db2, snowflake, oracle) |
| dialect-options | object | {} | Additional options to pass to the database driver |
| database | string or object | stats.db | Database configuration |
| database.name | string | verdaccio_stats | Database name |
| database.username | string | | Database username |
| database.password | string | | Database password |
| database.host | string | localhost | Database host |
| database.port | number | 3306 | Database port |
| iso-week | boolean | false | Whether to use ISO week format |
| count-downloads | boolean | true | Whether to count downloads |
| count-manifest-views | boolean | true | Whether to count manifest views |
| flush-interval | number or string | 5000 | Flush interval in ms or a duration string (e.g. 5s, 1m); 0 = realtime, <0 disables timer |
| max-pending-entries | number | 10000 | Flush when the number of pending entry keys reaches this threshold |
Usage
After installing and configuring the plugin, it will automatically begin collecting the specified statistics. The data will be stored in the configured database file.
You can view the statistics by visiting the following URL:
http://your-registry.com/-/web/statsLicense
See the LICENSE file for details.
