Spock Analytics
  • GET STARTED
    • 📊Spock Analytics
    • ❓Why Spock Analytics
    • 💡Use Cases
    • ⚙️Onboarding
    • 🖖Learn about Spock
      • View
      • Understand
  • CONTRACT CONFIGURATION
    • Contract Form
  • SDK CONFIGURATION
    • SDK
    • Full API Reference
    • Supported Wallets
    • NPM package
    • Example applications
  • ADAPTER CONFIGURATION
    • Adapter
    • Transformers
    • TVL Extractors
    • How to code an adapter?
    • Functions we have written so you don't have to
      • Multicall
      • Sum Balances
    • GitHub repo
Powered by GitBook
On this page
  • Web3Analyitcs.init
  • Web3Analytics.walletProvider
  • Web3Analytics.trackWalletConnection
  • Web3Analytics.trackPageView
  • Web3Analytics.optOutTracking
  • Web3Analytics.optInTracking
  • Web3Analytics.hasOptedOutTracking
  1. SDK CONFIGURATION

Full API Reference

PreviousSDKNextSupported Wallets

Last updated 1 year ago

Web3Analyitcs.init

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

Usage

Web3Analytics.init({ appKey: 'YOUR APP KEY'});
Argument
Type
Description

appKey

String

Optional

debug

Boolean

Defaults to false. Enable consoles for all the tracking events.

dataPoints

string[]

By default, SDK will track all data

inactivityTimeout

number

Defaults to 30. This field takes time in mins to specify the inactivity duration in which the session will expire.

optOut

Boolean

Defaults to false. Opt users out of tracking.

testENV

Boolean

Defaults to false. Enable testing version of SDK in which SDK will interact with testing servers.

testMode

Boolean

Defaults to false. Enable test mode in which you can test tracking events without logging data onto the server in order to avoid storing testing data.

Web3Analytics.walletProvider

Pass web3 provider to track wallet connections for all and transaction status that are submitted or rejected on the dApp.

Usage

Web3Analytics.walletProvider(window.ethereum);

In case of handling multiple wallets on the dApp. Example in React.

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

const { provider } = useWeb3React();

//in order to pass an updated provider if the user changes wallet, account or chain.
useEffect(() => {
  if (provider?.provider) {
    Web3Analytics.walletProvider(provider.provider);
  }
}, [provider]);
Argument
Type
Description

provider

Web3Provider

EIP-1193 Standard Provider or Web3Provider-compatible Provider

Web3Analytics.trackWalletConnection

Web3Analytics.trackWalletConnection('Ledger', '0x...96', 1);
Argument
Type
Description

walletType

String

Name of wallet

account

String

User Ethereum address

chainId

number

User connected chainId

Web3Analytics.trackPageView

Track all the pages visited on a DApp.

Usage

Web3Analytics.trackPageView('/home');
Argument
Type
Description

path

String

Path of the page. e.g. '/about', '/dashboard/stats'

search

String

Query string of the page. eg: '?id=ab02'

Web3Analytics.optOutTracking

Opt user out from tracking.

Usage

Web3Analytics.optOutTracking();
Argument
Type
Description

expiration

number

Default 365. Duration in days for which the user is opt-out

Web3Analytics.optInTracking

Opt user in tracking.

Usage

Web3Analytics.optInTracking();
Argument
Type
Description

expiration

number

Default 365. Duration in days for which the user is opt-in

Web3Analytics.hasOptedOutTracking

Getter method for the status of user tracking consent.

Usage

Web3Analytics.hasOptedOutTracking();
Argument
Return Type
Description

-

number

Status of user tracking consent

Unique appKey like eba6...28c for tracking. Can be obtained from the app's page.

points. But you can limit them by passing the desired .

To track other wallets that are currently not supported as mentioned . Usage

supported wallets
here
configuration
datapoints