1.5.0 • Published 6 months ago

analytics-web3 v1.5.0

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
6 months ago

Spock Analytics SDK

Spock analytics SDK analytics-web3 is a Javascript module to collect and log all the data and events of DApp for analytics.

Spock

Spock aims to accelerate your growth by tracking & analyzing crucial and opportunity-centric metrics that will help you to amplify your growth and reach to the right customer segment.

Table of contents

Installation

Install analytics-web3 sdk by using npm

npm install --save analytics-web3

or yarn

yarn add analytics-web3

Usage

Initialize and track wallet connection and transactions by passing web3 provider.

import Web3Analytics from 'analytics-web3';
Web3Analytics.init({ appKey: 'eba6...28c' });
Web3Analytics.walletProvider(window.ethereum);

API

Web3Analytics.init(options)

Web3Analytics must be initialized with appKey by invoking init method at the top level of application before using other methods.

Web3Analytics.init({ appKey: 'eba6...28c', debug: true });
ValueTypeDescription
appKeyStringUnique appKey like eba6...28c for tracking. Can be obtained by getting onboarded in Spock.
Optional
debugBooleanDefaults to false. Enable consoles for all the tracking events.
dataPointsstring[]By default SDK will track all data points. But you can limit them by passing the desired datapoints.
inactivityTimeoutnumberDefaults to 30. This field takes time in mins to specify the inactivity duration in which the session will expires.
optOutBooleanDefaults to false. Opt users out of tracking.
testENVBooleanDefaults to false. Enable testing version of SDK in which SDK will interact with testing servers.
testModeBooleanDefaults to false. Enable testMode in which you can test tracking events without logging data onto server. Inordre to avoid store testing data.

Web3Analytics.walletProvider(provider)

Pass web3 provider to track wallet connections for all Supporting Wallets and transactions state that are submitted or rejected from DApp.

Web3Analytics.walletProvider(window.ethereum);

In-case of handling multiple wallets on DApp. Example in React.

import { useWeb3React } from '@web3-react/core';

const { provider } = useWeb3React();

// in-order to pass updated provider if user changes wallet, account or chain.
useEffect(() => {
  if (provider?.provider) {
    Web3Analytics.walletProvider(provider.provider);
  }
}, [provider]);
ValueTypeDescription
providerWeb3ProviderEIP-1193 Standard Provider or Web3Provider-compatible Provider.

Web3Analytics.trackWalletConnection(walletType,account,chainId)

To track other wallets that currently not include in Supporting Wallets.

Web3Analytics.trackWalletConnection('Ledger', '0x...96', 1);
ValueTypeDescription
walletTypeStringName of wallet
accountStringUser ethereum address
chainIdnumberUser connected chainId

Web3Analytics.trackPageView(pathname,search)

Track all the pages visited on a DApp.

Web3Analytics.trackPageView('/home');
ValueTypeDescription
pathnameStringPath of the page. e.g. '/about', '/dashboard/stats'
searchStringQuery string of the pgae. eg: '?id=ab02'

Web3Analytics.optOutTracking(expiration)

Opt user out from tracking.

Web3Analytics.optOutTracking();
ValueTypeDescription
expirationnumberDefault 365. Duration in days for which user is opt-out.

Web3Analytics.optInTracking(expiration)

Opt user in tracking.

Web3Analytics.optInTracking();
ValueTypeDescription
expirationnumberDefault 365. Duration in days for which user is opt-in.

Web3Analytics.hasOptedOutTracking()

Getter method for the status of user tracking consent.

Web3Analytics.hasOptedOutTracking();
ValueReturn TypeDescription
-BooleanStatus of user tracking consent.

Web3Analytics.widgetOnClick(method)

For custom on-click implementation of widget button.

Web3Analytics.widgetOnClick(({ campaignId }) => {
  if (campaignId === YOUR_CAMPAIGN_ID) {
    //do something
  }
});
ParamTypeDescription
campaignIdnumberUnique campaign id belongs to the widget.
redirectUrlstring / undefinedRedirect url set on the campaign button click.

Supporting wallets

  • MetaMask
  • WalletConnect
  • Coinbase Wallet
  • Portis
  • Fortmatic

To track wallet not including in the list you can use trackWalletConnection method.

Datapoints

  • web3 (Mandatory) - Wallet Address, Chain ID, Wallet Type, Wallet Connection, Max Gas Fee, Quoted Gas Fee, Transaction Hash, Transaction Status, Submitted and Rejected Transaction Count and Failed Transactions.
  • web2 - Current URL, Operating System, Browser, Referrer, Device, Referring Domain, Screen Width, Screen height, Search Engine, Page Views, External Links and UTM Params.
  • demographics - Country, City and Region.
  • engage - Campaign Serving, Campaign Clicks, Click Through Rate (CTR), Transaction Through Rate (TTR), Unique Wallets, Dialogs Served, and Dialogs Closed.

License

UNLICENSED

Demo

Example code for analytics-web3 integration Spock Analytics Demo

Documentation

You can use these docs for knowing more about Spock Analytics.

Credits

Backed by xord.com

1.2.0

8 months ago

1.1.0

9 months ago

1.3.3

8 months ago

1.5.0

6 months ago

1.3.2

8 months ago

1.4.0

8 months ago

1.3.1

8 months ago

1.3.0

8 months ago

1.5.0-beta.0

7 months ago

1.2.0-beta.0

8 months ago

1.0.1

11 months ago

1.0.0

11 months ago

1.0.0-beta.4

1 year ago

1.0.0-beta.5

12 months ago

1.0.0-beta.6

12 months ago

1.0.0-beta.2

1 year ago

1.0.0-beta.3

1 year ago

1.0.0-beta.0

1 year ago

1.0.0-beta.1

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

2 years ago

0.1.0-beta.7

2 years ago

0.1.0-beta.6

2 years ago

0.1.0-beta.5

2 years ago

0.1.0-beta.4

2 years ago

0.1.0-beta.3

2 years ago

0.1.0-beta.2

2 years ago

0.1.0-beta.1

2 years ago

0.1.0-beta.0

2 years ago