UNPKG

@grafana/faro-web-sdk

Version:

Faro instrumentations, metas, transports for web.

51 lines 2.54 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.UserActionInstrumentation = void 0; var faro_core_1 = require("@grafana/faro-core"); var processUserActionEventHandler_1 = require("./processUserActionEventHandler"); var UserActionInstrumentation = /** @class */ (function (_super) { __extends(UserActionInstrumentation, _super); function UserActionInstrumentation() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.name = '@grafana/faro-web-sdk:instrumentation-user-action'; _this.version = faro_core_1.VERSION; return _this; } UserActionInstrumentation.prototype.initialize = function () { var _a = (0, processUserActionEventHandler_1.getUserEventHandler)(faro_core_1.faro), processUserEvent = _a.processUserEvent, processUserActionStarted = _a.processUserActionStarted; window.addEventListener('pointerdown', processUserEvent); window.addEventListener('keydown', function (ev) { if ([' ', 'Enter'].includes(ev.key)) { processUserEvent(ev); } }); this._userActionSub = faro_core_1.userActionsMessageBus.subscribe(function (_a) { var type = _a.type, userAction = _a.userAction; if (type === 'user_action_start') { processUserActionStarted(userAction); } }); }; UserActionInstrumentation.prototype.destroy = function () { var _a; (_a = this._userActionSub) === null || _a === void 0 ? void 0 : _a.unsubscribe(); }; return UserActionInstrumentation; }(faro_core_1.BaseInstrumentation)); exports.UserActionInstrumentation = UserActionInstrumentation; //# sourceMappingURL=instrumentation.js.map