0.2.7 • Published 5 years ago

@daocasino/dc-statistics-client v0.2.7

Weekly downloads
1
License
GPL-3.0
Repository
-
Last release
5 years ago

DC STATISTICS CLIENT

To analyze your bankroller performance, you can deploy an optional statistics module.

It collects: channel opening and closing data, player roll.

It requires connecting to the statistics client library (see the procedure below).

With this component in place, you can store analytical data. Also, you can request data from your server for front-end.

INSTALLATION

NPM

npm i --save @daocasino/dc-statistics-client

Yarn

yarn add @daocasino/dc-statistics-client

##USAGE Import package

import { DCStatisticClient } from '@daocasino/dc-statistics-client'

Initialize new instance

const statisticsClient = new DCStatisticClient({
    authKey: YOUR_KEY,
    host: 'http://127.0.0.1:4994',
    protocol: 'http'
})

You can also use ws as protocol

const statisticsClient = new DCStatisticClient({
    authKey: YOUR_KEY,
    host: 'ws://127.0.0.1:4994',
    protocol: 'ws'
})

Collect

this.statisticsClient
.openChannel('0xTransactionHash', '0xUserAddress', 'dice')
.catch((error) => {
  console.error(error)
})
this.statisticsClient
.roll('0xTransactionHash', '0xUserAddress', 'dice', 20 /* bet value */)
.catch((error) => {
  console.error(error)
})
this.statisticsClient
.closeChannel('0xTransactionHash', '0xUserAddress', 'dice')
.catch((error) => {
  console.error(error)
})

DEPENDENCIES

This client is WS dependent.

GET USER DATA

You can get statistics in a simple way:

curl http://127.0.0.1/statistics?userAddress=0xuserAddress