@sho-js/analytics
TypeScript icon, indicating that this package has built-in type declarations

6.0.2 • Public • Published

Wearesho Analytics

Installation

npm i --save @sho-js/analytics

Usage

Setup

Create instance of WeareshoAnalytics.Service with following params:

import * as WeareshoAnalytics from "@sho-js/analytics";

const axiosInstance = Axios.create({baseURL: "https://wearesho.public.api.com/"});

const token = ""; // your way to receive unique fingerprint value
const components = {
    resolution: "1920,1080",
    offset: 3,
    // ... other key/value pairs
};

const fingerPrint: FingerPrint = { token, components }

const analytics = await WeareshoAnalytics.Service.create(axiosInstance, fingerPrint);

where

  • axiosInstance - instance of Axios. Required.
  • fingerPrint - fingerprint data. Required.

Actions

analytics.action("some unique action name");
analytics.input("fieldName", ["valuePrev", "valueNext"]);
analytics.user(1 /* UserId */);

Helpers

const actionHandler = analytics.handler(analytics.action, "some unique action name");
const inputHandler = analytics.handler(analytics.input, "fieldName", ["valuePrev", "valueNext"]);
const userHandler = analytics.handler(analytics.input, 1);

<button onClick={actionHandler}/>
<button onClick={inputHandler}/>
<button onClick={userHandler}/>

Readme

Keywords

Package Sidebar

Install

npm i @sho-js/analytics

Weekly Downloads

1

Version

6.0.2

License

MIT

Unpacked Size

21.7 kB

Total Files

9

Last publish

Collaborators

  • horat1us
  • sashabeton