@atlaskit/editor-plugin-quick-insert 14.1.2 → 15.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 +20 -0
- package/compass.yml +3 -3
- package/dist/cjs/app-category-analytics.js +152 -135
- package/dist/cjs/quickInsertPlugin.js +3 -1
- package/dist/es2019/app-category-analytics.js +112 -98
- package/dist/es2019/quickInsertPlugin.js +3 -1
- package/dist/esm/app-category-analytics.js +152 -135
- package/dist/esm/quickInsertPlugin.js +3 -1
- package/dist/types/app-category-analytics.d.ts +5 -2
- package/package.json +8 -8
- package/editor-plugin-quick-insert.docs.tsx +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-quick-insert
|
|
2
2
|
|
|
3
|
+
## 15.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`bb37742539a7d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bb37742539a7d) -
|
|
8
|
+
Rename Quick Insert category analytics from app counts to macro counts, add reusable extension app
|
|
9
|
+
identity, and track internal, ecosystem, and all macro/app counts for externally provided items
|
|
10
|
+
behind `platform_editor_slash_app_category_analytics`. GUID-only app identities are grouped as
|
|
11
|
+
`unknown`.
|
|
12
|
+
|
|
13
|
+
Breaking change: `CategoryInformation` and `QuickInsertInformationAttributes` from
|
|
14
|
+
`@atlaskit/editor-common/analytics/types/quick-insert-events` have changed shape. Update usages to
|
|
15
|
+
the new fields (`internalMacroCount`, `internalAppCount`, `internalAppMacroMax`,
|
|
16
|
+
`ecosystemMacroCount`, `ecosystemAppCount`, `ecosystemAppMacroMax`, `allMacroCount`,
|
|
17
|
+
`allAppCount`, and `allAppMacroMax`) and add the `allCategories` aggregate. Remove references to
|
|
18
|
+
the removed `appCount` and `appMacros` fields. `ExtensionApp.ownership` has been replaced by
|
|
19
|
+
`ExtensionApp.source` (`internal` or `ecosystem`); update app metadata producers accordingly.
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 14.1.2
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/compass.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
configVersion: 1
|
|
2
2
|
id: ari:cloud:compass:a436116f-02ce-4520-8fbb-7301462a1674:component/c5751cc6-3513-4070-9deb-af31e86aed34/2f21d665-dd06-4dab-87b8-ba8867f6ce2e
|
|
3
3
|
name: '@atlaskit/editor-plugin-quick-insert'
|
|
4
|
-
ownerId: ari:cloud:identity::team/
|
|
4
|
+
ownerId: ari:cloud:identity::team/cf6a670b-5252-4c68-a769-9207de366beb # Editor Developers
|
|
5
5
|
labels:
|
|
6
6
|
- platform-code
|
|
7
7
|
- platform-afm
|
|
@@ -16,14 +16,14 @@ links:
|
|
|
16
16
|
url: https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master
|
|
17
17
|
- name: Slack Channel
|
|
18
18
|
type: CHAT_CHANNEL
|
|
19
|
-
url: https://atlassian.enterprise.slack.com/archives/
|
|
19
|
+
url: https://atlassian.enterprise.slack.com/archives/CFG3PSQ9E # #help-editor
|
|
20
20
|
- name: Editor Plugin Quick Insert
|
|
21
21
|
type: REPOSITORY
|
|
22
22
|
url: https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master/platform/packages/editor/editor-plugin-quick-insert
|
|
23
23
|
customFields:
|
|
24
24
|
- name: Department
|
|
25
25
|
type: text
|
|
26
|
-
value:
|
|
26
|
+
value: Editor Developers
|
|
27
27
|
- name: Trusted Reviewer Teams
|
|
28
28
|
type: text
|
|
29
29
|
value: ari:cloud:identity::team/cf6a670b-5252-4c68-a769-9207de366beb
|
|
@@ -13,151 +13,168 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
13
13
|
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; } }
|
|
14
14
|
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; }
|
|
15
15
|
var QUICK_INSERT_ITEMS_ANALYTICS_DELAY_MS = exports.QUICK_INSERT_ITEMS_ANALYTICS_DELAY_MS = 10000;
|
|
16
|
+
var GUID_ONLY_APP_KEY_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
17
|
+
var isGuidOnlyAppKey = function isGuidOnlyAppKey(appKey) {
|
|
18
|
+
return GUID_ONLY_APP_KEY_REGEX.test(appKey);
|
|
19
|
+
};
|
|
16
20
|
var sectionCategoryKeys = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _keys.BLOCK_TEMPLATES_SECTION.key, 'blockTemplates'), _keys.DATA_AND_CHARTS_SECTION.key, 'dataAndCharts'), _keys.EMBED_SECTION.key, 'embed'), _keys.MEDIA_SECTION.key, 'media'), _keys.OTHER_SECTION.key, 'other'), _keys.ROVO_SECTION.key, 'rovo'), _keys.STRUCTURE_SECTION.key, 'structure'), _keys.TEXT_FORMATTING_SECTION.key, 'textFormatting');
|
|
17
21
|
var legacyCategoryKeys = new Set(['admin', 'ai', 'block-templates', 'communication', 'confluence-content', 'data-and-charts', 'development', 'embed', 'external-content', 'formatting', 'media', 'navigation', 'other', 'reporting', 'skills', 'structure', 'text-formatting', 'visuals']);
|
|
18
22
|
var isLegacyCategoryKey = function isLegacyCategoryKey(category) {
|
|
19
23
|
return legacyCategoryKeys.has(category);
|
|
20
24
|
};
|
|
21
|
-
var calculateQuickInsertItemsAttributes = exports.calculateQuickInsertItemsAttributes = function calculateQuickInsertItemsAttributes(
|
|
25
|
+
var calculateQuickInsertItemsAttributes = exports.calculateQuickInsertItemsAttributes = function calculateQuickInsertItemsAttributes(_ref) {
|
|
26
|
+
var providedItems = _ref.providedItems;
|
|
27
|
+
var emptyCategoryInformation = function emptyCategoryInformation() {
|
|
28
|
+
return {
|
|
29
|
+
internalMacroCount: 0,
|
|
30
|
+
internalAppCount: 0,
|
|
31
|
+
internalAppMacroMax: 0,
|
|
32
|
+
ecosystemMacroCount: 0,
|
|
33
|
+
ecosystemAppCount: 0,
|
|
34
|
+
ecosystemAppMacroMax: 0,
|
|
35
|
+
allMacroCount: 0,
|
|
36
|
+
allAppCount: 0,
|
|
37
|
+
allAppMacroMax: 0
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
var emptyCategoryCounts = {
|
|
41
|
+
blockTemplates: emptyCategoryInformation(),
|
|
42
|
+
dataAndCharts: emptyCategoryInformation(),
|
|
43
|
+
embed: emptyCategoryInformation(),
|
|
44
|
+
media: emptyCategoryInformation(),
|
|
45
|
+
other: emptyCategoryInformation(),
|
|
46
|
+
rovo: emptyCategoryInformation(),
|
|
47
|
+
structure: emptyCategoryInformation(),
|
|
48
|
+
textFormatting: emptyCategoryInformation()
|
|
49
|
+
};
|
|
50
|
+
var emptyLegacyCategoryCounts = {
|
|
51
|
+
admin: emptyCategoryInformation(),
|
|
52
|
+
ai: emptyCategoryInformation(),
|
|
53
|
+
'block-templates': emptyCategoryInformation(),
|
|
54
|
+
communication: emptyCategoryInformation(),
|
|
55
|
+
'confluence-content': emptyCategoryInformation(),
|
|
56
|
+
'data-and-charts': emptyCategoryInformation(),
|
|
57
|
+
development: emptyCategoryInformation(),
|
|
58
|
+
embed: emptyCategoryInformation(),
|
|
59
|
+
'external-content': emptyCategoryInformation(),
|
|
60
|
+
formatting: emptyCategoryInformation(),
|
|
61
|
+
media: emptyCategoryInformation(),
|
|
62
|
+
navigation: emptyCategoryInformation(),
|
|
63
|
+
other: emptyCategoryInformation(),
|
|
64
|
+
reporting: emptyCategoryInformation(),
|
|
65
|
+
skills: emptyCategoryInformation(),
|
|
66
|
+
structure: emptyCategoryInformation(),
|
|
67
|
+
'text-formatting': emptyCategoryInformation(),
|
|
68
|
+
uncategorized: emptyCategoryInformation(),
|
|
69
|
+
visuals: emptyCategoryInformation()
|
|
70
|
+
};
|
|
22
71
|
var attributes = {
|
|
23
|
-
category:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
media: {
|
|
34
|
-
appCount: 0
|
|
35
|
-
},
|
|
36
|
-
other: {
|
|
37
|
-
appCount: 0
|
|
38
|
-
},
|
|
39
|
-
rovo: {
|
|
40
|
-
appCount: 0
|
|
41
|
-
},
|
|
42
|
-
structure: {
|
|
43
|
-
appCount: 0
|
|
44
|
-
},
|
|
45
|
-
textFormatting: {
|
|
46
|
-
appCount: 0
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
legacyCategory: {
|
|
50
|
-
admin: {
|
|
51
|
-
appCount: 0
|
|
52
|
-
},
|
|
53
|
-
ai: {
|
|
54
|
-
appCount: 0
|
|
55
|
-
},
|
|
56
|
-
'block-templates': {
|
|
57
|
-
appCount: 0
|
|
58
|
-
},
|
|
59
|
-
communication: {
|
|
60
|
-
appCount: 0
|
|
61
|
-
},
|
|
62
|
-
'confluence-content': {
|
|
63
|
-
appCount: 0
|
|
64
|
-
},
|
|
65
|
-
'data-and-charts': {
|
|
66
|
-
appCount: 0
|
|
67
|
-
},
|
|
68
|
-
development: {
|
|
69
|
-
appCount: 0
|
|
70
|
-
},
|
|
71
|
-
embed: {
|
|
72
|
-
appCount: 0
|
|
73
|
-
},
|
|
74
|
-
'external-content': {
|
|
75
|
-
appCount: 0
|
|
76
|
-
},
|
|
77
|
-
formatting: {
|
|
78
|
-
appCount: 0
|
|
79
|
-
},
|
|
80
|
-
media: {
|
|
81
|
-
appCount: 0
|
|
82
|
-
},
|
|
83
|
-
navigation: {
|
|
84
|
-
appCount: 0
|
|
85
|
-
},
|
|
86
|
-
other: {
|
|
87
|
-
appCount: 0
|
|
88
|
-
},
|
|
89
|
-
reporting: {
|
|
90
|
-
appCount: 0
|
|
91
|
-
},
|
|
92
|
-
skills: {
|
|
93
|
-
appCount: 0
|
|
94
|
-
},
|
|
95
|
-
structure: {
|
|
96
|
-
appCount: 0
|
|
97
|
-
},
|
|
98
|
-
'text-formatting': {
|
|
99
|
-
appCount: 0
|
|
100
|
-
},
|
|
101
|
-
uncategorized: {
|
|
102
|
-
appCount: 0
|
|
103
|
-
},
|
|
104
|
-
visuals: {
|
|
105
|
-
appCount: 0
|
|
106
|
-
}
|
|
72
|
+
category: emptyCategoryCounts,
|
|
73
|
+
legacyCategory: emptyLegacyCategoryCounts,
|
|
74
|
+
allCategories: emptyCategoryInformation()
|
|
75
|
+
};
|
|
76
|
+
var appMacroCounts = new WeakMap();
|
|
77
|
+
var getAppMacroCounts = function getAppMacroCounts(category) {
|
|
78
|
+
var existingCounts = appMacroCounts.get(category);
|
|
79
|
+
if (existingCounts) {
|
|
80
|
+
return existingCounts;
|
|
107
81
|
}
|
|
82
|
+
var counts = {
|
|
83
|
+
all: new Map(),
|
|
84
|
+
internal: new Map(),
|
|
85
|
+
ecosystem: new Map()
|
|
86
|
+
};
|
|
87
|
+
appMacroCounts.set(category, counts);
|
|
88
|
+
return counts;
|
|
108
89
|
};
|
|
109
|
-
var
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
90
|
+
var countAppMacro = function countAppMacro(appKey, counts) {
|
|
91
|
+
var _counts$get;
|
|
92
|
+
var appMacroCount = ((_counts$get = counts.get(appKey)) !== null && _counts$get !== void 0 ? _counts$get : 0) + 1;
|
|
93
|
+
counts.set(appKey, appMacroCount);
|
|
94
|
+
return appMacroCount;
|
|
95
|
+
};
|
|
96
|
+
var countCategoryItem = function countCategoryItem(category, item) {
|
|
97
|
+
var _item$app;
|
|
98
|
+
category.allMacroCount += 1;
|
|
99
|
+
var _ref2 = (_item$app = item.app) !== null && _item$app !== void 0 ? _item$app : {},
|
|
100
|
+
_ref2$key = _ref2.key,
|
|
101
|
+
appKey = _ref2$key === void 0 ? 'unknown' : _ref2$key,
|
|
102
|
+
source = _ref2.source;
|
|
103
|
+
var appMacroKey = isGuidOnlyAppKey(appKey) ? 'unknown' : appKey;
|
|
104
|
+
var counts = getAppMacroCounts(category);
|
|
105
|
+
var allAppMacroCount = countAppMacro(appMacroKey, counts.all);
|
|
106
|
+
category.allAppCount = counts.all.size;
|
|
107
|
+
category.allAppMacroMax = Math.max(category.allAppMacroMax, allAppMacroCount);
|
|
108
|
+
if (source === 'internal') {
|
|
109
|
+
category.internalMacroCount += 1;
|
|
110
|
+
var internalAppMacroCount = countAppMacro(appMacroKey, counts.internal);
|
|
111
|
+
category.internalAppCount = counts.internal.size;
|
|
112
|
+
category.internalAppMacroMax = Math.max(category.internalAppMacroMax, internalAppMacroCount);
|
|
113
|
+
} else if (source === 'ecosystem') {
|
|
114
|
+
category.ecosystemMacroCount += 1;
|
|
115
|
+
var ecosystemAppMacroCount = countAppMacro(appMacroKey, counts.ecosystem);
|
|
116
|
+
category.ecosystemAppCount = counts.ecosystem.size;
|
|
117
|
+
category.ecosystemAppMacroMax = Math.max(category.ecosystemAppMacroMax, ecosystemAppMacroCount);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
var countItem = function countItem(item) {
|
|
121
|
+
var _categories$map$filte;
|
|
122
|
+
countCategoryItem(attributes.allCategories, item);
|
|
123
|
+
var categories = item.categories;
|
|
124
|
+
var normalizedCategories = new Set((_categories$map$filte = categories === null || categories === void 0 ? void 0 : categories.map(function (category) {
|
|
125
|
+
return category.trim().toLowerCase();
|
|
126
|
+
}).filter(Boolean)) !== null && _categories$map$filte !== void 0 ? _categories$map$filte : []);
|
|
127
|
+
var hasUnknownCategory = normalizedCategories.size === 0;
|
|
128
|
+
var _iterator = _createForOfIteratorHelper(normalizedCategories),
|
|
129
|
+
_step;
|
|
130
|
+
try {
|
|
131
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
132
|
+
var category = _step.value;
|
|
133
|
+
if (isLegacyCategoryKey(category)) {
|
|
134
|
+
countCategoryItem(attributes.legacyCategory[category], item);
|
|
135
|
+
} else {
|
|
136
|
+
hasUnknownCategory = true;
|
|
129
137
|
}
|
|
130
|
-
} catch (err) {
|
|
131
|
-
_iterator2.e(err);
|
|
132
|
-
} finally {
|
|
133
|
-
_iterator2.f();
|
|
134
138
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
} catch (err) {
|
|
140
|
+
_iterator.e(err);
|
|
141
|
+
} finally {
|
|
142
|
+
_iterator.f();
|
|
143
|
+
}
|
|
144
|
+
if (hasUnknownCategory) {
|
|
145
|
+
countCategoryItem(attributes.legacyCategory.uncategorized, item);
|
|
146
|
+
}
|
|
147
|
+
var _iterator2 = _createForOfIteratorHelper((0, _getMenuItemParents.getQuickInsertMenuItemParents)({
|
|
148
|
+
categories: categories,
|
|
149
|
+
rank: 0
|
|
150
|
+
})),
|
|
151
|
+
_step2;
|
|
152
|
+
try {
|
|
153
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
154
|
+
var key = _step2.value.key;
|
|
155
|
+
var categoryKey = sectionCategoryKeys[key];
|
|
156
|
+
if (!categoryKey) {
|
|
157
|
+
continue;
|
|
150
158
|
}
|
|
151
|
-
|
|
152
|
-
_iterator3.e(err);
|
|
153
|
-
} finally {
|
|
154
|
-
_iterator3.f();
|
|
159
|
+
countCategoryItem(attributes.category[categoryKey], item);
|
|
155
160
|
}
|
|
161
|
+
} catch (err) {
|
|
162
|
+
_iterator2.e(err);
|
|
163
|
+
} finally {
|
|
164
|
+
_iterator2.f();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
var _iterator3 = _createForOfIteratorHelper(providedItems),
|
|
168
|
+
_step3;
|
|
169
|
+
try {
|
|
170
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
171
|
+
var item = _step3.value;
|
|
172
|
+
countItem(item);
|
|
156
173
|
}
|
|
157
174
|
} catch (err) {
|
|
158
|
-
|
|
175
|
+
_iterator3.e(err);
|
|
159
176
|
} finally {
|
|
160
|
-
|
|
177
|
+
_iterator3.f();
|
|
161
178
|
}
|
|
162
179
|
return attributes;
|
|
163
180
|
};
|
|
@@ -167,14 +184,14 @@ var createQuickInsertItemsAnalyticsScheduler = exports.createQuickInsertItemsAna
|
|
|
167
184
|
var idleCallbackId;
|
|
168
185
|
var destroyed = false;
|
|
169
186
|
var scheduled = false;
|
|
170
|
-
var emit = function emit(
|
|
187
|
+
var emit = function emit(options) {
|
|
171
188
|
if (destroyed) {
|
|
172
189
|
return;
|
|
173
190
|
}
|
|
174
191
|
dispatchAnalyticsEvent({
|
|
175
192
|
action: _analytics.ACTION.QUICK_INSERT_INFORMATION,
|
|
176
193
|
actionSubject: _analytics.ACTION_SUBJECT.QUICK_INSERT,
|
|
177
|
-
attributes: calculateQuickInsertItemsAttributes(
|
|
194
|
+
attributes: calculateQuickInsertItemsAttributes(options),
|
|
178
195
|
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
179
196
|
});
|
|
180
197
|
};
|
|
@@ -191,7 +208,7 @@ var createQuickInsertItemsAnalyticsScheduler = exports.createQuickInsertItemsAna
|
|
|
191
208
|
window.cancelIdleCallback(idleCallbackId);
|
|
192
209
|
}
|
|
193
210
|
},
|
|
194
|
-
schedule: function schedule(
|
|
211
|
+
schedule: function schedule(options) {
|
|
195
212
|
if (scheduled || destroyed) {
|
|
196
213
|
return;
|
|
197
214
|
}
|
|
@@ -202,11 +219,11 @@ var createQuickInsertItemsAnalyticsScheduler = exports.createQuickInsertItemsAna
|
|
|
202
219
|
}
|
|
203
220
|
if (typeof window.requestIdleCallback === 'function') {
|
|
204
221
|
idleCallbackId = window.requestIdleCallback(function () {
|
|
205
|
-
return emit(
|
|
222
|
+
return emit(options);
|
|
206
223
|
});
|
|
207
224
|
} else if (typeof window.requestAnimationFrame === 'function') {
|
|
208
225
|
animationFrameId = window.requestAnimationFrame(function () {
|
|
209
|
-
return emit(
|
|
226
|
+
return emit(options);
|
|
210
227
|
});
|
|
211
228
|
}
|
|
212
229
|
}, QUICK_INSERT_ITEMS_ANALYTICS_DELAY_MS);
|
|
@@ -410,7 +410,9 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
|
|
|
410
410
|
})(editorView.state, editorView.dispatch);
|
|
411
411
|
if (!isDestroyed && !quickInsertItemsAnalyticsScheduler && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_app_category_analytics')) {
|
|
412
412
|
quickInsertItemsAnalyticsScheduler = (0, _appCategoryAnalytics.createQuickInsertItemsAnalyticsScheduler)(dispatchAnalyticsEvent);
|
|
413
|
-
quickInsertItemsAnalyticsScheduler.schedule(
|
|
413
|
+
quickInsertItemsAnalyticsScheduler.schedule({
|
|
414
|
+
providedItems: providedItems
|
|
415
|
+
});
|
|
414
416
|
}
|
|
415
417
|
_context.next = 9;
|
|
416
418
|
break;
|
|
@@ -2,6 +2,8 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/anal
|
|
|
2
2
|
import { getQuickInsertMenuItemParents } from '@atlaskit/editor-common/quick-insert/get-menu-item-parents';
|
|
3
3
|
import { BLOCK_TEMPLATES_SECTION, DATA_AND_CHARTS_SECTION, EMBED_SECTION, MEDIA_SECTION, OTHER_SECTION, ROVO_SECTION, STRUCTURE_SECTION, TEXT_FORMATTING_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
|
|
4
4
|
export const QUICK_INSERT_ITEMS_ANALYTICS_DELAY_MS = 10_000;
|
|
5
|
+
const GUID_ONLY_APP_KEY_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
6
|
+
const isGuidOnlyAppKey = appKey => GUID_ONLY_APP_KEY_REGEX.test(appKey);
|
|
5
7
|
const sectionCategoryKeys = {
|
|
6
8
|
[BLOCK_TEMPLATES_SECTION.key]: 'blockTemplates',
|
|
7
9
|
[DATA_AND_CHARTS_SECTION.key]: 'dataAndCharts',
|
|
@@ -14,119 +16,131 @@ const sectionCategoryKeys = {
|
|
|
14
16
|
};
|
|
15
17
|
const legacyCategoryKeys = new Set(['admin', 'ai', 'block-templates', 'communication', 'confluence-content', 'data-and-charts', 'development', 'embed', 'external-content', 'formatting', 'media', 'navigation', 'other', 'reporting', 'skills', 'structure', 'text-formatting', 'visuals']);
|
|
16
18
|
const isLegacyCategoryKey = category => legacyCategoryKeys.has(category);
|
|
17
|
-
export const calculateQuickInsertItemsAttributes =
|
|
19
|
+
export const calculateQuickInsertItemsAttributes = ({
|
|
20
|
+
providedItems
|
|
21
|
+
}) => {
|
|
22
|
+
const emptyCategoryInformation = () => ({
|
|
23
|
+
internalMacroCount: 0,
|
|
24
|
+
internalAppCount: 0,
|
|
25
|
+
internalAppMacroMax: 0,
|
|
26
|
+
ecosystemMacroCount: 0,
|
|
27
|
+
ecosystemAppCount: 0,
|
|
28
|
+
ecosystemAppMacroMax: 0,
|
|
29
|
+
allMacroCount: 0,
|
|
30
|
+
allAppCount: 0,
|
|
31
|
+
allAppMacroMax: 0
|
|
32
|
+
});
|
|
33
|
+
const emptyCategoryCounts = {
|
|
34
|
+
blockTemplates: emptyCategoryInformation(),
|
|
35
|
+
dataAndCharts: emptyCategoryInformation(),
|
|
36
|
+
embed: emptyCategoryInformation(),
|
|
37
|
+
media: emptyCategoryInformation(),
|
|
38
|
+
other: emptyCategoryInformation(),
|
|
39
|
+
rovo: emptyCategoryInformation(),
|
|
40
|
+
structure: emptyCategoryInformation(),
|
|
41
|
+
textFormatting: emptyCategoryInformation()
|
|
42
|
+
};
|
|
43
|
+
const emptyLegacyCategoryCounts = {
|
|
44
|
+
admin: emptyCategoryInformation(),
|
|
45
|
+
ai: emptyCategoryInformation(),
|
|
46
|
+
'block-templates': emptyCategoryInformation(),
|
|
47
|
+
communication: emptyCategoryInformation(),
|
|
48
|
+
'confluence-content': emptyCategoryInformation(),
|
|
49
|
+
'data-and-charts': emptyCategoryInformation(),
|
|
50
|
+
development: emptyCategoryInformation(),
|
|
51
|
+
embed: emptyCategoryInformation(),
|
|
52
|
+
'external-content': emptyCategoryInformation(),
|
|
53
|
+
formatting: emptyCategoryInformation(),
|
|
54
|
+
media: emptyCategoryInformation(),
|
|
55
|
+
navigation: emptyCategoryInformation(),
|
|
56
|
+
other: emptyCategoryInformation(),
|
|
57
|
+
reporting: emptyCategoryInformation(),
|
|
58
|
+
skills: emptyCategoryInformation(),
|
|
59
|
+
structure: emptyCategoryInformation(),
|
|
60
|
+
'text-formatting': emptyCategoryInformation(),
|
|
61
|
+
uncategorized: emptyCategoryInformation(),
|
|
62
|
+
visuals: emptyCategoryInformation()
|
|
63
|
+
};
|
|
18
64
|
const attributes = {
|
|
19
|
-
category:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
media: {
|
|
30
|
-
appCount: 0
|
|
31
|
-
},
|
|
32
|
-
other: {
|
|
33
|
-
appCount: 0
|
|
34
|
-
},
|
|
35
|
-
rovo: {
|
|
36
|
-
appCount: 0
|
|
37
|
-
},
|
|
38
|
-
structure: {
|
|
39
|
-
appCount: 0
|
|
40
|
-
},
|
|
41
|
-
textFormatting: {
|
|
42
|
-
appCount: 0
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
legacyCategory: {
|
|
46
|
-
admin: {
|
|
47
|
-
appCount: 0
|
|
48
|
-
},
|
|
49
|
-
ai: {
|
|
50
|
-
appCount: 0
|
|
51
|
-
},
|
|
52
|
-
'block-templates': {
|
|
53
|
-
appCount: 0
|
|
54
|
-
},
|
|
55
|
-
communication: {
|
|
56
|
-
appCount: 0
|
|
57
|
-
},
|
|
58
|
-
'confluence-content': {
|
|
59
|
-
appCount: 0
|
|
60
|
-
},
|
|
61
|
-
'data-and-charts': {
|
|
62
|
-
appCount: 0
|
|
63
|
-
},
|
|
64
|
-
development: {
|
|
65
|
-
appCount: 0
|
|
66
|
-
},
|
|
67
|
-
embed: {
|
|
68
|
-
appCount: 0
|
|
69
|
-
},
|
|
70
|
-
'external-content': {
|
|
71
|
-
appCount: 0
|
|
72
|
-
},
|
|
73
|
-
formatting: {
|
|
74
|
-
appCount: 0
|
|
75
|
-
},
|
|
76
|
-
media: {
|
|
77
|
-
appCount: 0
|
|
78
|
-
},
|
|
79
|
-
navigation: {
|
|
80
|
-
appCount: 0
|
|
81
|
-
},
|
|
82
|
-
other: {
|
|
83
|
-
appCount: 0
|
|
84
|
-
},
|
|
85
|
-
reporting: {
|
|
86
|
-
appCount: 0
|
|
87
|
-
},
|
|
88
|
-
skills: {
|
|
89
|
-
appCount: 0
|
|
90
|
-
},
|
|
91
|
-
structure: {
|
|
92
|
-
appCount: 0
|
|
93
|
-
},
|
|
94
|
-
'text-formatting': {
|
|
95
|
-
appCount: 0
|
|
96
|
-
},
|
|
97
|
-
uncategorized: {
|
|
98
|
-
appCount: 0
|
|
99
|
-
},
|
|
100
|
-
visuals: {
|
|
101
|
-
appCount: 0
|
|
102
|
-
}
|
|
65
|
+
category: emptyCategoryCounts,
|
|
66
|
+
legacyCategory: emptyLegacyCategoryCounts,
|
|
67
|
+
allCategories: emptyCategoryInformation()
|
|
68
|
+
};
|
|
69
|
+
const appMacroCounts = new WeakMap();
|
|
70
|
+
const getAppMacroCounts = category => {
|
|
71
|
+
const existingCounts = appMacroCounts.get(category);
|
|
72
|
+
if (existingCounts) {
|
|
73
|
+
return existingCounts;
|
|
103
74
|
}
|
|
75
|
+
const counts = {
|
|
76
|
+
all: new Map(),
|
|
77
|
+
internal: new Map(),
|
|
78
|
+
ecosystem: new Map()
|
|
79
|
+
};
|
|
80
|
+
appMacroCounts.set(category, counts);
|
|
81
|
+
return counts;
|
|
82
|
+
};
|
|
83
|
+
const countAppMacro = (appKey, counts) => {
|
|
84
|
+
var _counts$get;
|
|
85
|
+
const appMacroCount = ((_counts$get = counts.get(appKey)) !== null && _counts$get !== void 0 ? _counts$get : 0) + 1;
|
|
86
|
+
counts.set(appKey, appMacroCount);
|
|
87
|
+
return appMacroCount;
|
|
104
88
|
};
|
|
105
|
-
|
|
106
|
-
var _item$
|
|
107
|
-
|
|
89
|
+
const countCategoryItem = (category, item) => {
|
|
90
|
+
var _item$app;
|
|
91
|
+
category.allMacroCount += 1;
|
|
92
|
+
const {
|
|
93
|
+
key: appKey = 'unknown',
|
|
94
|
+
source
|
|
95
|
+
} = (_item$app = item.app) !== null && _item$app !== void 0 ? _item$app : {};
|
|
96
|
+
const appMacroKey = isGuidOnlyAppKey(appKey) ? 'unknown' : appKey;
|
|
97
|
+
const counts = getAppMacroCounts(category);
|
|
98
|
+
const allAppMacroCount = countAppMacro(appMacroKey, counts.all);
|
|
99
|
+
category.allAppCount = counts.all.size;
|
|
100
|
+
category.allAppMacroMax = Math.max(category.allAppMacroMax, allAppMacroCount);
|
|
101
|
+
if (source === 'internal') {
|
|
102
|
+
category.internalMacroCount += 1;
|
|
103
|
+
const internalAppMacroCount = countAppMacro(appMacroKey, counts.internal);
|
|
104
|
+
category.internalAppCount = counts.internal.size;
|
|
105
|
+
category.internalAppMacroMax = Math.max(category.internalAppMacroMax, internalAppMacroCount);
|
|
106
|
+
} else if (source === 'ecosystem') {
|
|
107
|
+
category.ecosystemMacroCount += 1;
|
|
108
|
+
const ecosystemAppMacroCount = countAppMacro(appMacroKey, counts.ecosystem);
|
|
109
|
+
category.ecosystemAppCount = counts.ecosystem.size;
|
|
110
|
+
category.ecosystemAppMacroMax = Math.max(category.ecosystemAppMacroMax, ecosystemAppMacroCount);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const countItem = item => {
|
|
114
|
+
var _categories$map$filte;
|
|
115
|
+
countCategoryItem(attributes.allCategories, item);
|
|
116
|
+
const categories = item.categories;
|
|
117
|
+
const normalizedCategories = new Set((_categories$map$filte = categories === null || categories === void 0 ? void 0 : categories.map(category => category.trim().toLowerCase()).filter(Boolean)) !== null && _categories$map$filte !== void 0 ? _categories$map$filte : []);
|
|
108
118
|
let hasUnknownCategory = normalizedCategories.size === 0;
|
|
109
119
|
for (const category of normalizedCategories) {
|
|
110
120
|
if (isLegacyCategoryKey(category)) {
|
|
111
|
-
attributes.legacyCategory[category]
|
|
121
|
+
countCategoryItem(attributes.legacyCategory[category], item);
|
|
112
122
|
} else {
|
|
113
123
|
hasUnknownCategory = true;
|
|
114
124
|
}
|
|
115
125
|
}
|
|
116
126
|
if (hasUnknownCategory) {
|
|
117
|
-
attributes.legacyCategory.uncategorized
|
|
127
|
+
countCategoryItem(attributes.legacyCategory.uncategorized, item);
|
|
118
128
|
}
|
|
119
129
|
for (const {
|
|
120
130
|
key
|
|
121
131
|
} of getQuickInsertMenuItemParents({
|
|
122
|
-
categories
|
|
132
|
+
categories,
|
|
123
133
|
rank: 0
|
|
124
134
|
})) {
|
|
125
135
|
const categoryKey = sectionCategoryKeys[key];
|
|
126
|
-
if (categoryKey) {
|
|
127
|
-
|
|
136
|
+
if (!categoryKey) {
|
|
137
|
+
continue;
|
|
128
138
|
}
|
|
139
|
+
countCategoryItem(attributes.category[categoryKey], item);
|
|
129
140
|
}
|
|
141
|
+
};
|
|
142
|
+
for (const item of providedItems) {
|
|
143
|
+
countItem(item);
|
|
130
144
|
}
|
|
131
145
|
return attributes;
|
|
132
146
|
};
|
|
@@ -136,14 +150,14 @@ export const createQuickInsertItemsAnalyticsScheduler = dispatchAnalyticsEvent =
|
|
|
136
150
|
let idleCallbackId;
|
|
137
151
|
let destroyed = false;
|
|
138
152
|
let scheduled = false;
|
|
139
|
-
const emit =
|
|
153
|
+
const emit = options => {
|
|
140
154
|
if (destroyed) {
|
|
141
155
|
return;
|
|
142
156
|
}
|
|
143
157
|
dispatchAnalyticsEvent({
|
|
144
158
|
action: ACTION.QUICK_INSERT_INFORMATION,
|
|
145
159
|
actionSubject: ACTION_SUBJECT.QUICK_INSERT,
|
|
146
|
-
attributes: calculateQuickInsertItemsAttributes(
|
|
160
|
+
attributes: calculateQuickInsertItemsAttributes(options),
|
|
147
161
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
148
162
|
});
|
|
149
163
|
};
|
|
@@ -160,7 +174,7 @@ export const createQuickInsertItemsAnalyticsScheduler = dispatchAnalyticsEvent =
|
|
|
160
174
|
window.cancelIdleCallback(idleCallbackId);
|
|
161
175
|
}
|
|
162
176
|
},
|
|
163
|
-
schedule:
|
|
177
|
+
schedule: options => {
|
|
164
178
|
if (scheduled || destroyed) {
|
|
165
179
|
return;
|
|
166
180
|
}
|
|
@@ -170,9 +184,9 @@ export const createQuickInsertItemsAnalyticsScheduler = dispatchAnalyticsEvent =
|
|
|
170
184
|
return;
|
|
171
185
|
}
|
|
172
186
|
if (typeof window.requestIdleCallback === 'function') {
|
|
173
|
-
idleCallbackId = window.requestIdleCallback(() => emit(
|
|
187
|
+
idleCallbackId = window.requestIdleCallback(() => emit(options));
|
|
174
188
|
} else if (typeof window.requestAnimationFrame === 'function') {
|
|
175
|
-
animationFrameId = window.requestAnimationFrame(() => emit(
|
|
189
|
+
animationFrameId = window.requestAnimationFrame(() => emit(options));
|
|
176
190
|
}
|
|
177
191
|
}, QUICK_INSERT_ITEMS_ANALYTICS_DELAY_MS);
|
|
178
192
|
}
|
|
@@ -350,7 +350,9 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
|
|
|
350
350
|
})(editorView.state, editorView.dispatch);
|
|
351
351
|
if (!isDestroyed && !quickInsertItemsAnalyticsScheduler && isExperimentEnabled('platform_editor_slash_app_category_analytics')) {
|
|
352
352
|
quickInsertItemsAnalyticsScheduler = createQuickInsertItemsAnalyticsScheduler(dispatchAnalyticsEvent);
|
|
353
|
-
quickInsertItemsAnalyticsScheduler.schedule(
|
|
353
|
+
quickInsertItemsAnalyticsScheduler.schedule({
|
|
354
|
+
providedItems
|
|
355
|
+
});
|
|
354
356
|
}
|
|
355
357
|
} catch (e) {
|
|
356
358
|
// eslint-disable-next-line no-console
|
|
@@ -6,151 +6,168 @@ import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/anal
|
|
|
6
6
|
import { getQuickInsertMenuItemParents } from '@atlaskit/editor-common/quick-insert/get-menu-item-parents';
|
|
7
7
|
import { BLOCK_TEMPLATES_SECTION, DATA_AND_CHARTS_SECTION, EMBED_SECTION, MEDIA_SECTION, OTHER_SECTION, ROVO_SECTION, STRUCTURE_SECTION, TEXT_FORMATTING_SECTION } from '@atlaskit/editor-common/quick-insert/keys';
|
|
8
8
|
export var QUICK_INSERT_ITEMS_ANALYTICS_DELAY_MS = 10000;
|
|
9
|
+
var GUID_ONLY_APP_KEY_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
10
|
+
var isGuidOnlyAppKey = function isGuidOnlyAppKey(appKey) {
|
|
11
|
+
return GUID_ONLY_APP_KEY_REGEX.test(appKey);
|
|
12
|
+
};
|
|
9
13
|
var sectionCategoryKeys = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, BLOCK_TEMPLATES_SECTION.key, 'blockTemplates'), DATA_AND_CHARTS_SECTION.key, 'dataAndCharts'), EMBED_SECTION.key, 'embed'), MEDIA_SECTION.key, 'media'), OTHER_SECTION.key, 'other'), ROVO_SECTION.key, 'rovo'), STRUCTURE_SECTION.key, 'structure'), TEXT_FORMATTING_SECTION.key, 'textFormatting');
|
|
10
14
|
var legacyCategoryKeys = new Set(['admin', 'ai', 'block-templates', 'communication', 'confluence-content', 'data-and-charts', 'development', 'embed', 'external-content', 'formatting', 'media', 'navigation', 'other', 'reporting', 'skills', 'structure', 'text-formatting', 'visuals']);
|
|
11
15
|
var isLegacyCategoryKey = function isLegacyCategoryKey(category) {
|
|
12
16
|
return legacyCategoryKeys.has(category);
|
|
13
17
|
};
|
|
14
|
-
export var calculateQuickInsertItemsAttributes = function calculateQuickInsertItemsAttributes(
|
|
18
|
+
export var calculateQuickInsertItemsAttributes = function calculateQuickInsertItemsAttributes(_ref) {
|
|
19
|
+
var providedItems = _ref.providedItems;
|
|
20
|
+
var emptyCategoryInformation = function emptyCategoryInformation() {
|
|
21
|
+
return {
|
|
22
|
+
internalMacroCount: 0,
|
|
23
|
+
internalAppCount: 0,
|
|
24
|
+
internalAppMacroMax: 0,
|
|
25
|
+
ecosystemMacroCount: 0,
|
|
26
|
+
ecosystemAppCount: 0,
|
|
27
|
+
ecosystemAppMacroMax: 0,
|
|
28
|
+
allMacroCount: 0,
|
|
29
|
+
allAppCount: 0,
|
|
30
|
+
allAppMacroMax: 0
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
var emptyCategoryCounts = {
|
|
34
|
+
blockTemplates: emptyCategoryInformation(),
|
|
35
|
+
dataAndCharts: emptyCategoryInformation(),
|
|
36
|
+
embed: emptyCategoryInformation(),
|
|
37
|
+
media: emptyCategoryInformation(),
|
|
38
|
+
other: emptyCategoryInformation(),
|
|
39
|
+
rovo: emptyCategoryInformation(),
|
|
40
|
+
structure: emptyCategoryInformation(),
|
|
41
|
+
textFormatting: emptyCategoryInformation()
|
|
42
|
+
};
|
|
43
|
+
var emptyLegacyCategoryCounts = {
|
|
44
|
+
admin: emptyCategoryInformation(),
|
|
45
|
+
ai: emptyCategoryInformation(),
|
|
46
|
+
'block-templates': emptyCategoryInformation(),
|
|
47
|
+
communication: emptyCategoryInformation(),
|
|
48
|
+
'confluence-content': emptyCategoryInformation(),
|
|
49
|
+
'data-and-charts': emptyCategoryInformation(),
|
|
50
|
+
development: emptyCategoryInformation(),
|
|
51
|
+
embed: emptyCategoryInformation(),
|
|
52
|
+
'external-content': emptyCategoryInformation(),
|
|
53
|
+
formatting: emptyCategoryInformation(),
|
|
54
|
+
media: emptyCategoryInformation(),
|
|
55
|
+
navigation: emptyCategoryInformation(),
|
|
56
|
+
other: emptyCategoryInformation(),
|
|
57
|
+
reporting: emptyCategoryInformation(),
|
|
58
|
+
skills: emptyCategoryInformation(),
|
|
59
|
+
structure: emptyCategoryInformation(),
|
|
60
|
+
'text-formatting': emptyCategoryInformation(),
|
|
61
|
+
uncategorized: emptyCategoryInformation(),
|
|
62
|
+
visuals: emptyCategoryInformation()
|
|
63
|
+
};
|
|
15
64
|
var attributes = {
|
|
16
|
-
category:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
media: {
|
|
27
|
-
appCount: 0
|
|
28
|
-
},
|
|
29
|
-
other: {
|
|
30
|
-
appCount: 0
|
|
31
|
-
},
|
|
32
|
-
rovo: {
|
|
33
|
-
appCount: 0
|
|
34
|
-
},
|
|
35
|
-
structure: {
|
|
36
|
-
appCount: 0
|
|
37
|
-
},
|
|
38
|
-
textFormatting: {
|
|
39
|
-
appCount: 0
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
legacyCategory: {
|
|
43
|
-
admin: {
|
|
44
|
-
appCount: 0
|
|
45
|
-
},
|
|
46
|
-
ai: {
|
|
47
|
-
appCount: 0
|
|
48
|
-
},
|
|
49
|
-
'block-templates': {
|
|
50
|
-
appCount: 0
|
|
51
|
-
},
|
|
52
|
-
communication: {
|
|
53
|
-
appCount: 0
|
|
54
|
-
},
|
|
55
|
-
'confluence-content': {
|
|
56
|
-
appCount: 0
|
|
57
|
-
},
|
|
58
|
-
'data-and-charts': {
|
|
59
|
-
appCount: 0
|
|
60
|
-
},
|
|
61
|
-
development: {
|
|
62
|
-
appCount: 0
|
|
63
|
-
},
|
|
64
|
-
embed: {
|
|
65
|
-
appCount: 0
|
|
66
|
-
},
|
|
67
|
-
'external-content': {
|
|
68
|
-
appCount: 0
|
|
69
|
-
},
|
|
70
|
-
formatting: {
|
|
71
|
-
appCount: 0
|
|
72
|
-
},
|
|
73
|
-
media: {
|
|
74
|
-
appCount: 0
|
|
75
|
-
},
|
|
76
|
-
navigation: {
|
|
77
|
-
appCount: 0
|
|
78
|
-
},
|
|
79
|
-
other: {
|
|
80
|
-
appCount: 0
|
|
81
|
-
},
|
|
82
|
-
reporting: {
|
|
83
|
-
appCount: 0
|
|
84
|
-
},
|
|
85
|
-
skills: {
|
|
86
|
-
appCount: 0
|
|
87
|
-
},
|
|
88
|
-
structure: {
|
|
89
|
-
appCount: 0
|
|
90
|
-
},
|
|
91
|
-
'text-formatting': {
|
|
92
|
-
appCount: 0
|
|
93
|
-
},
|
|
94
|
-
uncategorized: {
|
|
95
|
-
appCount: 0
|
|
96
|
-
},
|
|
97
|
-
visuals: {
|
|
98
|
-
appCount: 0
|
|
99
|
-
}
|
|
65
|
+
category: emptyCategoryCounts,
|
|
66
|
+
legacyCategory: emptyLegacyCategoryCounts,
|
|
67
|
+
allCategories: emptyCategoryInformation()
|
|
68
|
+
};
|
|
69
|
+
var appMacroCounts = new WeakMap();
|
|
70
|
+
var getAppMacroCounts = function getAppMacroCounts(category) {
|
|
71
|
+
var existingCounts = appMacroCounts.get(category);
|
|
72
|
+
if (existingCounts) {
|
|
73
|
+
return existingCounts;
|
|
100
74
|
}
|
|
75
|
+
var counts = {
|
|
76
|
+
all: new Map(),
|
|
77
|
+
internal: new Map(),
|
|
78
|
+
ecosystem: new Map()
|
|
79
|
+
};
|
|
80
|
+
appMacroCounts.set(category, counts);
|
|
81
|
+
return counts;
|
|
101
82
|
};
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
83
|
+
var countAppMacro = function countAppMacro(appKey, counts) {
|
|
84
|
+
var _counts$get;
|
|
85
|
+
var appMacroCount = ((_counts$get = counts.get(appKey)) !== null && _counts$get !== void 0 ? _counts$get : 0) + 1;
|
|
86
|
+
counts.set(appKey, appMacroCount);
|
|
87
|
+
return appMacroCount;
|
|
88
|
+
};
|
|
89
|
+
var countCategoryItem = function countCategoryItem(category, item) {
|
|
90
|
+
var _item$app;
|
|
91
|
+
category.allMacroCount += 1;
|
|
92
|
+
var _ref2 = (_item$app = item.app) !== null && _item$app !== void 0 ? _item$app : {},
|
|
93
|
+
_ref2$key = _ref2.key,
|
|
94
|
+
appKey = _ref2$key === void 0 ? 'unknown' : _ref2$key,
|
|
95
|
+
source = _ref2.source;
|
|
96
|
+
var appMacroKey = isGuidOnlyAppKey(appKey) ? 'unknown' : appKey;
|
|
97
|
+
var counts = getAppMacroCounts(category);
|
|
98
|
+
var allAppMacroCount = countAppMacro(appMacroKey, counts.all);
|
|
99
|
+
category.allAppCount = counts.all.size;
|
|
100
|
+
category.allAppMacroMax = Math.max(category.allAppMacroMax, allAppMacroCount);
|
|
101
|
+
if (source === 'internal') {
|
|
102
|
+
category.internalMacroCount += 1;
|
|
103
|
+
var internalAppMacroCount = countAppMacro(appMacroKey, counts.internal);
|
|
104
|
+
category.internalAppCount = counts.internal.size;
|
|
105
|
+
category.internalAppMacroMax = Math.max(category.internalAppMacroMax, internalAppMacroCount);
|
|
106
|
+
} else if (source === 'ecosystem') {
|
|
107
|
+
category.ecosystemMacroCount += 1;
|
|
108
|
+
var ecosystemAppMacroCount = countAppMacro(appMacroKey, counts.ecosystem);
|
|
109
|
+
category.ecosystemAppCount = counts.ecosystem.size;
|
|
110
|
+
category.ecosystemAppMacroMax = Math.max(category.ecosystemAppMacroMax, ecosystemAppMacroCount);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var countItem = function countItem(item) {
|
|
114
|
+
var _categories$map$filte;
|
|
115
|
+
countCategoryItem(attributes.allCategories, item);
|
|
116
|
+
var categories = item.categories;
|
|
117
|
+
var normalizedCategories = new Set((_categories$map$filte = categories === null || categories === void 0 ? void 0 : categories.map(function (category) {
|
|
118
|
+
return category.trim().toLowerCase();
|
|
119
|
+
}).filter(Boolean)) !== null && _categories$map$filte !== void 0 ? _categories$map$filte : []);
|
|
120
|
+
var hasUnknownCategory = normalizedCategories.size === 0;
|
|
121
|
+
var _iterator = _createForOfIteratorHelper(normalizedCategories),
|
|
122
|
+
_step;
|
|
123
|
+
try {
|
|
124
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
125
|
+
var category = _step.value;
|
|
126
|
+
if (isLegacyCategoryKey(category)) {
|
|
127
|
+
countCategoryItem(attributes.legacyCategory[category], item);
|
|
128
|
+
} else {
|
|
129
|
+
hasUnknownCategory = true;
|
|
122
130
|
}
|
|
123
|
-
} catch (err) {
|
|
124
|
-
_iterator2.e(err);
|
|
125
|
-
} finally {
|
|
126
|
-
_iterator2.f();
|
|
127
131
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
} catch (err) {
|
|
133
|
+
_iterator.e(err);
|
|
134
|
+
} finally {
|
|
135
|
+
_iterator.f();
|
|
136
|
+
}
|
|
137
|
+
if (hasUnknownCategory) {
|
|
138
|
+
countCategoryItem(attributes.legacyCategory.uncategorized, item);
|
|
139
|
+
}
|
|
140
|
+
var _iterator2 = _createForOfIteratorHelper(getQuickInsertMenuItemParents({
|
|
141
|
+
categories: categories,
|
|
142
|
+
rank: 0
|
|
143
|
+
})),
|
|
144
|
+
_step2;
|
|
145
|
+
try {
|
|
146
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
147
|
+
var key = _step2.value.key;
|
|
148
|
+
var categoryKey = sectionCategoryKeys[key];
|
|
149
|
+
if (!categoryKey) {
|
|
150
|
+
continue;
|
|
143
151
|
}
|
|
144
|
-
|
|
145
|
-
_iterator3.e(err);
|
|
146
|
-
} finally {
|
|
147
|
-
_iterator3.f();
|
|
152
|
+
countCategoryItem(attributes.category[categoryKey], item);
|
|
148
153
|
}
|
|
154
|
+
} catch (err) {
|
|
155
|
+
_iterator2.e(err);
|
|
156
|
+
} finally {
|
|
157
|
+
_iterator2.f();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var _iterator3 = _createForOfIteratorHelper(providedItems),
|
|
161
|
+
_step3;
|
|
162
|
+
try {
|
|
163
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
164
|
+
var item = _step3.value;
|
|
165
|
+
countItem(item);
|
|
149
166
|
}
|
|
150
167
|
} catch (err) {
|
|
151
|
-
|
|
168
|
+
_iterator3.e(err);
|
|
152
169
|
} finally {
|
|
153
|
-
|
|
170
|
+
_iterator3.f();
|
|
154
171
|
}
|
|
155
172
|
return attributes;
|
|
156
173
|
};
|
|
@@ -160,14 +177,14 @@ export var createQuickInsertItemsAnalyticsScheduler = function createQuickInsert
|
|
|
160
177
|
var idleCallbackId;
|
|
161
178
|
var destroyed = false;
|
|
162
179
|
var scheduled = false;
|
|
163
|
-
var emit = function emit(
|
|
180
|
+
var emit = function emit(options) {
|
|
164
181
|
if (destroyed) {
|
|
165
182
|
return;
|
|
166
183
|
}
|
|
167
184
|
dispatchAnalyticsEvent({
|
|
168
185
|
action: ACTION.QUICK_INSERT_INFORMATION,
|
|
169
186
|
actionSubject: ACTION_SUBJECT.QUICK_INSERT,
|
|
170
|
-
attributes: calculateQuickInsertItemsAttributes(
|
|
187
|
+
attributes: calculateQuickInsertItemsAttributes(options),
|
|
171
188
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
172
189
|
});
|
|
173
190
|
};
|
|
@@ -184,7 +201,7 @@ export var createQuickInsertItemsAnalyticsScheduler = function createQuickInsert
|
|
|
184
201
|
window.cancelIdleCallback(idleCallbackId);
|
|
185
202
|
}
|
|
186
203
|
},
|
|
187
|
-
schedule: function schedule(
|
|
204
|
+
schedule: function schedule(options) {
|
|
188
205
|
if (scheduled || destroyed) {
|
|
189
206
|
return;
|
|
190
207
|
}
|
|
@@ -195,11 +212,11 @@ export var createQuickInsertItemsAnalyticsScheduler = function createQuickInsert
|
|
|
195
212
|
}
|
|
196
213
|
if (typeof window.requestIdleCallback === 'function') {
|
|
197
214
|
idleCallbackId = window.requestIdleCallback(function () {
|
|
198
|
-
return emit(
|
|
215
|
+
return emit(options);
|
|
199
216
|
});
|
|
200
217
|
} else if (typeof window.requestAnimationFrame === 'function') {
|
|
201
218
|
animationFrameId = window.requestAnimationFrame(function () {
|
|
202
|
-
return emit(
|
|
219
|
+
return emit(options);
|
|
203
220
|
});
|
|
204
221
|
}
|
|
205
222
|
}, QUICK_INSERT_ITEMS_ANALYTICS_DELAY_MS);
|
|
@@ -403,7 +403,9 @@ function quickInsertPluginFactory(defaultItems, providerFactory, getIntl, dispat
|
|
|
403
403
|
})(editorView.state, editorView.dispatch);
|
|
404
404
|
if (!isDestroyed && !quickInsertItemsAnalyticsScheduler && isExperimentEnabled('platform_editor_slash_app_category_analytics')) {
|
|
405
405
|
quickInsertItemsAnalyticsScheduler = createQuickInsertItemsAnalyticsScheduler(dispatchAnalyticsEvent);
|
|
406
|
-
quickInsertItemsAnalyticsScheduler.schedule(
|
|
406
|
+
quickInsertItemsAnalyticsScheduler.schedule({
|
|
407
|
+
providedItems: providedItems
|
|
408
|
+
});
|
|
407
409
|
}
|
|
408
410
|
_context.next = 9;
|
|
409
411
|
break;
|
|
@@ -2,8 +2,11 @@ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import type { QuickInsertInformationAttributes } from '@atlaskit/editor-common/analytics/types/quick-insert-events';
|
|
3
3
|
import type { QuickInsertItem } from '@atlaskit/editor-common/provider-factory';
|
|
4
4
|
export declare const QUICK_INSERT_ITEMS_ANALYTICS_DELAY_MS = 10000;
|
|
5
|
-
export
|
|
5
|
+
export type QuickInsertItemsAnalyticsOptions = {
|
|
6
|
+
providedItems: readonly QuickInsertItem[];
|
|
7
|
+
};
|
|
8
|
+
export declare const calculateQuickInsertItemsAttributes: ({ providedItems, }: QuickInsertItemsAnalyticsOptions) => QuickInsertInformationAttributes;
|
|
6
9
|
export declare const createQuickInsertItemsAnalyticsScheduler: (dispatchAnalyticsEvent: DispatchAnalyticsEvent) => {
|
|
7
10
|
destroy: () => void;
|
|
8
|
-
schedule: (
|
|
11
|
+
schedule: (options: QuickInsertItemsAnalyticsOptions) => void;
|
|
9
12
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-quick-insert",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "Quick insert plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,24 +22,24 @@
|
|
|
22
22
|
"atlaskit:src": "src/index.ts",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@atlaskit/button": "^25.0.0",
|
|
25
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
26
|
-
"@atlaskit/editor-plugin-connectivity": "^
|
|
27
|
-
"@atlaskit/editor-plugin-metrics": "^
|
|
28
|
-
"@atlaskit/editor-plugin-type-ahead": "^
|
|
29
|
-
"@atlaskit/editor-plugin-ui-control-registry": "^
|
|
25
|
+
"@atlaskit/editor-plugin-analytics": "^15.0.0",
|
|
26
|
+
"@atlaskit/editor-plugin-connectivity": "^15.0.0",
|
|
27
|
+
"@atlaskit/editor-plugin-metrics": "^16.0.0",
|
|
28
|
+
"@atlaskit/editor-plugin-type-ahead": "^16.0.0",
|
|
29
|
+
"@atlaskit/editor-plugin-ui-control-registry": "^9.0.0",
|
|
30
30
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
31
31
|
"@atlaskit/editor-ui-control-model": "^2.6.0",
|
|
32
32
|
"@atlaskit/icon": "^37.3.0",
|
|
33
33
|
"@atlaskit/modal-dialog": "^16.3.0",
|
|
34
34
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
35
35
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
36
|
-
"@atlaskit/tmp-editor-statsig": "^147.
|
|
36
|
+
"@atlaskit/tmp-editor-statsig": "^147.1.0",
|
|
37
37
|
"@atlaskit/tokens": "^16.7.0",
|
|
38
38
|
"@babel/runtime": "^7.0.0",
|
|
39
39
|
"@emotion/react": "^11.7.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@atlaskit/editor-common": "^
|
|
42
|
+
"@atlaskit/editor-common": "^119.0.0",
|
|
43
43
|
"react": "^18.2.0 || ^19.2.0",
|
|
44
44
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
45
45
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Testing structured MCP docs for review — ignore this file.
|
|
3
|
-
* Contact #dst-structured-content in Slack with questions.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import path from 'path';
|
|
7
|
-
|
|
8
|
-
import type { StructuredContentSource } from '@atlassian/structured-docs-types/types';
|
|
9
|
-
|
|
10
|
-
import packageJson from './package.json';
|
|
11
|
-
|
|
12
|
-
const packagePath = path.resolve(__dirname);
|
|
13
|
-
|
|
14
|
-
const documentation: StructuredContentSource = {
|
|
15
|
-
utilities: [
|
|
16
|
-
{
|
|
17
|
-
kind: 'function',
|
|
18
|
-
name: 'quickInsertPlugin',
|
|
19
|
-
description: 'Quick insert plugin for @atlaskit/editor-core',
|
|
20
|
-
status: 'general-availability',
|
|
21
|
-
import: {
|
|
22
|
-
name: 'quickInsertPlugin',
|
|
23
|
-
package: '@atlaskit/editor-plugin-quick-insert',
|
|
24
|
-
type: 'named',
|
|
25
|
-
packagePath,
|
|
26
|
-
packageJson,
|
|
27
|
-
},
|
|
28
|
-
usageGuidelines: [],
|
|
29
|
-
accessibilityGuidelines: [],
|
|
30
|
-
keywords: ['editor', 'editor-plugin-quick-insert', 'atlaskit'],
|
|
31
|
-
categories: ['editor'],
|
|
32
|
-
signature: 'quickInsertPlugin: QuickInsertPlugin',
|
|
33
|
-
examples: [],
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export default documentation;
|