UNPKG

@atlaskit/editor-plugin-metrics

Version:

Metrics plugin for @atlaskit/editor-core

26 lines 855 B
import _defineProperty from "@babel/runtime/helpers/defineProperty"; const ACTIVE_SESSION_IDLE_TIME = 5000; export class ActiveSessionTimer { constructor(api) { _defineProperty(this, "startTimer", () => { if (this.timerId) { clearTimeout(this.timerId); } this.timerId = window.setTimeout(() => { if (this.api) { var _this$api$metrics; this.api.core.actions.execute((_this$api$metrics = this.api.metrics) === null || _this$api$metrics === void 0 ? void 0 : _this$api$metrics.commands.stopActiveSession()); } this.cleanupTimer(); }, ACTIVE_SESSION_IDLE_TIME); }); _defineProperty(this, "cleanupTimer", () => { if (this.timerId) { clearTimeout(this.timerId); this.timerId = null; } }); this.timerId = null; this.api = api; } }