@atlaskit/editor-plugin-base 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,6 @@ import { countNodes, getAnalyticsEventSeverity, isPerformanceAPIAvailable, isPer
5
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import { setInteractionType } from '../utils/frozen-editor';
7
7
  import InputLatencyTracker from '../utils/input-latency-tracking';
8
- import { getContextIdentifier } from './context-identifier';
9
8
  export const frozenEditorPluginKey = new PluginKey('frozenEditor');
10
9
  const DEFAULT_KEYSTROKE_SAMPLING_LIMIT = 100;
11
10
  const DEFAULT_SLOW_THRESHOLD = 300;
@@ -15,8 +14,8 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
15
14
  const DEFAULT_TRACK_SEVERITY_ENABLED = false;
16
15
  export const DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
17
16
  export const DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
18
- const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) => {
19
- var _getContextIdentifier;
17
+ const dispatchLongTaskEvent = contextIdentifierPlugin => (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) => {
18
+ var _contextIdentifierPlu, _contextIdentifierPlu2;
20
19
  const {
21
20
  state
22
21
  } = view;
@@ -25,7 +24,7 @@ const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, getNodeCount,
25
24
  action: ACTION.BROWSER_FREEZE,
26
25
  actionSubject: ACTION_SUBJECT.EDITOR,
27
26
  attributes: {
28
- objectId: (_getContextIdentifier = getContextIdentifier(state)) === null || _getContextIdentifier === void 0 ? void 0 : _getContextIdentifier.objectId,
27
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 ? void 0 : (_contextIdentifierPlu = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu === void 0 ? void 0 : (_contextIdentifierPlu2 = _contextIdentifierPlu.contextIdentifierProvider) === null || _contextIdentifierPlu2 === void 0 ? void 0 : _contextIdentifierPlu2.objectId,
29
28
  freezeTime: time,
30
29
  nodeSize: state.doc.nodeSize,
31
30
  ...nodesCount,
@@ -35,7 +34,7 @@ const dispatchLongTaskEvent = (dispatchAnalyticsEvent, view, time, getNodeCount,
35
34
  eventType: EVENT_TYPE.OPERATIONAL
36
35
  });
37
36
  };
38
- export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) => {
37
+ export default (contextIdentifierPlugin => (dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) => {
39
38
  let interactionType;
40
39
  let inputLatencyTracker = null;
41
40
  let inputLatencySingleKeyTracker = null;
@@ -64,7 +63,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
64
63
  const severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
65
64
  const severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
66
65
  const createDispatchSample = (action, view) => (time, severity) => {
67
- var _getContextIdentifier2;
66
+ var _contextIdentifierPlu3, _contextIdentifierPlu4;
68
67
  const {
69
68
  state
70
69
  } = view;
@@ -76,7 +75,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
76
75
  time,
77
76
  nodeSize: state.doc.nodeSize,
78
77
  ...nodesCount,
79
- objectId: (_getContextIdentifier2 = getContextIdentifier(state)) === null || _getContextIdentifier2 === void 0 ? void 0 : _getContextIdentifier2.objectId,
78
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 ? void 0 : (_contextIdentifierPlu3 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu3 === void 0 ? void 0 : (_contextIdentifierPlu4 = _contextIdentifierPlu3.contextIdentifierProvider) === null || _contextIdentifierPlu4 === void 0 ? void 0 : _contextIdentifierPlu4.objectId,
80
79
  severity: shouldTrackSeverity ? severity : undefined
81
80
  },
82
81
  eventType: EVENT_TYPE.OPERATIONAL
@@ -88,7 +87,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
88
87
  median,
89
88
  sampleSize
90
89
  }, severity) => {
91
- var _getContextIdentifier3;
90
+ var _contextIdentifierPlu5, _contextIdentifierPlu6;
92
91
  const {
93
92
  state
94
93
  } = view;
@@ -103,7 +102,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
103
102
  ...nodeCount,
104
103
  nodeSize: state.doc.nodeSize,
105
104
  severity: shouldTrackSeverity ? severity : undefined,
106
- objectId: (_getContextIdentifier3 = getContextIdentifier(state)) === null || _getContextIdentifier3 === void 0 ? void 0 : _getContextIdentifier3.objectId
105
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 ? void 0 : (_contextIdentifierPlu5 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu5 === void 0 ? void 0 : (_contextIdentifierPlu6 = _contextIdentifierPlu5.contextIdentifierProvider) === null || _contextIdentifierPlu6 === void 0 ? void 0 : _contextIdentifierPlu6.objectId
107
106
  },
108
107
  eventType: EVENT_TYPE.OPERATIONAL
109
108
  };
@@ -167,7 +166,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
167
166
  isSlow,
168
167
  severity
169
168
  }) => {
170
- var _getContextIdentifier4;
169
+ var _contextIdentifierPlu7, _contextIdentifierPlu8;
171
170
  const {
172
171
  state
173
172
  } = view;
@@ -180,7 +179,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
180
179
  experienceStore === null || experienceStore === void 0 ? void 0 : experienceStore.success(EditorExperience.typing, {
181
180
  nodeSize: state.doc.nodeSize,
182
181
  ...nodesCount,
183
- objectId: (_getContextIdentifier4 = getContextIdentifier(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId,
182
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 ? void 0 : (_contextIdentifierPlu7 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu7 === void 0 ? void 0 : (_contextIdentifierPlu8 = _contextIdentifierPlu7.contextIdentifierProvider) === null || _contextIdentifierPlu8 === void 0 ? void 0 : _contextIdentifierPlu8.objectId,
184
183
  time,
185
184
  severity: shouldTrackSeverity ? severity : undefined
186
185
  });
@@ -188,7 +187,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
188
187
  dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING, view),
189
188
  dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_AVG, view),
190
189
  onSlowInput: time => {
191
- var _getContextIdentifier5;
190
+ var _contextIdentifierPlu9, _contextIdentifierPlu10;
192
191
  const {
193
192
  state
194
193
  } = view;
@@ -200,7 +199,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
200
199
  time,
201
200
  nodeSize: state.doc.nodeSize,
202
201
  ...nodesCount,
203
- objectId: (_getContextIdentifier5 = getContextIdentifier(state)) === null || _getContextIdentifier5 === void 0 ? void 0 : _getContextIdentifier5.objectId
202
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 ? void 0 : (_contextIdentifierPlu9 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu9 === void 0 ? void 0 : (_contextIdentifierPlu10 = _contextIdentifierPlu9.contextIdentifierProvider) === null || _contextIdentifierPlu10 === void 0 ? void 0 : _contextIdentifierPlu10.objectId
204
203
  },
205
204
  eventType: EVENT_TYPE.OPERATIONAL
206
205
  });
@@ -236,7 +235,7 @@ export default ((dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, u
236
235
  duration
237
236
  } = perfEntries[i];
238
237
  if (duration > freezeThreshold) {
239
- dispatchLongTaskEvent(dispatchAnalyticsEvent, view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? getAnalyticsEventSeverity(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
238
+ dispatchLongTaskEvent(contextIdentifierPlugin)(dispatchAnalyticsEvent, view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? getAnalyticsEventSeverity(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
240
239
  }
241
240
  }
242
241
  });
@@ -6,7 +6,6 @@ import { keymap } from '@atlaskit/editor-common/keymaps';
6
6
  import { baseKeymap } from '@atlaskit/editor-prosemirror/commands';
7
7
  import { history } from '@atlaskit/editor-prosemirror/history';
8
8
  import { setKeyboardHeight } from './commands';
9
- import contextIdentifierPlugin, { getContextIdentifier } from './pm-plugins/context-identifier';
10
9
  import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
11
10
  import filterStepsPlugin from './pm-plugins/filter-steps';
12
11
  import frozenEditor from './pm-plugins/frozen-editor';
@@ -22,7 +21,6 @@ var basePlugin = function basePlugin(_ref) {
22
21
  name: 'base',
23
22
  getSharedState: function getSharedState(editorState) {
24
23
  return {
25
- contextIdentifier: getContextIdentifier(editorState),
26
24
  keyboardHeight: getKeyboardHeight(editorState)
27
25
  };
28
26
  },
@@ -63,7 +61,7 @@ var basePlugin = function basePlugin(_ref) {
63
61
  plugin: function plugin(_ref3) {
64
62
  var _options$inputTrackin;
65
63
  var dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
66
- return options !== null && options !== void 0 && (_options$inputTrackin = options.inputTracking) !== null && _options$inputTrackin !== void 0 && _options$inputTrackin.enabled || options !== null && options !== void 0 && options.ufo ? frozenEditor(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
64
+ return options !== null && options !== void 0 && (_options$inputTrackin = options.inputTracking) !== null && _options$inputTrackin !== void 0 && _options$inputTrackin.enabled || options !== null && options !== void 0 && options.ufo ? frozenEditor(api === null || api === void 0 ? void 0 : api.contextIdentifier)(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
67
65
  }
68
66
  }, {
69
67
  name: 'history',
@@ -84,13 +82,6 @@ var basePlugin = function basePlugin(_ref) {
84
82
  }
85
83
  }));
86
84
  }
87
- }, {
88
- name: 'contextIdentifier',
89
- plugin: function plugin(_ref4) {
90
- var dispatch = _ref4.dispatch,
91
- providerFactory = _ref4.providerFactory;
92
- return contextIdentifierPlugin(dispatch, providerFactory);
93
- }
94
85
  });
95
86
  if (options && options.allowScrollGutter) {
96
87
  plugins.push({
@@ -8,7 +8,6 @@ import { countNodes, getAnalyticsEventSeverity, isPerformanceAPIAvailable, isPer
8
8
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
9
  import { setInteractionType } from '../utils/frozen-editor';
10
10
  import InputLatencyTracker from '../utils/input-latency-tracking';
11
- import { getContextIdentifier } from './context-identifier';
12
11
  export var frozenEditorPluginKey = new PluginKey('frozenEditor');
13
12
  var DEFAULT_KEYSTROKE_SAMPLING_LIMIT = 100;
14
13
  var DEFAULT_SLOW_THRESHOLD = 300;
@@ -18,234 +17,238 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
18
17
  var DEFAULT_TRACK_SEVERITY_ENABLED = false;
19
18
  export var DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL = 100;
20
19
  export var DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED = 500;
21
- var dispatchLongTaskEvent = function dispatchLongTaskEvent(dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) {
22
- var _getContextIdentifier;
23
- var state = view.state;
24
- var nodesCount = getNodeCount(state);
25
- return dispatchAnalyticsEvent({
26
- action: ACTION.BROWSER_FREEZE,
27
- actionSubject: ACTION_SUBJECT.EDITOR,
28
- attributes: _objectSpread(_objectSpread({
29
- objectId: (_getContextIdentifier = getContextIdentifier(state)) === null || _getContextIdentifier === void 0 ? void 0 : _getContextIdentifier.objectId,
30
- freezeTime: time,
31
- nodeSize: state.doc.nodeSize
32
- }, nodesCount), {}, {
33
- interactionType: interactionType,
34
- severity: severity
35
- }),
36
- eventType: EVENT_TYPE.OPERATIONAL
37
- });
20
+ var dispatchLongTaskEvent = function dispatchLongTaskEvent(contextIdentifierPlugin) {
21
+ return function (dispatchAnalyticsEvent, view, time, getNodeCount, interactionType, severity) {
22
+ var _contextIdentifierPlu;
23
+ var state = view.state;
24
+ var nodesCount = getNodeCount(state);
25
+ return dispatchAnalyticsEvent({
26
+ action: ACTION.BROWSER_FREEZE,
27
+ actionSubject: ACTION_SUBJECT.EDITOR,
28
+ attributes: _objectSpread(_objectSpread({
29
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu === void 0 || (_contextIdentifierPlu = _contextIdentifierPlu.contextIdentifierProvider) === null || _contextIdentifierPlu === void 0 ? void 0 : _contextIdentifierPlu.objectId,
30
+ freezeTime: time,
31
+ nodeSize: state.doc.nodeSize
32
+ }, nodesCount), {}, {
33
+ interactionType: interactionType,
34
+ severity: severity
35
+ }),
36
+ eventType: EVENT_TYPE.OPERATIONAL
37
+ });
38
+ };
38
39
  };
39
- export default (function (dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) {
40
- var interactionType;
41
- var inputLatencyTracker = null;
42
- var inputLatencySingleKeyTracker = null;
43
- var inputLatencyRenderedTracker = null;
44
- if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
45
- interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.LOADING);
46
- }
47
- var samplingRate = inputTracking && typeof inputTracking.samplingRate === 'number' ? inputTracking.samplingRate : DEFAULT_KEYSTROKE_SAMPLING_LIMIT;
48
- var slowThreshold = inputTracking && typeof inputTracking.slowThreshold === 'number' ? inputTracking.slowThreshold : DEFAULT_SLOW_THRESHOLD;
49
- var freezeThreshold = inputTracking && typeof inputTracking.freezeThreshold === 'number' ? inputTracking.freezeThreshold : DEFAULT_FREEZE_THRESHOLD;
50
- var allowCountNodes = inputTracking && inputTracking.countNodes;
51
- var prevNodeCountState = null;
52
- var prevNodeCount = {};
40
+ export default (function (contextIdentifierPlugin) {
41
+ return function (dispatchAnalyticsEvent, inputTracking, browserFreezeTracking, ufo) {
42
+ var interactionType;
43
+ var inputLatencyTracker = null;
44
+ var inputLatencySingleKeyTracker = null;
45
+ var inputLatencyRenderedTracker = null;
46
+ if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
47
+ interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.LOADING);
48
+ }
49
+ var samplingRate = inputTracking && typeof inputTracking.samplingRate === 'number' ? inputTracking.samplingRate : DEFAULT_KEYSTROKE_SAMPLING_LIMIT;
50
+ var slowThreshold = inputTracking && typeof inputTracking.slowThreshold === 'number' ? inputTracking.slowThreshold : DEFAULT_SLOW_THRESHOLD;
51
+ var freezeThreshold = inputTracking && typeof inputTracking.freezeThreshold === 'number' ? inputTracking.freezeThreshold : DEFAULT_FREEZE_THRESHOLD;
52
+ var allowCountNodes = inputTracking && inputTracking.countNodes;
53
+ var prevNodeCountState = null;
54
+ var prevNodeCount = {};
53
55
 
54
- // Cache the result as we were calling this multiple times
55
- // and has potential to be expensive
56
- var getNodeCount = function getNodeCount(state) {
57
- if (state === prevNodeCountState) {
56
+ // Cache the result as we were calling this multiple times
57
+ // and has potential to be expensive
58
+ var getNodeCount = function getNodeCount(state) {
59
+ if (state === prevNodeCountState) {
60
+ return prevNodeCount;
61
+ }
62
+ prevNodeCount = allowCountNodes ? countNodes(state) : {};
63
+ prevNodeCountState = state;
58
64
  return prevNodeCount;
59
- }
60
- prevNodeCount = allowCountNodes ? countNodes(state) : {};
61
- prevNodeCountState = state;
62
- return prevNodeCount;
63
- };
64
- var shouldTrackSeverity = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.trackSeverity) || DEFAULT_TRACK_SEVERITY_ENABLED;
65
- var severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
66
- var severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
67
- var createDispatchSample = function createDispatchSample(action, view) {
68
- return function (time, severity) {
69
- var _getContextIdentifier2;
70
- var state = view.state;
71
- var nodesCount = getNodeCount(state);
72
- var samplePayload = {
73
- action: action,
74
- actionSubject: ACTION_SUBJECT.EDITOR,
75
- attributes: _objectSpread(_objectSpread({
76
- time: time,
77
- nodeSize: state.doc.nodeSize
78
- }, nodesCount), {}, {
79
- objectId: (_getContextIdentifier2 = getContextIdentifier(state)) === null || _getContextIdentifier2 === void 0 ? void 0 : _getContextIdentifier2.objectId,
80
- severity: shouldTrackSeverity ? severity : undefined
81
- }),
82
- eventType: EVENT_TYPE.OPERATIONAL
65
+ };
66
+ var shouldTrackSeverity = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.trackSeverity) || DEFAULT_TRACK_SEVERITY_ENABLED;
67
+ var severityThresholdNormal = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityNormalThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_NORMAL;
68
+ var severityThresholdDegraded = (inputTracking === null || inputTracking === void 0 ? void 0 : inputTracking.severityDegradedThreshold) || DEFAULT_TRACK_SEVERITY_THRESHOLD_DEGRADED;
69
+ var createDispatchSample = function createDispatchSample(action, view) {
70
+ return function (time, severity) {
71
+ var _contextIdentifierPlu2;
72
+ var state = view.state;
73
+ var nodesCount = getNodeCount(state);
74
+ var samplePayload = {
75
+ action: action,
76
+ actionSubject: ACTION_SUBJECT.EDITOR,
77
+ attributes: _objectSpread(_objectSpread({
78
+ time: time,
79
+ nodeSize: state.doc.nodeSize
80
+ }, nodesCount), {}, {
81
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu2 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu2 === void 0 || (_contextIdentifierPlu2 = _contextIdentifierPlu2.contextIdentifierProvider) === null || _contextIdentifierPlu2 === void 0 ? void 0 : _contextIdentifierPlu2.objectId,
82
+ severity: shouldTrackSeverity ? severity : undefined
83
+ }),
84
+ eventType: EVENT_TYPE.OPERATIONAL
85
+ };
86
+ dispatchAnalyticsEvent(samplePayload);
83
87
  };
84
- dispatchAnalyticsEvent(samplePayload);
85
88
  };
86
- };
87
- var createDispatchAverage = function createDispatchAverage(action, view) {
88
- return function (_ref, severity) {
89
- var _getContextIdentifier3;
90
- var mean = _ref.mean,
91
- median = _ref.median,
92
- sampleSize = _ref.sampleSize;
93
- var state = view.state;
94
- var nodeCount = getNodeCount(state);
95
- var averagePayload = {
96
- action: action,
97
- actionSubject: ACTION_SUBJECT.EDITOR,
98
- attributes: _objectSpread(_objectSpread({
99
- mean: mean,
100
- median: median,
101
- sampleSize: sampleSize
102
- }, nodeCount), {}, {
103
- nodeSize: state.doc.nodeSize,
104
- severity: shouldTrackSeverity ? severity : undefined,
105
- objectId: (_getContextIdentifier3 = getContextIdentifier(state)) === null || _getContextIdentifier3 === void 0 ? void 0 : _getContextIdentifier3.objectId
106
- }),
107
- eventType: EVENT_TYPE.OPERATIONAL
89
+ var createDispatchAverage = function createDispatchAverage(action, view) {
90
+ return function (_ref, severity) {
91
+ var _contextIdentifierPlu3;
92
+ var mean = _ref.mean,
93
+ median = _ref.median,
94
+ sampleSize = _ref.sampleSize;
95
+ var state = view.state;
96
+ var nodeCount = getNodeCount(state);
97
+ var averagePayload = {
98
+ action: action,
99
+ actionSubject: ACTION_SUBJECT.EDITOR,
100
+ attributes: _objectSpread(_objectSpread({
101
+ mean: mean,
102
+ median: median,
103
+ sampleSize: sampleSize
104
+ }, nodeCount), {}, {
105
+ nodeSize: state.doc.nodeSize,
106
+ severity: shouldTrackSeverity ? severity : undefined,
107
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu3 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu3 === void 0 || (_contextIdentifierPlu3 = _contextIdentifierPlu3.contextIdentifierProvider) === null || _contextIdentifierPlu3 === void 0 ? void 0 : _contextIdentifierPlu3.objectId
108
+ }),
109
+ eventType: EVENT_TYPE.OPERATIONAL
110
+ };
111
+ dispatchAnalyticsEvent(averagePayload);
108
112
  };
109
- dispatchAnalyticsEvent(averagePayload);
110
113
  };
111
- };
112
- return new SafePlugin({
113
- key: frozenEditorPluginKey,
114
- props: isPerformanceAPIAvailable() ? {
115
- handleTextInput: function handleTextInput(view) {
116
- if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
117
- interactionType = BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
118
- }
119
- if (inputLatencyTracker) {
120
- var end = inputLatencyTracker.start();
114
+ return new SafePlugin({
115
+ key: frozenEditorPluginKey,
116
+ props: isPerformanceAPIAvailable() ? {
117
+ handleTextInput: function handleTextInput(view) {
118
+ if (browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType) {
119
+ interactionType = BROWSER_FREEZE_INTERACTION_TYPE.TYPING;
120
+ }
121
+ if (inputLatencyTracker) {
122
+ var end = inputLatencyTracker.start();
121
123
 
122
- // This is called after all handleTextInput events are executed which means first handleTextInput time incorporates following handleTextInput processing time
123
- // Also this is called before browser rendering so it doesn't count it.
124
- requestAnimationFrame(end);
125
- }
126
- if (inputLatencySingleKeyTracker) {
127
- var _end = inputLatencySingleKeyTracker.start();
124
+ // This is called after all handleTextInput events are executed which means first handleTextInput time incorporates following handleTextInput processing time
125
+ // Also this is called before browser rendering so it doesn't count it.
126
+ requestAnimationFrame(end);
127
+ }
128
+ if (inputLatencySingleKeyTracker) {
129
+ var _end = inputLatencySingleKeyTracker.start();
128
130
 
129
- // This is executed before next handleTextInput when multiple keypress events are in one animation frame
130
- // so it tracks individual keypress processing time
131
- Promise.resolve().then(_end);
132
- }
133
- if (inputLatencyRenderedTracker) {
134
- var _end2 = inputLatencyRenderedTracker.start();
131
+ // This is executed before next handleTextInput when multiple keypress events are in one animation frame
132
+ // so it tracks individual keypress processing time
133
+ Promise.resolve().then(_end);
134
+ }
135
+ if (inputLatencyRenderedTracker) {
136
+ var _end2 = inputLatencyRenderedTracker.start();
135
137
 
136
- // This is called at the next event loop so it counts browser rendering time.
137
- setTimeout(_end2);
138
- }
139
- return false;
140
- },
141
- handleDOMEvents: browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? {
142
- click: function click() {
143
- interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.CLICKING);
138
+ // This is called at the next event loop so it counts browser rendering time.
139
+ setTimeout(_end2);
140
+ }
144
141
  return false;
145
142
  },
146
- paste: function paste() {
147
- interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.PASTING);
148
- return false;
149
- }
150
- } : undefined
151
- } : undefined,
152
- view: function view(_view) {
153
- if (!isPerformanceObserverAvailable()) {
154
- return {};
155
- }
156
- var experienceStore = ufo ? ExperienceStore.getInstance(_view) : undefined;
157
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
158
- inputLatencyTracker = new InputLatencyTracker({
159
- samplingRate: samplingRate,
160
- slowThreshold: slowThreshold,
161
- normalThreshold: severityThresholdNormal,
162
- degradedThreshold: severityThresholdDegraded,
163
- onSampleStart: function onSampleStart() {
164
- experienceStore === null || experienceStore === void 0 || experienceStore.start(EditorExperience.typing);
165
- },
166
- onSampleEnd: function onSampleEnd(time, _ref2) {
167
- var _getContextIdentifier4;
168
- var isSlow = _ref2.isSlow,
169
- severity = _ref2.severity;
170
- var state = _view.state;
171
- var nodesCount = getNodeCount(state);
172
- if (isSlow) {
173
- experienceStore === null || experienceStore === void 0 || experienceStore.addMetadata(EditorExperience.typing, {
174
- slowInput: true
175
- });
176
- }
177
- experienceStore === null || experienceStore === void 0 || experienceStore.success(EditorExperience.typing, _objectSpread(_objectSpread({
178
- nodeSize: state.doc.nodeSize
179
- }, nodesCount), {}, {
180
- objectId: (_getContextIdentifier4 = getContextIdentifier(state)) === null || _getContextIdentifier4 === void 0 ? void 0 : _getContextIdentifier4.objectId,
181
- time: time,
182
- severity: shouldTrackSeverity ? severity : undefined
183
- }));
143
+ handleDOMEvents: browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? {
144
+ click: function click() {
145
+ interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.CLICKING);
146
+ return false;
184
147
  },
185
- dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING, _view),
186
- dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_AVG, _view),
187
- onSlowInput: function onSlowInput(time) {
188
- var _getContextIdentifier5;
189
- var state = _view.state;
190
- var nodesCount = getNodeCount(state);
191
- dispatchAnalyticsEvent({
192
- action: ACTION.SLOW_INPUT,
193
- actionSubject: ACTION_SUBJECT.EDITOR,
194
- attributes: _objectSpread(_objectSpread({
195
- time: time,
148
+ paste: function paste() {
149
+ interactionType = setInteractionType(BROWSER_FREEZE_INTERACTION_TYPE.PASTING);
150
+ return false;
151
+ }
152
+ } : undefined
153
+ } : undefined,
154
+ view: function view(_view) {
155
+ if (!isPerformanceObserverAvailable()) {
156
+ return {};
157
+ }
158
+ var experienceStore = ufo ? ExperienceStore.getInstance(_view) : undefined;
159
+ if (inputTracking !== null && inputTracking !== void 0 && inputTracking.enabled) {
160
+ inputLatencyTracker = new InputLatencyTracker({
161
+ samplingRate: samplingRate,
162
+ slowThreshold: slowThreshold,
163
+ normalThreshold: severityThresholdNormal,
164
+ degradedThreshold: severityThresholdDegraded,
165
+ onSampleStart: function onSampleStart() {
166
+ experienceStore === null || experienceStore === void 0 || experienceStore.start(EditorExperience.typing);
167
+ },
168
+ onSampleEnd: function onSampleEnd(time, _ref2) {
169
+ var _contextIdentifierPlu4;
170
+ var isSlow = _ref2.isSlow,
171
+ severity = _ref2.severity;
172
+ var state = _view.state;
173
+ var nodesCount = getNodeCount(state);
174
+ if (isSlow) {
175
+ experienceStore === null || experienceStore === void 0 || experienceStore.addMetadata(EditorExperience.typing, {
176
+ slowInput: true
177
+ });
178
+ }
179
+ experienceStore === null || experienceStore === void 0 || experienceStore.success(EditorExperience.typing, _objectSpread(_objectSpread({
196
180
  nodeSize: state.doc.nodeSize
197
181
  }, nodesCount), {}, {
198
- objectId: (_getContextIdentifier5 = getContextIdentifier(state)) === null || _getContextIdentifier5 === void 0 ? void 0 : _getContextIdentifier5.objectId
199
- }),
200
- eventType: EVENT_TYPE.OPERATIONAL
201
- });
202
- }
203
- });
204
- }
205
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackSingleKeypress) {
206
- inputLatencySingleKeyTracker = new InputLatencyTracker({
207
- samplingRate: samplingRate,
208
- slowThreshold: slowThreshold,
209
- normalThreshold: severityThresholdNormal,
210
- degradedThreshold: severityThresholdDegraded,
211
- dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS, _view),
212
- dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS_AVG, _view)
213
- });
214
- }
215
- if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackRenderingTime) {
216
- inputLatencyRenderedTracker = new InputLatencyTracker({
217
- samplingRate: samplingRate,
218
- slowThreshold: slowThreshold,
219
- normalThreshold: severityThresholdNormal,
220
- degradedThreshold: severityThresholdDegraded,
221
- dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_RENDERED, _view),
222
- dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_RENDERED_AVG, _view)
223
- });
224
- }
225
- var observer;
226
- try {
227
- observer = new PerformanceObserver(function (list) {
228
- var perfEntries = list.getEntries();
229
- for (var i = 0; i < perfEntries.length; i++) {
230
- var duration = perfEntries[i].duration;
231
- if (duration > freezeThreshold) {
232
- dispatchLongTaskEvent(dispatchAnalyticsEvent, _view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? getAnalyticsEventSeverity(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
182
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu4 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu4 === void 0 || (_contextIdentifierPlu4 = _contextIdentifierPlu4.contextIdentifierProvider) === null || _contextIdentifierPlu4 === void 0 ? void 0 : _contextIdentifierPlu4.objectId,
183
+ time: time,
184
+ severity: shouldTrackSeverity ? severity : undefined
185
+ }));
186
+ },
187
+ dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING, _view),
188
+ dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_AVG, _view),
189
+ onSlowInput: function onSlowInput(time) {
190
+ var _contextIdentifierPlu5;
191
+ var state = _view.state;
192
+ var nodesCount = getNodeCount(state);
193
+ dispatchAnalyticsEvent({
194
+ action: ACTION.SLOW_INPUT,
195
+ actionSubject: ACTION_SUBJECT.EDITOR,
196
+ attributes: _objectSpread(_objectSpread({
197
+ time: time,
198
+ nodeSize: state.doc.nodeSize
199
+ }, nodesCount), {}, {
200
+ objectId: contextIdentifierPlugin === null || contextIdentifierPlugin === void 0 || (_contextIdentifierPlu5 = contextIdentifierPlugin.sharedState.currentState()) === null || _contextIdentifierPlu5 === void 0 || (_contextIdentifierPlu5 = _contextIdentifierPlu5.contextIdentifierProvider) === null || _contextIdentifierPlu5 === void 0 ? void 0 : _contextIdentifierPlu5.objectId
201
+ }),
202
+ eventType: EVENT_TYPE.OPERATIONAL
203
+ });
233
204
  }
234
- }
235
- });
236
-
237
- // register observer for long task notifications
238
- observer.observe({
239
- entryTypes: ['longtask']
240
- });
241
- } catch (e) {}
242
- return {
243
- destroy: function destroy() {
244
- var _inputLatencyTracker, _observer;
245
- (_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 || _inputLatencyTracker.flush();
246
- (_observer = observer) === null || _observer === void 0 || _observer.disconnect();
205
+ });
247
206
  }
248
- };
249
- }
250
- });
207
+ if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackSingleKeypress) {
208
+ inputLatencySingleKeyTracker = new InputLatencyTracker({
209
+ samplingRate: samplingRate,
210
+ slowThreshold: slowThreshold,
211
+ normalThreshold: severityThresholdNormal,
212
+ degradedThreshold: severityThresholdDegraded,
213
+ dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS, _view),
214
+ dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_SINGLE_KEYPRESS_AVG, _view)
215
+ });
216
+ }
217
+ if (inputTracking !== null && inputTracking !== void 0 && inputTracking.trackRenderingTime) {
218
+ inputLatencyRenderedTracker = new InputLatencyTracker({
219
+ samplingRate: samplingRate,
220
+ slowThreshold: slowThreshold,
221
+ normalThreshold: severityThresholdNormal,
222
+ degradedThreshold: severityThresholdDegraded,
223
+ dispatchSample: createDispatchSample(ACTION.INPUT_PERF_SAMPLING_RENDERED, _view),
224
+ dispatchAverage: createDispatchAverage(ACTION.INPUT_PERF_SAMPLING_RENDERED_AVG, _view)
225
+ });
226
+ }
227
+ var observer;
228
+ try {
229
+ observer = new PerformanceObserver(function (list) {
230
+ var perfEntries = list.getEntries();
231
+ for (var i = 0; i < perfEntries.length; i++) {
232
+ var duration = perfEntries[i].duration;
233
+ if (duration > freezeThreshold) {
234
+ dispatchLongTaskEvent(contextIdentifierPlugin)(dispatchAnalyticsEvent, _view, duration, getNodeCount, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackInteractionType ? interactionType : undefined, browserFreezeTracking !== null && browserFreezeTracking !== void 0 && browserFreezeTracking.trackSeverity ? getAnalyticsEventSeverity(duration, browserFreezeTracking.severityNormalThreshold || NORMAL_SEVERITY_THRESHOLD, browserFreezeTracking.severityDegradedThreshold || DEGRADED_SEVERITY_THRESHOLD) : undefined);
235
+ }
236
+ }
237
+ });
238
+
239
+ // register observer for long task notifications
240
+ observer.observe({
241
+ entryTypes: ['longtask']
242
+ });
243
+ } catch (e) {}
244
+ return {
245
+ destroy: function destroy() {
246
+ var _inputLatencyTracker, _observer;
247
+ (_inputLatencyTracker = inputLatencyTracker) === null || _inputLatencyTracker === void 0 || _inputLatencyTracker.flush();
248
+ (_observer = observer) === null || _observer === void 0 || _observer.disconnect();
249
+ }
250
+ };
251
+ }
252
+ });
253
+ };
251
254
  });