@atlaskit/editor-plugin-collab-edit
Version:
Collab Edit plugin for @atlaskit/editor-core
49 lines (48 loc) • 2.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addSynchronyErrorAnalytics = exports.addSynchronyEntityAnalytics = void 0;
var _analytics = require("@atlaskit/editor-common/analytics");
var _coreUtils = require("@atlaskit/editor-common/core-utils");
var _utils = require("@atlaskit/editor-common/utils");
var addSynchronyErrorAnalytics = exports.addSynchronyErrorAnalytics = function addSynchronyErrorAnalytics(state, tr, featureFlags, editorAnalyticsApi) {
return function (error) {
var browserExtensions = (0, _utils.sniffUserBrowserExtensions)({
extensions: ['grammarly']
});
var payload = {
action: _analytics.ACTION.SYNCHRONY_ERROR,
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
attributes: {
error: error,
browserExtensions: browserExtensions
}
};
if (featureFlags.synchronyErrorDocStructure) {
// Ignored via go/ees005
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
payload.attributes.docStructure = (0, _coreUtils.getDocStructure)(state.doc, {
compact: true
});
}
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(payload)(tr);
return tr;
};
};
var addSynchronyEntityAnalytics = exports.addSynchronyEntityAnalytics = function addSynchronyEntityAnalytics(state, tr) {
return function (type, editorAnalyticsApi) {
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
action: type === 'error' ? _analytics.ACTION.SYNCHRONY_ENTITY_ERROR : _analytics.ACTION.SYNCHRONY_DISCONNECTED,
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
attributes: {
// https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine
onLine: navigator.onLine,
visibilityState: document.visibilityState
}
})(tr);
return tr;
};
};