UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

49 lines 1.84 kB
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _regeneratorRuntime from "@babel/runtime/regenerator"; import { ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics'; /** * * Util function to be used with the Editor component to send duration analytics * * @param action * @param props * @param getCreateAnalyticsEvent return the CreateUIAnalyticsEvent of the Editor * @returns */ export default function sendDurationAnalytics(action, props, createAnalyticsEvent) { return /*#__PURE__*/function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(duration, startTime) { var contextIdentifier, objectId; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return props.contextIdentifierProvider; case 2: contextIdentifier = _context.sent; objectId = contextIdentifier === null || contextIdentifier === void 0 ? void 0 : contextIdentifier.objectId; if (createAnalyticsEvent) { fireAnalyticsEvent(createAnalyticsEvent)({ payload: { action: action, actionSubject: ACTION_SUBJECT.EDITOR, attributes: { duration: duration, startTime: startTime, objectId: objectId }, eventType: EVENT_TYPE.OPERATIONAL } }); } case 5: case "end": return _context.stop(); } }, _callee); })); return function (_x, _x2) { return _ref.apply(this, arguments); }; }(); }