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

0.4.0 • Public • Published

Analytics Client

This is the client SDK for Analytics

Install

npm install --save @tokenscript/analytics-client

How to use

  1. Initialize the sdk client

The analytics client will generate a distinctId(uuid) to be used for the following event report and user identification.

import Analytics from '@tokenscript/analytics-client';

const analyticsUrl = "http://127.0.0.1:3006";
// jwt token is generated per client_id/brand/campaign
const jwtToken = "eyJhbGciOiJIUzI...";

const analytics = new Analytics(analyticsUrl, jwtToken);
  1. Hook with Token Negotiator

By connecting to the tokenNegotiator, all the concerned events triggered from tokenNegotiator will be reported automatically.

// accept the token negotiator instance
analytics.connectTokenNegotiator(window.tokenNegotiator); 
  1. Manual user/event report

When Token Negotiator is not used or a custom event outside of Token Negotiator need to be reported, user can perform manual report by directly accessing the tRPC client

// Report event (timestamp is added automatically)
analytics.client.event({
  name: "customer-event",
  properties: {...}
});

// Identify user
analytics.client.user({
  email: "a@b.com",
  chain_id: 1,
  wallet_address: "0x123abc..."
});

Readme

Keywords

none

Package Sidebar

Install

npm i @tokenscript/analytics-client

Weekly Downloads

1

Version

0.4.0

License

none

Unpacked Size

18.4 kB

Total Files

18

Last publish

Collaborators

  • jsbrown
  • stj89
  • jf-stl
  • futantan
  • jot2re
  • micwallace
  • victor928
  • nicholastaras