@atlaskit/editor-synced-block-provider 3.11.0 → 3.12.1
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 +17 -0
- package/dist/cjs/clients/block-service/blockService.js +2 -2
- package/dist/cjs/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +92 -136
- package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +95 -124
- package/dist/cjs/utils/errorHandling.js +79 -19
- package/dist/cjs/utils/experienceTracking.js +119 -0
- package/dist/es2019/clients/block-service/blockService.js +2 -2
- package/dist/es2019/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +85 -126
- package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +80 -89
- package/dist/es2019/utils/errorHandling.js +61 -10
- package/dist/es2019/utils/experienceTracking.js +113 -0
- package/dist/esm/clients/block-service/blockService.js +2 -2
- package/dist/esm/providers/block-service/blockServiceAPI.js +1 -1
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +93 -137
- package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +96 -125
- package/dist/esm/utils/errorHandling.js +77 -18
- package/dist/esm/utils/experienceTracking.js +113 -0
- package/dist/types/clients/block-service/blockService.d.ts +5 -5
- package/dist/types/providers/block-service/blockServiceAPI.d.ts +1 -1
- package/dist/types/providers/types.d.ts +5 -5
- package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +0 -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 +5 -5
- package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +1 -1
- package/dist/types-ts4.5/providers/types.d.ts +5 -5
- package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +0 -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 -2
|
@@ -13,7 +13,8 @@ import { logException } from '@atlaskit/editor-common/monitoring';
|
|
|
13
13
|
import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
15
|
import { SyncBlockError } from '../common/types';
|
|
16
|
-
import { fetchErrorPayload, getSourceInfoErrorPayload, updateReferenceErrorPayload } from '../utils/errorHandling';
|
|
16
|
+
import { fetchErrorPayload, fetchSuccessPayload, getSourceInfoErrorPayload, updateReferenceErrorPayload } from '../utils/errorHandling';
|
|
17
|
+
import { getFetchExperience, getFetchSourceInfoExperience, getSaveReferenceExperience } from '../utils/experienceTracking';
|
|
17
18
|
import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
|
|
18
19
|
import { parseResourceId } from '../utils/resourceId';
|
|
19
20
|
import { createSyncBlockNode } from '../utils/utils';
|
|
@@ -50,16 +51,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
50
51
|
key: "setFireAnalyticsEvent",
|
|
51
52
|
value: function setFireAnalyticsEvent(fireAnalyticsEvent) {
|
|
52
53
|
this.fireAnalyticsEvent = fireAnalyticsEvent;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
value: function setExperiences(fetchExperience, fetchSourceInfoExperience, saveExperience) {
|
|
57
|
-
// don't reset experiences after they have already been set
|
|
58
|
-
if (!this.fetchExperience || !this.fetchSourceInfoExperience || !this.saveExperience) {
|
|
59
|
-
this.fetchExperience = fetchExperience;
|
|
60
|
-
this.fetchSourceInfoExperience = fetchSourceInfoExperience;
|
|
61
|
-
this.saveExperience = saveExperience;
|
|
62
|
-
}
|
|
54
|
+
this.fetchExperience = getFetchExperience(fireAnalyticsEvent);
|
|
55
|
+
this.fetchSourceInfoExperience = getFetchSourceInfoExperience(fireAnalyticsEvent);
|
|
56
|
+
this.saveExperience = getSaveReferenceExperience(fireAnalyticsEvent);
|
|
63
57
|
}
|
|
64
58
|
}, {
|
|
65
59
|
key: "generateResourceIdForReference",
|
|
@@ -90,7 +84,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
90
84
|
key: "refreshSubscriptions",
|
|
91
85
|
value: (function () {
|
|
92
86
|
var _refreshSubscriptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
93
|
-
var syncBlocks, _iterator, _step, _loop, _this$
|
|
87
|
+
var syncBlocks, _iterator, _step, _loop, _this$fireAnalyticsEv;
|
|
94
88
|
return _regeneratorRuntime.wrap(function _callee$(_context2) {
|
|
95
89
|
while (1) switch (_context2.prev = _context2.next) {
|
|
96
90
|
case 0:
|
|
@@ -153,13 +147,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
153
147
|
logException(_context2.t2, {
|
|
154
148
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
155
149
|
});
|
|
156
|
-
|
|
157
|
-
(_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 || _this$fetchExperience.failure({
|
|
158
|
-
reason: _context2.t2.message
|
|
159
|
-
});
|
|
160
|
-
} else {
|
|
161
|
-
(_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, fetchErrorPayload(_context2.t2.message));
|
|
162
|
-
}
|
|
150
|
+
(_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, fetchErrorPayload(_context2.t2.message));
|
|
163
151
|
case 29:
|
|
164
152
|
_context2.prev = 29;
|
|
165
153
|
this.isRefreshingSubscriptions = false;
|
|
@@ -181,11 +169,6 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
181
169
|
var _this = this;
|
|
182
170
|
try {
|
|
183
171
|
if (!resourceId || !this.dataProvider) {
|
|
184
|
-
// make sure experience has been started before throwing error
|
|
185
|
-
if (fg('platform_synced_block_dogfooding')) {
|
|
186
|
-
var _this$fetchSourceInfo;
|
|
187
|
-
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
188
|
-
}
|
|
189
172
|
throw new Error('Data provider or resourceId not set');
|
|
190
173
|
}
|
|
191
174
|
if (fg('platform_synced_block_dogfooding')) {
|
|
@@ -198,10 +181,6 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
198
181
|
}
|
|
199
182
|
var existingSyncBlock = this.getFromCache(resourceId);
|
|
200
183
|
if (!existingSyncBlock) {
|
|
201
|
-
if (fg('platform_synced_block_dogfooding')) {
|
|
202
|
-
var _this$fetchSourceInfo2;
|
|
203
|
-
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.start({});
|
|
204
|
-
}
|
|
205
184
|
throw new Error('No existing sync block to fetch source info for');
|
|
206
185
|
}
|
|
207
186
|
var _ref = existingSyncBlock.data || {},
|
|
@@ -227,31 +206,23 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
227
206
|
return Promise.resolve(undefined);
|
|
228
207
|
}
|
|
229
208
|
}
|
|
230
|
-
|
|
231
|
-
// only start experience if there is data to fetch
|
|
232
|
-
if (fg('platform_synced_block_dogfooding')) {
|
|
233
|
-
var _this$fetchSourceInfo3;
|
|
234
|
-
(_this$fetchSourceInfo3 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 || _this$fetchSourceInfo3.start({});
|
|
235
|
-
}
|
|
236
209
|
if (!sourceAri || !product || !blockInstanceId) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
(_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 || _this$fetchSourceInfo4.failure({
|
|
240
|
-
reason: 'SourceAri, product or blockInstanceId missing'
|
|
241
|
-
});
|
|
242
|
-
} else {
|
|
243
|
-
var _this$fireAnalyticsEv2;
|
|
244
|
-
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing'));
|
|
245
|
-
}
|
|
210
|
+
var _this$fireAnalyticsEv2;
|
|
211
|
+
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing', resourceId));
|
|
246
212
|
return Promise.resolve(undefined);
|
|
247
213
|
}
|
|
214
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
215
|
+
var _this$fetchSourceInfo;
|
|
216
|
+
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
217
|
+
}
|
|
248
218
|
var sourceInfoPromise = this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, this.fireAnalyticsEvent).then(function (sourceInfo) {
|
|
249
219
|
if (!sourceInfo) {
|
|
250
220
|
if (fg('platform_synced_block_dogfooding')) {
|
|
251
|
-
var _this$
|
|
252
|
-
(_this$
|
|
221
|
+
var _this$fetchSourceInfo2, _this$fireAnalyticsEv3;
|
|
222
|
+
(_this$fetchSourceInfo2 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.failure({
|
|
253
223
|
reason: 'No source info returned'
|
|
254
224
|
});
|
|
225
|
+
(_this$fireAnalyticsEv3 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(_this, getSourceInfoErrorPayload('No source info returned', resourceId));
|
|
255
226
|
}
|
|
256
227
|
return undefined;
|
|
257
228
|
}
|
|
@@ -261,26 +232,26 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
261
232
|
}
|
|
262
233
|
if (fg('platform_synced_block_dogfooding')) {
|
|
263
234
|
if (sourceInfo.title && sourceInfo.url) {
|
|
264
|
-
var _this$
|
|
265
|
-
(_this$
|
|
235
|
+
var _this$fetchSourceInfo3;
|
|
236
|
+
(_this$fetchSourceInfo3 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 || _this$fetchSourceInfo3.success();
|
|
266
237
|
} else {
|
|
267
|
-
var _this$
|
|
268
|
-
(_this$
|
|
238
|
+
var _this$fetchSourceInfo4, _this$fireAnalyticsEv4;
|
|
239
|
+
(_this$fetchSourceInfo4 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 || _this$fetchSourceInfo4.failure({
|
|
269
240
|
reason: 'Missing title or url'
|
|
270
241
|
});
|
|
242
|
+
(_this$fireAnalyticsEv4 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(_this, getSourceInfoErrorPayload('Missing title or url', resourceId));
|
|
271
243
|
}
|
|
272
244
|
return sourceInfo;
|
|
273
245
|
}
|
|
274
246
|
}).catch(function (error) {
|
|
247
|
+
var _this$fireAnalyticsEv5;
|
|
275
248
|
if (fg('platform_synced_block_dogfooding')) {
|
|
276
|
-
var _this$
|
|
277
|
-
(_this$
|
|
249
|
+
var _this$fetchSourceInfo5;
|
|
250
|
+
(_this$fetchSourceInfo5 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo5 === void 0 || _this$fetchSourceInfo5.failure({
|
|
278
251
|
reason: error.message
|
|
279
252
|
});
|
|
280
|
-
} else {
|
|
281
|
-
var _this$fireAnalyticsEv3;
|
|
282
|
-
(_this$fireAnalyticsEv3 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(_this, getSourceInfoErrorPayload(error.message));
|
|
283
253
|
}
|
|
254
|
+
(_this$fireAnalyticsEv5 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(_this, getSourceInfoErrorPayload(error.message, resourceId));
|
|
284
255
|
return undefined;
|
|
285
256
|
}).finally(function () {
|
|
286
257
|
if (fg('platform_synced_block_dogfooding')) {
|
|
@@ -296,18 +267,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
296
267
|
this.syncBlockSourceInfoRequestsOld.set(resourceId, true);
|
|
297
268
|
}
|
|
298
269
|
} catch (error) {
|
|
270
|
+
var _this$fireAnalyticsEv6;
|
|
299
271
|
logException(error, {
|
|
300
272
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
301
273
|
});
|
|
302
|
-
|
|
303
|
-
var _this$fetchSourceInfo9;
|
|
304
|
-
(_this$fetchSourceInfo9 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo9 === void 0 || _this$fetchSourceInfo9.failure({
|
|
305
|
-
reason: error.message
|
|
306
|
-
});
|
|
307
|
-
} else {
|
|
308
|
-
var _this$fireAnalyticsEv4;
|
|
309
|
-
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, getSourceInfoErrorPayload(error.message));
|
|
310
|
-
}
|
|
274
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, getSourceInfoErrorPayload(error.message, resourceId));
|
|
311
275
|
}
|
|
312
276
|
return Promise.resolve(undefined);
|
|
313
277
|
}
|
|
@@ -322,7 +286,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
322
286
|
value: (function () {
|
|
323
287
|
var _fetchSyncBlocksData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(syncBlockNodes) {
|
|
324
288
|
var _this2 = this;
|
|
325
|
-
var nodesToFetch, _this$
|
|
289
|
+
var nodesToFetch, _this$fetchExperience, data, resolvedData, hasUnexpectedError, hasExpectedError, _this$fetchExperience2, _this$fetchExperience3, _this$fetchExperience4;
|
|
326
290
|
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
|
327
291
|
while (1) switch (_context3.prev = _context3.next) {
|
|
328
292
|
case 0:
|
|
@@ -350,19 +314,18 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
350
314
|
}
|
|
351
315
|
return _context3.abrupt("return");
|
|
352
316
|
case 6:
|
|
353
|
-
// only start fetch experience if there is data to fetch
|
|
354
|
-
if (fg('platform_synced_block_dogfooding')) {
|
|
355
|
-
(_this$fetchExperience2 = this.fetchExperience) === null || _this$fetchExperience2 === void 0 || _this$fetchExperience2.start({});
|
|
356
|
-
}
|
|
357
317
|
if (this.dataProvider) {
|
|
358
|
-
_context3.next =
|
|
318
|
+
_context3.next = 8;
|
|
359
319
|
break;
|
|
360
320
|
}
|
|
361
321
|
throw new Error('Data provider not set');
|
|
362
|
-
case
|
|
322
|
+
case 8:
|
|
363
323
|
nodesToFetch.forEach(function (node) {
|
|
364
324
|
_this2.syncBlockFetchDataRequests.set(node.attrs.resourceId, true);
|
|
365
325
|
});
|
|
326
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
327
|
+
(_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 || _this$fetchExperience.start({});
|
|
328
|
+
}
|
|
366
329
|
_context3.next = 12;
|
|
367
330
|
return this.dataProvider.fetchNodesData(nodesToFetch).finally(function () {
|
|
368
331
|
nodesToFetch.forEach(function (node) {
|
|
@@ -372,18 +335,12 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
372
335
|
case 12:
|
|
373
336
|
data = _context3.sent;
|
|
374
337
|
resolvedData = [];
|
|
375
|
-
|
|
376
|
-
|
|
338
|
+
hasUnexpectedError = false;
|
|
339
|
+
hasExpectedError = false;
|
|
377
340
|
data.forEach(function (syncBlockInstance) {
|
|
378
341
|
if (!syncBlockInstance.resourceId) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
reason: syncBlockInstance.error || 'Returned sync block instance does not have resource id'
|
|
382
|
-
});
|
|
383
|
-
} else {
|
|
384
|
-
var _this2$fireAnalyticsE;
|
|
385
|
-
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, fetchErrorPayload(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
|
|
386
|
-
}
|
|
342
|
+
var _this2$fireAnalyticsE;
|
|
343
|
+
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, fetchErrorPayload(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
|
|
387
344
|
return;
|
|
388
345
|
}
|
|
389
346
|
var existingSyncBlock = _this2.getFromCache(syncBlockInstance.resourceId);
|
|
@@ -391,36 +348,31 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
391
348
|
_this2.updateCache(resolvedSyncBlockInstance);
|
|
392
349
|
resolvedData.push(resolvedSyncBlockInstance);
|
|
393
350
|
if (syncBlockInstance.error) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
var _this2$fireAnalyticsE2;
|
|
401
|
-
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, fetchErrorPayload(syncBlockInstance.error));
|
|
351
|
+
var _this2$fireAnalyticsE2;
|
|
352
|
+
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, fetchErrorPayload(syncBlockInstance.error, syncBlockInstance.resourceId));
|
|
353
|
+
if (syncBlockInstance.error === SyncBlockError.NotFound || syncBlockInstance.error === SyncBlockError.Forbidden) {
|
|
354
|
+
hasExpectedError = true;
|
|
355
|
+
} else if (syncBlockInstance.error) {
|
|
356
|
+
hasUnexpectedError = true;
|
|
402
357
|
}
|
|
403
358
|
return;
|
|
359
|
+
} else if (fg('platform_synced_block_dogfooding')) {
|
|
360
|
+
var _this2$fireAnalyticsE3, _syncBlockInstance$da, _syncBlockInstance$da2;
|
|
361
|
+
(_this2$fireAnalyticsE3 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE3 === void 0 || _this2$fireAnalyticsE3.call(_this2, fetchSuccessPayload(syncBlockInstance.resourceId, (_syncBlockInstance$da = syncBlockInstance.data) === null || _syncBlockInstance$da === void 0 ? void 0 : _syncBlockInstance$da.blockInstanceId, (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product));
|
|
404
362
|
}
|
|
405
|
-
successfulFetched.push(syncBlockInstance.resourceId);
|
|
406
363
|
_this2.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
407
364
|
});
|
|
408
365
|
if (fg('platform_synced_block_dogfooding')) {
|
|
409
|
-
if (
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
(_this$fetchExperience3 = this.fetchExperience) === null || _this$fetchExperience3 === void 0 || _this$fetchExperience3.success({
|
|
413
|
-
metadata: {
|
|
414
|
-
successfulFetched: successfulFetched
|
|
415
|
-
}
|
|
366
|
+
if (hasUnexpectedError) {
|
|
367
|
+
(_this$fetchExperience2 = this.fetchExperience) === null || _this$fetchExperience2 === void 0 || _this$fetchExperience2.failure({
|
|
368
|
+
reason: 'Unexpected error during fetch'
|
|
416
369
|
});
|
|
417
|
-
} else {
|
|
418
|
-
(_this$
|
|
419
|
-
|
|
420
|
-
successfulFetched: successfulFetched,
|
|
421
|
-
failedFetch: failedFetch
|
|
422
|
-
}
|
|
370
|
+
} else if (hasExpectedError) {
|
|
371
|
+
(_this$fetchExperience3 = this.fetchExperience) === null || _this$fetchExperience3 === void 0 || _this$fetchExperience3.abort({
|
|
372
|
+
reason: 'Expected error: NotFound or PermissionDenied'
|
|
423
373
|
});
|
|
374
|
+
} else {
|
|
375
|
+
(_this$fetchExperience4 = this.fetchExperience) === null || _this$fetchExperience4 === void 0 || _this$fetchExperience4.success();
|
|
424
376
|
}
|
|
425
377
|
}
|
|
426
378
|
case 18:
|
|
@@ -514,18 +466,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
514
466
|
callback(cachedData);
|
|
515
467
|
} else {
|
|
516
468
|
this.fetchSyncBlocksData([syncBlockNode]).catch(function (error) {
|
|
469
|
+
var _this3$fireAnalyticsE;
|
|
517
470
|
logException(error, {
|
|
518
471
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
519
472
|
});
|
|
520
|
-
|
|
521
|
-
var _this3$fetchExperienc;
|
|
522
|
-
(_this3$fetchExperienc = _this3.fetchExperience) === null || _this3$fetchExperienc === void 0 || _this3$fetchExperienc.failure({
|
|
523
|
-
reason: error.message
|
|
524
|
-
});
|
|
525
|
-
} else {
|
|
526
|
-
var _this3$fireAnalyticsE;
|
|
527
|
-
(_this3$fireAnalyticsE = _this3.fireAnalyticsEvent) === null || _this3$fireAnalyticsE === void 0 || _this3$fireAnalyticsE.call(_this3, fetchErrorPayload(error.message));
|
|
528
|
-
}
|
|
473
|
+
(_this3$fireAnalyticsE = _this3.fireAnalyticsEvent) === null || _this3$fireAnalyticsE === void 0 || _this3$fireAnalyticsE.call(_this3, fetchErrorPayload(error.message, resourceId));
|
|
529
474
|
});
|
|
530
475
|
}
|
|
531
476
|
return function () {
|
|
@@ -606,11 +551,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
606
551
|
}
|
|
607
552
|
return this.subscribeToSyncBlock(resourceId, localId, callback);
|
|
608
553
|
} catch (error) {
|
|
609
|
-
var _this$
|
|
554
|
+
var _this$fireAnalyticsEv7;
|
|
610
555
|
logException(error, {
|
|
611
556
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
612
557
|
});
|
|
613
|
-
(_this$
|
|
558
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, fetchErrorPayload(error.message));
|
|
614
559
|
return function () {};
|
|
615
560
|
}
|
|
616
561
|
}
|
|
@@ -634,12 +579,12 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
634
579
|
key: "getProviderFactory",
|
|
635
580
|
value: function getProviderFactory(resourceId) {
|
|
636
581
|
if (!this.dataProvider) {
|
|
637
|
-
var _this$
|
|
582
|
+
var _this$fireAnalyticsEv8;
|
|
638
583
|
var error = new Error('Data provider not set');
|
|
639
584
|
logException(error, {
|
|
640
585
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
641
586
|
});
|
|
642
|
-
(_this$
|
|
587
|
+
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, fetchErrorPayload(error.message));
|
|
643
588
|
return undefined;
|
|
644
589
|
}
|
|
645
590
|
var _this$dataProvider$ge = this.dataProvider.getSyncedBlockRendererProviderOptions(),
|
|
@@ -668,11 +613,11 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
668
613
|
try {
|
|
669
614
|
this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
|
|
670
615
|
} catch (error) {
|
|
671
|
-
var _this$
|
|
616
|
+
var _this$fireAnalyticsEv9;
|
|
672
617
|
logException(error, {
|
|
673
618
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
674
619
|
});
|
|
675
|
-
(_this$
|
|
620
|
+
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, fetchErrorPayload(error.message, resourceId));
|
|
676
621
|
}
|
|
677
622
|
}
|
|
678
623
|
return providerFactory;
|
|
@@ -728,9 +673,12 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
728
673
|
return;
|
|
729
674
|
}
|
|
730
675
|
var syncBlock = this.getFromCache(resourceId);
|
|
731
|
-
if (!syncBlock
|
|
732
|
-
|
|
733
|
-
|
|
676
|
+
if (!syncBlock) {
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
if (!((_syncBlock$data2 = syncBlock.data) !== null && _syncBlock$data2 !== void 0 && _syncBlock$data2.sourceAri) || !((_syncBlock$data3 = syncBlock.data) !== null && _syncBlock$data3 !== void 0 && _syncBlock$data3.product)) {
|
|
680
|
+
var _this$fireAnalyticsEv0;
|
|
681
|
+
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, fetchErrorPayload('Sync block source ari or product not found'));
|
|
734
682
|
return;
|
|
735
683
|
}
|
|
736
684
|
var parentInfo = this.dataProvider.retrieveSyncBlockParentInfo((_syncBlock$data4 = syncBlock.data) === null || _syncBlock$data4 === void 0 ? void 0 : _syncBlock$data4.sourceAri, (_syncBlock$data5 = syncBlock.data) === null || _syncBlock$data5 === void 0 ? void 0 : _syncBlock$data5.product);
|
|
@@ -780,7 +728,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
780
728
|
key: "flush",
|
|
781
729
|
value: (function () {
|
|
782
730
|
var _flush = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
783
|
-
var success, blocks, _this$saveExperience, updateResult, _this$
|
|
731
|
+
var success, blocks, _this$saveExperience, updateResult, _this$fireAnalyticsEv1, _this$saveExperience2, _this$fireAnalyticsEv10, _this$saveExperience3, _this$saveExperience4;
|
|
784
732
|
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
785
733
|
while (1) switch (_context4.prev = _context4.next) {
|
|
786
734
|
case 0:
|
|
@@ -811,21 +759,21 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
811
759
|
this.isCacheDirty = false;
|
|
812
760
|
return _context4.abrupt("return", true);
|
|
813
761
|
case 9:
|
|
814
|
-
if (fg('platform_synced_block_dogfooding')) {
|
|
815
|
-
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
816
|
-
}
|
|
817
762
|
if (this.dataProvider) {
|
|
818
|
-
_context4.next =
|
|
763
|
+
_context4.next = 11;
|
|
819
764
|
break;
|
|
820
765
|
}
|
|
821
766
|
throw new Error('Data provider not set');
|
|
822
|
-
case
|
|
767
|
+
case 11:
|
|
823
768
|
// reset isCacheDirty early to prevent race condition
|
|
824
769
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
825
770
|
// on a live page and the reference sync block is being saved while the user
|
|
826
771
|
// is still making changes, the new changes might not be saved if they all happen
|
|
827
772
|
// exactly at a time when the updateReferenceData is being executed asynchronously.
|
|
828
773
|
this.isCacheDirty = false;
|
|
774
|
+
if (fg('platform_synced_block_dogfooding')) {
|
|
775
|
+
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
776
|
+
}
|
|
829
777
|
_context4.next = 15;
|
|
830
778
|
return this.dataProvider.updateReferenceData(blocks);
|
|
831
779
|
case 15:
|
|
@@ -836,11 +784,10 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
836
784
|
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 || _this$saveExperience2.failure({
|
|
837
785
|
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
838
786
|
});
|
|
839
|
-
} else {
|
|
840
|
-
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
841
787
|
}
|
|
788
|
+
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
842
789
|
}
|
|
843
|
-
_context4.next =
|
|
790
|
+
_context4.next = 25;
|
|
844
791
|
break;
|
|
845
792
|
case 19:
|
|
846
793
|
_context4.prev = 19;
|
|
@@ -853,25 +800,24 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
853
800
|
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure({
|
|
854
801
|
reason: _context4.t0.message
|
|
855
802
|
});
|
|
856
|
-
} else {
|
|
857
|
-
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, updateReferenceErrorPayload(_context4.t0.message));
|
|
858
803
|
}
|
|
859
|
-
|
|
860
|
-
|
|
804
|
+
(_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 || _this$fireAnalyticsEv10.call(this, updateReferenceErrorPayload(_context4.t0.message));
|
|
805
|
+
case 25:
|
|
806
|
+
_context4.prev = 25;
|
|
861
807
|
if (!success) {
|
|
862
808
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
863
809
|
this.isCacheDirty = true;
|
|
864
810
|
} else if (fg('platform_synced_block_dogfooding')) {
|
|
865
811
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
|
|
866
812
|
}
|
|
867
|
-
return _context4.finish(
|
|
868
|
-
case 27:
|
|
869
|
-
return _context4.abrupt("return", success);
|
|
813
|
+
return _context4.finish(25);
|
|
870
814
|
case 28:
|
|
815
|
+
return _context4.abrupt("return", success);
|
|
816
|
+
case 29:
|
|
871
817
|
case "end":
|
|
872
818
|
return _context4.stop();
|
|
873
819
|
}
|
|
874
|
-
}, _callee3, this, [[3, 19,
|
|
820
|
+
}, _callee3, this, [[3, 19, 25, 28]]);
|
|
875
821
|
}));
|
|
876
822
|
function flush() {
|
|
877
823
|
return _flush.apply(this, arguments);
|
|
@@ -881,6 +827,7 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
881
827
|
}, {
|
|
882
828
|
key: "destroy",
|
|
883
829
|
value: function destroy() {
|
|
830
|
+
var _this$saveExperience5, _this$fetchExperience5, _this$fetchSourceInfo6;
|
|
884
831
|
this.dataProvider = undefined;
|
|
885
832
|
this.syncBlockCache.clear();
|
|
886
833
|
this.subscriptions.clear();
|
|
@@ -894,6 +841,15 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
894
841
|
providerFactory.destroy();
|
|
895
842
|
});
|
|
896
843
|
this.providerFactories.clear();
|
|
844
|
+
(_this$saveExperience5 = this.saveExperience) === null || _this$saveExperience5 === void 0 || _this$saveExperience5.abort({
|
|
845
|
+
reason: 'editor-destroyed'
|
|
846
|
+
});
|
|
847
|
+
(_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 || _this$fetchExperience5.abort({
|
|
848
|
+
reason: 'editor-destroyed'
|
|
849
|
+
});
|
|
850
|
+
(_this$fetchSourceInfo6 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo6 === void 0 || _this$fetchSourceInfo6.abort({
|
|
851
|
+
reason: 'editor-destroyed'
|
|
852
|
+
});
|
|
897
853
|
this.fireAnalyticsEvent = undefined;
|
|
898
854
|
}
|
|
899
855
|
}]);
|