Electron.js / Tauri
If you're looking to integrate Astrolytics into a web application instead, check out the Browser SDK.
To start using this module, sign up and get an app ID on Astrolytics.io.
Installation
Using npm or yarn (recommended):
Usage
First sign-up and get a tracking ID for your app here.
With ES6 imports:
Or with CommonJS imports:
Then:
You only need to call init
once.
Options
You can init Astrolytics with options:
Each property is optional. You can start using the module with just the app ID.
The module will try to autodetect a maximum of data as possible but some can fail to detect. It will tell you in the logs which one it failed to detect.
You can manually add data:
Electron Version detection
Version detection only works on Electron's main process as newest Electron versions don't supply the remote module version.
To get the version programmatically in Electron's renderer process you need to setup the remote object, you can then track the version with:
Identify your users
You can track specific users actions on the 'User Explorer' section of your dashboard.
For that, you need to supply an userId
, a string that will allow you to track your users.
It can be your own generated ID, an email, username... etc.
You can also pass custom attributes to be reported along with it.
If you call .identify()
multiple times, the last one will be remembered as the current user data (it will overwrite).
Later on, you can update the userId only (and keep the attributes) with this method:
Update user attributes
You can report custom user attributes 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 Astrolytics.setProps
multiple times without overwriting past props.
Properties can either numbers, strings or booleans. Nested properties or arrays aren't supported at the moment.
Overwrite past properties by setting the second parameter as true.
Events
Send your own events and track user actions:
They are a couple event names that are reserved by Astrolytics: init
, error:
and astrolytics:
. Don't report events containing these strings.
Attach custom data
You can also add extra information to tracked events, as a JSON object.
Properties can either numbers, strings or booleans. Nested properties or arrays aren't supported at the moment (they won't show in the dashboard).
Example
Pages and Screen Views
You can set up Astrolytics to track page visits and screen views in your app.
For that, whenever the user navigates to a different page, call the .page()
method with the new view name.
You can attach extra info about the view. Example:
Params can either be numbers, strings or booleans. Nested params or arrays aren't supported at the moment (they won't show in the dashboard).
Toggle tracking
This will completely disable any communication with Astrolytics' servers.
To opt-out your users from tracking, use the following methods:
and to opt back in:
This change won't persist after restarts so you have to handle the saving of the settings.
You can also supply a disableTracking: true
option to the module on start if you want to directly prevent tracking.
Error tracking
Astrolytics will by default report all uncaughtException
, unhandledRejection
and windowError
events.
If you'd like to report another type of error, you can do so with:
Contact hello@astrolytics.io for any inquiry
Last updated