Record
Important
The usage record keys are used to aggregate usage record values. There is a limit of 5000 unique usage record keys per usage store per hour. If you exceed this limit, some usage record keys will be ignored.
import { record } from "usage-api";
const res = authAndRecord(
process.env.USAGE_API_KEY,
{
usageStoreId: "my-usage-store-id", // required
onNoUsageStore: { // optional, default block
type: "create",
rateLimits: [ // optional, max 3 rate limits per usage store
{
rateLimitId: "my-rate-limit-id",
limit: 100,
timeWindowSeconds: 60
}
]
} | {
type: "block"
}
usageRecords: [ // required, max 10 usage records per request
{
key: "Usage_Record_Key", // required
value: 1 // required
},
{
key: "Usage_Record_Key_the_second",
value: 0.001
}
]
rateLimitBehavior: "ignore" | "log-and-block" | "log-only" // default log-and-block
blockBehavior: "ignore" | "block" // default block
}
);
type res = {
success: true,
} | {
success: false,
message: string
}