Skip to content

chore: add Reporting docs #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pages/service/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"companion": {
"title": "Companion"
},
"reporting": {
"title": "Reporting"
},
"--- References": {
"type": "separator",
"title": "References"
Expand Down
132 changes: 132 additions & 0 deletions pages/service/reporting.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Reporting

Throughout time you'll run transactions to move on-chain assets for the [Profiles](/service/profiles/creating-profiles) you create. As for all blockchains - for each transaction, gas needs to be spend in order to fulfil a transaction. In order to provide you with insights into the data, we provide a couple of simple methods that allow you to pull in this data.

#### Game report

A report per game will get you a complete overview for your game, for every chain you support. This could come in handy if your game is targetting two chains to reach a wider target audience.

**Note:** chain information is environment specific, meaning that you won't find both testnet and mainnet information within the same response.

```typescript
const report = await beam.reporting.getTotalGameUsage();

// {
// "chains": [
// {
// "policies": [
// {
// "totalTransactionFeeInUSD": "string",
// "totalTransactionFee": "string",
// "averageTransactionFee": "string",
// "transactionCount": 0,
// "chainId": 13337,
// "policy": {
// "id": "string",
// "name": "string",
// "model": "ContractFunctions",
// "chainId": 0
// },
// "periods": [
// {
// "totalTransactionFeeInUSD": "string",
// "totalTransactionFee": "string",
// "averageTransactionFee": "string",
// "transactionCount": 0,
// "start": 0,
// "end": 0
// }
// ]
// }
// ],
// "summary": {
// "totalTransactionFeeInUSD": "string",
// "totalTransactionFee": "string",
// "averageTransactionFee": "string",
// "transactionCount": 0,
// "chainId": 13337
// }
// }
// ]
// }
```

#### Chain report

For most developers, retrieving a report for the specific chain they're building on will suffice. The `getTotalGameUsageByChain` method allows you to do just that, provided that you passed a supported `chainId` to the method.

If you're developing on Beam (chain), you will be able to retrieve your games gas expensees by passing the following chain id's:

- **13337** - testnet
- **4327** - mainnet

```typescript
const report = await beam.reporting.getTotalGameUsageByChain(13337);

// {
// "policies": [
// {
// "totalTransactionFeeInUSD": "string",
// "totalTransactionFee": "string",
// "averageTransactionFee": "string",
// "transactionCount": 0,
// "chainId": 13337,
// "policy": {
// "id": "string",
// "name": "string",
// "model": "ContractFunctions",
// "chainId": 0
// },
// "periods": [
// {
// "totalTransactionFeeInUSD": "string",
// "totalTransactionFee": "string",
// "averageTransactionFee": "string",
// "transactionCount": 0,
// "start": 0,
// "end": 0
// }
// ]
// }
// ],
// "summary": {
// "totalTransactionFeeInUSD": "string",
// "totalTransactionFee": "string",
// "averageTransactionFee": "string",
// "transactionCount": 0,
// "chainId": 13337
// }
// }
```

#### Policy report

For more granular reporting per policy, you're able to retrieve the information for one specific policy by providing the policyId.

```typescript
const report = await beam.reporting.getPolicyUsage("clozl24n600003b6ysfapkqq1");

// {
// "totalTransactionFeeInUSD": "string",
// "totalTransactionFee": "string",
// "averageTransactionFee": "string",
// "transactionCount": 0,
// "chainId": 13337,
// "policy": {
// "id": "string",
// "name": "string",
// "model": "ContractFunctions",
// "chainId": 0
// },
// "periods": [
// {
// "totalTransactionFeeInUSD": "string",
// "totalTransactionFee": "string",
// "averageTransactionFee": "string",
// "transactionCount": 0,
// "start": 0,
// "end": 0
// }
// ]
// }
```