@atlaskit/editor-synced-block-provider 3.12.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 +9 -0
- 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/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/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/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/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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7f41011a1b0ff`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7f41011a1b0ff) -
|
|
8
|
+
EDITOR-1665 update sync block experience events to use general experience ids, keep existing error
|
|
9
|
+
events and add success events
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 3.12.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -16,6 +16,7 @@ var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
|
16
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
17
|
var _types = require("../common/types");
|
|
18
18
|
var _errorHandling = require("../utils/errorHandling");
|
|
19
|
+
var _experienceTracking = require("../utils/experienceTracking");
|
|
19
20
|
var _resolveSyncBlockInstance = require("../utils/resolveSyncBlockInstance");
|
|
20
21
|
var _resourceId = require("../utils/resourceId");
|
|
21
22
|
var _utils = require("../utils/utils");
|
|
@@ -56,16 +57,9 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
56
57
|
key: "setFireAnalyticsEvent",
|
|
57
58
|
value: function setFireAnalyticsEvent(fireAnalyticsEvent) {
|
|
58
59
|
this.fireAnalyticsEvent = fireAnalyticsEvent;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
value: function setExperiences(fetchExperience, fetchSourceInfoExperience, saveExperience) {
|
|
63
|
-
// don't reset experiences after they have already been set
|
|
64
|
-
if (!this.fetchExperience || !this.fetchSourceInfoExperience || !this.saveExperience) {
|
|
65
|
-
this.fetchExperience = fetchExperience;
|
|
66
|
-
this.fetchSourceInfoExperience = fetchSourceInfoExperience;
|
|
67
|
-
this.saveExperience = saveExperience;
|
|
68
|
-
}
|
|
60
|
+
this.fetchExperience = (0, _experienceTracking.getFetchExperience)(fireAnalyticsEvent);
|
|
61
|
+
this.fetchSourceInfoExperience = (0, _experienceTracking.getFetchSourceInfoExperience)(fireAnalyticsEvent);
|
|
62
|
+
this.saveExperience = (0, _experienceTracking.getSaveReferenceExperience)(fireAnalyticsEvent);
|
|
69
63
|
}
|
|
70
64
|
}, {
|
|
71
65
|
key: "generateResourceIdForReference",
|
|
@@ -96,7 +90,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
96
90
|
key: "refreshSubscriptions",
|
|
97
91
|
value: (function () {
|
|
98
92
|
var _refreshSubscriptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
99
|
-
var syncBlocks, _iterator, _step, _loop, _this$
|
|
93
|
+
var syncBlocks, _iterator, _step, _loop, _this$fireAnalyticsEv;
|
|
100
94
|
return _regenerator.default.wrap(function _callee$(_context2) {
|
|
101
95
|
while (1) switch (_context2.prev = _context2.next) {
|
|
102
96
|
case 0:
|
|
@@ -159,13 +153,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
159
153
|
(0, _monitoring.logException)(_context2.t2, {
|
|
160
154
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
161
155
|
});
|
|
162
|
-
|
|
163
|
-
(_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 || _this$fetchExperience.failure({
|
|
164
|
-
reason: _context2.t2.message
|
|
165
|
-
});
|
|
166
|
-
} else {
|
|
167
|
-
(_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, (0, _errorHandling.fetchErrorPayload)(_context2.t2.message));
|
|
168
|
-
}
|
|
156
|
+
(_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 || _this$fireAnalyticsEv.call(this, (0, _errorHandling.fetchErrorPayload)(_context2.t2.message));
|
|
169
157
|
case 29:
|
|
170
158
|
_context2.prev = 29;
|
|
171
159
|
this.isRefreshingSubscriptions = false;
|
|
@@ -187,11 +175,6 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
187
175
|
var _this = this;
|
|
188
176
|
try {
|
|
189
177
|
if (!resourceId || !this.dataProvider) {
|
|
190
|
-
// make sure experience has been started before throwing error
|
|
191
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
192
|
-
var _this$fetchSourceInfo;
|
|
193
|
-
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
194
|
-
}
|
|
195
178
|
throw new Error('Data provider or resourceId not set');
|
|
196
179
|
}
|
|
197
180
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
@@ -204,10 +187,6 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
204
187
|
}
|
|
205
188
|
var existingSyncBlock = this.getFromCache(resourceId);
|
|
206
189
|
if (!existingSyncBlock) {
|
|
207
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
208
|
-
var _this$fetchSourceInfo2;
|
|
209
|
-
(_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.start({});
|
|
210
|
-
}
|
|
211
190
|
throw new Error('No existing sync block to fetch source info for');
|
|
212
191
|
}
|
|
213
192
|
var _ref = existingSyncBlock.data || {},
|
|
@@ -233,31 +212,23 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
233
212
|
return Promise.resolve(undefined);
|
|
234
213
|
}
|
|
235
214
|
}
|
|
236
|
-
|
|
237
|
-
// only start experience if there is data to fetch
|
|
238
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
239
|
-
var _this$fetchSourceInfo3;
|
|
240
|
-
(_this$fetchSourceInfo3 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 || _this$fetchSourceInfo3.start({});
|
|
241
|
-
}
|
|
242
215
|
if (!sourceAri || !product || !blockInstanceId) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
(_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 || _this$fetchSourceInfo4.failure({
|
|
246
|
-
reason: 'SourceAri, product or blockInstanceId missing'
|
|
247
|
-
});
|
|
248
|
-
} else {
|
|
249
|
-
var _this$fireAnalyticsEv2;
|
|
250
|
-
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.getSourceInfoErrorPayload)('SourceAri, product or blockInstanceId missing'));
|
|
251
|
-
}
|
|
216
|
+
var _this$fireAnalyticsEv2;
|
|
217
|
+
(_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 || _this$fireAnalyticsEv2.call(this, (0, _errorHandling.getSourceInfoErrorPayload)('SourceAri, product or blockInstanceId missing', resourceId));
|
|
252
218
|
return Promise.resolve(undefined);
|
|
253
219
|
}
|
|
220
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
221
|
+
var _this$fetchSourceInfo;
|
|
222
|
+
(_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 || _this$fetchSourceInfo.start({});
|
|
223
|
+
}
|
|
254
224
|
var sourceInfoPromise = this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, this.fireAnalyticsEvent).then(function (sourceInfo) {
|
|
255
225
|
if (!sourceInfo) {
|
|
256
226
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
257
|
-
var _this$
|
|
258
|
-
(_this$
|
|
227
|
+
var _this$fetchSourceInfo2, _this$fireAnalyticsEv3;
|
|
228
|
+
(_this$fetchSourceInfo2 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 || _this$fetchSourceInfo2.failure({
|
|
259
229
|
reason: 'No source info returned'
|
|
260
230
|
});
|
|
231
|
+
(_this$fireAnalyticsEv3 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(_this, (0, _errorHandling.getSourceInfoErrorPayload)('No source info returned', resourceId));
|
|
261
232
|
}
|
|
262
233
|
return undefined;
|
|
263
234
|
}
|
|
@@ -267,26 +238,26 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
267
238
|
}
|
|
268
239
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
269
240
|
if (sourceInfo.title && sourceInfo.url) {
|
|
270
|
-
var _this$
|
|
271
|
-
(_this$
|
|
241
|
+
var _this$fetchSourceInfo3;
|
|
242
|
+
(_this$fetchSourceInfo3 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 || _this$fetchSourceInfo3.success();
|
|
272
243
|
} else {
|
|
273
|
-
var _this$
|
|
274
|
-
(_this$
|
|
244
|
+
var _this$fetchSourceInfo4, _this$fireAnalyticsEv4;
|
|
245
|
+
(_this$fetchSourceInfo4 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 || _this$fetchSourceInfo4.failure({
|
|
275
246
|
reason: 'Missing title or url'
|
|
276
247
|
});
|
|
248
|
+
(_this$fireAnalyticsEv4 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(_this, (0, _errorHandling.getSourceInfoErrorPayload)('Missing title or url', resourceId));
|
|
277
249
|
}
|
|
278
250
|
return sourceInfo;
|
|
279
251
|
}
|
|
280
252
|
}).catch(function (error) {
|
|
253
|
+
var _this$fireAnalyticsEv5;
|
|
281
254
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
282
|
-
var _this$
|
|
283
|
-
(_this$
|
|
255
|
+
var _this$fetchSourceInfo5;
|
|
256
|
+
(_this$fetchSourceInfo5 = _this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo5 === void 0 || _this$fetchSourceInfo5.failure({
|
|
284
257
|
reason: error.message
|
|
285
258
|
});
|
|
286
|
-
} else {
|
|
287
|
-
var _this$fireAnalyticsEv3;
|
|
288
|
-
(_this$fireAnalyticsEv3 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(_this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
|
|
289
259
|
}
|
|
260
|
+
(_this$fireAnalyticsEv5 = _this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 || _this$fireAnalyticsEv5.call(_this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message, resourceId));
|
|
290
261
|
return undefined;
|
|
291
262
|
}).finally(function () {
|
|
292
263
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
@@ -302,18 +273,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
302
273
|
this.syncBlockSourceInfoRequestsOld.set(resourceId, true);
|
|
303
274
|
}
|
|
304
275
|
} catch (error) {
|
|
276
|
+
var _this$fireAnalyticsEv6;
|
|
305
277
|
(0, _monitoring.logException)(error, {
|
|
306
278
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
307
279
|
});
|
|
308
|
-
|
|
309
|
-
var _this$fetchSourceInfo9;
|
|
310
|
-
(_this$fetchSourceInfo9 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo9 === void 0 || _this$fetchSourceInfo9.failure({
|
|
311
|
-
reason: error.message
|
|
312
|
-
});
|
|
313
|
-
} else {
|
|
314
|
-
var _this$fireAnalyticsEv4;
|
|
315
|
-
(_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 || _this$fireAnalyticsEv4.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message));
|
|
316
|
-
}
|
|
280
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 || _this$fireAnalyticsEv6.call(this, (0, _errorHandling.getSourceInfoErrorPayload)(error.message, resourceId));
|
|
317
281
|
}
|
|
318
282
|
return Promise.resolve(undefined);
|
|
319
283
|
}
|
|
@@ -328,7 +292,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
328
292
|
value: (function () {
|
|
329
293
|
var _fetchSyncBlocksData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(syncBlockNodes) {
|
|
330
294
|
var _this2 = this;
|
|
331
|
-
var nodesToFetch, _this$
|
|
295
|
+
var nodesToFetch, _this$fetchExperience, data, resolvedData, hasUnexpectedError, hasExpectedError, _this$fetchExperience2, _this$fetchExperience3, _this$fetchExperience4;
|
|
332
296
|
return _regenerator.default.wrap(function _callee2$(_context3) {
|
|
333
297
|
while (1) switch (_context3.prev = _context3.next) {
|
|
334
298
|
case 0:
|
|
@@ -356,19 +320,18 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
356
320
|
}
|
|
357
321
|
return _context3.abrupt("return");
|
|
358
322
|
case 6:
|
|
359
|
-
// only start fetch experience if there is data to fetch
|
|
360
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
361
|
-
(_this$fetchExperience2 = this.fetchExperience) === null || _this$fetchExperience2 === void 0 || _this$fetchExperience2.start({});
|
|
362
|
-
}
|
|
363
323
|
if (this.dataProvider) {
|
|
364
|
-
_context3.next =
|
|
324
|
+
_context3.next = 8;
|
|
365
325
|
break;
|
|
366
326
|
}
|
|
367
327
|
throw new Error('Data provider not set');
|
|
368
|
-
case
|
|
328
|
+
case 8:
|
|
369
329
|
nodesToFetch.forEach(function (node) {
|
|
370
330
|
_this2.syncBlockFetchDataRequests.set(node.attrs.resourceId, true);
|
|
371
331
|
});
|
|
332
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
333
|
+
(_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 || _this$fetchExperience.start({});
|
|
334
|
+
}
|
|
372
335
|
_context3.next = 12;
|
|
373
336
|
return this.dataProvider.fetchNodesData(nodesToFetch).finally(function () {
|
|
374
337
|
nodesToFetch.forEach(function (node) {
|
|
@@ -378,18 +341,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
378
341
|
case 12:
|
|
379
342
|
data = _context3.sent;
|
|
380
343
|
resolvedData = [];
|
|
381
|
-
|
|
382
|
-
|
|
344
|
+
hasUnexpectedError = false;
|
|
345
|
+
hasExpectedError = false;
|
|
383
346
|
data.forEach(function (syncBlockInstance) {
|
|
384
347
|
if (!syncBlockInstance.resourceId) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
reason: syncBlockInstance.error || 'Returned sync block instance does not have resource id'
|
|
388
|
-
});
|
|
389
|
-
} else {
|
|
390
|
-
var _this2$fireAnalyticsE;
|
|
391
|
-
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
|
|
392
|
-
}
|
|
348
|
+
var _this2$fireAnalyticsE;
|
|
349
|
+
(_this2$fireAnalyticsE = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE === void 0 || _this2$fireAnalyticsE.call(_this2, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
|
|
393
350
|
return;
|
|
394
351
|
}
|
|
395
352
|
var existingSyncBlock = _this2.getFromCache(syncBlockInstance.resourceId);
|
|
@@ -397,36 +354,31 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
397
354
|
_this2.updateCache(resolvedSyncBlockInstance);
|
|
398
355
|
resolvedData.push(resolvedSyncBlockInstance);
|
|
399
356
|
if (syncBlockInstance.error) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
var _this2$fireAnalyticsE2;
|
|
407
|
-
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error));
|
|
357
|
+
var _this2$fireAnalyticsE2;
|
|
358
|
+
(_this2$fireAnalyticsE2 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE2 === void 0 || _this2$fireAnalyticsE2.call(_this2, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error, syncBlockInstance.resourceId));
|
|
359
|
+
if (syncBlockInstance.error === _types.SyncBlockError.NotFound || syncBlockInstance.error === _types.SyncBlockError.Forbidden) {
|
|
360
|
+
hasExpectedError = true;
|
|
361
|
+
} else if (syncBlockInstance.error) {
|
|
362
|
+
hasUnexpectedError = true;
|
|
408
363
|
}
|
|
409
364
|
return;
|
|
365
|
+
} else if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
366
|
+
var _this2$fireAnalyticsE3, _syncBlockInstance$da, _syncBlockInstance$da2;
|
|
367
|
+
(_this2$fireAnalyticsE3 = _this2.fireAnalyticsEvent) === null || _this2$fireAnalyticsE3 === void 0 || _this2$fireAnalyticsE3.call(_this2, (0, _errorHandling.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));
|
|
410
368
|
}
|
|
411
|
-
successfulFetched.push(syncBlockInstance.resourceId);
|
|
412
369
|
_this2.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
413
370
|
});
|
|
414
371
|
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
415
|
-
if (
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
(_this$fetchExperience3 = this.fetchExperience) === null || _this$fetchExperience3 === void 0 || _this$fetchExperience3.success({
|
|
419
|
-
metadata: {
|
|
420
|
-
successfulFetched: successfulFetched
|
|
421
|
-
}
|
|
372
|
+
if (hasUnexpectedError) {
|
|
373
|
+
(_this$fetchExperience2 = this.fetchExperience) === null || _this$fetchExperience2 === void 0 || _this$fetchExperience2.failure({
|
|
374
|
+
reason: 'Unexpected error during fetch'
|
|
422
375
|
});
|
|
423
|
-
} else {
|
|
424
|
-
(_this$
|
|
425
|
-
|
|
426
|
-
successfulFetched: successfulFetched,
|
|
427
|
-
failedFetch: failedFetch
|
|
428
|
-
}
|
|
376
|
+
} else if (hasExpectedError) {
|
|
377
|
+
(_this$fetchExperience3 = this.fetchExperience) === null || _this$fetchExperience3 === void 0 || _this$fetchExperience3.abort({
|
|
378
|
+
reason: 'Expected error: NotFound or PermissionDenied'
|
|
429
379
|
});
|
|
380
|
+
} else {
|
|
381
|
+
(_this$fetchExperience4 = this.fetchExperience) === null || _this$fetchExperience4 === void 0 || _this$fetchExperience4.success();
|
|
430
382
|
}
|
|
431
383
|
}
|
|
432
384
|
case 18:
|
|
@@ -520,18 +472,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
520
472
|
callback(cachedData);
|
|
521
473
|
} else {
|
|
522
474
|
this.fetchSyncBlocksData([syncBlockNode]).catch(function (error) {
|
|
475
|
+
var _this3$fireAnalyticsE;
|
|
523
476
|
(0, _monitoring.logException)(error, {
|
|
524
477
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
525
478
|
});
|
|
526
|
-
|
|
527
|
-
var _this3$fetchExperienc;
|
|
528
|
-
(_this3$fetchExperienc = _this3.fetchExperience) === null || _this3$fetchExperienc === void 0 || _this3$fetchExperienc.failure({
|
|
529
|
-
reason: error.message
|
|
530
|
-
});
|
|
531
|
-
} else {
|
|
532
|
-
var _this3$fireAnalyticsE;
|
|
533
|
-
(_this3$fireAnalyticsE = _this3.fireAnalyticsEvent) === null || _this3$fireAnalyticsE === void 0 || _this3$fireAnalyticsE.call(_this3, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
534
|
-
}
|
|
479
|
+
(_this3$fireAnalyticsE = _this3.fireAnalyticsEvent) === null || _this3$fireAnalyticsE === void 0 || _this3$fireAnalyticsE.call(_this3, (0, _errorHandling.fetchErrorPayload)(error.message, resourceId));
|
|
535
480
|
});
|
|
536
481
|
}
|
|
537
482
|
return function () {
|
|
@@ -612,11 +557,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
612
557
|
}
|
|
613
558
|
return this.subscribeToSyncBlock(resourceId, localId, callback);
|
|
614
559
|
} catch (error) {
|
|
615
|
-
var _this$
|
|
560
|
+
var _this$fireAnalyticsEv7;
|
|
616
561
|
(0, _monitoring.logException)(error, {
|
|
617
562
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
618
563
|
});
|
|
619
|
-
(_this$
|
|
564
|
+
(_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 || _this$fireAnalyticsEv7.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
620
565
|
return function () {};
|
|
621
566
|
}
|
|
622
567
|
}
|
|
@@ -640,12 +585,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
640
585
|
key: "getProviderFactory",
|
|
641
586
|
value: function getProviderFactory(resourceId) {
|
|
642
587
|
if (!this.dataProvider) {
|
|
643
|
-
var _this$
|
|
588
|
+
var _this$fireAnalyticsEv8;
|
|
644
589
|
var error = new Error('Data provider not set');
|
|
645
590
|
(0, _monitoring.logException)(error, {
|
|
646
591
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
647
592
|
});
|
|
648
|
-
(_this$
|
|
593
|
+
(_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 || _this$fireAnalyticsEv8.call(this, (0, _errorHandling.fetchErrorPayload)(error.message));
|
|
649
594
|
return undefined;
|
|
650
595
|
}
|
|
651
596
|
var _this$dataProvider$ge = this.dataProvider.getSyncedBlockRendererProviderOptions(),
|
|
@@ -674,11 +619,11 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
674
619
|
try {
|
|
675
620
|
this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
|
|
676
621
|
} catch (error) {
|
|
677
|
-
var _this$
|
|
622
|
+
var _this$fireAnalyticsEv9;
|
|
678
623
|
(0, _monitoring.logException)(error, {
|
|
679
624
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
680
625
|
});
|
|
681
|
-
(_this$
|
|
626
|
+
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, (0, _errorHandling.fetchErrorPayload)(error.message, resourceId));
|
|
682
627
|
}
|
|
683
628
|
}
|
|
684
629
|
return providerFactory;
|
|
@@ -734,9 +679,12 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
734
679
|
return;
|
|
735
680
|
}
|
|
736
681
|
var syncBlock = this.getFromCache(resourceId);
|
|
737
|
-
if (!syncBlock
|
|
738
|
-
|
|
739
|
-
|
|
682
|
+
if (!syncBlock) {
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
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)) {
|
|
686
|
+
var _this$fireAnalyticsEv0;
|
|
687
|
+
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, (0, _errorHandling.fetchErrorPayload)('Sync block source ari or product not found'));
|
|
740
688
|
return;
|
|
741
689
|
}
|
|
742
690
|
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);
|
|
@@ -786,7 +734,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
786
734
|
key: "flush",
|
|
787
735
|
value: (function () {
|
|
788
736
|
var _flush = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
789
|
-
var success, blocks, _this$saveExperience, updateResult, _this$
|
|
737
|
+
var success, blocks, _this$saveExperience, updateResult, _this$fireAnalyticsEv1, _this$saveExperience2, _this$fireAnalyticsEv10, _this$saveExperience3, _this$saveExperience4;
|
|
790
738
|
return _regenerator.default.wrap(function _callee3$(_context4) {
|
|
791
739
|
while (1) switch (_context4.prev = _context4.next) {
|
|
792
740
|
case 0:
|
|
@@ -817,21 +765,21 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
817
765
|
this.isCacheDirty = false;
|
|
818
766
|
return _context4.abrupt("return", true);
|
|
819
767
|
case 9:
|
|
820
|
-
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
821
|
-
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
822
|
-
}
|
|
823
768
|
if (this.dataProvider) {
|
|
824
|
-
_context4.next =
|
|
769
|
+
_context4.next = 11;
|
|
825
770
|
break;
|
|
826
771
|
}
|
|
827
772
|
throw new Error('Data provider not set');
|
|
828
|
-
case
|
|
773
|
+
case 11:
|
|
829
774
|
// reset isCacheDirty early to prevent race condition
|
|
830
775
|
// There is a race condition where if a user makes changes (create/delete) to a reference sync block
|
|
831
776
|
// on a live page and the reference sync block is being saved while the user
|
|
832
777
|
// is still making changes, the new changes might not be saved if they all happen
|
|
833
778
|
// exactly at a time when the updateReferenceData is being executed asynchronously.
|
|
834
779
|
this.isCacheDirty = false;
|
|
780
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
781
|
+
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 || _this$saveExperience.start();
|
|
782
|
+
}
|
|
835
783
|
_context4.next = 15;
|
|
836
784
|
return this.dataProvider.updateReferenceData(blocks);
|
|
837
785
|
case 15:
|
|
@@ -842,11 +790,10 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
842
790
|
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 || _this$saveExperience2.failure({
|
|
843
791
|
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
844
792
|
});
|
|
845
|
-
} else {
|
|
846
|
-
(_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 || _this$fireAnalyticsEv9.call(this, (0, _errorHandling.updateReferenceErrorPayload)(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
847
793
|
}
|
|
794
|
+
(_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 || _this$fireAnalyticsEv1.call(this, (0, _errorHandling.updateReferenceErrorPayload)(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
848
795
|
}
|
|
849
|
-
_context4.next =
|
|
796
|
+
_context4.next = 25;
|
|
850
797
|
break;
|
|
851
798
|
case 19:
|
|
852
799
|
_context4.prev = 19;
|
|
@@ -859,25 +806,24 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
859
806
|
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 || _this$saveExperience3.failure({
|
|
860
807
|
reason: _context4.t0.message
|
|
861
808
|
});
|
|
862
|
-
} else {
|
|
863
|
-
(_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 || _this$fireAnalyticsEv0.call(this, (0, _errorHandling.updateReferenceErrorPayload)(_context4.t0.message));
|
|
864
809
|
}
|
|
865
|
-
|
|
866
|
-
|
|
810
|
+
(_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 || _this$fireAnalyticsEv10.call(this, (0, _errorHandling.updateReferenceErrorPayload)(_context4.t0.message));
|
|
811
|
+
case 25:
|
|
812
|
+
_context4.prev = 25;
|
|
867
813
|
if (!success) {
|
|
868
814
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
869
815
|
this.isCacheDirty = true;
|
|
870
816
|
} else if ((0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
871
817
|
(_this$saveExperience4 = this.saveExperience) === null || _this$saveExperience4 === void 0 || _this$saveExperience4.success();
|
|
872
818
|
}
|
|
873
|
-
return _context4.finish(
|
|
874
|
-
case 27:
|
|
875
|
-
return _context4.abrupt("return", success);
|
|
819
|
+
return _context4.finish(25);
|
|
876
820
|
case 28:
|
|
821
|
+
return _context4.abrupt("return", success);
|
|
822
|
+
case 29:
|
|
877
823
|
case "end":
|
|
878
824
|
return _context4.stop();
|
|
879
825
|
}
|
|
880
|
-
}, _callee3, this, [[3, 19,
|
|
826
|
+
}, _callee3, this, [[3, 19, 25, 28]]);
|
|
881
827
|
}));
|
|
882
828
|
function flush() {
|
|
883
829
|
return _flush.apply(this, arguments);
|
|
@@ -887,6 +833,7 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
887
833
|
}, {
|
|
888
834
|
key: "destroy",
|
|
889
835
|
value: function destroy() {
|
|
836
|
+
var _this$saveExperience5, _this$fetchExperience5, _this$fetchSourceInfo6;
|
|
890
837
|
this.dataProvider = undefined;
|
|
891
838
|
this.syncBlockCache.clear();
|
|
892
839
|
this.subscriptions.clear();
|
|
@@ -900,6 +847,15 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
900
847
|
providerFactory.destroy();
|
|
901
848
|
});
|
|
902
849
|
this.providerFactories.clear();
|
|
850
|
+
(_this$saveExperience5 = this.saveExperience) === null || _this$saveExperience5 === void 0 || _this$saveExperience5.abort({
|
|
851
|
+
reason: 'editor-destroyed'
|
|
852
|
+
});
|
|
853
|
+
(_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 || _this$fetchExperience5.abort({
|
|
854
|
+
reason: 'editor-destroyed'
|
|
855
|
+
});
|
|
856
|
+
(_this$fetchSourceInfo6 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo6 === void 0 || _this$fetchSourceInfo6.abort({
|
|
857
|
+
reason: 'editor-destroyed'
|
|
858
|
+
});
|
|
903
859
|
this.fireAnalyticsEvent = undefined;
|
|
904
860
|
}
|
|
905
861
|
}]);
|