UNPKG

@grafana/faro-web-sdk

Version:

Faro instrumentations, metas, transports for web.

32 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UserActionInstrumentation = void 0; const faro_core_1 = require("@grafana/faro-core"); const processUserActionEventHandler_1 = require("./processUserActionEventHandler"); class UserActionInstrumentation extends faro_core_1.BaseInstrumentation { constructor() { super(...arguments); this.name = '@grafana/faro-web-sdk:instrumentation-user-action'; this.version = faro_core_1.VERSION; } initialize() { const { processUserEvent, processUserActionStarted } = (0, processUserActionEventHandler_1.getUserEventHandler)(faro_core_1.faro); window.addEventListener('pointerdown', processUserEvent); window.addEventListener('keydown', (ev) => { if ([' ', 'Enter'].includes(ev.key)) { processUserEvent(ev); } }); this._userActionSub = faro_core_1.userActionsMessageBus.subscribe(({ type, userAction }) => { if (type === 'user_action_start') { processUserActionStarted(userAction); } }); } destroy() { var _a; (_a = this._userActionSub) === null || _a === void 0 ? void 0 : _a.unsubscribe(); } } exports.UserActionInstrumentation = UserActionInstrumentation; //# sourceMappingURL=instrumentation.js.map