UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

29 lines (20 loc) 659 B
import { loadGTAG } from "../google/loadGTAG.js"; import { MetricsGateway } from "./MetricsGateway.js"; export class GoogleAnalyticsMetrics extends MetricsGateway { constructor(key) { super(); this.api = { gtag: loadGTAG(key) }; } record(type, event) { const payload = Object.assign({}, event); if (typeof event.category === "string") { payload.event_category = event.category; } if (typeof event.label === "string") { payload.event_label = event.label; } this.api.gtag('event', type, payload); } }