npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

astrolytics-browser

v1.0.7

Published

![Astrolytics.io](docs/readme-banner.jpg)

Downloads

13

Readme

Astrolytics.io Browser SDK

Astrolytics.io

Table of Contents

  1. Getting Started
  2. Usage
  3. How to Contribute

Getting Started

To get started with Astrolytics, create an account at Astrolytics and grab the App ID, then use the SDK to start tracking events.

Installation

As NPM package (recommended)

# with npm
npm install astrolytics-browser

# or with yarn
yarn add astrolytics-browser

or as browser script

<script src="https://cdn.jsdelivr.net/npm/astrolytics-browser/dist/bundle.iife.js"></script>

we recommend using a specific version in case a non-backwards compatible change is introduced

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bundle.iife.js"></script>

Usage

import Astrolytics from 'astrolytics-browser';

Astrolytics.init('YOUR_APP_ID');

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:

Astrolytics.init('APP_ID', { disableErrorReports: true })

User Identification

Identify a user by a unique ID and optionally set custom properties.

Astrolytics.identify('04f8846d-ecca-4a81-8740-f6428ceb7f7b', { firstName: 'Brendan', lastName: 'Eich' });

Page Tracking

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.

Disabling Tracking

To disable tracking

Astrolytics.disableTracking();

Enabling Tracking

To enable tracking

Astrolytics.enableTracking();

How to Contribute

We're always looking for contributions from the community. Here's how you can help:

  1. Report Bugs: Create an issue report detailing the bug you've found.
  2. Suggest Features: Have a great idea for Astrolytics? Don't hesitate to put it forward by creating an issue.
  3. Submit Pull Requests: Feel free to fix a bug or add a new feature and create a pull request. Make sure to follow the existing code style, and write clear commit messages explaining your changes.