@atlaskit/insm 1.2.12 → 2.0.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 +23 -0
- package/api/package.json +7 -0
- package/compass.yml +3 -3
- package/dist/cjs/api.js +77 -0
- package/dist/cjs/dom-element-count.js +16 -0
- package/dist/cjs/editor-dom-registry.js +65 -0
- package/dist/cjs/index.js +11 -60
- package/dist/cjs/insm-session.js +6 -2
- package/dist/cjs/insm.js +52 -2
- package/dist/es2019/api.js +70 -0
- package/dist/es2019/dom-element-count.js +10 -0
- package/dist/es2019/editor-dom-registry.js +45 -0
- package/dist/es2019/index.js +5 -60
- package/dist/es2019/insm-session.js +6 -0
- package/dist/es2019/insm.js +46 -2
- package/dist/esm/api.js +70 -0
- package/dist/esm/dom-element-count.js +10 -0
- package/dist/esm/editor-dom-registry.js +58 -0
- package/dist/esm/index.js +5 -60
- package/dist/esm/insm-session.js +6 -2
- package/dist/esm/insm.js +52 -2
- package/dist/types/api.d.ts +13 -0
- package/dist/types/dom-element-count.d.ts +8 -0
- package/dist/types/editor-dom-registry.d.ts +33 -0
- package/dist/types/index.d.ts +1 -13
- package/dist/types/insm.d.ts +34 -2
- package/package.json +4 -2
- package/dist/cjs/period-measurers/afps.js +0 -193
- package/dist/es2019/period-measurers/afps.js +0 -153
- package/dist/esm/period-measurers/afps.js +0 -186
- package/dist/types/period-measurers/afps.d.ts +0 -57
package/dist/es2019/insm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { countDomElements } from './dom-element-count';
|
|
3
|
+
import { EditorDomRegistry } from './editor-dom-registry';
|
|
2
4
|
import { INSMSession } from './insm-session';
|
|
3
|
-
import { AnimationFPSIM } from './period-measurers/afps';
|
|
4
5
|
import { INPTracker } from './inp-measurers/inp';
|
|
5
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
7
|
export class INSM {
|
|
@@ -11,7 +12,12 @@ export class INSM {
|
|
|
11
12
|
* page session.
|
|
12
13
|
*/
|
|
13
14
|
_defineProperty(this, "runningHeavyTasks", new Set());
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The editor is tracked at the insm layer (rather than per session) as it can
|
|
17
|
+
* outlive, or be mounted after, the session it is measured by.
|
|
18
|
+
*/
|
|
19
|
+
_defineProperty(this, "editorDomRegistry", new EditorDomRegistry());
|
|
20
|
+
this.periodMeasurers = [new INPTracker()];
|
|
15
21
|
this.options = options;
|
|
16
22
|
|
|
17
23
|
// If this does throw -- we do want an unhandledRejection rejection to be passed to the window
|
|
@@ -72,6 +78,44 @@ export class INSM {
|
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Registers the page editor's content DOM element (`editorView.dom`) with insm.
|
|
83
|
+
*
|
|
84
|
+
* insm does not locate the editor itself - the element is provided by the editor so
|
|
85
|
+
* that session events can report its DOM element count (`editorDomSize`).
|
|
86
|
+
*
|
|
87
|
+
* A session measures a page, so only the page's own editor should register. Secondary
|
|
88
|
+
* editors (inline comments, nested legacy content extensions) must not, as the
|
|
89
|
+
* reported size would then depend on which editor registered last.
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* insm.registerEditorDom(editorView.dom);
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
registerEditorDom(editorDom) {
|
|
96
|
+
this.editorDomRegistry.register(editorDom);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Unregisters the editor's content DOM element. This is expected to be called when
|
|
101
|
+
* the editor is destroyed.
|
|
102
|
+
*/
|
|
103
|
+
unregisterEditorDom(editorDom) {
|
|
104
|
+
this.editorDomRegistry.unregister(editorDom);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The number of DOM elements inside the registered editor, used as a proxy for
|
|
109
|
+
* document complexity in performance events.
|
|
110
|
+
*
|
|
111
|
+
* Undefined when no editor is registered, or the registered one is no longer in
|
|
112
|
+
* the document.
|
|
113
|
+
*/
|
|
114
|
+
getEditorDomSize() {
|
|
115
|
+
const editorDom = this.editorDomRegistry.editorDom;
|
|
116
|
+
return editorDom ? countDomElements(editorDom) : undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
75
119
|
/**
|
|
76
120
|
* Call this when starting a new experience. This is expected to be wired to the product
|
|
77
121
|
* routing solution.
|
package/dist/esm/api.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { INSM } from './insm';
|
|
2
|
+
var initialisedInsm;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Initializes the INSM (Interactivity Session Measurement) tooling
|
|
6
|
+
*/
|
|
7
|
+
export function init(options) {
|
|
8
|
+
initialisedInsm = new INSM(options);
|
|
9
|
+
}
|
|
10
|
+
function insmInitialised() {
|
|
11
|
+
if (!initialisedInsm) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* **In**teractivity **s**ession **m**onitoring
|
|
19
|
+
*/
|
|
20
|
+
export var insm = {
|
|
21
|
+
startHeavyTask: function startHeavyTask(heavyTaskName) {
|
|
22
|
+
if (insmInitialised()) {
|
|
23
|
+
initialisedInsm.startHeavyTask(heavyTaskName);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
endHeavyTask: function endHeavyTask(heavyTaskName) {
|
|
27
|
+
if (insmInitialised()) {
|
|
28
|
+
initialisedInsm.endHeavyTask(heavyTaskName);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
registerEditorDom: function registerEditorDom(editorDom) {
|
|
32
|
+
if (insmInitialised()) {
|
|
33
|
+
initialisedInsm.registerEditorDom(editorDom);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
unregisterEditorDom: function unregisterEditorDom(editorDom) {
|
|
37
|
+
if (insmInitialised()) {
|
|
38
|
+
initialisedInsm.unregisterEditorDom(editorDom);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
start: function start(experienceKey, experienceProperties) {
|
|
42
|
+
if (insmInitialised()) {
|
|
43
|
+
initialisedInsm.start(experienceKey, experienceProperties);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
overrideExperienceKey: function overrideExperienceKey(experienceKey) {
|
|
47
|
+
if (insmInitialised()) {
|
|
48
|
+
initialisedInsm.overrideExperienceKey(experienceKey);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
stopEarly: function stopEarly(reasonKey, description) {
|
|
52
|
+
if (insmInitialised()) {
|
|
53
|
+
initialisedInsm.stopEarly(reasonKey, description);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
// We only expose details and feature start/stop to consumers
|
|
57
|
+
// as the other properties are internals for the insm and InsmPeriod
|
|
58
|
+
// to interact with the running session.
|
|
59
|
+
get session() {
|
|
60
|
+
if (insmInitialised()) {
|
|
61
|
+
return initialisedInsm.runningSession;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
// @ts-expect-error Private method for testing purposes
|
|
65
|
+
__setAnalyticsWebClient: function __setAnalyticsWebClient(analyticsWebClient) {
|
|
66
|
+
if (initialisedInsm) {
|
|
67
|
+
initialisedInsm.analyticsWebClient = analyticsWebClient;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the total number of DOM elements inside the given element.
|
|
3
|
+
*
|
|
4
|
+
* Uses the native `getElementsByTagName('*')`, which counts descendants iteratively in the
|
|
5
|
+
* browser engine -- intentionally not a recursive JS walk, so it can't overflow the stack on
|
|
6
|
+
* very large documents.
|
|
7
|
+
*/
|
|
8
|
+
export function countDomElements(element) {
|
|
9
|
+
return element.getElementsByTagName('*').length;
|
|
10
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
/**
|
|
4
|
+
* Holds the page editor's content DOM.
|
|
5
|
+
*
|
|
6
|
+
* insm holds no reference to the editor, so the element is registered from the outside — it is
|
|
7
|
+
* the same `editorView.dom` element the editor measures for the `editorDomSize` attribute on
|
|
8
|
+
* its INP event.
|
|
9
|
+
*
|
|
10
|
+
* Only the page editor registers itself: an insm session measures a page, and secondary
|
|
11
|
+
* editors on the page (inline comments, nested legacy content extensions) would make the
|
|
12
|
+
* registration ambiguous.
|
|
13
|
+
*
|
|
14
|
+
* The element is held via a `WeakRef` so a destroyed editor's DOM can be collected even if
|
|
15
|
+
* `unregister` is never reached.
|
|
16
|
+
*/
|
|
17
|
+
export var EditorDomRegistry = /*#__PURE__*/function () {
|
|
18
|
+
function EditorDomRegistry() {
|
|
19
|
+
_classCallCheck(this, EditorDomRegistry);
|
|
20
|
+
}
|
|
21
|
+
return _createClass(EditorDomRegistry, [{
|
|
22
|
+
key: "register",
|
|
23
|
+
value:
|
|
24
|
+
/**
|
|
25
|
+
* Registers the page editor's content DOM element (`editorView.dom`).
|
|
26
|
+
*/
|
|
27
|
+
function register(editorDom) {
|
|
28
|
+
this.registered = new WeakRef(editorDom);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Unregisters an editor's content DOM element. Expected to be called when the editor is
|
|
33
|
+
* destroyed. Ignored when a different editor is currently registered, so an editor being
|
|
34
|
+
* torn down after its replacement registered does not clear the newer one.
|
|
35
|
+
*/
|
|
36
|
+
}, {
|
|
37
|
+
key: "unregister",
|
|
38
|
+
value: function unregister(editorDom) {
|
|
39
|
+
var _this$registered;
|
|
40
|
+
if (((_this$registered = this.registered) === null || _this$registered === void 0 ? void 0 : _this$registered.deref()) === editorDom) {
|
|
41
|
+
this.registered = undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The registered editor's content DOM, or undefined when no editor is registered or the
|
|
47
|
+
* registered one is no longer in the document -- ie. an experience without a page editor,
|
|
48
|
+
* or a session which outlived the editor.
|
|
49
|
+
*/
|
|
50
|
+
}, {
|
|
51
|
+
key: "editorDom",
|
|
52
|
+
get: function get() {
|
|
53
|
+
var _this$registered2;
|
|
54
|
+
var editorDom = (_this$registered2 = this.registered) === null || _this$registered2 === void 0 ? void 0 : _this$registered2.deref();
|
|
55
|
+
return editorDom !== null && editorDom !== void 0 && editorDom.isConnected ? editorDom : undefined;
|
|
56
|
+
}
|
|
57
|
+
}]);
|
|
58
|
+
}();
|
package/dist/esm/index.js
CHANGED
|
@@ -1,60 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export function init(options) {
|
|
8
|
-
initialisedInsm = new INSM(options);
|
|
9
|
-
}
|
|
10
|
-
function insmInitialised() {
|
|
11
|
-
if (!initialisedInsm) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* **In**teractivity **s**ession **m**onitoring
|
|
19
|
-
*/
|
|
20
|
-
export var insm = {
|
|
21
|
-
startHeavyTask: function startHeavyTask(heavyTaskName) {
|
|
22
|
-
if (insmInitialised()) {
|
|
23
|
-
initialisedInsm.startHeavyTask(heavyTaskName);
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
endHeavyTask: function endHeavyTask(heavyTaskName) {
|
|
27
|
-
if (insmInitialised()) {
|
|
28
|
-
initialisedInsm.endHeavyTask(heavyTaskName);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
start: function start(experienceKey, experienceProperties) {
|
|
32
|
-
if (insmInitialised()) {
|
|
33
|
-
initialisedInsm.start(experienceKey, experienceProperties);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
overrideExperienceKey: function overrideExperienceKey(experienceKey) {
|
|
37
|
-
if (insmInitialised()) {
|
|
38
|
-
initialisedInsm.overrideExperienceKey(experienceKey);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
stopEarly: function stopEarly(reasonKey, description) {
|
|
42
|
-
if (insmInitialised()) {
|
|
43
|
-
initialisedInsm.stopEarly(reasonKey, description);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
// We only expose details and feature start/stop to consumers
|
|
47
|
-
// as the other properties are internals for the insm and InsmPeriod
|
|
48
|
-
// to interact with the running session.
|
|
49
|
-
get session() {
|
|
50
|
-
if (insmInitialised()) {
|
|
51
|
-
return initialisedInsm.runningSession;
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
// @ts-expect-error Private method for testing purposes
|
|
55
|
-
__setAnalyticsWebClient: function __setAnalyticsWebClient(analyticsWebClient) {
|
|
56
|
-
if (initialisedInsm) {
|
|
57
|
-
initialisedInsm.analyticsWebClient = analyticsWebClient;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
1
|
+
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
|
+
// Entry file in package.json
|
|
3
|
+
// Barrel kept for existing consumers -- new call sites should import from the
|
|
4
|
+
// `@atlaskit/insm/api` entry point instead.
|
|
5
|
+
export { init, insm } from './api';
|
package/dist/esm/insm-session.js
CHANGED
|
@@ -7,6 +7,7 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
7
7
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
8
8
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9
9
|
import Bowser from 'bowser-ultralight';
|
|
10
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
10
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
12
|
import { PeriodTracking } from './insm-period';
|
|
12
13
|
import { LongAnimationFrameMeasurer } from './session-measurers/LongAnimationFrameMeasurer';
|
|
@@ -198,11 +199,14 @@ export var INSMSession = /*#__PURE__*/function () {
|
|
|
198
199
|
var operationalEvent = {
|
|
199
200
|
actionSubject: 'insm',
|
|
200
201
|
action: 'measured',
|
|
201
|
-
attributes: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, this.staticProperties), evaluatedAddedProperties), {}, {
|
|
202
|
+
attributes: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, this.staticProperties), evaluatedAddedProperties), {}, {
|
|
202
203
|
'event:population': this.insm.options.population,
|
|
203
204
|
experienceKey: this.experienceKey,
|
|
204
205
|
initial: this.experienceProperties.initial,
|
|
205
|
-
contentId: this.experienceProperties.contentId
|
|
206
|
+
contentId: this.experienceProperties.contentId
|
|
207
|
+
}, isExperimentEnabled('platform_editor_insm_dom_node_count') ? {
|
|
208
|
+
editorDomSize: this.insm.getEditorDomSize()
|
|
209
|
+
} : {}), {}, {
|
|
206
210
|
timing: {
|
|
207
211
|
startedAt: this.startedAt,
|
|
208
212
|
// Note: this will not match up with the periods sum of durations, as it includes
|
package/dist/esm/insm.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import { countDomElements } from './dom-element-count';
|
|
5
|
+
import { EditorDomRegistry } from './editor-dom-registry';
|
|
4
6
|
import { INSMSession } from './insm-session';
|
|
5
|
-
import { AnimationFPSIM } from './period-measurers/afps';
|
|
6
7
|
import { INPTracker } from './inp-measurers/inp';
|
|
7
8
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
9
|
export var INSM = /*#__PURE__*/function () {
|
|
@@ -15,7 +16,12 @@ export var INSM = /*#__PURE__*/function () {
|
|
|
15
16
|
* page session.
|
|
16
17
|
*/
|
|
17
18
|
_defineProperty(this, "runningHeavyTasks", new Set());
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The editor is tracked at the insm layer (rather than per session) as it can
|
|
21
|
+
* outlive, or be mounted after, the session it is measured by.
|
|
22
|
+
*/
|
|
23
|
+
_defineProperty(this, "editorDomRegistry", new EditorDomRegistry());
|
|
24
|
+
this.periodMeasurers = [new INPTracker()];
|
|
19
25
|
this.options = options;
|
|
20
26
|
|
|
21
27
|
// If this does throw -- we do want an unhandledRejection rejection to be passed to the window
|
|
@@ -82,6 +88,50 @@ export var INSM = /*#__PURE__*/function () {
|
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Registers the page editor's content DOM element (`editorView.dom`) with insm.
|
|
93
|
+
*
|
|
94
|
+
* insm does not locate the editor itself - the element is provided by the editor so
|
|
95
|
+
* that session events can report its DOM element count (`editorDomSize`).
|
|
96
|
+
*
|
|
97
|
+
* A session measures a page, so only the page's own editor should register. Secondary
|
|
98
|
+
* editors (inline comments, nested legacy content extensions) must not, as the
|
|
99
|
+
* reported size would then depend on which editor registered last.
|
|
100
|
+
*
|
|
101
|
+
* ```ts
|
|
102
|
+
* insm.registerEditorDom(editorView.dom);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
}, {
|
|
106
|
+
key: "registerEditorDom",
|
|
107
|
+
value: function registerEditorDom(editorDom) {
|
|
108
|
+
this.editorDomRegistry.register(editorDom);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Unregisters the editor's content DOM element. This is expected to be called when
|
|
113
|
+
* the editor is destroyed.
|
|
114
|
+
*/
|
|
115
|
+
}, {
|
|
116
|
+
key: "unregisterEditorDom",
|
|
117
|
+
value: function unregisterEditorDom(editorDom) {
|
|
118
|
+
this.editorDomRegistry.unregister(editorDom);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The number of DOM elements inside the registered editor, used as a proxy for
|
|
123
|
+
* document complexity in performance events.
|
|
124
|
+
*
|
|
125
|
+
* Undefined when no editor is registered, or the registered one is no longer in
|
|
126
|
+
* the document.
|
|
127
|
+
*/
|
|
128
|
+
}, {
|
|
129
|
+
key: "getEditorDomSize",
|
|
130
|
+
value: function getEditorDomSize() {
|
|
131
|
+
var editorDom = this.editorDomRegistry.editorDom;
|
|
132
|
+
return editorDom ? countDomElements(editorDom) : undefined;
|
|
133
|
+
}
|
|
134
|
+
|
|
85
135
|
/**
|
|
86
136
|
* Call this when starting a new experience. This is expected to be wired to the product
|
|
87
137
|
* routing solution.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { INSMOptions } from './types';
|
|
2
|
+
import type { INSMSession } from './insm-session';
|
|
3
|
+
import { INSM } from './insm';
|
|
4
|
+
/**
|
|
5
|
+
* Initializes the INSM (Interactivity Session Measurement) tooling
|
|
6
|
+
*/
|
|
7
|
+
export declare function init(options: INSMOptions): void;
|
|
8
|
+
/**
|
|
9
|
+
* **In**teractivity **s**ession **m**onitoring
|
|
10
|
+
*/
|
|
11
|
+
export declare const insm: Pick<INSM, 'start' | 'stopEarly' | 'startHeavyTask' | 'endHeavyTask' | 'overrideExperienceKey' | 'registerEditorDom' | 'unregisterEditorDom'> & {
|
|
12
|
+
session: Pick<INSMSession, 'details' | 'startFeature' | 'endFeature' | 'addProperties' | 'setProperty'> | undefined;
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the total number of DOM elements inside the given element.
|
|
3
|
+
*
|
|
4
|
+
* Uses the native `getElementsByTagName('*')`, which counts descendants iteratively in the
|
|
5
|
+
* browser engine -- intentionally not a recursive JS walk, so it can't overflow the stack on
|
|
6
|
+
* very large documents.
|
|
7
|
+
*/
|
|
8
|
+
export declare function countDomElements(element: Element): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Holds the page editor's content DOM.
|
|
3
|
+
*
|
|
4
|
+
* insm holds no reference to the editor, so the element is registered from the outside — it is
|
|
5
|
+
* the same `editorView.dom` element the editor measures for the `editorDomSize` attribute on
|
|
6
|
+
* its INP event.
|
|
7
|
+
*
|
|
8
|
+
* Only the page editor registers itself: an insm session measures a page, and secondary
|
|
9
|
+
* editors on the page (inline comments, nested legacy content extensions) would make the
|
|
10
|
+
* registration ambiguous.
|
|
11
|
+
*
|
|
12
|
+
* The element is held via a `WeakRef` so a destroyed editor's DOM can be collected even if
|
|
13
|
+
* `unregister` is never reached.
|
|
14
|
+
*/
|
|
15
|
+
export declare class EditorDomRegistry {
|
|
16
|
+
private registered;
|
|
17
|
+
/**
|
|
18
|
+
* Registers the page editor's content DOM element (`editorView.dom`).
|
|
19
|
+
*/
|
|
20
|
+
register(editorDom: HTMLElement): void;
|
|
21
|
+
/**
|
|
22
|
+
* Unregisters an editor's content DOM element. Expected to be called when the editor is
|
|
23
|
+
* destroyed. Ignored when a different editor is currently registered, so an editor being
|
|
24
|
+
* torn down after its replacement registered does not clear the newer one.
|
|
25
|
+
*/
|
|
26
|
+
unregister(editorDom: HTMLElement): void;
|
|
27
|
+
/**
|
|
28
|
+
* The registered editor's content DOM, or undefined when no editor is registered or the
|
|
29
|
+
* registered one is no longer in the document -- ie. an experience without a page editor,
|
|
30
|
+
* or a session which outlived the editor.
|
|
31
|
+
*/
|
|
32
|
+
get editorDom(): HTMLElement | undefined;
|
|
33
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { INSMSession } from './insm-session';
|
|
3
|
-
import { INSM } from './insm';
|
|
4
|
-
/**
|
|
5
|
-
* Initializes the INSM (Interactivity Session Measurement) tooling
|
|
6
|
-
*/
|
|
7
|
-
export declare function init(options: INSMOptions): void;
|
|
8
|
-
/**
|
|
9
|
-
* **In**teractivity **s**ession **m**onitoring
|
|
10
|
-
*/
|
|
11
|
-
export declare const insm: Pick<INSM, 'start' | 'stopEarly' | 'startHeavyTask' | 'endHeavyTask' | 'overrideExperienceKey'> & {
|
|
12
|
-
session: Pick<INSMSession, 'details' | 'startFeature' | 'endFeature' | 'addProperties' | 'setProperty'> | undefined;
|
|
13
|
-
};
|
|
1
|
+
export { init, insm } from './api';
|
package/dist/types/insm.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
2
2
|
import { INSMSession } from './insm-session';
|
|
3
3
|
import type { ExperienceProperties, INSMOptions } from './types';
|
|
4
|
-
import { AnimationFPSIM } from './period-measurers/afps';
|
|
5
4
|
import { INPTracker } from './inp-measurers/inp';
|
|
6
5
|
export declare class INSM {
|
|
7
6
|
analyticsWebClient?: AnalyticsWebClient;
|
|
8
7
|
runningSession?: INSMSession;
|
|
9
8
|
options: INSMOptions;
|
|
10
|
-
periodMeasurers: [
|
|
9
|
+
periodMeasurers: [INPTracker];
|
|
11
10
|
/**
|
|
12
11
|
* Heavy tasks are tracked at the insm layer as heavy tasks
|
|
13
12
|
* are expected at times to be unrelated to the current
|
|
14
13
|
* page session.
|
|
15
14
|
*/
|
|
16
15
|
runningHeavyTasks: Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* The editor is tracked at the insm layer (rather than per session) as it can
|
|
18
|
+
* outlive, or be mounted after, the session it is measured by.
|
|
19
|
+
*/
|
|
20
|
+
private editorDomRegistry;
|
|
17
21
|
constructor(options: INSMOptions);
|
|
18
22
|
/**
|
|
19
23
|
* Starts a heavy task in the currently running session.
|
|
@@ -28,6 +32,34 @@ export declare class INSM {
|
|
|
28
32
|
* Ends a heavy task in the currently running session
|
|
29
33
|
*/
|
|
30
34
|
endHeavyTask(heavyTaskName: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Registers the page editor's content DOM element (`editorView.dom`) with insm.
|
|
37
|
+
*
|
|
38
|
+
* insm does not locate the editor itself - the element is provided by the editor so
|
|
39
|
+
* that session events can report its DOM element count (`editorDomSize`).
|
|
40
|
+
*
|
|
41
|
+
* A session measures a page, so only the page's own editor should register. Secondary
|
|
42
|
+
* editors (inline comments, nested legacy content extensions) must not, as the
|
|
43
|
+
* reported size would then depend on which editor registered last.
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* insm.registerEditorDom(editorView.dom);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
registerEditorDom(editorDom: HTMLElement): void;
|
|
50
|
+
/**
|
|
51
|
+
* Unregisters the editor's content DOM element. This is expected to be called when
|
|
52
|
+
* the editor is destroyed.
|
|
53
|
+
*/
|
|
54
|
+
unregisterEditorDom(editorDom: HTMLElement): void;
|
|
55
|
+
/**
|
|
56
|
+
* The number of DOM elements inside the registered editor, used as a proxy for
|
|
57
|
+
* document complexity in performance events.
|
|
58
|
+
*
|
|
59
|
+
* Undefined when no editor is registered, or the registered one is no longer in
|
|
60
|
+
* the document.
|
|
61
|
+
*/
|
|
62
|
+
getEditorDomSize(): number | undefined;
|
|
31
63
|
/**
|
|
32
64
|
* Call this when starting a new experience. This is expected to be wired to the product
|
|
33
65
|
* routing solution.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/insm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "INSM tooling measures user-perceived interactivity of a page",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"atlaskit:src": "src/index.ts",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@atlaskit/analytics-listeners": "^11.1.0",
|
|
21
|
-
"@atlaskit/
|
|
21
|
+
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
22
|
+
"@atlaskit/tmp-editor-statsig": "^147.1.0",
|
|
22
23
|
"@babel/runtime": "^7.0.0",
|
|
23
24
|
"bowser-ultralight": "^1.0.6"
|
|
24
25
|
},
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
"react": "^18.2.0 || ^19.2.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
30
|
+
"@atlassian/experiment-test-utils": "^0.2.0",
|
|
29
31
|
"@atlassian/structured-docs-types": "workspace:^",
|
|
30
32
|
"react": "^19.2.0"
|
|
31
33
|
}
|