UNPKG

@atlaskit/editor-plugin-metrics

Version:

Metrics plugin for @atlaskit/editor-core

28 lines 1.07 kB
import _createClass from "@babel/runtime/helpers/createClass"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; var ACTIVE_SESSION_IDLE_TIME = 5000; export var ActiveSessionTimer = /*#__PURE__*/_createClass(function ActiveSessionTimer(api) { var _this = this; _classCallCheck(this, ActiveSessionTimer); _defineProperty(this, "startTimer", function () { if (_this.timerId) { clearTimeout(_this.timerId); } _this.timerId = window.setTimeout(function () { 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", function () { if (_this.timerId) { clearTimeout(_this.timerId); _this.timerId = null; } }); this.timerId = null; this.api = api; });