UNPKG

@snap/camera-kit

Version:
31 lines 937 B
import { Metric, serializeMetricDimensions } from "./Metric"; export function isCountMetric(value) { var _a; return ((_a = value.metric) === null || _a === void 0 ? void 0 : _a.$case) === "count"; } export class Count extends Metric { static count(name, n, dimensions = {}) { const count = new Count(name, dimensions); count.increment(n); return count; } constructor(name, dimensions = {}) { super(name, dimensions); this.name = name; this.count = 0; } increment(count) { this.count += count; return this.count; } toOperationalMetric() { return [ { name: `${this.name}${serializeMetricDimensions(this.dimensions)}`, timestamp: new Date(), metric: { $case: "count", count: `${Math.ceil(this.count)}` }, }, ]; } } //# sourceMappingURL=Count.js.map