0.4.0 • Published 1 year ago

@tokenscript/analytics-client v0.4.0

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

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..."
});
0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago