Replace 'YOUR_APP_ID' with the unique ID of your app. You can get it here.
You can check examples with different frameworks here.
API
Astrolytics supports passing the following options as second argument to the Astrolytics.init() method:
Astrolytics.init('APP_ID', { endpoint:'wss://app.astrolytics.io',// only option, we don't allow self hosting yet :( disableInDev:true,// disable in development mode. We recommend not to call// `init` method, as that will be more reliable. debug:false,// if set to `true`, will log a bunch of things. disableTracking:false,// will not track anything. You can also use `Astrolytics.disableTracking()`.// note that some events will still be added to the queue, so if you call// Astrolytics.enableTracking() again, they will be sent to the server. automaticPageTracking:true,// will track all page changes. reportInterval:2*1000,// at which interval the events are sent to the server. sessionTimeout:60*30*1000,// time after which the session is ended cutoff:60*60*48*1000,// time after which event that were not sent yet are deleted disableErrorReports:false,// wether to disable error tracking})
Tracking
Track events with optional custom data
Astrolytics.track("click", { foo:'bar' });
Error Tracking
Track errors with a name and the Error object.
Astrolytics.trackError(name, error);
By default Astrolytics will listen for window.onerror and window.onunhandledrejection events and send them to the API. If you want to disable this behaviour, you can set disableErrorReports to true:
Track page views with the page name and optional parameters. If the page name is not provided, the current window's pathname is used.
Astrolytics.page('/about', { foo:'baz' });
By default, Astrolytics will track any page change by polling the url every 50 ms. If you prefer to manually track page changes, set automaticPageTracking to false and call Astrolytics.page() on every page change.