Downcity City DocsGuides
Usage Service
Use @downcity/services to record service call events automatically.
The usage service records service events through hooks. It records facts only; your studio still decides pricing, plans, and charging rules.
Enable
import { usageService } from "@downcity/services";
base.use(usageService({
record_errors: true,
}));Query Events
const events = await admin.service("usage").get("events");
const summary = await admin.service("usage").get("summary");End users can query their own usage:
const events = await user.service("usage").get("me");summary groups counts by studio, service, and status, which is useful for admin dashboards.
The service creates service_usage_events automatically and records studio, user, service, model, and call status.