https://github.com/75lb/usage-stats-cli
A minimal, offline-friendly Google Analytics Measurement Protocol client for tracking usage statistics in shell and javascript applications.
https://github.com/75lb/usage-stats-cli
Last synced: 3 months ago
JSON representation
A minimal, offline-friendly Google Analytics Measurement Protocol client for tracking usage statistics in shell and javascript applications.
- Host: GitHub
- URL: https://github.com/75lb/usage-stats-cli
- Owner: 75lb
- License: mit
- Created: 2017-02-10T00:23:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-30T22:15:59.000Z (about 9 years ago)
- Last Synced: 2025-12-27T13:49:27.297Z (7 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.org/package/usage-stats-cli)
[](https://www.npmjs.org/package/usage-stats-cli)
[](https://travis-ci.org/75lb/usage-stats-cli)
[](https://coveralls.io/github/75lb/usage-stats-cli?branch=master)
[](https://david-dm.org/75lb/usage-stats-cli)
[](https://github.com/feross/standard)
# usage-stats-cli
A minimal, offline-friendly [Google Analytics Measurement Protocol](https://developers.google.com/analytics/devguides/collection/protocol/v1/) client for tracking usage statistics in shell and javascript applications.
This is a low-level API client, it doesn't hold any opinion of how usage tracking should be done. If you're looking for a convention which leverages the power and flexibility of [Custom Metrics and Dimensions](https://support.google.com/analytics/answer/2709828?hl=en&ref_topic=2709827), take a look at [app-usage-stats](https://github.com/75lb/app-usage-stats).
## Synopsis
Tracking statistics in shell scripts:
```sh
# Track an event: category 'Backup', action 'start'
usage-stats event --tid UA-98765432-1 --ec Backup --ea start
# Perform the backup
cp files/** backup/
# Track an event: category 'Backup', action 'complete'
usage-stats event --tid UA-98765432-1 --ec Backup --ea complete
```
## Protocol Parameters
See [here](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters) for the full list of Google Analytics Measurement Protocol parameters.
### Sent by default
All parameters are send on demand, beside this list.
* Operating System version (sent in the UserAgent)
* [Client ID](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid) (a random UUID, generated once per OS user and stored)
* [Language](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ul) (`process.env.LANG`, if set)
* [Screen resolution](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#sr) (terminal rows by columns, by default)
## CLI Reference
To install the command line client:
```
$ npm install -g usage-stats-cli
```
Running the tool with no arguments will print the usage guide:
usage-stats
A minimal, offline-friendly Google Analytics Measurement Protocol client for
tracking usage statistics in shell and javascript applications.
Synopsis
$ usage-stats <command> <command-options>
$ usage-stats <command> --help
Commands
screenview Track a screenview
event Track an event
exception Track an exception
* * *
© 2016-17 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).