@atlaskit/editor-core 221.8.3 → 221.9.0
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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/composable-editor/core-editor.js +6 -1
- package/dist/cjs/composable-editor/editor-inp-metrics.js +17 -6
- package/dist/cjs/create-editor/ReactEditorView.js +9 -0
- package/dist/cjs/utils/getEditorDomSize.js +17 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/composable-editor/core-editor.js +6 -1
- package/dist/es2019/composable-editor/editor-inp-metrics.js +16 -4
- package/dist/es2019/create-editor/ReactEditorView.js +9 -0
- package/dist/es2019/utils/getEditorDomSize.js +11 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/composable-editor/core-editor.js +6 -1
- package/dist/esm/composable-editor/editor-inp-metrics.js +17 -6
- package/dist/esm/create-editor/ReactEditorView.js +9 -0
- package/dist/esm/utils/getEditorDomSize.js +11 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/composable-editor/editor-inp-metrics.d.ts +7 -1
- package/dist/types/utils/getEditorDomSize.d.ts +10 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 221.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`1f968eb29f086`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1f968eb29f086) -
|
|
8
|
+
Add editorDomSize (total editor DOM element count) to proseMirrorRendered, INP and UFO performance
|
|
9
|
+
events, gated behind the platform_editor_dom_node_count experiment
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 221.8.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -53,6 +53,7 @@ function Editor(passedProps) {
|
|
|
53
53
|
var editorActions = editorContext.editorActions || editorActionsPlaceholderInstance;
|
|
54
54
|
var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
|
|
55
55
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
56
|
+
var editorViewRef = (0, _react.useRef)(null);
|
|
56
57
|
var handleAnalyticsEvent = (0, _react.useCallback)(function (data) {
|
|
57
58
|
(0, _analytics.fireAnalyticsEvent)(createAnalyticsEvent)(data);
|
|
58
59
|
}, [createAnalyticsEvent]);
|
|
@@ -67,6 +68,7 @@ function Editor(passedProps) {
|
|
|
67
68
|
contextIdentifierProvider = _propsRef$current.contextIdentifierProvider,
|
|
68
69
|
onEditorReady = _propsRef$current.onEditorReady,
|
|
69
70
|
featureFlags = _propsRef$current.featureFlags;
|
|
71
|
+
editorViewRef.current = instance.view;
|
|
70
72
|
editorActions._privateRegisterEditor(instance.view, instance.eventDispatcher, instance.transformer, getFeatureFlagsFromRef);
|
|
71
73
|
if (onEditorReady) {
|
|
72
74
|
(0, _performanceMeasures.startMeasure)(_measureEnum.default.ON_EDITOR_READY_CALLBACK);
|
|
@@ -79,6 +81,7 @@ function Editor(passedProps) {
|
|
|
79
81
|
}, [editorActions, createAnalyticsEvent, getFeatureFlagsFromRef, propsRef]);
|
|
80
82
|
var onEditorDestroyed = (0, _react.useCallback)(function (_instance) {
|
|
81
83
|
var onDestroy = propsRef.current.onDestroy;
|
|
84
|
+
editorViewRef.current = null;
|
|
82
85
|
editorActions._privateUnregisterEditor();
|
|
83
86
|
if (onDestroy) {
|
|
84
87
|
onDestroy();
|
|
@@ -93,7 +96,9 @@ function Editor(passedProps) {
|
|
|
93
96
|
}
|
|
94
97
|
}, [onSaveFromProps]);
|
|
95
98
|
var isFullPageAppearance = Boolean(props.appearance && ['full-page', 'full-width'].concat((0, _toConsumableArray2.default)((0, _experiments.editorExperiment)('platform_synced_block', true) ? ['max'] : [])).includes(props.appearance));
|
|
96
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, isFullPageAppearance ? /*#__PURE__*/_react.default.createElement(_editorInpMetrics.EditorINPMetrics,
|
|
99
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, isFullPageAppearance ? /*#__PURE__*/_react.default.createElement(_editorInpMetrics.EditorINPMetrics, {
|
|
100
|
+
editorViewRef: editorViewRef
|
|
101
|
+
}) : null, /*#__PURE__*/_react.default.createElement(_editorInternal.EditorInternal, {
|
|
97
102
|
props: props,
|
|
98
103
|
handleAnalyticsEvent: handleAnalyticsEvent,
|
|
99
104
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
@@ -11,18 +11,28 @@ var _useAnalyticsEvents = require("@atlaskit/analytics-next/useAnalyticsEvents")
|
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _inp = require("@atlaskit/editor-performance-metrics/inp");
|
|
13
13
|
var _interactionMetrics = require("@atlaskit/react-ufo/interaction-metrics");
|
|
14
|
-
var
|
|
14
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
|
+
var _getEditorDomSize = require("../utils/getEditorDomSize");
|
|
16
|
+
var EditorINPMetrics = exports.EditorINPMetrics = function EditorINPMetrics(_ref) {
|
|
17
|
+
var editorViewRef = _ref.editorViewRef;
|
|
15
18
|
var analyticsEvents = (0, _useAnalyticsEvents.useAnalyticsEvents)();
|
|
16
19
|
|
|
17
20
|
// onMount lifecycle hook
|
|
18
21
|
(0, _react.useEffect)(function () {
|
|
19
22
|
var cleanupFn;
|
|
20
23
|
var cleanupIdleCallback = createIdleCallback(function () {
|
|
21
|
-
cleanupFn = (0, _inp.setupINPTracking)(function (
|
|
22
|
-
var value =
|
|
24
|
+
cleanupFn = (0, _inp.setupINPTracking)(function (_ref2) {
|
|
25
|
+
var value = _ref2.value;
|
|
23
26
|
var interaction = (0, _interactionMetrics.getActiveInteraction)();
|
|
24
27
|
var ufoName = interaction === null || interaction === void 0 ? void 0 : interaction.ufoName;
|
|
25
|
-
|
|
28
|
+
var editorDomSize;
|
|
29
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_dom_node_count', 'isEnabled', true)) {
|
|
30
|
+
var editorView = editorViewRef.current;
|
|
31
|
+
if (editorView) {
|
|
32
|
+
editorDomSize = (0, _getEditorDomSize.getEditorDomSize)(editorView);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
sendAnalytics(analyticsEvents.createAnalyticsEvent, value, ufoName, editorDomSize);
|
|
26
36
|
});
|
|
27
37
|
});
|
|
28
38
|
|
|
@@ -40,7 +50,7 @@ var EditorINPMetrics = exports.EditorINPMetrics = function EditorINPMetrics() {
|
|
|
40
50
|
// This component doesn't render anything
|
|
41
51
|
return null;
|
|
42
52
|
};
|
|
43
|
-
var sendAnalytics = (0, _debounce.default)(function (createAnalyticsEvent, value, ufoName) {
|
|
53
|
+
var sendAnalytics = (0, _debounce.default)(function (createAnalyticsEvent, value, ufoName, editorDomSize) {
|
|
44
54
|
(0, _analytics.fireAnalyticsEvent)(createAnalyticsEvent)({
|
|
45
55
|
payload: {
|
|
46
56
|
// @ts-expect-error Temporary data
|
|
@@ -49,7 +59,8 @@ var sendAnalytics = (0, _debounce.default)(function (createAnalyticsEvent, value
|
|
|
49
59
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
50
60
|
attributes: {
|
|
51
61
|
inp: value,
|
|
52
|
-
ufoName: ufoName
|
|
62
|
+
ufoName: ufoName,
|
|
63
|
+
editorDomSize: editorDomSize
|
|
53
64
|
}
|
|
54
65
|
}
|
|
55
66
|
});
|
|
@@ -35,12 +35,14 @@ var _editorSsrRenderer = require("@atlaskit/editor-ssr-renderer");
|
|
|
35
35
|
var _createSsrEditorState = require("@atlaskit/editor-ssr-renderer/create-ssr-editor-state");
|
|
36
36
|
var _createSsrPmPlugins = require("@atlaskit/editor-ssr-renderer/create-ssr-pm-plugins");
|
|
37
37
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
38
|
+
var _customData = require("@atlaskit/react-ufo/custom-data");
|
|
38
39
|
var _interactionIdContext = require("@atlaskit/react-ufo/interaction-id-context");
|
|
39
40
|
var _interactionMetrics = require("@atlaskit/react-ufo/interaction-metrics");
|
|
40
41
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
41
42
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
42
43
|
var _useProviders = require("../composable-editor/hooks/useProviders");
|
|
43
44
|
var _featureFlagsFromProps = require("../utils/feature-flags-from-props");
|
|
45
|
+
var _getEditorDomSize = require("../utils/getEditorDomSize");
|
|
44
46
|
var _getNodesCountWithExtensionKeys = require("../utils/getNodesCountWithExtensionKeys");
|
|
45
47
|
var _getNodesVisibleInViewport = require("../utils/getNodesVisibleInViewport");
|
|
46
48
|
var _isChromeless = require("../utils/is-chromeless");
|
|
@@ -733,6 +735,7 @@ function ReactEditorView(props) {
|
|
|
733
735
|
} : {},
|
|
734
736
|
totalNodes = _ref4.totalNodes,
|
|
735
737
|
nodeSizeBucket = _ref4.nodeSizeBucket;
|
|
738
|
+
var editorDomSize = (0, _expValEquals.expValEquals)('platform_editor_dom_node_count', 'isEnabled', true) ? (0, _getEditorDomSize.getEditorDomSize)(viewRef.current) : undefined;
|
|
736
739
|
var interaction = (0, _interactionMetrics.getActiveInteraction)();
|
|
737
740
|
var pageLoadType = interaction === null || interaction === void 0 ? void 0 : interaction.type;
|
|
738
741
|
var pageType = interaction === null || interaction === void 0 ? void 0 : interaction.routeName;
|
|
@@ -757,6 +760,7 @@ function ReactEditorView(props) {
|
|
|
757
760
|
nodeSize: nodeSize,
|
|
758
761
|
nodeSizeBucket: nodeSizeBucket,
|
|
759
762
|
totalNodes: totalNodes,
|
|
763
|
+
editorDomSize: editorDomSize,
|
|
760
764
|
ttfb: ttfb,
|
|
761
765
|
severity: proseMirrorRenderedSeverity,
|
|
762
766
|
objectId: contextIdentifier === null || contextIdentifier === void 0 ? void 0 : contextIdentifier.objectId,
|
|
@@ -767,6 +771,11 @@ function ReactEditorView(props) {
|
|
|
767
771
|
extensionKeys: extensionKeys,
|
|
768
772
|
ufoInteractionId: (0, _interactionIdContext.getInteractionId)().current
|
|
769
773
|
};
|
|
774
|
+
if (editorDomSize !== undefined) {
|
|
775
|
+
(0, _customData.addUFOCustomData)({
|
|
776
|
+
editorDomSize: editorDomSize
|
|
777
|
+
});
|
|
778
|
+
}
|
|
770
779
|
dispatchAnalyticsEvent({
|
|
771
780
|
action: _analytics.ACTION.PROSEMIRROR_RENDERED,
|
|
772
781
|
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEditorDomSize = getEditorDomSize;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the total number of DOM elements inside the editor's content DOM,
|
|
9
|
+
* used as a proxy for document complexity in performance events.
|
|
10
|
+
*
|
|
11
|
+
* Uses the native `getElementsByTagName('*')`, which counts descendants
|
|
12
|
+
* iteratively in the browser engine — intentionally not a recursive JS walk, so
|
|
13
|
+
* it can't overflow the stack on very large documents.
|
|
14
|
+
*/
|
|
15
|
+
function getEditorDomSize(view) {
|
|
16
|
+
return view.dom.getElementsByTagName('*').length;
|
|
17
|
+
}
|
|
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/editor-core";
|
|
8
8
|
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
9
|
-
var version = exports.version = "221.8.
|
|
9
|
+
var version = exports.version = "221.8.3";
|
|
@@ -40,6 +40,7 @@ function Editor(passedProps) {
|
|
|
40
40
|
const {
|
|
41
41
|
createAnalyticsEvent
|
|
42
42
|
} = useAnalyticsEvents();
|
|
43
|
+
const editorViewRef = useRef(null);
|
|
43
44
|
const handleAnalyticsEvent = useCallback(data => {
|
|
44
45
|
fireAnalyticsEvent(createAnalyticsEvent)(data);
|
|
45
46
|
}, [createAnalyticsEvent]);
|
|
@@ -56,6 +57,7 @@ function Editor(passedProps) {
|
|
|
56
57
|
onEditorReady,
|
|
57
58
|
featureFlags
|
|
58
59
|
} = propsRef.current;
|
|
60
|
+
editorViewRef.current = instance.view;
|
|
59
61
|
editorActions._privateRegisterEditor(instance.view, instance.eventDispatcher, instance.transformer, getFeatureFlagsFromRef);
|
|
60
62
|
if (onEditorReady) {
|
|
61
63
|
startMeasure(measurements.ON_EDITOR_READY_CALLBACK);
|
|
@@ -70,6 +72,7 @@ function Editor(passedProps) {
|
|
|
70
72
|
const {
|
|
71
73
|
onDestroy
|
|
72
74
|
} = propsRef.current;
|
|
75
|
+
editorViewRef.current = null;
|
|
73
76
|
editorActions._privateUnregisterEditor();
|
|
74
77
|
if (onDestroy) {
|
|
75
78
|
onDestroy();
|
|
@@ -86,7 +89,9 @@ function Editor(passedProps) {
|
|
|
86
89
|
}
|
|
87
90
|
}, [onSaveFromProps]);
|
|
88
91
|
const isFullPageAppearance = Boolean(props.appearance && ['full-page', 'full-width', ...(editorExperiment('platform_synced_block', true) ? ['max'] : [])].includes(props.appearance));
|
|
89
|
-
return /*#__PURE__*/React.createElement(Fragment, null, isFullPageAppearance ? /*#__PURE__*/React.createElement(EditorINPMetrics,
|
|
92
|
+
return /*#__PURE__*/React.createElement(Fragment, null, isFullPageAppearance ? /*#__PURE__*/React.createElement(EditorINPMetrics, {
|
|
93
|
+
editorViewRef: editorViewRef
|
|
94
|
+
}) : null, /*#__PURE__*/React.createElement(EditorInternal, {
|
|
90
95
|
props: props,
|
|
91
96
|
handleAnalyticsEvent: handleAnalyticsEvent,
|
|
92
97
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
@@ -4,7 +4,11 @@ import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents'
|
|
|
4
4
|
import { ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { setupINPTracking } from '@atlaskit/editor-performance-metrics/inp';
|
|
6
6
|
import { getActiveInteraction } from '@atlaskit/react-ufo/interaction-metrics';
|
|
7
|
-
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
|
+
import { getEditorDomSize } from '../utils/getEditorDomSize';
|
|
9
|
+
export const EditorINPMetrics = ({
|
|
10
|
+
editorViewRef
|
|
11
|
+
}) => {
|
|
8
12
|
const analyticsEvents = useAnalyticsEvents();
|
|
9
13
|
|
|
10
14
|
// onMount lifecycle hook
|
|
@@ -16,7 +20,14 @@ export const EditorINPMetrics = () => {
|
|
|
16
20
|
}) => {
|
|
17
21
|
const interaction = getActiveInteraction();
|
|
18
22
|
const ufoName = interaction === null || interaction === void 0 ? void 0 : interaction.ufoName;
|
|
19
|
-
|
|
23
|
+
let editorDomSize;
|
|
24
|
+
if (expValEquals('platform_editor_dom_node_count', 'isEnabled', true)) {
|
|
25
|
+
const editorView = editorViewRef.current;
|
|
26
|
+
if (editorView) {
|
|
27
|
+
editorDomSize = getEditorDomSize(editorView);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
sendAnalytics(analyticsEvents.createAnalyticsEvent, value, ufoName, editorDomSize);
|
|
20
31
|
});
|
|
21
32
|
});
|
|
22
33
|
|
|
@@ -34,7 +45,7 @@ export const EditorINPMetrics = () => {
|
|
|
34
45
|
// This component doesn't render anything
|
|
35
46
|
return null;
|
|
36
47
|
};
|
|
37
|
-
const sendAnalytics = debounce((createAnalyticsEvent, value, ufoName) => {
|
|
48
|
+
const sendAnalytics = debounce((createAnalyticsEvent, value, ufoName, editorDomSize) => {
|
|
38
49
|
fireAnalyticsEvent(createAnalyticsEvent)({
|
|
39
50
|
payload: {
|
|
40
51
|
// @ts-expect-error Temporary data
|
|
@@ -43,7 +54,8 @@ const sendAnalytics = debounce((createAnalyticsEvent, value, ufoName) => {
|
|
|
43
54
|
eventType: EVENT_TYPE.TRACK,
|
|
44
55
|
attributes: {
|
|
45
56
|
inp: value,
|
|
46
|
-
ufoName
|
|
57
|
+
ufoName,
|
|
58
|
+
editorDomSize
|
|
47
59
|
}
|
|
48
60
|
}
|
|
49
61
|
});
|
|
@@ -24,12 +24,14 @@ import { EditorSSRRenderer } from '@atlaskit/editor-ssr-renderer';
|
|
|
24
24
|
import { createSSREditorState } from '@atlaskit/editor-ssr-renderer/create-ssr-editor-state';
|
|
25
25
|
import { createSSRPMPlugins } from '@atlaskit/editor-ssr-renderer/create-ssr-pm-plugins';
|
|
26
26
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
27
|
+
import { addUFOCustomData } from '@atlaskit/react-ufo/custom-data';
|
|
27
28
|
import { getInteractionId } from '@atlaskit/react-ufo/interaction-id-context';
|
|
28
29
|
import { abortAll, getActiveInteraction } from '@atlaskit/react-ufo/interaction-metrics';
|
|
29
30
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
30
31
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
31
32
|
import { useProviders } from '../composable-editor/hooks/useProviders';
|
|
32
33
|
import { createFeatureFlagsFromProps } from '../utils/feature-flags-from-props';
|
|
34
|
+
import { getEditorDomSize } from '../utils/getEditorDomSize';
|
|
33
35
|
import { getNodesCountWithExtensionKeys } from '../utils/getNodesCountWithExtensionKeys';
|
|
34
36
|
import { getNodesVisibleInViewport } from '../utils/getNodesVisibleInViewport';
|
|
35
37
|
import { isChromeless } from '../utils/is-chromeless';
|
|
@@ -684,6 +686,7 @@ export function ReactEditorView(props) {
|
|
|
684
686
|
}
|
|
685
687
|
})()
|
|
686
688
|
} : {};
|
|
689
|
+
const editorDomSize = expValEquals('platform_editor_dom_node_count', 'isEnabled', true) ? getEditorDomSize(viewRef.current) : undefined;
|
|
687
690
|
const interaction = getActiveInteraction();
|
|
688
691
|
const pageLoadType = interaction === null || interaction === void 0 ? void 0 : interaction.type;
|
|
689
692
|
const pageType = interaction === null || interaction === void 0 ? void 0 : interaction.routeName;
|
|
@@ -708,6 +711,7 @@ export function ReactEditorView(props) {
|
|
|
708
711
|
nodeSize,
|
|
709
712
|
nodeSizeBucket,
|
|
710
713
|
totalNodes,
|
|
714
|
+
editorDomSize,
|
|
711
715
|
ttfb,
|
|
712
716
|
severity: proseMirrorRenderedSeverity,
|
|
713
717
|
objectId: contextIdentifier === null || contextIdentifier === void 0 ? void 0 : contextIdentifier.objectId,
|
|
@@ -718,6 +722,11 @@ export function ReactEditorView(props) {
|
|
|
718
722
|
extensionKeys,
|
|
719
723
|
ufoInteractionId: getInteractionId().current
|
|
720
724
|
};
|
|
725
|
+
if (editorDomSize !== undefined) {
|
|
726
|
+
addUFOCustomData({
|
|
727
|
+
editorDomSize
|
|
728
|
+
});
|
|
729
|
+
}
|
|
721
730
|
dispatchAnalyticsEvent({
|
|
722
731
|
action: ACTION.PROSEMIRROR_RENDERED,
|
|
723
732
|
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the total number of DOM elements inside the editor's content DOM,
|
|
3
|
+
* used as a proxy for document complexity in performance events.
|
|
4
|
+
*
|
|
5
|
+
* Uses the native `getElementsByTagName('*')`, which counts descendants
|
|
6
|
+
* iteratively in the browser engine — intentionally not a recursive JS walk, so
|
|
7
|
+
* it can't overflow the stack on very large documents.
|
|
8
|
+
*/
|
|
9
|
+
export function getEditorDomSize(view) {
|
|
10
|
+
return view.dom.getElementsByTagName('*').length;
|
|
11
|
+
}
|
|
@@ -45,6 +45,7 @@ function Editor(passedProps) {
|
|
|
45
45
|
var editorActions = editorContext.editorActions || editorActionsPlaceholderInstance;
|
|
46
46
|
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
47
47
|
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
48
|
+
var editorViewRef = useRef(null);
|
|
48
49
|
var handleAnalyticsEvent = useCallback(function (data) {
|
|
49
50
|
fireAnalyticsEvent(createAnalyticsEvent)(data);
|
|
50
51
|
}, [createAnalyticsEvent]);
|
|
@@ -59,6 +60,7 @@ function Editor(passedProps) {
|
|
|
59
60
|
contextIdentifierProvider = _propsRef$current.contextIdentifierProvider,
|
|
60
61
|
onEditorReady = _propsRef$current.onEditorReady,
|
|
61
62
|
featureFlags = _propsRef$current.featureFlags;
|
|
63
|
+
editorViewRef.current = instance.view;
|
|
62
64
|
editorActions._privateRegisterEditor(instance.view, instance.eventDispatcher, instance.transformer, getFeatureFlagsFromRef);
|
|
63
65
|
if (onEditorReady) {
|
|
64
66
|
startMeasure(measurements.ON_EDITOR_READY_CALLBACK);
|
|
@@ -71,6 +73,7 @@ function Editor(passedProps) {
|
|
|
71
73
|
}, [editorActions, createAnalyticsEvent, getFeatureFlagsFromRef, propsRef]);
|
|
72
74
|
var onEditorDestroyed = useCallback(function (_instance) {
|
|
73
75
|
var onDestroy = propsRef.current.onDestroy;
|
|
76
|
+
editorViewRef.current = null;
|
|
74
77
|
editorActions._privateUnregisterEditor();
|
|
75
78
|
if (onDestroy) {
|
|
76
79
|
onDestroy();
|
|
@@ -85,7 +88,9 @@ function Editor(passedProps) {
|
|
|
85
88
|
}
|
|
86
89
|
}, [onSaveFromProps]);
|
|
87
90
|
var isFullPageAppearance = Boolean(props.appearance && ['full-page', 'full-width'].concat(_toConsumableArray(editorExperiment('platform_synced_block', true) ? ['max'] : [])).includes(props.appearance));
|
|
88
|
-
return /*#__PURE__*/React.createElement(Fragment, null, isFullPageAppearance ? /*#__PURE__*/React.createElement(EditorINPMetrics,
|
|
91
|
+
return /*#__PURE__*/React.createElement(Fragment, null, isFullPageAppearance ? /*#__PURE__*/React.createElement(EditorINPMetrics, {
|
|
92
|
+
editorViewRef: editorViewRef
|
|
93
|
+
}) : null, /*#__PURE__*/React.createElement(EditorInternal, {
|
|
89
94
|
props: props,
|
|
90
95
|
handleAnalyticsEvent: handleAnalyticsEvent,
|
|
91
96
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
@@ -4,18 +4,28 @@ import { useAnalyticsEvents } from '@atlaskit/analytics-next/useAnalyticsEvents'
|
|
|
4
4
|
import { ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { setupINPTracking } from '@atlaskit/editor-performance-metrics/inp';
|
|
6
6
|
import { getActiveInteraction } from '@atlaskit/react-ufo/interaction-metrics';
|
|
7
|
-
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
|
+
import { getEditorDomSize } from '../utils/getEditorDomSize';
|
|
9
|
+
export var EditorINPMetrics = function EditorINPMetrics(_ref) {
|
|
10
|
+
var editorViewRef = _ref.editorViewRef;
|
|
8
11
|
var analyticsEvents = useAnalyticsEvents();
|
|
9
12
|
|
|
10
13
|
// onMount lifecycle hook
|
|
11
14
|
useEffect(function () {
|
|
12
15
|
var cleanupFn;
|
|
13
16
|
var cleanupIdleCallback = createIdleCallback(function () {
|
|
14
|
-
cleanupFn = setupINPTracking(function (
|
|
15
|
-
var value =
|
|
17
|
+
cleanupFn = setupINPTracking(function (_ref2) {
|
|
18
|
+
var value = _ref2.value;
|
|
16
19
|
var interaction = getActiveInteraction();
|
|
17
20
|
var ufoName = interaction === null || interaction === void 0 ? void 0 : interaction.ufoName;
|
|
18
|
-
|
|
21
|
+
var editorDomSize;
|
|
22
|
+
if (expValEquals('platform_editor_dom_node_count', 'isEnabled', true)) {
|
|
23
|
+
var editorView = editorViewRef.current;
|
|
24
|
+
if (editorView) {
|
|
25
|
+
editorDomSize = getEditorDomSize(editorView);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
sendAnalytics(analyticsEvents.createAnalyticsEvent, value, ufoName, editorDomSize);
|
|
19
29
|
});
|
|
20
30
|
});
|
|
21
31
|
|
|
@@ -33,7 +43,7 @@ export var EditorINPMetrics = function EditorINPMetrics() {
|
|
|
33
43
|
// This component doesn't render anything
|
|
34
44
|
return null;
|
|
35
45
|
};
|
|
36
|
-
var sendAnalytics = debounce(function (createAnalyticsEvent, value, ufoName) {
|
|
46
|
+
var sendAnalytics = debounce(function (createAnalyticsEvent, value, ufoName, editorDomSize) {
|
|
37
47
|
fireAnalyticsEvent(createAnalyticsEvent)({
|
|
38
48
|
payload: {
|
|
39
49
|
// @ts-expect-error Temporary data
|
|
@@ -42,7 +52,8 @@ var sendAnalytics = debounce(function (createAnalyticsEvent, value, ufoName) {
|
|
|
42
52
|
eventType: EVENT_TYPE.TRACK,
|
|
43
53
|
attributes: {
|
|
44
54
|
inp: value,
|
|
45
|
-
ufoName: ufoName
|
|
55
|
+
ufoName: ufoName,
|
|
56
|
+
editorDomSize: editorDomSize
|
|
46
57
|
}
|
|
47
58
|
}
|
|
48
59
|
});
|
|
@@ -32,12 +32,14 @@ import { EditorSSRRenderer } from '@atlaskit/editor-ssr-renderer';
|
|
|
32
32
|
import { createSSREditorState } from '@atlaskit/editor-ssr-renderer/create-ssr-editor-state';
|
|
33
33
|
import { createSSRPMPlugins } from '@atlaskit/editor-ssr-renderer/create-ssr-pm-plugins';
|
|
34
34
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
35
|
+
import { addUFOCustomData } from '@atlaskit/react-ufo/custom-data';
|
|
35
36
|
import { getInteractionId } from '@atlaskit/react-ufo/interaction-id-context';
|
|
36
37
|
import { abortAll, getActiveInteraction } from '@atlaskit/react-ufo/interaction-metrics';
|
|
37
38
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
38
39
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
39
40
|
import { useProviders } from '../composable-editor/hooks/useProviders';
|
|
40
41
|
import { createFeatureFlagsFromProps } from '../utils/feature-flags-from-props';
|
|
42
|
+
import { getEditorDomSize } from '../utils/getEditorDomSize';
|
|
41
43
|
import { getNodesCountWithExtensionKeys } from '../utils/getNodesCountWithExtensionKeys';
|
|
42
44
|
import { getNodesVisibleInViewport } from '../utils/getNodesVisibleInViewport';
|
|
43
45
|
import { isChromeless } from '../utils/is-chromeless';
|
|
@@ -724,6 +726,7 @@ export function ReactEditorView(props) {
|
|
|
724
726
|
} : {},
|
|
725
727
|
totalNodes = _ref4.totalNodes,
|
|
726
728
|
nodeSizeBucket = _ref4.nodeSizeBucket;
|
|
729
|
+
var editorDomSize = expValEquals('platform_editor_dom_node_count', 'isEnabled', true) ? getEditorDomSize(viewRef.current) : undefined;
|
|
727
730
|
var interaction = getActiveInteraction();
|
|
728
731
|
var pageLoadType = interaction === null || interaction === void 0 ? void 0 : interaction.type;
|
|
729
732
|
var pageType = interaction === null || interaction === void 0 ? void 0 : interaction.routeName;
|
|
@@ -748,6 +751,7 @@ export function ReactEditorView(props) {
|
|
|
748
751
|
nodeSize: nodeSize,
|
|
749
752
|
nodeSizeBucket: nodeSizeBucket,
|
|
750
753
|
totalNodes: totalNodes,
|
|
754
|
+
editorDomSize: editorDomSize,
|
|
751
755
|
ttfb: ttfb,
|
|
752
756
|
severity: proseMirrorRenderedSeverity,
|
|
753
757
|
objectId: contextIdentifier === null || contextIdentifier === void 0 ? void 0 : contextIdentifier.objectId,
|
|
@@ -758,6 +762,11 @@ export function ReactEditorView(props) {
|
|
|
758
762
|
extensionKeys: extensionKeys,
|
|
759
763
|
ufoInteractionId: getInteractionId().current
|
|
760
764
|
};
|
|
765
|
+
if (editorDomSize !== undefined) {
|
|
766
|
+
addUFOCustomData({
|
|
767
|
+
editorDomSize: editorDomSize
|
|
768
|
+
});
|
|
769
|
+
}
|
|
761
770
|
dispatchAnalyticsEvent({
|
|
762
771
|
action: ACTION.PROSEMIRROR_RENDERED,
|
|
763
772
|
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the total number of DOM elements inside the editor's content DOM,
|
|
3
|
+
* used as a proxy for document complexity in performance events.
|
|
4
|
+
*
|
|
5
|
+
* Uses the native `getElementsByTagName('*')`, which counts descendants
|
|
6
|
+
* iteratively in the browser engine — intentionally not a recursive JS walk, so
|
|
7
|
+
* it can't overflow the stack on very large documents.
|
|
8
|
+
*/
|
|
9
|
+
export function getEditorDomSize(view) {
|
|
10
|
+
return view.dom.getElementsByTagName('*').length;
|
|
11
|
+
}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
type EditorINPMetricsProps = {
|
|
4
|
+
editorViewRef: RefObject<EditorView | null>;
|
|
5
|
+
};
|
|
6
|
+
export declare const EditorINPMetrics: ({ editorViewRef }: EditorINPMetricsProps) => null;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the total number of DOM elements inside the editor's content DOM,
|
|
4
|
+
* used as a proxy for document complexity in performance events.
|
|
5
|
+
*
|
|
6
|
+
* Uses the native `getElementsByTagName('*')`, which counts descendants
|
|
7
|
+
* iteratively in the browser engine — intentionally not a recursive JS walk, so
|
|
8
|
+
* it can't overflow the stack on very large documents.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getEditorDomSize(view: EditorView): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "221.
|
|
3
|
+
"version": "221.9.0",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@atlaskit/react-ufo": "^7.3.0",
|
|
69
69
|
"@atlaskit/task-decision": "^21.4.0",
|
|
70
70
|
"@atlaskit/tmp-editor-statsig": "^124.2.0",
|
|
71
|
-
"@atlaskit/tokens": "^15.
|
|
71
|
+
"@atlaskit/tokens": "^15.7.0",
|
|
72
72
|
"@atlaskit/tooltip": "^23.1.0",
|
|
73
73
|
"@atlaskit/width-detector": "^6.2.0",
|
|
74
74
|
"@babel/runtime": "^7.0.0",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"uuid": "^3.1.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
|
-
"@atlaskit/editor-common": "^116.
|
|
88
|
+
"@atlaskit/editor-common": "^116.27.0",
|
|
89
89
|
"@atlaskit/link-provider": "^5.2.0",
|
|
90
90
|
"@atlaskit/media-core": "^38.0.0",
|
|
91
91
|
"react": "^18.2.0",
|