@atlaskit/editor-synced-block-provider 3.30.1 → 3.30.2
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 +8 -0
- package/dist/cjs/hooks/useFetchSyncBlockData.js +11 -5
- package/dist/cjs/providers/block-service/blockServiceAPI.js +31 -10
- package/dist/cjs/providers/syncBlockProvider.js +6 -2
- package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +15 -8
- package/dist/es2019/hooks/useFetchSyncBlockData.js +12 -6
- package/dist/es2019/providers/block-service/blockServiceAPI.js +31 -10
- package/dist/es2019/providers/syncBlockProvider.js +6 -2
- package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +27 -20
- package/dist/esm/hooks/useFetchSyncBlockData.js +11 -5
- package/dist/esm/providers/block-service/blockServiceAPI.js +31 -10
- package/dist/esm/providers/syncBlockProvider.js +6 -2
- package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +15 -8
- package/dist/types/hooks/useFetchSyncBlockData.d.ts +1 -1
- package/dist/types-ts4.5/hooks/useFetchSyncBlockData.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-synced-block-provider
|
|
2
2
|
|
|
3
|
+
## 3.30.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e794387202d1b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e794387202d1b) -
|
|
8
|
+
EDITOR-4824 add additional error logging for sync blocks
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 3.30.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -12,11 +12,13 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
12
12
|
var _react = require("react");
|
|
13
13
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
14
14
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _types = require("../common/types");
|
|
17
|
+
var _errorHandling = require("../utils/errorHandling");
|
|
16
18
|
var _utils = require("../utils/utils");
|
|
17
19
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
20
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
-
var useFetchSyncBlockData = exports.useFetchSyncBlockData = function useFetchSyncBlockData(manager, resourceId, localId,
|
|
21
|
+
var useFetchSyncBlockData = exports.useFetchSyncBlockData = function useFetchSyncBlockData(manager, resourceId, localId, fireAnalyticsEvent) {
|
|
20
22
|
// Initialize both states from a single cache lookup to avoid race conditions.
|
|
21
23
|
// When a block is moved/remounted, the old component's cleanup may clear the cache
|
|
22
24
|
// before or after the new component mounts. By doing a single lookup, we ensure
|
|
@@ -77,9 +79,13 @@ var useFetchSyncBlockData = exports.useFetchSyncBlockData = function useFetchSyn
|
|
|
77
79
|
(0, _monitoring.logException)(_context.t0, {
|
|
78
80
|
location: 'editor-synced-block-provider/useFetchSyncBlockData'
|
|
79
81
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
82
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
|
|
83
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent((0, _errorHandling.fetchErrorPayload)(_context.t0.message));
|
|
84
|
+
} else {
|
|
85
|
+
manager === null || manager === void 0 || (_manager$referenceMan2 = manager.referenceManager) === null || _manager$referenceMan2 === void 0 || (_manager$referenceMan2 = _manager$referenceMan2.fetchExperience) === null || _manager$referenceMan2 === void 0 || _manager$referenceMan2.failure({
|
|
86
|
+
reason: _context.t0.message
|
|
87
|
+
});
|
|
88
|
+
}
|
|
83
89
|
|
|
84
90
|
// Set error state if fetching fails
|
|
85
91
|
setFetchState({
|
|
@@ -103,7 +109,7 @@ var useFetchSyncBlockData = exports.useFetchSyncBlockData = function useFetchSyn
|
|
|
103
109
|
return _context.stop();
|
|
104
110
|
}
|
|
105
111
|
}, _callee, null, [[2, 11]]);
|
|
106
|
-
})), [isLoading, localId, manager.referenceManager, resourceId]);
|
|
112
|
+
})), [isLoading, localId, manager.referenceManager, resourceId, fireAnalyticsEvent]);
|
|
107
113
|
(0, _react.useEffect)(function () {
|
|
108
114
|
if ((0, _coreUtils.isSSR)()) {
|
|
109
115
|
// in SSR, we don't need to subscribe to updates,
|
|
@@ -12,6 +12,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
12
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
14
|
var _react = require("react");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _ari = require("../../clients/block-service/ari");
|
|
16
17
|
var _blockService = require("../../clients/block-service/blockService");
|
|
17
18
|
var _blockSubscription = require("../../clients/block-service/blockSubscription");
|
|
@@ -300,12 +301,22 @@ var _batchFetchData = exports.batchFetchData = /*#__PURE__*/function () {
|
|
|
300
301
|
resourceId: resourceId
|
|
301
302
|
});
|
|
302
303
|
} catch (_unused3) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
304
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
|
|
305
|
+
results.push({
|
|
306
|
+
error: {
|
|
307
|
+
type: _types.SyncBlockError.Errored,
|
|
308
|
+
reason: "parsing JSON content response failed for resourceId: ".concat(resourceId, " localId: ").concat(blockAri)
|
|
309
|
+
},
|
|
310
|
+
resourceId: resourceId
|
|
311
|
+
});
|
|
312
|
+
} else {
|
|
313
|
+
results.push({
|
|
314
|
+
error: {
|
|
315
|
+
type: _types.SyncBlockError.Errored
|
|
316
|
+
},
|
|
317
|
+
resourceId: resourceId
|
|
318
|
+
});
|
|
319
|
+
}
|
|
309
320
|
}
|
|
310
321
|
case 25:
|
|
311
322
|
_context2.next = 14;
|
|
@@ -345,7 +356,10 @@ var _batchFetchData = exports.batchFetchData = /*#__PURE__*/function () {
|
|
|
345
356
|
case 44:
|
|
346
357
|
processedResourceIds.add(_resourceId);
|
|
347
358
|
results.push({
|
|
348
|
-
error: {
|
|
359
|
+
error: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? {
|
|
360
|
+
type: mapErrorResponseCode(errorResponse.code),
|
|
361
|
+
reason: errorResponse.reason
|
|
362
|
+
} : {
|
|
349
363
|
type: mapErrorResponseCode(errorResponse.code)
|
|
350
364
|
},
|
|
351
365
|
resourceId: _resourceId
|
|
@@ -391,7 +405,8 @@ var _batchFetchData = exports.batchFetchData = /*#__PURE__*/function () {
|
|
|
391
405
|
return _context2.abrupt("return", blockNodeIdentifiers.map(function (blockNodeIdentifier) {
|
|
392
406
|
return {
|
|
393
407
|
error: {
|
|
394
|
-
type: _context2.t2 instanceof _blockService.BlockError ? mapBlockError(_context2.t2) : _types.SyncBlockError.Errored
|
|
408
|
+
type: _context2.t2 instanceof _blockService.BlockError ? mapBlockError(_context2.t2) : _types.SyncBlockError.Errored,
|
|
409
|
+
reason: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? _context2.t2.message : undefined
|
|
395
410
|
},
|
|
396
411
|
resourceId: blockNodeIdentifier.resourceId
|
|
397
412
|
};
|
|
@@ -477,14 +492,20 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
477
492
|
break;
|
|
478
493
|
}
|
|
479
494
|
return _context3.abrupt("return", {
|
|
480
|
-
error: {
|
|
495
|
+
error: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? {
|
|
496
|
+
type: mapBlockError(_context3.t0),
|
|
497
|
+
reason: _context3.t0.message
|
|
498
|
+
} : {
|
|
481
499
|
type: mapBlockError(_context3.t0)
|
|
482
500
|
},
|
|
483
501
|
resourceId: resourceId
|
|
484
502
|
});
|
|
485
503
|
case 16:
|
|
486
504
|
return _context3.abrupt("return", {
|
|
487
|
-
error: {
|
|
505
|
+
error: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? {
|
|
506
|
+
type: _types.SyncBlockError.Errored,
|
|
507
|
+
reason: _context3.t0.message
|
|
508
|
+
} : {
|
|
488
509
|
type: _types.SyncBlockError.Errored
|
|
489
510
|
},
|
|
490
511
|
resourceId: resourceId
|
|
@@ -14,6 +14,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
14
14
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
16
|
var _react = require("react");
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
18
|
var _ari = require("../clients/block-service/ari");
|
|
18
19
|
var _ari2 = require("../clients/confluence/ari");
|
|
19
20
|
var _sourceInfo2 = require("../clients/confluence/sourceInfo");
|
|
@@ -114,9 +115,12 @@ var SyncedBlockProvider = exports.SyncedBlockProvider = /*#__PURE__*/function (_
|
|
|
114
115
|
return _context.abrupt("return", Promise.allSettled(blockIdentifiers.map(function (blockIdentifier) {
|
|
115
116
|
return _this2.fetchProvider.fetchData(blockIdentifier.resourceId).then(function (data) {
|
|
116
117
|
return data;
|
|
117
|
-
}, function () {
|
|
118
|
+
}, function (error) {
|
|
118
119
|
return {
|
|
119
|
-
error: {
|
|
120
|
+
error: (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? {
|
|
121
|
+
type: _types.SyncBlockError.Errored,
|
|
122
|
+
reason: error
|
|
123
|
+
} : {
|
|
120
124
|
type: _types.SyncBlockError.Errored
|
|
121
125
|
},
|
|
122
126
|
resourceId: blockIdentifier.resourceId
|
|
@@ -425,8 +425,9 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
425
425
|
});
|
|
426
426
|
this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
427
427
|
} else {
|
|
428
|
-
var
|
|
429
|
-
(
|
|
428
|
+
var _syncBlockInstance$er, _syncBlockInstance$er2, _syncBlockInstance$er3, _this$fireAnalyticsEv3;
|
|
429
|
+
var errorMessage = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type) : (_syncBlockInstance$er3 = syncBlockInstance.error) === null || _syncBlockInstance$er3 === void 0 ? void 0 : _syncBlockInstance$er3.type;
|
|
430
|
+
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, (0, _errorHandling.fetchErrorPayload)(errorMessage, syncBlockInstance.resourceId));
|
|
430
431
|
}
|
|
431
432
|
}
|
|
432
433
|
|
|
@@ -765,8 +766,9 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
765
766
|
data.forEach(function (syncBlockInstance) {
|
|
766
767
|
var _resolvedSyncBlockIns;
|
|
767
768
|
if (!syncBlockInstance.resourceId) {
|
|
768
|
-
var
|
|
769
|
-
(
|
|
769
|
+
var _syncBlockInstance$er4, _syncBlockInstance$er5, _syncBlockInstance$er6, _this9$fireAnalyticsE;
|
|
770
|
+
var payload = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_3') ? ((_syncBlockInstance$er4 = syncBlockInstance.error) === null || _syncBlockInstance$er4 === void 0 ? void 0 : _syncBlockInstance$er4.reason) || ((_syncBlockInstance$er5 = syncBlockInstance.error) === null || _syncBlockInstance$er5 === void 0 ? void 0 : _syncBlockInstance$er5.type) || 'Returned sync block instance does not have resource id' : ((_syncBlockInstance$er6 = syncBlockInstance.error) === null || _syncBlockInstance$er6 === void 0 ? void 0 : _syncBlockInstance$er6.type) || 'Returned sync block instance does not have resource id';
|
|
771
|
+
(_this9$fireAnalyticsE = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE === void 0 || _this9$fireAnalyticsE.call(_this9, (0, _errorHandling.fetchErrorPayload)(payload));
|
|
770
772
|
return;
|
|
771
773
|
}
|
|
772
774
|
var existingSyncBlock = _this9.getFromCache(syncBlockInstance.resourceId);
|
|
@@ -784,8 +786,13 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
784
786
|
_this9.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
785
787
|
}
|
|
786
788
|
if (syncBlockInstance.error) {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_3')) {
|
|
790
|
+
var _this9$fireAnalyticsE2;
|
|
791
|
+
(_this9$fireAnalyticsE2 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE2 === void 0 || _this9$fireAnalyticsE2.call(_this9, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
792
|
+
} else {
|
|
793
|
+
var _this9$fireAnalyticsE3;
|
|
794
|
+
(_this9$fireAnalyticsE3 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE3 === void 0 || _this9$fireAnalyticsE3.call(_this9, (0, _errorHandling.fetchErrorPayload)(syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
795
|
+
}
|
|
789
796
|
if (syncBlockInstance.error.type === _types.SyncBlockError.NotFound || syncBlockInstance.error.type === _types.SyncBlockError.Forbidden) {
|
|
790
797
|
hasExpectedError = true;
|
|
791
798
|
} else if (syncBlockInstance.error) {
|
|
@@ -796,8 +803,8 @@ var ReferenceSyncBlockStoreManager = exports.ReferenceSyncBlockStoreManager = /*
|
|
|
796
803
|
var callbacks = _this9.subscriptions.get(syncBlockInstance.resourceId);
|
|
797
804
|
var localIds = callbacks ? Object.keys(callbacks) : [];
|
|
798
805
|
localIds.forEach(function (localId) {
|
|
799
|
-
var _this9$
|
|
800
|
-
(_this9$
|
|
806
|
+
var _this9$fireAnalyticsE4, _syncBlockInstance$da2;
|
|
807
|
+
(_this9$fireAnalyticsE4 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE4 === void 0 || _this9$fireAnalyticsE4.call(_this9, (0, _errorHandling.fetchSuccessPayload)(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product));
|
|
801
808
|
});
|
|
802
809
|
}
|
|
803
810
|
_this9.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
3
3
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { SyncBlockError } from '../common/types';
|
|
6
|
+
import { fetchErrorPayload } from '../utils/errorHandling';
|
|
5
7
|
import { createSyncBlockNode } from '../utils/utils';
|
|
6
|
-
export const useFetchSyncBlockData = (manager, resourceId, localId,
|
|
8
|
+
export const useFetchSyncBlockData = (manager, resourceId, localId, fireAnalyticsEvent) => {
|
|
7
9
|
// Initialize both states from a single cache lookup to avoid race conditions.
|
|
8
10
|
// When a block is moved/remounted, the old component's cleanup may clear the cache
|
|
9
11
|
// before or after the new component mounts. By doing a single lookup, we ensure
|
|
@@ -42,13 +44,17 @@ export const useFetchSyncBlockData = (manager, resourceId, localId, _fireAnalyti
|
|
|
42
44
|
// Fetch sync block data, the `subscribeToSyncBlock` will update the state once data is fetched
|
|
43
45
|
await manager.referenceManager.fetchSyncBlocksData([syncBlockNode]);
|
|
44
46
|
} catch (error) {
|
|
45
|
-
var _manager$referenceMan2, _manager$referenceMan3;
|
|
46
47
|
logException(error, {
|
|
47
48
|
location: 'editor-synced-block-provider/useFetchSyncBlockData'
|
|
48
49
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
50
|
+
if (fg('platform_synced_block_patch_3')) {
|
|
51
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent(fetchErrorPayload(error.message));
|
|
52
|
+
} else {
|
|
53
|
+
var _manager$referenceMan2, _manager$referenceMan3;
|
|
54
|
+
manager === null || manager === void 0 ? void 0 : (_manager$referenceMan2 = manager.referenceManager) === null || _manager$referenceMan2 === void 0 ? void 0 : (_manager$referenceMan3 = _manager$referenceMan2.fetchExperience) === null || _manager$referenceMan3 === void 0 ? void 0 : _manager$referenceMan3.failure({
|
|
55
|
+
reason: error.message
|
|
56
|
+
});
|
|
57
|
+
}
|
|
52
58
|
|
|
53
59
|
// Set error state if fetching fails
|
|
54
60
|
setFetchState({
|
|
@@ -66,7 +72,7 @@ export const useFetchSyncBlockData = (manager, resourceId, localId, _fireAnalyti
|
|
|
66
72
|
...prev,
|
|
67
73
|
isLoading: false
|
|
68
74
|
}));
|
|
69
|
-
}, [isLoading, localId, manager.referenceManager, resourceId]);
|
|
75
|
+
}, [isLoading, localId, manager.referenceManager, resourceId, fireAnalyticsEvent]);
|
|
70
76
|
useEffect(() => {
|
|
71
77
|
if (isSSR()) {
|
|
72
78
|
// in SSR, we don't need to subscribe to updates,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable require-unicode-regexp */
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
4
5
|
import { batchRetrieveSyncedBlocks, BlockError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock } from '../../clients/block-service/blockService';
|
|
5
6
|
import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
|
|
@@ -242,12 +243,22 @@ export const batchFetchData = async (cloudId, parentAri, blockNodeIdentifiers) =
|
|
|
242
243
|
resourceId
|
|
243
244
|
});
|
|
244
245
|
} catch {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
246
|
+
if (fg('platform_synced_block_patch_3')) {
|
|
247
|
+
results.push({
|
|
248
|
+
error: {
|
|
249
|
+
type: SyncBlockError.Errored,
|
|
250
|
+
reason: `parsing JSON content response failed for resourceId: ${resourceId} localId: ${blockAri}`
|
|
251
|
+
},
|
|
252
|
+
resourceId
|
|
253
|
+
});
|
|
254
|
+
} else {
|
|
255
|
+
results.push({
|
|
256
|
+
error: {
|
|
257
|
+
type: SyncBlockError.Errored
|
|
258
|
+
},
|
|
259
|
+
resourceId
|
|
260
|
+
});
|
|
261
|
+
}
|
|
251
262
|
}
|
|
252
263
|
}
|
|
253
264
|
}
|
|
@@ -262,7 +273,10 @@ export const batchFetchData = async (cloudId, parentAri, blockNodeIdentifiers) =
|
|
|
262
273
|
}
|
|
263
274
|
processedResourceIds.add(resourceId);
|
|
264
275
|
results.push({
|
|
265
|
-
error: {
|
|
276
|
+
error: fg('platform_synced_block_patch_3') ? {
|
|
277
|
+
type: mapErrorResponseCode(errorResponse.code),
|
|
278
|
+
reason: errorResponse.reason
|
|
279
|
+
} : {
|
|
266
280
|
type: mapErrorResponseCode(errorResponse.code)
|
|
267
281
|
},
|
|
268
282
|
resourceId
|
|
@@ -286,7 +300,8 @@ export const batchFetchData = async (cloudId, parentAri, blockNodeIdentifiers) =
|
|
|
286
300
|
// If batch request fails, return error for all resourceIds
|
|
287
301
|
return blockNodeIdentifiers.map(blockNodeIdentifier => ({
|
|
288
302
|
error: {
|
|
289
|
-
type: error instanceof BlockError ? mapBlockError(error) : SyncBlockError.Errored
|
|
303
|
+
type: error instanceof BlockError ? mapBlockError(error) : SyncBlockError.Errored,
|
|
304
|
+
reason: fg('platform_synced_block_patch_3') ? error.message : undefined
|
|
290
305
|
},
|
|
291
306
|
resourceId: blockNodeIdentifier.resourceId
|
|
292
307
|
}));
|
|
@@ -354,14 +369,20 @@ class BlockServiceADFFetchProvider {
|
|
|
354
369
|
} catch (error) {
|
|
355
370
|
if (error instanceof BlockError) {
|
|
356
371
|
return {
|
|
357
|
-
error: {
|
|
372
|
+
error: fg('platform_synced_block_patch_3') ? {
|
|
373
|
+
type: mapBlockError(error),
|
|
374
|
+
reason: error.message
|
|
375
|
+
} : {
|
|
358
376
|
type: mapBlockError(error)
|
|
359
377
|
},
|
|
360
378
|
resourceId
|
|
361
379
|
};
|
|
362
380
|
}
|
|
363
381
|
return {
|
|
364
|
-
error: {
|
|
382
|
+
error: fg('platform_synced_block_patch_3') ? {
|
|
383
|
+
type: SyncBlockError.Errored,
|
|
384
|
+
reason: error.message
|
|
385
|
+
} : {
|
|
365
386
|
type: SyncBlockError.Errored
|
|
366
387
|
},
|
|
367
388
|
resourceId
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
4
5
|
import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
|
|
5
6
|
import { fetchConfluencePageInfo } from '../clients/confluence/sourceInfo';
|
|
@@ -70,9 +71,12 @@ export class SyncedBlockProvider extends SyncBlockDataProviderInterface {
|
|
|
70
71
|
return Promise.allSettled(blockIdentifiers.map(blockIdentifier => {
|
|
71
72
|
return this.fetchProvider.fetchData(blockIdentifier.resourceId).then(data => {
|
|
72
73
|
return data;
|
|
73
|
-
},
|
|
74
|
+
}, error => {
|
|
74
75
|
return {
|
|
75
|
-
error: {
|
|
76
|
+
error: fg('platform_synced_block_patch_3') ? {
|
|
77
|
+
type: SyncBlockError.Errored,
|
|
78
|
+
reason: error
|
|
79
|
+
} : {
|
|
76
80
|
type: SyncBlockError.Errored
|
|
77
81
|
},
|
|
78
82
|
resourceId: blockIdentifier.resourceId
|
|
@@ -310,8 +310,9 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
310
310
|
});
|
|
311
311
|
this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
312
312
|
} else {
|
|
313
|
-
var
|
|
314
|
-
(
|
|
313
|
+
var _syncBlockInstance$er, _syncBlockInstance$er2, _syncBlockInstance$er3, _this$fireAnalyticsEv6;
|
|
314
|
+
const errorMessage = fg('platform_synced_block_patch_3') ? ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type) : (_syncBlockInstance$er3 = syncBlockInstance.error) === null || _syncBlockInstance$er3 === void 0 ? void 0 : _syncBlockInstance$er3.type;
|
|
315
|
+
(_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, fetchErrorPayload(errorMessage, syncBlockInstance.resourceId));
|
|
315
316
|
}
|
|
316
317
|
}
|
|
317
318
|
|
|
@@ -573,8 +574,9 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
573
574
|
data.forEach(syncBlockInstance => {
|
|
574
575
|
var _resolvedSyncBlockIns;
|
|
575
576
|
if (!syncBlockInstance.resourceId) {
|
|
576
|
-
var
|
|
577
|
-
(
|
|
577
|
+
var _syncBlockInstance$er4, _syncBlockInstance$er5, _syncBlockInstance$er6, _this$fireAnalyticsEv11;
|
|
578
|
+
const payload = fg('platform_synced_block_patch_3') ? ((_syncBlockInstance$er4 = syncBlockInstance.error) === null || _syncBlockInstance$er4 === void 0 ? void 0 : _syncBlockInstance$er4.reason) || ((_syncBlockInstance$er5 = syncBlockInstance.error) === null || _syncBlockInstance$er5 === void 0 ? void 0 : _syncBlockInstance$er5.type) || 'Returned sync block instance does not have resource id' : ((_syncBlockInstance$er6 = syncBlockInstance.error) === null || _syncBlockInstance$er6 === void 0 ? void 0 : _syncBlockInstance$er6.type) || 'Returned sync block instance does not have resource id';
|
|
579
|
+
(_this$fireAnalyticsEv11 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv11 === void 0 ? void 0 : _this$fireAnalyticsEv11.call(this, fetchErrorPayload(payload));
|
|
578
580
|
return;
|
|
579
581
|
}
|
|
580
582
|
const existingSyncBlock = this.getFromCache(syncBlockInstance.resourceId);
|
|
@@ -592,8 +594,13 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
592
594
|
this.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
593
595
|
}
|
|
594
596
|
if (syncBlockInstance.error) {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
+
if (fg('platform_synced_block_patch_3')) {
|
|
598
|
+
var _this$fireAnalyticsEv12;
|
|
599
|
+
(_this$fireAnalyticsEv12 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv12 === void 0 ? void 0 : _this$fireAnalyticsEv12.call(this, fetchErrorPayload(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
600
|
+
} else {
|
|
601
|
+
var _this$fireAnalyticsEv13;
|
|
602
|
+
(_this$fireAnalyticsEv13 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv13 === void 0 ? void 0 : _this$fireAnalyticsEv13.call(this, fetchErrorPayload(syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
603
|
+
}
|
|
597
604
|
if (syncBlockInstance.error.type === SyncBlockError.NotFound || syncBlockInstance.error.type === SyncBlockError.Forbidden) {
|
|
598
605
|
hasExpectedError = true;
|
|
599
606
|
} else if (syncBlockInstance.error) {
|
|
@@ -604,8 +611,8 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
604
611
|
const callbacks = this.subscriptions.get(syncBlockInstance.resourceId);
|
|
605
612
|
const localIds = callbacks ? Object.keys(callbacks) : [];
|
|
606
613
|
localIds.forEach(localId => {
|
|
607
|
-
var _this$
|
|
608
|
-
(_this$
|
|
614
|
+
var _this$fireAnalyticsEv14, _syncBlockInstance$da2;
|
|
615
|
+
(_this$fireAnalyticsEv14 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv14 === void 0 ? void 0 : _this$fireAnalyticsEv14.call(this, fetchSuccessPayload(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product));
|
|
609
616
|
});
|
|
610
617
|
}
|
|
611
618
|
this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
@@ -818,11 +825,11 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
818
825
|
}
|
|
819
826
|
return this.subscribeToSyncBlock(resourceId, localId, callback);
|
|
820
827
|
} catch (error) {
|
|
821
|
-
var _this$
|
|
828
|
+
var _this$fireAnalyticsEv15;
|
|
822
829
|
logException(error, {
|
|
823
830
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
824
831
|
});
|
|
825
|
-
(_this$
|
|
832
|
+
(_this$fireAnalyticsEv15 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv15 === void 0 ? void 0 : _this$fireAnalyticsEv15.call(this, fetchErrorPayload(error.message));
|
|
826
833
|
return () => {};
|
|
827
834
|
}
|
|
828
835
|
}
|
|
@@ -842,12 +849,12 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
842
849
|
}
|
|
843
850
|
getProviderFactory(resourceId) {
|
|
844
851
|
if (!this.dataProvider) {
|
|
845
|
-
var _this$
|
|
852
|
+
var _this$fireAnalyticsEv16;
|
|
846
853
|
const error = new Error('Data provider not set');
|
|
847
854
|
logException(error, {
|
|
848
855
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
849
856
|
});
|
|
850
|
-
(_this$
|
|
857
|
+
(_this$fireAnalyticsEv16 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv16 === void 0 ? void 0 : _this$fireAnalyticsEv16.call(this, fetchErrorPayload(error.message));
|
|
851
858
|
return undefined;
|
|
852
859
|
}
|
|
853
860
|
const {
|
|
@@ -877,11 +884,11 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
877
884
|
try {
|
|
878
885
|
this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
|
|
879
886
|
} catch (error) {
|
|
880
|
-
var _this$
|
|
887
|
+
var _this$fireAnalyticsEv17;
|
|
881
888
|
logException(error, {
|
|
882
889
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
883
890
|
});
|
|
884
|
-
(_this$
|
|
891
|
+
(_this$fireAnalyticsEv17 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv17 === void 0 ? void 0 : _this$fireAnalyticsEv17.call(this, fetchErrorPayload(error.message, resourceId));
|
|
885
892
|
}
|
|
886
893
|
}
|
|
887
894
|
return providerFactory;
|
|
@@ -937,8 +944,8 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
937
944
|
return;
|
|
938
945
|
}
|
|
939
946
|
if (!syncBlock.data.sourceAri || !syncBlock.data.product) {
|
|
940
|
-
var _this$
|
|
941
|
-
(_this$
|
|
947
|
+
var _this$fireAnalyticsEv18;
|
|
948
|
+
(_this$fireAnalyticsEv18 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv18 === void 0 ? void 0 : _this$fireAnalyticsEv18.call(this, fetchErrorPayload('Sync block source ari or product not found'));
|
|
942
949
|
return;
|
|
943
950
|
}
|
|
944
951
|
const parentInfo = this.dataProvider.retrieveSyncBlockParentInfo((_syncBlock$data2 = syncBlock.data) === null || _syncBlock$data2 === void 0 ? void 0 : _syncBlock$data2.sourceAri, (_syncBlock$data3 = syncBlock.data) === null || _syncBlock$data3 === void 0 ? void 0 : _syncBlock$data3.product);
|
|
@@ -1056,15 +1063,15 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
1056
1063
|
(_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 ? void 0 : _this$saveExperience.start();
|
|
1057
1064
|
const updateResult = await this.dataProvider.updateReferenceData(blocks);
|
|
1058
1065
|
if (!updateResult.success) {
|
|
1059
|
-
var _this$saveExperience2, _this$
|
|
1066
|
+
var _this$saveExperience2, _this$fireAnalyticsEv19;
|
|
1060
1067
|
success = false;
|
|
1061
1068
|
(_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 ? void 0 : _this$saveExperience2.failure({
|
|
1062
1069
|
reason: updateResult.error || 'Failed to update reference synced blocks on the document'
|
|
1063
1070
|
});
|
|
1064
|
-
(_this$
|
|
1071
|
+
(_this$fireAnalyticsEv19 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv19 === void 0 ? void 0 : _this$fireAnalyticsEv19.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document'));
|
|
1065
1072
|
}
|
|
1066
1073
|
} catch (error) {
|
|
1067
|
-
var _this$saveExperience3, _this$
|
|
1074
|
+
var _this$saveExperience3, _this$fireAnalyticsEv20;
|
|
1068
1075
|
success = false;
|
|
1069
1076
|
logException(error, {
|
|
1070
1077
|
location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
|
|
@@ -1072,7 +1079,7 @@ export class ReferenceSyncBlockStoreManager {
|
|
|
1072
1079
|
(_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 ? void 0 : _this$saveExperience3.failure({
|
|
1073
1080
|
reason: error.message
|
|
1074
1081
|
});
|
|
1075
|
-
(_this$
|
|
1082
|
+
(_this$fireAnalyticsEv20 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv20 === void 0 ? void 0 : _this$fireAnalyticsEv20.call(this, updateReferenceErrorPayload(error.message));
|
|
1076
1083
|
} finally {
|
|
1077
1084
|
if (!success) {
|
|
1078
1085
|
// set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
|
|
@@ -7,9 +7,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
8
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
9
9
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { SyncBlockError } from '../common/types';
|
|
12
|
+
import { fetchErrorPayload } from '../utils/errorHandling';
|
|
11
13
|
import { createSyncBlockNode } from '../utils/utils';
|
|
12
|
-
export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resourceId, localId,
|
|
14
|
+
export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resourceId, localId, fireAnalyticsEvent) {
|
|
13
15
|
// Initialize both states from a single cache lookup to avoid race conditions.
|
|
14
16
|
// When a block is moved/remounted, the old component's cleanup may clear the cache
|
|
15
17
|
// before or after the new component mounts. By doing a single lookup, we ensure
|
|
@@ -70,9 +72,13 @@ export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resou
|
|
|
70
72
|
logException(_context.t0, {
|
|
71
73
|
location: 'editor-synced-block-provider/useFetchSyncBlockData'
|
|
72
74
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
75
|
+
if (fg('platform_synced_block_patch_3')) {
|
|
76
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent(fetchErrorPayload(_context.t0.message));
|
|
77
|
+
} else {
|
|
78
|
+
manager === null || manager === void 0 || (_manager$referenceMan2 = manager.referenceManager) === null || _manager$referenceMan2 === void 0 || (_manager$referenceMan2 = _manager$referenceMan2.fetchExperience) === null || _manager$referenceMan2 === void 0 || _manager$referenceMan2.failure({
|
|
79
|
+
reason: _context.t0.message
|
|
80
|
+
});
|
|
81
|
+
}
|
|
76
82
|
|
|
77
83
|
// Set error state if fetching fails
|
|
78
84
|
setFetchState({
|
|
@@ -96,7 +102,7 @@ export var useFetchSyncBlockData = function useFetchSyncBlockData(manager, resou
|
|
|
96
102
|
return _context.stop();
|
|
97
103
|
}
|
|
98
104
|
}, _callee, null, [[2, 11]]);
|
|
99
|
-
})), [isLoading, localId, manager.referenceManager, resourceId]);
|
|
105
|
+
})), [isLoading, localId, manager.referenceManager, resourceId, fireAnalyticsEvent]);
|
|
100
106
|
useEffect(function () {
|
|
101
107
|
if (isSSR()) {
|
|
102
108
|
// in SSR, we don't need to subscribe to updates,
|
|
@@ -11,6 +11,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
11
11
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
12
|
/* eslint-disable require-unicode-regexp */
|
|
13
13
|
import { useMemo } from 'react';
|
|
14
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
15
|
import { generateBlockAri, generateBlockAriFromReference } from '../../clients/block-service/ari';
|
|
15
16
|
import { batchRetrieveSyncedBlocks, BlockError, createSyncedBlock, deleteSyncedBlock, getReferenceSyncedBlocks, getReferenceSyncedBlocksByBlockAri, getSyncedBlockContent, updateReferenceSyncedBlockOnDocument, updateSyncedBlock } from '../../clients/block-service/blockService';
|
|
16
17
|
import { subscribeToBlockUpdates as subscribeToBlockUpdatesWS } from '../../clients/block-service/blockSubscription';
|
|
@@ -294,12 +295,22 @@ var _batchFetchData = /*#__PURE__*/function () {
|
|
|
294
295
|
resourceId: resourceId
|
|
295
296
|
});
|
|
296
297
|
} catch (_unused3) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
298
|
+
if (fg('platform_synced_block_patch_3')) {
|
|
299
|
+
results.push({
|
|
300
|
+
error: {
|
|
301
|
+
type: SyncBlockError.Errored,
|
|
302
|
+
reason: "parsing JSON content response failed for resourceId: ".concat(resourceId, " localId: ").concat(blockAri)
|
|
303
|
+
},
|
|
304
|
+
resourceId: resourceId
|
|
305
|
+
});
|
|
306
|
+
} else {
|
|
307
|
+
results.push({
|
|
308
|
+
error: {
|
|
309
|
+
type: SyncBlockError.Errored
|
|
310
|
+
},
|
|
311
|
+
resourceId: resourceId
|
|
312
|
+
});
|
|
313
|
+
}
|
|
303
314
|
}
|
|
304
315
|
case 25:
|
|
305
316
|
_context2.next = 14;
|
|
@@ -339,7 +350,10 @@ var _batchFetchData = /*#__PURE__*/function () {
|
|
|
339
350
|
case 44:
|
|
340
351
|
processedResourceIds.add(_resourceId);
|
|
341
352
|
results.push({
|
|
342
|
-
error: {
|
|
353
|
+
error: fg('platform_synced_block_patch_3') ? {
|
|
354
|
+
type: mapErrorResponseCode(errorResponse.code),
|
|
355
|
+
reason: errorResponse.reason
|
|
356
|
+
} : {
|
|
343
357
|
type: mapErrorResponseCode(errorResponse.code)
|
|
344
358
|
},
|
|
345
359
|
resourceId: _resourceId
|
|
@@ -385,7 +399,8 @@ var _batchFetchData = /*#__PURE__*/function () {
|
|
|
385
399
|
return _context2.abrupt("return", blockNodeIdentifiers.map(function (blockNodeIdentifier) {
|
|
386
400
|
return {
|
|
387
401
|
error: {
|
|
388
|
-
type: _context2.t2 instanceof BlockError ? mapBlockError(_context2.t2) : SyncBlockError.Errored
|
|
402
|
+
type: _context2.t2 instanceof BlockError ? mapBlockError(_context2.t2) : SyncBlockError.Errored,
|
|
403
|
+
reason: fg('platform_synced_block_patch_3') ? _context2.t2.message : undefined
|
|
389
404
|
},
|
|
390
405
|
resourceId: blockNodeIdentifier.resourceId
|
|
391
406
|
};
|
|
@@ -472,14 +487,20 @@ var BlockServiceADFFetchProvider = /*#__PURE__*/function () {
|
|
|
472
487
|
break;
|
|
473
488
|
}
|
|
474
489
|
return _context3.abrupt("return", {
|
|
475
|
-
error: {
|
|
490
|
+
error: fg('platform_synced_block_patch_3') ? {
|
|
491
|
+
type: mapBlockError(_context3.t0),
|
|
492
|
+
reason: _context3.t0.message
|
|
493
|
+
} : {
|
|
476
494
|
type: mapBlockError(_context3.t0)
|
|
477
495
|
},
|
|
478
496
|
resourceId: resourceId
|
|
479
497
|
});
|
|
480
498
|
case 16:
|
|
481
499
|
return _context3.abrupt("return", {
|
|
482
|
-
error: {
|
|
500
|
+
error: fg('platform_synced_block_patch_3') ? {
|
|
501
|
+
type: SyncBlockError.Errored,
|
|
502
|
+
reason: _context3.t0.message
|
|
503
|
+
} : {
|
|
483
504
|
type: SyncBlockError.Errored
|
|
484
505
|
},
|
|
485
506
|
resourceId: resourceId
|
|
@@ -11,6 +11,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
11
11
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
13
|
import { useMemo } from 'react';
|
|
14
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
15
|
import { getProductFromSourceAri } from '../clients/block-service/ari';
|
|
15
16
|
import { getPageIdAndTypeFromConfluencePageAri } from '../clients/confluence/ari';
|
|
16
17
|
import { fetchConfluencePageInfo } from '../clients/confluence/sourceInfo';
|
|
@@ -107,9 +108,12 @@ export var SyncedBlockProvider = /*#__PURE__*/function (_SyncBlockDataProvide) {
|
|
|
107
108
|
return _context.abrupt("return", Promise.allSettled(blockIdentifiers.map(function (blockIdentifier) {
|
|
108
109
|
return _this2.fetchProvider.fetchData(blockIdentifier.resourceId).then(function (data) {
|
|
109
110
|
return data;
|
|
110
|
-
}, function () {
|
|
111
|
+
}, function (error) {
|
|
111
112
|
return {
|
|
112
|
-
error: {
|
|
113
|
+
error: fg('platform_synced_block_patch_3') ? {
|
|
114
|
+
type: SyncBlockError.Errored,
|
|
115
|
+
reason: error
|
|
116
|
+
} : {
|
|
113
117
|
type: SyncBlockError.Errored
|
|
114
118
|
},
|
|
115
119
|
resourceId: blockIdentifier.resourceId
|
|
@@ -418,8 +418,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
418
418
|
});
|
|
419
419
|
this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
420
420
|
} else {
|
|
421
|
-
var
|
|
422
|
-
(
|
|
421
|
+
var _syncBlockInstance$er, _syncBlockInstance$er2, _syncBlockInstance$er3, _this$fireAnalyticsEv3;
|
|
422
|
+
var errorMessage = fg('platform_synced_block_patch_3') ? ((_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.reason) || ((_syncBlockInstance$er2 = syncBlockInstance.error) === null || _syncBlockInstance$er2 === void 0 ? void 0 : _syncBlockInstance$er2.type) : (_syncBlockInstance$er3 = syncBlockInstance.error) === null || _syncBlockInstance$er3 === void 0 ? void 0 : _syncBlockInstance$er3.type;
|
|
423
|
+
(_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 || _this$fireAnalyticsEv3.call(this, fetchErrorPayload(errorMessage, syncBlockInstance.resourceId));
|
|
423
424
|
}
|
|
424
425
|
}
|
|
425
426
|
|
|
@@ -758,8 +759,9 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
758
759
|
data.forEach(function (syncBlockInstance) {
|
|
759
760
|
var _resolvedSyncBlockIns;
|
|
760
761
|
if (!syncBlockInstance.resourceId) {
|
|
761
|
-
var
|
|
762
|
-
(
|
|
762
|
+
var _syncBlockInstance$er4, _syncBlockInstance$er5, _syncBlockInstance$er6, _this9$fireAnalyticsE;
|
|
763
|
+
var payload = fg('platform_synced_block_patch_3') ? ((_syncBlockInstance$er4 = syncBlockInstance.error) === null || _syncBlockInstance$er4 === void 0 ? void 0 : _syncBlockInstance$er4.reason) || ((_syncBlockInstance$er5 = syncBlockInstance.error) === null || _syncBlockInstance$er5 === void 0 ? void 0 : _syncBlockInstance$er5.type) || 'Returned sync block instance does not have resource id' : ((_syncBlockInstance$er6 = syncBlockInstance.error) === null || _syncBlockInstance$er6 === void 0 ? void 0 : _syncBlockInstance$er6.type) || 'Returned sync block instance does not have resource id';
|
|
764
|
+
(_this9$fireAnalyticsE = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE === void 0 || _this9$fireAnalyticsE.call(_this9, fetchErrorPayload(payload));
|
|
763
765
|
return;
|
|
764
766
|
}
|
|
765
767
|
var existingSyncBlock = _this9.getFromCache(syncBlockInstance.resourceId);
|
|
@@ -777,8 +779,13 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
777
779
|
_this9.newlyAddedSyncBlocks.delete(syncBlockInstance.resourceId);
|
|
778
780
|
}
|
|
779
781
|
if (syncBlockInstance.error) {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
+
if (fg('platform_synced_block_patch_3')) {
|
|
783
|
+
var _this9$fireAnalyticsE2;
|
|
784
|
+
(_this9$fireAnalyticsE2 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE2 === void 0 || _this9$fireAnalyticsE2.call(_this9, fetchErrorPayload(syncBlockInstance.error.reason || syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
785
|
+
} else {
|
|
786
|
+
var _this9$fireAnalyticsE3;
|
|
787
|
+
(_this9$fireAnalyticsE3 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE3 === void 0 || _this9$fireAnalyticsE3.call(_this9, fetchErrorPayload(syncBlockInstance.error.type, syncBlockInstance.resourceId));
|
|
788
|
+
}
|
|
782
789
|
if (syncBlockInstance.error.type === SyncBlockError.NotFound || syncBlockInstance.error.type === SyncBlockError.Forbidden) {
|
|
783
790
|
hasExpectedError = true;
|
|
784
791
|
} else if (syncBlockInstance.error) {
|
|
@@ -789,8 +796,8 @@ export var ReferenceSyncBlockStoreManager = /*#__PURE__*/function () {
|
|
|
789
796
|
var callbacks = _this9.subscriptions.get(syncBlockInstance.resourceId);
|
|
790
797
|
var localIds = callbacks ? Object.keys(callbacks) : [];
|
|
791
798
|
localIds.forEach(function (localId) {
|
|
792
|
-
var _this9$
|
|
793
|
-
(_this9$
|
|
799
|
+
var _this9$fireAnalyticsE4, _syncBlockInstance$da2;
|
|
800
|
+
(_this9$fireAnalyticsE4 = _this9.fireAnalyticsEvent) === null || _this9$fireAnalyticsE4 === void 0 || _this9$fireAnalyticsE4.call(_this9, fetchSuccessPayload(syncBlockInstance.resourceId, localId, (_syncBlockInstance$da2 = syncBlockInstance.data) === null || _syncBlockInstance$da2 === void 0 ? void 0 : _syncBlockInstance$da2.product));
|
|
794
801
|
});
|
|
795
802
|
}
|
|
796
803
|
_this9.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
|
|
@@ -12,5 +12,5 @@ export interface UseFetchSyncBlockDataResult {
|
|
|
12
12
|
ssrProviders?: SSRProviders | null;
|
|
13
13
|
syncBlockInstance: SyncBlockInstance | null;
|
|
14
14
|
}
|
|
15
|
-
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string,
|
|
15
|
+
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => UseFetchSyncBlockDataResult;
|
|
16
16
|
export {};
|
|
@@ -12,5 +12,5 @@ export interface UseFetchSyncBlockDataResult {
|
|
|
12
12
|
ssrProviders?: SSRProviders | null;
|
|
13
13
|
syncBlockInstance: SyncBlockInstance | null;
|
|
14
14
|
}
|
|
15
|
-
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string,
|
|
15
|
+
export declare const useFetchSyncBlockData: (manager: SyncBlockStoreManager, resourceId?: string, localId?: string, fireAnalyticsEvent?: (payload: RendererSyncBlockEventPayload) => void) => UseFetchSyncBlockDataResult;
|
|
16
16
|
export {};
|
package/package.json
CHANGED