@atlaskit/editor-synced-block-provider 3.12.0 → 3.13.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 +25 -0
- package/dist/cjs/clients/block-service/blockSubscription.js +124 -0
- package/dist/cjs/clients/jira/sourceInfo.js +152 -0
- package/dist/cjs/providers/block-service/blockServiceAPI.js +43 -6
- package/dist/cjs/providers/syncBlockProvider.js +40 -8
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +393 -204
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +95 -124
- package/dist/cjs/store-manager/syncBlockStoreManager.js +2 -2
- package/dist/cjs/utils/errorHandling.js +79 -19
- package/dist/cjs/utils/experienceTracking.js +119 -0
- package/dist/cjs/utils/resolveSyncBlockInstance.js +1 -1
- package/dist/es2019/clients/block-service/blockSubscription.js +125 -0
- package/dist/es2019/clients/jira/sourceInfo.js +87 -0
- package/dist/es2019/providers/block-service/blockServiceAPI.js +40 -5
- package/dist/es2019/providers/syncBlockProvider.js +26 -2
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +286 -139
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +80 -89
- package/dist/es2019/store-manager/syncBlockStoreManager.js +2 -2
- package/dist/es2019/utils/errorHandling.js +61 -10
- package/dist/es2019/utils/experienceTracking.js +113 -0
- package/dist/es2019/utils/resolveSyncBlockInstance.js +1 -1
- package/dist/esm/clients/block-service/blockSubscription.js +118 -0
- package/dist/esm/clients/jira/sourceInfo.js +147 -0
- package/dist/esm/providers/block-service/blockServiceAPI.js +43 -6
- package/dist/esm/providers/syncBlockProvider.js +38 -6
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +394 -205
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +96 -125
- package/dist/esm/store-manager/syncBlockStoreManager.js +2 -2
- package/dist/esm/utils/errorHandling.js +77 -18
- package/dist/esm/utils/experienceTracking.js +113 -0
- package/dist/esm/utils/resolveSyncBlockInstance.js +1 -1
- package/dist/types/clients/block-service/blockService.d.ts +2 -2
- package/dist/types/clients/block-service/blockSubscription.d.ts +38 -0
- package/dist/types/clients/jira/sourceInfo.d.ts +2 -0
- package/dist/types/common/types.d.ts +4 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +8 -0
- package/dist/types/providers/syncBlockProvider.d.ts +9 -1
- package/dist/types/providers/types.d.ts +22 -6
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +59 -1
- package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -5
- package/dist/types/utils/errorHandling.d.ts +14 -9
- package/dist/types/utils/experienceTracking.d.ts +51 -0
- package/dist/types-ts4.5/clients/block-service/blockService.d.ts +2 -2
- package/dist/types-ts4.5/clients/block-service/blockSubscription.d.ts +38 -0
- package/dist/types-ts4.5/clients/jira/sourceInfo.d.ts +2 -0
- package/dist/types-ts4.5/common/types.d.ts +4 -2
- package/dist/types-ts4.5/index.d.ts +2 -2
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +8 -0
- package/dist/types-ts4.5/providers/syncBlockProvider.d.ts +9 -1
- package/dist/types-ts4.5/providers/types.d.ts +22 -6
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +59 -1
- package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -5
- package/dist/types-ts4.5/utils/errorHandling.d.ts +14 -9
- package/dist/types-ts4.5/utils/experienceTracking.d.ts +51 -0
- package/package.json +2 -1
|
@@ -2,7 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { SyncBlockError } from '../common/types';
|
|
5
|
-
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload } from '../utils/errorHandling';
|
|
5
|
+
import { updateErrorPayload, createErrorPayload, deleteErrorPayload, updateCacheErrorPayload, getSourceInfoErrorPayload, updateSuccessPayload, createSuccessPayload, deleteSuccessPayload } from '../utils/errorHandling';
|
|
6
|
+
import { getCreateSourceExperience, getDeleteSourceExperience, getSaveSourceExperience } from '../utils/experienceTracking';
|
|
6
7
|
import { convertSyncBlockPMNodeToSyncBlockData } from '../utils/utils';
|
|
7
8
|
// A store manager responsible for the lifecycle and state management of source sync blocks in an editor instance.
|
|
8
9
|
// Designed to manage local in-memory state and synchronize with an external data provider.
|
|
@@ -22,15 +23,9 @@ export class SourceSyncBlockStoreManager {
|
|
|
22
23
|
}
|
|
23
24
|
setFireAnalyticsEvent(fireAnalyticsEvent) {
|
|
24
25
|
this.fireAnalyticsEvent = fireAnalyticsEvent;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
}
|
|
29
|
-
setSaveExperience(saveExperience) {
|
|
30
|
-
this.saveExperience = saveExperience;
|
|
31
|
-
}
|
|
32
|
-
setDeleteExperience(deleteExperience) {
|
|
33
|
-
this.deleteExperience = deleteExperience;
|
|
26
|
+
this.createExperience = getCreateSourceExperience(fireAnalyticsEvent);
|
|
27
|
+
this.saveExperience = getSaveSourceExperience(fireAnalyticsEvent);
|
|
28
|
+
this.deleteExperience = getDeleteSourceExperience(fireAnalyticsEvent);
|
|
34
29
|
}
|
|
35
30
|
isSourceBlock(node) {
|
|
36
31
|
return node.type.name === 'bodiedSyncBlock';
|
|
@@ -101,16 +96,14 @@ export class SourceSyncBlockStoreManager {
|
|
|
101
96
|
if (bodiedSyncBlockNodes.length === 0) {
|
|
102
97
|
return Promise.resolve(true);
|
|
103
98
|
}
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
if (!this.dataProvider) {
|
|
100
|
+
throw new Error('Data provider not set');
|
|
101
|
+
}
|
|
106
102
|
if (fg('platform_synced_block_dogfooding')) {
|
|
107
103
|
var _this$saveExperience;
|
|
108
104
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 ? void 0 : _this$saveExperience.start({});
|
|
109
105
|
}
|
|
110
106
|
;
|
|
111
|
-
if (!this.dataProvider) {
|
|
112
|
-
throw new Error('Data provider not set');
|
|
113
|
-
}
|
|
114
107
|
const writeResults = await this.dataProvider.writeNodesData(bodiedSyncBlockNodes, bodiedSyncBlockData);
|
|
115
108
|
writeResults.forEach(result => {
|
|
116
109
|
// set isDirty to true for cases where it failed to save the sync block to the BE
|
|
@@ -121,19 +114,14 @@ export class SourceSyncBlockStoreManager {
|
|
|
121
114
|
}
|
|
122
115
|
}
|
|
123
116
|
});
|
|
124
|
-
const successfulSaved = writeResults.filter(result => result.resourceId && !result.error).map(result => ({
|
|
125
|
-
resourceId: result.resourceId
|
|
126
|
-
}));
|
|
127
|
-
const failedSave = writeResults.filter(result => !result.resourceId || result.error).map(result => ({
|
|
128
|
-
resourceId: result.resourceId || 'unknown',
|
|
129
|
-
failReason: result.error || 'Failed to save sync blocks'
|
|
130
|
-
}));
|
|
131
117
|
if (writeResults.every(result => result.resourceId && !result.error)) {
|
|
132
118
|
if (fg('platform_synced_block_dogfooding')) {
|
|
133
119
|
var _this$saveExperience2;
|
|
134
|
-
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 ? void 0 : _this$saveExperience2.success(
|
|
135
|
-
|
|
136
|
-
|
|
120
|
+
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 ? void 0 : _this$saveExperience2.success();
|
|
121
|
+
writeResults.forEach(result => {
|
|
122
|
+
if (result.resourceId && !result.error) {
|
|
123
|
+
var _this$fireAnalyticsEv2;
|
|
124
|
+
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 ? void 0 : _this$fireAnalyticsEv2.call(this, updateSuccessPayload(result.resourceId, false));
|
|
137
125
|
}
|
|
138
126
|
});
|
|
139
127
|
}
|
|
@@ -142,33 +130,20 @@ export class SourceSyncBlockStoreManager {
|
|
|
142
130
|
} else {
|
|
143
131
|
if (fg('platform_synced_block_dogfooding')) {
|
|
144
132
|
var _this$saveExperience3;
|
|
145
|
-
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 ? void 0 : _this$saveExperience3.failure(
|
|
146
|
-
metadata: {
|
|
147
|
-
successfulSaved,
|
|
148
|
-
failedSave
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
} else {
|
|
152
|
-
writeResults.filter(result => !result.resourceId || result.error).forEach(result => {
|
|
153
|
-
var _this$fireAnalyticsEv2;
|
|
154
|
-
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 ? void 0 : _this$fireAnalyticsEv2.call(this, updateErrorPayload(result.error || 'Failed to write data'));
|
|
155
|
-
});
|
|
133
|
+
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 ? void 0 : _this$saveExperience3.failure();
|
|
156
134
|
}
|
|
135
|
+
writeResults.filter(result => !result.resourceId || result.error).forEach(result => {
|
|
136
|
+
var _this$fireAnalyticsEv3;
|
|
137
|
+
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 ? void 0 : _this$fireAnalyticsEv3.call(this, updateErrorPayload(result.error || 'Failed to write data', result.resourceId));
|
|
138
|
+
});
|
|
157
139
|
return false;
|
|
158
140
|
}
|
|
159
141
|
} catch (error) {
|
|
142
|
+
var _this$fireAnalyticsEv4;
|
|
160
143
|
logException(error, {
|
|
161
144
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
162
145
|
});
|
|
163
|
-
|
|
164
|
-
var _this$saveExperience4;
|
|
165
|
-
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 ? void 0 : _this$saveExperience4.failure({
|
|
166
|
-
reason: error.message
|
|
167
|
-
});
|
|
168
|
-
} else {
|
|
169
|
-
var _this$fireAnalyticsEv3;
|
|
170
|
-
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 ? void 0 : _this$fireAnalyticsEv3.call(this, updateErrorPayload(error.message));
|
|
171
|
-
}
|
|
146
|
+
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 ? void 0 : _this$fireAnalyticsEv4.call(this, updateErrorPayload(error.message));
|
|
172
147
|
return false;
|
|
173
148
|
}
|
|
174
149
|
}
|
|
@@ -190,6 +165,13 @@ export class SourceSyncBlockStoreManager {
|
|
|
190
165
|
commitPendingCreation(success) {
|
|
191
166
|
if (success && this.creationCallback) {
|
|
192
167
|
this.creationCallback();
|
|
168
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
169
|
+
var _this$fireAnalyticsEv5;
|
|
170
|
+
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, createSuccessPayload(this.pendingResourceId || ''));
|
|
171
|
+
}
|
|
172
|
+
} else if (success && !this.creationCallback && fg('platform_synced_block_dogfooding')) {
|
|
173
|
+
var _this$fireAnalyticsEv6;
|
|
174
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, createErrorPayload('creation callback missing', this.pendingResourceId));
|
|
193
175
|
}
|
|
194
176
|
this.pendingResourceId = undefined;
|
|
195
177
|
this.creationCallback = undefined;
|
|
@@ -235,6 +217,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
235
217
|
*/
|
|
236
218
|
createBodiedSyncBlockNode(attrs) {
|
|
237
219
|
try {
|
|
220
|
+
var _this$createExperienc;
|
|
238
221
|
if (!this.dataProvider) {
|
|
239
222
|
throw new Error('Data provider not set');
|
|
240
223
|
}
|
|
@@ -242,6 +225,7 @@ export class SourceSyncBlockStoreManager {
|
|
|
242
225
|
resourceId,
|
|
243
226
|
localId: blockInstanceId
|
|
244
227
|
} = attrs;
|
|
228
|
+
(_this$createExperienc = this.createExperience) === null || _this$createExperienc === void 0 ? void 0 : _this$createExperienc.start({});
|
|
245
229
|
this.dataProvider.createNodeData({
|
|
246
230
|
content: [],
|
|
247
231
|
blockInstanceId,
|
|
@@ -250,50 +234,45 @@ export class SourceSyncBlockStoreManager {
|
|
|
250
234
|
const resourceId = result.resourceId;
|
|
251
235
|
if (resourceId) {
|
|
252
236
|
this.commitPendingCreation(true);
|
|
237
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
238
|
+
var _this$createExperienc2;
|
|
239
|
+
(_this$createExperienc2 = this.createExperience) === null || _this$createExperienc2 === void 0 ? void 0 : _this$createExperienc2.success();
|
|
240
|
+
}
|
|
253
241
|
} else {
|
|
242
|
+
var _this$fireAnalyticsEv7;
|
|
254
243
|
this.commitPendingCreation(false);
|
|
255
244
|
if (fg('platform_synced_block_dogfooding')) {
|
|
256
|
-
var _this$
|
|
257
|
-
(_this$
|
|
245
|
+
var _this$createExperienc3;
|
|
246
|
+
(_this$createExperienc3 = this.createExperience) === null || _this$createExperienc3 === void 0 ? void 0 : _this$createExperienc3.failure({
|
|
258
247
|
reason: result.error || 'Failed to create bodied sync block'
|
|
259
248
|
});
|
|
260
|
-
} else {
|
|
261
|
-
var _this$fireAnalyticsEv4;
|
|
262
|
-
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 ? void 0 : _this$fireAnalyticsEv4.call(this, createErrorPayload(result.error || 'Failed to create bodied sync block'));
|
|
263
249
|
}
|
|
250
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, createErrorPayload(result.error || 'Failed to create bodied sync block', resourceId));
|
|
264
251
|
}
|
|
265
252
|
}).catch(error => {
|
|
253
|
+
var _this$fireAnalyticsEv8;
|
|
266
254
|
this.commitPendingCreation(false);
|
|
267
255
|
logException(error, {
|
|
268
256
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
269
257
|
});
|
|
270
258
|
if (fg('platform_synced_block_dogfooding')) {
|
|
271
|
-
var _this$
|
|
272
|
-
(_this$
|
|
259
|
+
var _this$createExperienc4;
|
|
260
|
+
(_this$createExperienc4 = this.createExperience) === null || _this$createExperienc4 === void 0 ? void 0 : _this$createExperienc4.failure({
|
|
273
261
|
reason: error.message
|
|
274
262
|
});
|
|
275
|
-
} else {
|
|
276
|
-
var _this$fireAnalyticsEv5;
|
|
277
|
-
(_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, createErrorPayload(error.message));
|
|
278
263
|
}
|
|
264
|
+
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, createErrorPayload(error.message, resourceId));
|
|
279
265
|
});
|
|
280
266
|
this.registerPendingCreation(resourceId);
|
|
281
267
|
} catch (error) {
|
|
268
|
+
var _this$fireAnalyticsEv9;
|
|
282
269
|
if (this.hasPendingCreation()) {
|
|
283
270
|
this.commitPendingCreation(false);
|
|
284
271
|
}
|
|
285
272
|
logException(error, {
|
|
286
273
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
287
274
|
});
|
|
288
|
-
|
|
289
|
-
var _this$createExperienc3;
|
|
290
|
-
(_this$createExperienc3 = this.createExperience) === null || _this$createExperienc3 === void 0 ? void 0 : _this$createExperienc3.failure({
|
|
291
|
-
reason: error.message
|
|
292
|
-
});
|
|
293
|
-
} else {
|
|
294
|
-
var _this$fireAnalyticsEv6;
|
|
295
|
-
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, createErrorPayload(error.message));
|
|
296
|
-
}
|
|
275
|
+
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 ? void 0 : _this$fireAnalyticsEv9.call(this, createErrorPayload(error.message));
|
|
297
276
|
}
|
|
298
277
|
}
|
|
299
278
|
async delete(syncBlockIds, onDelete, onDeleteCompleted) {
|
|
@@ -304,6 +283,10 @@ export class SourceSyncBlockStoreManager {
|
|
|
304
283
|
syncBlockIds.forEach(Ids => {
|
|
305
284
|
this.setPendingDeletion(Ids, true);
|
|
306
285
|
});
|
|
286
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
287
|
+
var _this$deleteExperienc;
|
|
288
|
+
(_this$deleteExperienc = this.deleteExperience) === null || _this$deleteExperienc === void 0 ? void 0 : _this$deleteExperienc.start({});
|
|
289
|
+
}
|
|
307
290
|
const results = await this.dataProvider.deleteNodesData(syncBlockIds.map(attrs => attrs.resourceId));
|
|
308
291
|
let callback;
|
|
309
292
|
const isDeleteSuccessful = results.every(result => result.success);
|
|
@@ -312,29 +295,34 @@ export class SourceSyncBlockStoreManager {
|
|
|
312
295
|
onDelete();
|
|
313
296
|
callback = Ids => this.syncBlockCache.delete(Ids.resourceId);
|
|
314
297
|
this.clearPendingDeletion();
|
|
298
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
299
|
+
var _this$deleteExperienc2;
|
|
300
|
+
(_this$deleteExperienc2 = this.deleteExperience) === null || _this$deleteExperienc2 === void 0 ? void 0 : _this$deleteExperienc2.success();
|
|
301
|
+
results.forEach(result => {
|
|
302
|
+
var _this$fireAnalyticsEv0;
|
|
303
|
+
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, deleteSuccessPayload(result.resourceId));
|
|
304
|
+
});
|
|
305
|
+
}
|
|
315
306
|
} else {
|
|
316
307
|
callback = Ids => {
|
|
317
308
|
this.setPendingDeletion(Ids, false);
|
|
318
309
|
};
|
|
319
310
|
if (fg('platform_synced_block_dogfooding')) {
|
|
320
|
-
var _this$
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
metadata: {
|
|
330
|
-
successfulDeleted,
|
|
331
|
-
failedDelete
|
|
311
|
+
var _this$deleteExperienc3;
|
|
312
|
+
(_this$deleteExperienc3 = this.deleteExperience) === null || _this$deleteExperienc3 === void 0 ? void 0 : _this$deleteExperienc3.failure();
|
|
313
|
+
results.forEach(result => {
|
|
314
|
+
if (result.success) {
|
|
315
|
+
var _this$fireAnalyticsEv1;
|
|
316
|
+
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 ? void 0 : _this$fireAnalyticsEv1.call(this, deleteSuccessPayload(result.resourceId));
|
|
317
|
+
} else {
|
|
318
|
+
var _this$fireAnalyticsEv10;
|
|
319
|
+
(_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 ? void 0 : _this$fireAnalyticsEv10.call(this, deleteErrorPayload(result.error || 'Failed to delete synced block', result.resourceId));
|
|
332
320
|
}
|
|
333
321
|
});
|
|
334
322
|
} else {
|
|
335
323
|
results.filter(result => result.resourceId === undefined).forEach(result => {
|
|
336
|
-
var _this$
|
|
337
|
-
(_this$
|
|
324
|
+
var _this$fireAnalyticsEv11;
|
|
325
|
+
(_this$fireAnalyticsEv11 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv11 === void 0 ? void 0 : _this$fireAnalyticsEv11.call(this, deleteErrorPayload(result.error || 'Failed to delete synced block'));
|
|
338
326
|
});
|
|
339
327
|
}
|
|
340
328
|
}
|
|
@@ -342,20 +330,13 @@ export class SourceSyncBlockStoreManager {
|
|
|
342
330
|
return isDeleteSuccessful;
|
|
343
331
|
} catch (error) {
|
|
344
332
|
syncBlockIds.forEach(Ids => {
|
|
333
|
+
var _this$fireAnalyticsEv12;
|
|
345
334
|
this.setPendingDeletion(Ids, false);
|
|
335
|
+
(_this$fireAnalyticsEv12 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv12 === void 0 ? void 0 : _this$fireAnalyticsEv12.call(this, deleteErrorPayload(error.message, Ids.resourceId));
|
|
346
336
|
});
|
|
347
337
|
logException(error, {
|
|
348
338
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
349
339
|
});
|
|
350
|
-
if (fg('platform_synced_block_dogfooding')) {
|
|
351
|
-
var _this$deleteExperienc2;
|
|
352
|
-
(_this$deleteExperienc2 = this.deleteExperience) === null || _this$deleteExperienc2 === void 0 ? void 0 : _this$deleteExperienc2.failure({
|
|
353
|
-
reason: error.message
|
|
354
|
-
});
|
|
355
|
-
} else {
|
|
356
|
-
var _this$fireAnalyticsEv8;
|
|
357
|
-
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, deleteErrorPayload(error.message));
|
|
358
|
-
}
|
|
359
340
|
onDeleteCompleted(false);
|
|
360
341
|
return false;
|
|
361
342
|
}
|
|
@@ -417,20 +398,30 @@ export class SourceSyncBlockStoreManager {
|
|
|
417
398
|
}
|
|
418
399
|
return this.dataProvider.fetchSyncBlockSourceInfo(localId, undefined, undefined, this.fireAnalyticsEvent);
|
|
419
400
|
} catch (error) {
|
|
420
|
-
var _this$
|
|
401
|
+
var _this$fireAnalyticsEv13;
|
|
421
402
|
logException(error, {
|
|
422
403
|
location: 'editor-synced-block-provider/sourceSyncBlockStoreManager'
|
|
423
404
|
});
|
|
424
|
-
(_this$
|
|
405
|
+
(_this$fireAnalyticsEv13 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv13 === void 0 ? void 0 : _this$fireAnalyticsEv13.call(this, getSourceInfoErrorPayload(error.message));
|
|
425
406
|
return Promise.resolve(undefined);
|
|
426
407
|
}
|
|
427
408
|
}
|
|
428
409
|
destroy() {
|
|
410
|
+
var _this$saveExperience4, _this$createExperienc5, _this$deleteExperienc4;
|
|
429
411
|
this.syncBlockCache.clear();
|
|
430
412
|
this.confirmationCallback = undefined;
|
|
431
413
|
this.pendingResourceId = undefined;
|
|
432
414
|
this.creationCallback = undefined;
|
|
433
415
|
this.dataProvider = undefined;
|
|
416
|
+
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 ? void 0 : _this$saveExperience4.abort({
|
|
417
|
+
reason: 'editor-destroyed'
|
|
418
|
+
});
|
|
419
|
+
(_this$createExperienc5 = this.createExperience) === null || _this$createExperienc5 === void 0 ? void 0 : _this$createExperienc5.abort({
|
|
420
|
+
reason: 'editor-destroyed'
|
|
421
|
+
});
|
|
422
|
+
(_this$deleteExperienc4 = this.deleteExperience) === null || _this$deleteExperienc4 === void 0 ? void 0 : _this$deleteExperienc4.abort({
|
|
423
|
+
reason: 'editor-destroyed'
|
|
424
|
+
});
|
|
434
425
|
this.clearPendingDeletion();
|
|
435
426
|
}
|
|
436
427
|
}
|
|
@@ -47,7 +47,7 @@ export class SyncBlockStoreManager {
|
|
|
47
47
|
}
|
|
48
48
|
return {
|
|
49
49
|
...sourceInfo,
|
|
50
|
-
|
|
50
|
+
onSameDocument: reference.onSameDocument,
|
|
51
51
|
hasAccess: reference.hasAccess,
|
|
52
52
|
productType: sourceInfo.productType
|
|
53
53
|
};
|
|
@@ -57,7 +57,7 @@ export class SyncBlockStoreManager {
|
|
|
57
57
|
if (sourceSyncBlockData) {
|
|
58
58
|
sourceInfos.push({
|
|
59
59
|
...sourceSyncBlockData,
|
|
60
|
-
|
|
60
|
+
onSameDocument: Boolean(sourceSyncBlockData === null || sourceSyncBlockData === void 0 ? void 0 : sourceSyncBlockData.onSameDocument),
|
|
61
61
|
hasAccess: true,
|
|
62
62
|
isSource: true,
|
|
63
63
|
productType: sourceSyncBlockData === null || sourceSyncBlockData === void 0 ? void 0 : sourceSyncBlockData.productType
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
export const stringifyError = error => {
|
|
3
4
|
try {
|
|
4
5
|
return JSON.stringify(error);
|
|
@@ -6,20 +7,70 @@ export const stringifyError = error => {
|
|
|
6
7
|
return undefined;
|
|
7
8
|
}
|
|
8
9
|
};
|
|
9
|
-
export const getErrorPayload = (actionSubjectId, error) => ({
|
|
10
|
+
export const getErrorPayload = (actionSubjectId, error, resourceId) => ({
|
|
10
11
|
action: ACTION.ERROR,
|
|
11
12
|
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
12
13
|
actionSubjectId,
|
|
13
14
|
eventType: EVENT_TYPE.OPERATIONAL,
|
|
14
|
-
attributes: {
|
|
15
|
+
attributes: fg('platform_synced_block_dogfooding') ? {
|
|
16
|
+
error,
|
|
17
|
+
...(resourceId && {
|
|
18
|
+
resourceId
|
|
19
|
+
})
|
|
20
|
+
} : {
|
|
15
21
|
error
|
|
16
22
|
}
|
|
17
23
|
});
|
|
18
|
-
export const fetchErrorPayload = error => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_FETCH, error);
|
|
19
|
-
export const getSourceInfoErrorPayload = error => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_GET_SOURCE_INFO, error);
|
|
20
|
-
export const updateErrorPayload = error => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_UPDATE, error);
|
|
21
|
-
export const updateReferenceErrorPayload = error => getErrorPayload(ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_UPDATE, error);
|
|
22
|
-
export const createErrorPayload = error => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE, error);
|
|
23
|
-
export const deleteErrorPayload = error => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_DELETE, error);
|
|
24
|
-
export const updateCacheErrorPayload = error => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_UPDATE_CACHE, error);
|
|
25
|
-
export const fetchReferencesErrorPayload = error => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_FETCH_REFERENCES, error);
|
|
24
|
+
export const fetchErrorPayload = (error, resourceId) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_FETCH, error, resourceId);
|
|
25
|
+
export const getSourceInfoErrorPayload = (error, resourceId) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_GET_SOURCE_INFO, error, resourceId);
|
|
26
|
+
export const updateErrorPayload = (error, resourceId) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_UPDATE, error, resourceId);
|
|
27
|
+
export const updateReferenceErrorPayload = (error, resourceId) => getErrorPayload(ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_UPDATE, error, resourceId);
|
|
28
|
+
export const createErrorPayload = (error, resourceId) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE, error, resourceId);
|
|
29
|
+
export const deleteErrorPayload = (error, resourceId) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_DELETE, error, resourceId);
|
|
30
|
+
export const updateCacheErrorPayload = (error, resourceId) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_UPDATE_CACHE, error, resourceId);
|
|
31
|
+
export const fetchReferencesErrorPayload = (error, resourceId) => getErrorPayload(ACTION_SUBJECT_ID.SYNCED_BLOCK_FETCH_REFERENCES, error, resourceId);
|
|
32
|
+
|
|
33
|
+
// Success payloads
|
|
34
|
+
export const fetchSuccessPayload = (resourceId, blockInstanceId, sourceProduct) => ({
|
|
35
|
+
action: ACTION.FETCHED,
|
|
36
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
37
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_FETCH,
|
|
38
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
39
|
+
attributes: {
|
|
40
|
+
resourceId,
|
|
41
|
+
blockInstanceId,
|
|
42
|
+
...(sourceProduct && {
|
|
43
|
+
sourceProduct
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
export const createSuccessPayload = resourceId => ({
|
|
48
|
+
action: ACTION.INSERTED,
|
|
49
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
50
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
51
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
52
|
+
attributes: {
|
|
53
|
+
resourceId
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
export const updateSuccessPayload = (resourceId, hasReference) => ({
|
|
57
|
+
action: ACTION.UPDATED,
|
|
58
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
59
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_UPDATE,
|
|
60
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
61
|
+
attributes: {
|
|
62
|
+
resourceId,
|
|
63
|
+
...(hasReference !== undefined && {
|
|
64
|
+
hasReference
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
export const deleteSuccessPayload = resourceId => ({
|
|
69
|
+
action: ACTION.DELETED,
|
|
70
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
71
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_DELETE,
|
|
72
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
73
|
+
attributes: {
|
|
74
|
+
resourceId
|
|
75
|
+
}
|
|
76
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { Experience, EXPERIENCE_ID, ExperienceCheckTimeout } from '@atlaskit/editor-common/experiences';
|
|
3
|
+
const TIMEOUT_DURATION = 30000;
|
|
4
|
+
export const createExperienceDispatcher = fireAnalyticsEvent => {
|
|
5
|
+
return payload => {
|
|
6
|
+
// Runtime type guard - only forward experience events
|
|
7
|
+
if (payload.action === ACTION.EXPERIENCE_MEASURED || payload.action === ACTION.EXPERIENCE_SAMPLED) {
|
|
8
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent(payload);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This experience tracks when a source sync block is saved to the BE.
|
|
15
|
+
*
|
|
16
|
+
* Start: When the flush source sync block function is called.
|
|
17
|
+
* Success: When the sync block save is successful within the timeout duration of start.
|
|
18
|
+
* Failure: When the timeout duration passes without the sync block being successfully saved
|
|
19
|
+
*/
|
|
20
|
+
export const getSaveSourceExperience = fireAnalyticsEvent => {
|
|
21
|
+
return new Experience(EXPERIENCE_ID.ASYNC_OPERATION, {
|
|
22
|
+
action: ACTION.SYNCED_BLOCK_UPDATE,
|
|
23
|
+
dispatchAnalyticsEvent: createExperienceDispatcher(fireAnalyticsEvent),
|
|
24
|
+
checks: [new ExperienceCheckTimeout({
|
|
25
|
+
durationMs: TIMEOUT_DURATION
|
|
26
|
+
})]
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* This experience tracks when a reference sync block is saved to the BE.
|
|
32
|
+
*
|
|
33
|
+
* Start: When the flush sync block function is called.
|
|
34
|
+
* Success: When the sync block save is successful within the timeout duration of start.
|
|
35
|
+
* Failure: When the timeout duration passes without the sync block being successfully saved
|
|
36
|
+
*/
|
|
37
|
+
export const getSaveReferenceExperience = fireAnalyticsEvent => {
|
|
38
|
+
return new Experience(EXPERIENCE_ID.ASYNC_OPERATION, {
|
|
39
|
+
action: ACTION.REFERENCE_SYNCED_BLOCK_UPDATE,
|
|
40
|
+
dispatchAnalyticsEvent: createExperienceDispatcher(fireAnalyticsEvent),
|
|
41
|
+
checks: [new ExperienceCheckTimeout({
|
|
42
|
+
durationMs: TIMEOUT_DURATION
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* This experience tracks when a reference sync block data is fetched from the BE.
|
|
49
|
+
*
|
|
50
|
+
* Start: When the fetchNodesData function is called.
|
|
51
|
+
* Success: When the fetching the data is successful within the timeout duration of start.
|
|
52
|
+
* Failure: When the timeout duration passes without the data being successfully fetched, or the fetch fails
|
|
53
|
+
*/
|
|
54
|
+
export const getFetchExperience = fireAnalyticsEvent => {
|
|
55
|
+
return new Experience(EXPERIENCE_ID.ASYNC_OPERATION, {
|
|
56
|
+
action: ACTION.SYNCED_BLOCK_FETCH,
|
|
57
|
+
dispatchAnalyticsEvent: createExperienceDispatcher(fireAnalyticsEvent),
|
|
58
|
+
checks: [new ExperienceCheckTimeout({
|
|
59
|
+
durationMs: TIMEOUT_DURATION
|
|
60
|
+
})]
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* This experience tracks when a reference sync block source info data (title, url) is fetched from the BE.
|
|
66
|
+
*
|
|
67
|
+
* Start: When the fetchSourceInfo function is called.
|
|
68
|
+
* Success: When the fetching the data is successful within the timeout duration of start.
|
|
69
|
+
* Failure: When the timeout duration passes without the data being successfully fetched, or the fetch fails
|
|
70
|
+
*/
|
|
71
|
+
export const getFetchSourceInfoExperience = fireAnalyticsEvent => {
|
|
72
|
+
return new Experience(EXPERIENCE_ID.ASYNC_OPERATION, {
|
|
73
|
+
action: ACTION.SYNCED_BLOCK_GET_SOURCE_INFO,
|
|
74
|
+
dispatchAnalyticsEvent: createExperienceDispatcher(fireAnalyticsEvent),
|
|
75
|
+
checks: [new ExperienceCheckTimeout({
|
|
76
|
+
durationMs: TIMEOUT_DURATION
|
|
77
|
+
})]
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* This experience tracks when a source sync block is deleted from the BE.
|
|
83
|
+
*
|
|
84
|
+
* Start: When the fetchSourceInfo function is called.
|
|
85
|
+
* Success: When the fetching the data is successful within the timeout duration of start.
|
|
86
|
+
* Failure: When the timeout duration passes without the data being successfully fetched, or the fetch fails
|
|
87
|
+
*/
|
|
88
|
+
export const getDeleteSourceExperience = fireAnalyticsEvent => {
|
|
89
|
+
return new Experience(EXPERIENCE_ID.ASYNC_OPERATION, {
|
|
90
|
+
action: ACTION.SYNCED_BLOCK_DELETE,
|
|
91
|
+
dispatchAnalyticsEvent: createExperienceDispatcher(fireAnalyticsEvent),
|
|
92
|
+
checks: [new ExperienceCheckTimeout({
|
|
93
|
+
durationMs: TIMEOUT_DURATION
|
|
94
|
+
})]
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* This experience tracks when a source sync block is created and registered to the BE.
|
|
100
|
+
*
|
|
101
|
+
* Start: When the fetchSourceInfo function is called.
|
|
102
|
+
* Success: When the fetching the data is successful within the timeout duration of start.
|
|
103
|
+
* Failure: When the timeout duration passes without the data being successfully fetched, or the fetch fails
|
|
104
|
+
*/
|
|
105
|
+
export const getCreateSourceExperience = fireAnalyticsEvent => {
|
|
106
|
+
return new Experience(EXPERIENCE_ID.ASYNC_OPERATION, {
|
|
107
|
+
action: ACTION.SYNCED_BLOCK_CREATE,
|
|
108
|
+
dispatchAnalyticsEvent: createExperienceDispatcher(fireAnalyticsEvent),
|
|
109
|
+
checks: [new ExperienceCheckTimeout({
|
|
110
|
+
durationMs: TIMEOUT_DURATION
|
|
111
|
+
})]
|
|
112
|
+
});
|
|
113
|
+
};
|
|
@@ -33,7 +33,7 @@ export const resolveSyncBlockInstance = (oldResult, newResult) => {
|
|
|
33
33
|
sourceTitle: ((_newResult$data2 = newResult.data) === null || _newResult$data2 === void 0 ? void 0 : _newResult$data2.sourceTitle) || ((_oldResult$data2 = oldResult.data) === null || _oldResult$data2 === void 0 ? void 0 : _oldResult$data2.sourceTitle) || undefined,
|
|
34
34
|
...(fg('platform_synced_block_dogfooding') && {
|
|
35
35
|
sourceSubType: ((_newResult$data3 = newResult.data) === null || _newResult$data3 === void 0 ? void 0 : _newResult$data3.sourceSubType) || ((_oldResult$data3 = oldResult.data) === null || _oldResult$data3 === void 0 ? void 0 : _oldResult$data3.sourceSubType) || undefined,
|
|
36
|
-
|
|
36
|
+
onSameDocument: ((_newResult$data4 = newResult.data) === null || _newResult$data4 === void 0 ? void 0 : _newResult$data4.onSameDocument) || ((_oldResult$data4 = oldResult.data) === null || _oldResult$data4 === void 0 ? void 0 : _oldResult$data4.onSameDocument) || undefined
|
|
37
37
|
})
|
|
38
38
|
}
|
|
39
39
|
};
|