@grafana/faro-web-sdk
Version:
Faro instrumentations, metas, transports for web.
26 lines • 1.02 kB
JavaScript
import { BaseInstrumentation, faro, VERSION } from '@grafana/faro-core';
import { getUserEventHandler } from './processUserActionEventHandler';
let processUserEventHandler;
export class UserActionInstrumentation extends BaseInstrumentation {
constructor() {
super(...arguments);
this.name = '@grafana/faro-web-sdk:instrumentation-user-action';
this.version = VERSION;
}
initialize() {
processUserEventHandler = getUserEventHandler(faro);
window.addEventListener('pointerdown', processUserEventHandler);
window.addEventListener('keydown', processUserEventHandler);
}
}
export function startUserAction(name, attributes) {
processUserEventHandler === null || processUserEventHandler === void 0 ? void 0 : processUserEventHandler(createUserActionApiEvent(name, attributes));
}
function createUserActionApiEvent(name, attributes) {
return {
name,
attributes,
type: 'apiEvent',
};
}
//# sourceMappingURL=instrumentation.js.map