1.0.18 • Published 3 years ago

autonomous-analytics v1.0.18

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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
1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.10

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago