Skip to Content

Statistic

Generic keyed counters/values under a statistics object on either branch. Keys support dot paths (nested) with literal-key fallback, same as GnosisStore path rules.

Policy: Exposed for inbound calls (other services use it for telemetry-style totals).

State

LocationKeys
Persistent.statisticsLong-lived totals (e.g. meta progression)
Ephemeral.statisticsPer-run totals

How it looks in persistent.json / ephemeral.json

Values are nested objects under statistics; keys may use dot paths when you address them from CallService.

persistent.json
{ "Persistent": { "statistics": { "meta": { "totalRuns": 12 } } } }
ephemeral.json
{ "Ephemeral": { "statistics": { "run": { "enemiesDefeated": 40 } } } }

Use a dot-path key when your JSON is nested (e.g. run.enemiesDefeated). persistent: true writes Persistent.statistics only; false updates Ephemeral and also mirrors the same key on Persistent (see Functions).

Events

None.

Functions

FunctionParametersBehavior
GetValuepersistent (bool), key or path (string)Returns { value: <node> }
SetValuepersistent, key/path, valueSets node at path
IncrementCounterpersistent, key/path, delta (optional, default 1)Adds to numeric stat; if persistent is false, also increments the same key on Persistent (lifetime total + run total)

Usage example — IncrementCounter

StatisticService.Example1.cs
private void BumpRunCounter(string key, int delta = 1) { if (Context?.Store == null || Context.CallService == null) return; var args = GnosisNode.CreateObject(Context.Store); args.Set("persistent", false); args.Set("key", key); args.Set("delta", delta); CallService("Statistic", "IncrementCounter", args); }

Statistics

This service is the statistics store; there is no separate metrics layer.

Usage by other services

Currency

Keys currency.<id>.earned, currency.<id>.spent, currency.<id>.interest. See Currency.

ephemeral.json
{ "Ephemeral": { "statistics": { "currency": { "money": { "earned": 0, "spent": 0, "interest": 0 } } } } }

Consumable

Keys consumables.added.total, consumables.removed.total, consumables.used.total, plus consumables.<action>.tag.<tag> when definitions have tags. See Consumable.

ephemeral.json
{ "Ephemeral": { "statistics": { "consumables": { "added": { "total": 0 }, "removed": { "total": 0 }, "used": { "total": 0 } } } } }

Upgrade

Keys upgrades.added.total, upgrades.removed.total, plus upgrades.<action>.tag.<tag> when definitions have tags. See Upgrade.

ephemeral.json
{ "Ephemeral": { "statistics": { "upgrades": { "added": { "total": 0 }, "removed": { "total": 0 } } } } }
Last updated on