Skip to main content

Analytics and bug tracking for Python desktop apps

Project description

nucleus-python PyPI PyPI - Python Version

We tried to make it as simple as possible to report the data you need to analyze your app and improve it.

This module is compatible with Python 3+.

To start using this module, sign up and get an app ID on the Nucleus website.

Installation

$ pip install nucleus-python

Usage

Add the following code to import Nucleus and init the analytics.

Don't use the import ... from syntax as you won't be able to access inside module variables and set the right variables.

import nucleus

nucleus.app_id = 'your app id'
nucleus.version = '1.3.9'

nucleus.app_started()

Only use app_started() once per session, if you are using Nucleus in several files call app_started() the soonest possible.

Sign up and get a tracking ID for your app here.

Options

You can init Nucleus with options:

nuclesu.report_interval = 20 # interval (in seconds) between server com
nucleus.disable_tracking = False # completely disable tracking
nucleus.user_id = 'user123' # set an identifier for this user
nucleus.debug = False # Show internal logs to help debug
nucleus.version = '1.3.9' # set the current version of your app
nucleus.locale = 'es_ES' # specify a custom locale (default: autodetected)

By default language is autodetected but you can overwrite it.

Identify your users

You can track specific users actions on the 'User Explorer' section of your dashboard.

For that, you can supply an userId when initing the Nucleus module.

It can be your own generated ID, an email, username... etc.

nucleus.user_id = 'someUniqueUserId'

nucleus.app_started()

Or if you don't know it on start, you can add it later with:

nucleus.set_user_id('someUniqueUserId')

Alternatively, set the autoUserId option of the module to True to automatically assign the user an ID based on his username and hostname.

Track custom data

You can add custom data along with the automatic data.

Those will be visible in your user dashboard if you previously set an user ID.

The module will remember past properties so you can use nucleus.set_props multiple times without overwriting past props.

Properties can either numbers, strings or booleans. Nested properties or arrays aren't supported at the moment.

nucleus.set_props({
	"age": 34,
	"name": 'Richard Hendricks',
	"jobType": 'CEO'
})

Enable overwrite: set the second parameter as True to overwrite past properties.

nucleus.set_props({
	"age": 23
}, True)

Events

After initializing Nucleus, you can send your own custom events.

nucleus.track("PLAYED_TRACK")

They are a couple event names that are reserved by Nucleus: init, error: and nucleus:.

You shouldn't report events containing these strings.

Tracking with data

You can add extra information to tracked events, as an object.

Properties can either numbers, strings or booleans.

Nested properties or arrays aren't supported at the moment.

Example:

nucleus.track("PLAYED_TRACK", data = {
	"trackName": 'My Awesome Song',
	"duration": 120
})

Toggle tracking

This will completely disable any communication with Nucleus' servers.

To opt-out your users from tracking:

nucleus.disable_tracking = True

and to opt back in:

nucleus.disable_tracking = False

This change won't persist after restarts so you have to handle the saving of the settings.

Errors

To track errors with Nucleus, simply add the tracking code to an exception and pass the exception as the unique parameter.

Nucleus will extract the relevant informations and show them in your dashboard.

try:
    my_app()
except Exception as e:
	nucleus.track_error(e)

Add this at the outermost level of your code to handle any otherwise uncaught exceptions before terminating.

The advantage of except Exception over the bare except is that there are a few exceptions that it wont catch, most obviously KeyboardInterrupt and SystemExit.


Contact hello@nucleus.sh for any inquiry

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

nucleus_python-0.2.0-py3.7.egg (9.8 kB view details)

Uploaded Source

nucleus_python-0.2.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file nucleus_python-0.2.0-py3.7.egg.

File metadata

  • Download URL: nucleus_python-0.2.0-py3.7.egg
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for nucleus_python-0.2.0-py3.7.egg
Algorithm Hash digest
SHA256 de4003e0bccb4d4c46ca47b2408ddf732d9e491fe2c85cd0ca6628d4881ec344
MD5 fdd989b1ddb7dc9e9d75d6510fc4911e
BLAKE2b-256 9dfdaba77d9846d274fbb5ebb723ba206e200607b287db55b0c938a44a2c6cf0

See more details on using hashes here.

File details

Details for the file nucleus_python-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: nucleus_python-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for nucleus_python-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55cbabd3e454baa351a7e3e4023b224d62c708b30948417428d8adeca2777197
MD5 965b95c02bac7460b7ca3eac40724e0c
BLAKE2b-256 7d442ca04d3493ce0000b877c3e6a64c20b10e0f23054793029ad1b673c5b60b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page