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

autonomous-analytics

v1.0.18

Published

Event tracking package for Autonomous Product

Downloads

26

Readme

Autonomous Analytics

Event tracking package for Autonomous products. This can be used on:

  • Web (JS, framework-independent)
  • React Native
  • Node.JS

Installation

npm install --save autonomous-analytics

Usage

Initialize

clientSecret is required for the library to work. Please contact Data team to obtain clientSecret for your product.

import ApiCaller from 'autonomous-analytics';

const caller = new ApiCaller({ clientSecret });

Optional options:

  • persistData: (key: string, value: string) => void

    to override the persistData built-in

  • getData: (key: string) => void

    to override the getData built-in

Event tracking

An event is an action of the user on your product. It could be a page load, a click on a specific button, and any other actions that you want to track.

Quick and dirty code to get started with event tracking:

import ApiCaller from 'autonomous-analytics';
const clientSecret = '<your client secret>';

const caller = new ApiCaller({ clientSecret });

const eventName = 'test_event_name';
const eventParams = [
    { key: 'event_key_1', value: 'event_value_1' },
    { key: 'event_key_2', value: 'event_value_2' },
]
const platform = 'web';
const userId = 1;

const response = caller.trackEvent({
    eventName: eventName,
    userId,
    eventParams,
    platform,
});

console.log(response);

References:

trackEvent()

Track a specific event

Params:

  • eventName: Name of your event (required)
  • userId: logged in user_id
  • userPseudoId: an ID represent a unique user accessing Autonomous product. For web-based products, you can use device fingerprint method to generate an pseudo ID.
  • platform: web, android or ios are accepted values. Default is web
  • eventParams: an array of parameters you may use to differentiate events. For example, you may attach button names, links name, page section names, and any other data you may need for further analyze user activities. This array consists of one or more { key, value } objects.

trackPageView()

Alias for caller.trackEvent(), but with less parameters. You may use this function to track pageview for your product

Params:

  • pageName: Name of your page (web) or screen (app) (required)
  • platform: Name of your platform, default to web

trackComponentLoadTime()

Alias for caller.trackEvent(), but with less parameters. You may use this function to track component load time for your product.

For component load, a prefix of component_load_ will be added to your component's name for data storage and query.

Params:

  • componentName: Name of your component
  • startTime: When the component is starting to load
  • endTime: When the component finishes loading