Anonymous usage statistics collecter
Project description
This package is meant to easily get usage statistics from the users of your program.
Statistics will be collected but won’t be uploaded until the user opts in. A message will be printed on stderr asking the user to explicitly opt in or opt out.
Usage
You can easily collect information from your program by adding usagestats to your project’s requirements and using the library. Here is an example:
import usagestats import sys optin_prompt = usagestats.Prompt(enable='cool_program --enable-stats', disable='cool_program --disable-stats') # Location where to store stats # Also allocates a unique ID for the user # The version is important, since the information you log (or the format) # might change in later versions of your program stats = usagestats.Stats('~/.myprog/usage_stats', optin_prompt, 'https://usagestats.example.org/', unique_user_id=True, version='0.1') def main(): if len(sys.argv) < 2: pass elif sys.argv.get(1) == '--enable-stats': stats.enable_reporting() sys.exit(0) elif sys.argv.get(1) == '--disable-stats': stats.disable_reporting() sys.exit(0) if sys.version_info < (3,): # Stores some info, will be reported when submit() is called stats.note({'mode': 'compatibility'}) # Report things stats.submit( # Dictionary containing the info {'what': 'Ran the program'}, # Flags making usagestats insert more details usagestats.OPERATING_SYSTEM, # Operating system/distribution usagestats.PYTHON_VERSION, # Python version info usagestats.SESSION_TIME, # Time since Stats object was created ) if __name__ == '__main__': main()
submit() will, by default, store the info in the specified directory. Nothing will be reported until the user opts in; a message will simply be printed to stderr:
Uploading usage statistics is currently DISABLED Please help us by providing anonymous usage statistics; you can enable this by running: cool_program --enable-stats If you do not want to see this message again, you can run: cool_program --disable-stats Nothing will be uploaded before you opt in.
Server
To collect the reports, any server will do; the reports are uploaded via POST as a LF-separated list of key:value pairs. A simple script for mod_wsgi is included; it writes each report to a separate file. Writing your own implementation in your language of choice (PHP, Java) with your own backend should be fairly straightforward.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file usagestats-0.7.tar.gz
.
File metadata
- Download URL: usagestats-0.7.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39cf0736dfec40c85416270fc43382bdef7af18da85e1e243075f145fe2b8aef |
|
MD5 | e30edc03a08ccea16f4824d9d7dd9eef |
|
BLAKE2b-256 | cda4fc67c6152c07d68510f8eaa6d5ed2c37b4f8e1c73c28bf8cb8e999b75979 |
File details
Details for the file usagestats-0.7-py2.py3-none-any.whl
.
File metadata
- Download URL: usagestats-0.7-py2.py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e375768b4b18687f06f9b6dc2b357b12cd8adf241cfc053772ed3a671dcc603d |
|
MD5 | a0077268e87b03367821ee9223ad1e31 |
|
BLAKE2b-256 | 82851093d0e40ae247808079f13fd5d3df2316706f7d35245d8d8978bf35f28b |