@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.
Files changed (34) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/clients/block-service/blockService.js +2 -2
  3. package/dist/cjs/providers/block-service/blockServiceAPI.js +1 -1
  4. package/dist/cjs/store-manager/referenceSyncBlockStoreManager.js +92 -136
  5. package/dist/cjs/store-manager/sourceSyncBlockStoreManager.js +95 -124
  6. package/dist/cjs/utils/errorHandling.js +79 -19
  7. package/dist/cjs/utils/experienceTracking.js +119 -0
  8. package/dist/es2019/clients/block-service/blockService.js +2 -2
  9. package/dist/es2019/providers/block-service/blockServiceAPI.js +1 -1
  10. package/dist/es2019/store-manager/referenceSyncBlockStoreManager.js +85 -126
  11. package/dist/es2019/store-manager/sourceSyncBlockStoreManager.js +80 -89
  12. package/dist/es2019/utils/errorHandling.js +61 -10
  13. package/dist/es2019/utils/experienceTracking.js +113 -0
  14. package/dist/esm/clients/block-service/blockService.js +2 -2
  15. package/dist/esm/providers/block-service/blockServiceAPI.js +1 -1
  16. package/dist/esm/store-manager/referenceSyncBlockStoreManager.js +93 -137
  17. package/dist/esm/store-manager/sourceSyncBlockStoreManager.js +96 -125
  18. package/dist/esm/utils/errorHandling.js +77 -18
  19. package/dist/esm/utils/experienceTracking.js +113 -0
  20. package/dist/types/clients/block-service/blockService.d.ts +5 -5
  21. package/dist/types/providers/block-service/blockServiceAPI.d.ts +1 -1
  22. package/dist/types/providers/types.d.ts +5 -5
  23. package/dist/types/store-manager/referenceSyncBlockStoreManager.d.ts +0 -1
  24. package/dist/types/store-manager/sourceSyncBlockStoreManager.d.ts +1 -5
  25. package/dist/types/utils/errorHandling.d.ts +14 -9
  26. package/dist/types/utils/experienceTracking.d.ts +51 -0
  27. package/dist/types-ts4.5/clients/block-service/blockService.d.ts +5 -5
  28. package/dist/types-ts4.5/providers/block-service/blockServiceAPI.d.ts +1 -1
  29. package/dist/types-ts4.5/providers/types.d.ts +5 -5
  30. package/dist/types-ts4.5/store-manager/referenceSyncBlockStoreManager.d.ts +0 -1
  31. package/dist/types-ts4.5/store-manager/sourceSyncBlockStoreManager.d.ts +1 -5
  32. package/dist/types-ts4.5/utils/errorHandling.d.ts +14 -9
  33. package/dist/types-ts4.5/utils/experienceTracking.d.ts +51 -0
  34. package/package.json +2 -2
@@ -100,8 +100,8 @@ export class BlockError extends Error {
100
100
  }
101
101
  }
102
102
  export const getSyncedBlockContent = async ({
103
- blockAri
104
- // documentAri,
103
+ blockAri,
104
+ documentAri
105
105
  }) => {
106
106
  // Disable sending documentAri for now. We'll add it back if we find a way to update references that follows the save & refresh principle.
107
107
  // Slack discussion here: https://atlassian.slack.com/archives/C09DZT1TBNW/p1767836775552099?thread_ts=1767836754.024889&cid=C09DZT1TBNW
@@ -256,7 +256,7 @@ class BlockServiceADFFetchProvider {
256
256
 
257
257
  /**
258
258
  * Batch fetches multiple synced blocks by their resource IDs.
259
- * @param blockNodeIdentifiers - Array of block node identifiers, containing block instance (local) ID + resource IDs to fetch
259
+ * @param resourceIds - Array of resource IDs to fetch
260
260
  * @returns Array of SyncBlockInstance results
261
261
  */
262
262
  async batchFetchData(blockNodeIdentifiers) {
@@ -3,7 +3,8 @@ import { logException } from '@atlaskit/editor-common/monitoring';
3
3
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
4
  import { fg } from '@atlaskit/platform-feature-flags';
5
5
  import { SyncBlockError } from '../common/types';
6
- import { fetchErrorPayload, getSourceInfoErrorPayload, updateReferenceErrorPayload } from '../utils/errorHandling';
6
+ import { fetchErrorPayload, fetchSuccessPayload, getSourceInfoErrorPayload, updateReferenceErrorPayload } from '../utils/errorHandling';
7
+ import { getFetchExperience, getFetchSourceInfoExperience, getSaveReferenceExperience } from '../utils/experienceTracking';
7
8
  import { resolveSyncBlockInstance } from '../utils/resolveSyncBlockInstance';
8
9
  import { parseResourceId } from '../utils/resourceId';
9
10
  import { createSyncBlockNode } from '../utils/utils';
@@ -37,14 +38,9 @@ export class ReferenceSyncBlockStoreManager {
37
38
  }
38
39
  setFireAnalyticsEvent(fireAnalyticsEvent) {
39
40
  this.fireAnalyticsEvent = fireAnalyticsEvent;
40
- }
41
- setExperiences(fetchExperience, fetchSourceInfoExperience, saveExperience) {
42
- // don't reset experiences after they have already been set
43
- if (!this.fetchExperience || !this.fetchSourceInfoExperience || !this.saveExperience) {
44
- this.fetchExperience = fetchExperience;
45
- this.fetchSourceInfoExperience = fetchSourceInfoExperience;
46
- this.saveExperience = saveExperience;
47
- }
41
+ this.fetchExperience = getFetchExperience(fireAnalyticsEvent);
42
+ this.fetchSourceInfoExperience = getFetchSourceInfoExperience(fireAnalyticsEvent);
43
+ this.saveExperience = getSaveReferenceExperience(fireAnalyticsEvent);
48
44
  }
49
45
  generateResourceIdForReference(sourceId) {
50
46
  if (!this.dataProvider) {
@@ -81,18 +77,11 @@ export class ReferenceSyncBlockStoreManager {
81
77
  // this function will update the cache and call the subscriptions
82
78
  await this.fetchSyncBlocksData(syncBlocks);
83
79
  } catch (error) {
80
+ var _this$fireAnalyticsEv;
84
81
  logException(error, {
85
82
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
86
83
  });
87
- if (fg('platform_synced_block_dogfooding')) {
88
- var _this$fetchExperience;
89
- (_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 ? void 0 : _this$fetchExperience.failure({
90
- reason: error.message
91
- });
92
- } else {
93
- var _this$fireAnalyticsEv;
94
- (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 ? void 0 : _this$fireAnalyticsEv.call(this, fetchErrorPayload(error.message));
95
- }
84
+ (_this$fireAnalyticsEv = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv === void 0 ? void 0 : _this$fireAnalyticsEv.call(this, fetchErrorPayload(error.message));
96
85
  } finally {
97
86
  this.isRefreshingSubscriptions = false;
98
87
  }
@@ -100,11 +89,6 @@ export class ReferenceSyncBlockStoreManager {
100
89
  fetchSyncBlockSourceInfo(resourceId) {
101
90
  try {
102
91
  if (!resourceId || !this.dataProvider) {
103
- // make sure experience has been started before throwing error
104
- if (fg('platform_synced_block_dogfooding')) {
105
- var _this$fetchSourceInfo;
106
- (_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 ? void 0 : _this$fetchSourceInfo.start({});
107
- }
108
92
  throw new Error('Data provider or resourceId not set');
109
93
  }
110
94
  if (fg('platform_synced_block_dogfooding')) {
@@ -117,10 +101,6 @@ export class ReferenceSyncBlockStoreManager {
117
101
  }
118
102
  const existingSyncBlock = this.getFromCache(resourceId);
119
103
  if (!existingSyncBlock) {
120
- if (fg('platform_synced_block_dogfooding')) {
121
- var _this$fetchSourceInfo2;
122
- (_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 ? void 0 : _this$fetchSourceInfo2.start({});
123
- }
124
104
  throw new Error('No existing sync block to fetch source info for');
125
105
  }
126
106
  const {
@@ -147,31 +127,23 @@ export class ReferenceSyncBlockStoreManager {
147
127
  return Promise.resolve(undefined);
148
128
  }
149
129
  }
150
-
151
- // only start experience if there is data to fetch
152
- if (fg('platform_synced_block_dogfooding')) {
153
- var _this$fetchSourceInfo3;
154
- (_this$fetchSourceInfo3 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 ? void 0 : _this$fetchSourceInfo3.start({});
155
- }
156
130
  if (!sourceAri || !product || !blockInstanceId) {
157
- if (fg('platform_synced_block_dogfooding')) {
158
- var _this$fetchSourceInfo4;
159
- (_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 ? void 0 : _this$fetchSourceInfo4.failure({
160
- reason: 'SourceAri, product or blockInstanceId missing'
161
- });
162
- } else {
163
- var _this$fireAnalyticsEv2;
164
- (_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 ? void 0 : _this$fireAnalyticsEv2.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing'));
165
- }
131
+ var _this$fireAnalyticsEv2;
132
+ (_this$fireAnalyticsEv2 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv2 === void 0 ? void 0 : _this$fireAnalyticsEv2.call(this, getSourceInfoErrorPayload('SourceAri, product or blockInstanceId missing', resourceId));
166
133
  return Promise.resolve(undefined);
167
134
  }
135
+ if (fg('platform_synced_block_dogfooding')) {
136
+ var _this$fetchSourceInfo;
137
+ (_this$fetchSourceInfo = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo === void 0 ? void 0 : _this$fetchSourceInfo.start({});
138
+ }
168
139
  const sourceInfoPromise = this.dataProvider.fetchSyncBlockSourceInfo(blockInstanceId, sourceAri, product, this.fireAnalyticsEvent).then(sourceInfo => {
169
140
  if (!sourceInfo) {
170
141
  if (fg('platform_synced_block_dogfooding')) {
171
- var _this$fetchSourceInfo5;
172
- (_this$fetchSourceInfo5 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo5 === void 0 ? void 0 : _this$fetchSourceInfo5.failure({
142
+ var _this$fetchSourceInfo2, _this$fireAnalyticsEv3;
143
+ (_this$fetchSourceInfo2 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo2 === void 0 ? void 0 : _this$fetchSourceInfo2.failure({
173
144
  reason: 'No source info returned'
174
145
  });
146
+ (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 ? void 0 : _this$fireAnalyticsEv3.call(this, getSourceInfoErrorPayload('No source info returned', resourceId));
175
147
  }
176
148
  return undefined;
177
149
  }
@@ -181,26 +153,26 @@ export class ReferenceSyncBlockStoreManager {
181
153
  }
182
154
  if (fg('platform_synced_block_dogfooding')) {
183
155
  if (sourceInfo.title && sourceInfo.url) {
184
- var _this$fetchSourceInfo6;
185
- (_this$fetchSourceInfo6 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo6 === void 0 ? void 0 : _this$fetchSourceInfo6.success();
156
+ var _this$fetchSourceInfo3;
157
+ (_this$fetchSourceInfo3 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo3 === void 0 ? void 0 : _this$fetchSourceInfo3.success();
186
158
  } else {
187
- var _this$fetchSourceInfo7;
188
- (_this$fetchSourceInfo7 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo7 === void 0 ? void 0 : _this$fetchSourceInfo7.failure({
159
+ var _this$fetchSourceInfo4, _this$fireAnalyticsEv4;
160
+ (_this$fetchSourceInfo4 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo4 === void 0 ? void 0 : _this$fetchSourceInfo4.failure({
189
161
  reason: 'Missing title or url'
190
162
  });
163
+ (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 ? void 0 : _this$fireAnalyticsEv4.call(this, getSourceInfoErrorPayload('Missing title or url', resourceId));
191
164
  }
192
165
  return sourceInfo;
193
166
  }
194
167
  }).catch(error => {
168
+ var _this$fireAnalyticsEv5;
195
169
  if (fg('platform_synced_block_dogfooding')) {
196
- var _this$fetchSourceInfo8;
197
- (_this$fetchSourceInfo8 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo8 === void 0 ? void 0 : _this$fetchSourceInfo8.failure({
170
+ var _this$fetchSourceInfo5;
171
+ (_this$fetchSourceInfo5 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo5 === void 0 ? void 0 : _this$fetchSourceInfo5.failure({
198
172
  reason: error.message
199
173
  });
200
- } else {
201
- var _this$fireAnalyticsEv3;
202
- (_this$fireAnalyticsEv3 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv3 === void 0 ? void 0 : _this$fireAnalyticsEv3.call(this, getSourceInfoErrorPayload(error.message));
203
174
  }
175
+ (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, getSourceInfoErrorPayload(error.message, resourceId));
204
176
  return undefined;
205
177
  }).finally(() => {
206
178
  if (fg('platform_synced_block_dogfooding')) {
@@ -216,18 +188,11 @@ export class ReferenceSyncBlockStoreManager {
216
188
  this.syncBlockSourceInfoRequestsOld.set(resourceId, true);
217
189
  }
218
190
  } catch (error) {
191
+ var _this$fireAnalyticsEv6;
219
192
  logException(error, {
220
193
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
221
194
  });
222
- if (fg('platform_synced_block_dogfooding')) {
223
- var _this$fetchSourceInfo9;
224
- (_this$fetchSourceInfo9 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo9 === void 0 ? void 0 : _this$fetchSourceInfo9.failure({
225
- reason: error.message
226
- });
227
- } else {
228
- var _this$fireAnalyticsEv4;
229
- (_this$fireAnalyticsEv4 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv4 === void 0 ? void 0 : _this$fireAnalyticsEv4.call(this, getSourceInfoErrorPayload(error.message));
230
- }
195
+ (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, getSourceInfoErrorPayload(error.message, resourceId));
231
196
  }
232
197
  return Promise.resolve(undefined);
233
198
  }
@@ -257,36 +222,28 @@ export class ReferenceSyncBlockStoreManager {
257
222
  if (nodesToFetch.length === 0) {
258
223
  return;
259
224
  }
260
-
261
- // only start fetch experience if there is data to fetch
262
- if (fg('platform_synced_block_dogfooding')) {
263
- var _this$fetchExperience2;
264
- (_this$fetchExperience2 = this.fetchExperience) === null || _this$fetchExperience2 === void 0 ? void 0 : _this$fetchExperience2.start({});
265
- }
266
225
  if (!this.dataProvider) {
267
226
  throw new Error('Data provider not set');
268
227
  }
269
228
  nodesToFetch.forEach(node => {
270
229
  this.syncBlockFetchDataRequests.set(node.attrs.resourceId, true);
271
230
  });
231
+ if (fg('platform_synced_block_dogfooding')) {
232
+ var _this$fetchExperience;
233
+ (_this$fetchExperience = this.fetchExperience) === null || _this$fetchExperience === void 0 ? void 0 : _this$fetchExperience.start({});
234
+ }
272
235
  const data = await this.dataProvider.fetchNodesData(nodesToFetch).finally(() => {
273
236
  nodesToFetch.forEach(node => {
274
237
  this.syncBlockFetchDataRequests.delete(node.attrs.resourceId);
275
238
  });
276
239
  });
277
240
  const resolvedData = [];
278
- const successfulFetched = [];
279
- const failedFetch = [];
241
+ let hasUnexpectedError = false;
242
+ let hasExpectedError = false;
280
243
  data.forEach(syncBlockInstance => {
281
244
  if (!syncBlockInstance.resourceId) {
282
- if (fg('platform_synced_block_dogfooding')) {
283
- failedFetch.push({
284
- reason: syncBlockInstance.error || 'Returned sync block instance does not have resource id'
285
- });
286
- } else {
287
- var _this$fireAnalyticsEv5;
288
- (_this$fireAnalyticsEv5 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv5 === void 0 ? void 0 : _this$fireAnalyticsEv5.call(this, fetchErrorPayload(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
289
- }
245
+ var _this$fireAnalyticsEv7;
246
+ (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, fetchErrorPayload(syncBlockInstance.error || 'Returned sync block instance does not have resource id'));
290
247
  return;
291
248
  }
292
249
  const existingSyncBlock = this.getFromCache(syncBlockInstance.resourceId);
@@ -294,36 +251,34 @@ export class ReferenceSyncBlockStoreManager {
294
251
  this.updateCache(resolvedSyncBlockInstance);
295
252
  resolvedData.push(resolvedSyncBlockInstance);
296
253
  if (syncBlockInstance.error) {
297
- if (fg('platform_synced_block_dogfooding')) {
298
- failedFetch.push({
299
- reason: syncBlockInstance.error,
300
- resourceId: syncBlockInstance.resourceId
301
- });
302
- } else {
303
- var _this$fireAnalyticsEv6;
304
- (_this$fireAnalyticsEv6 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv6 === void 0 ? void 0 : _this$fireAnalyticsEv6.call(this, fetchErrorPayload(syncBlockInstance.error));
254
+ var _this$fireAnalyticsEv8;
255
+ (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, fetchErrorPayload(syncBlockInstance.error, syncBlockInstance.resourceId));
256
+ if (syncBlockInstance.error === SyncBlockError.NotFound || syncBlockInstance.error === SyncBlockError.Forbidden) {
257
+ hasExpectedError = true;
258
+ } else if (syncBlockInstance.error) {
259
+ hasUnexpectedError = true;
305
260
  }
306
261
  return;
262
+ } else if (fg('platform_synced_block_dogfooding')) {
263
+ var _this$fireAnalyticsEv9, _syncBlockInstance$da, _syncBlockInstance$da2;
264
+ (_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 ? void 0 : _this$fireAnalyticsEv9.call(this, 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));
307
265
  }
308
- successfulFetched.push(syncBlockInstance.resourceId);
309
266
  this.fetchSyncBlockSourceInfo(resolvedSyncBlockInstance.resourceId);
310
267
  });
311
268
  if (fg('platform_synced_block_dogfooding')) {
312
- if (data.every(syncBlockInstance => syncBlockInstance.resourceId && !syncBlockInstance.error)) {
269
+ if (hasUnexpectedError) {
270
+ var _this$fetchExperience2;
271
+ (_this$fetchExperience2 = this.fetchExperience) === null || _this$fetchExperience2 === void 0 ? void 0 : _this$fetchExperience2.failure({
272
+ reason: 'Unexpected error during fetch'
273
+ });
274
+ } else if (hasExpectedError) {
313
275
  var _this$fetchExperience3;
314
- (_this$fetchExperience3 = this.fetchExperience) === null || _this$fetchExperience3 === void 0 ? void 0 : _this$fetchExperience3.success({
315
- metadata: {
316
- successfulFetched
317
- }
276
+ (_this$fetchExperience3 = this.fetchExperience) === null || _this$fetchExperience3 === void 0 ? void 0 : _this$fetchExperience3.abort({
277
+ reason: 'Expected error: NotFound or PermissionDenied'
318
278
  });
319
279
  } else {
320
280
  var _this$fetchExperience4;
321
- (_this$fetchExperience4 = this.fetchExperience) === null || _this$fetchExperience4 === void 0 ? void 0 : _this$fetchExperience4.failure({
322
- metadata: {
323
- successfulFetched,
324
- failedFetch
325
- }
326
- });
281
+ (_this$fetchExperience4 = this.fetchExperience) === null || _this$fetchExperience4 === void 0 ? void 0 : _this$fetchExperience4.success();
327
282
  }
328
283
  }
329
284
  }
@@ -400,18 +355,11 @@ export class ReferenceSyncBlockStoreManager {
400
355
  callback(cachedData);
401
356
  } else {
402
357
  this.fetchSyncBlocksData([syncBlockNode]).catch(error => {
358
+ var _this$fireAnalyticsEv0;
403
359
  logException(error, {
404
360
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
405
361
  });
406
- if (fg('platform_synced_block_dogfooding')) {
407
- var _this$fetchExperience5;
408
- (_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 ? void 0 : _this$fetchExperience5.failure({
409
- reason: error.message
410
- });
411
- } else {
412
- var _this$fireAnalyticsEv7;
413
- (_this$fireAnalyticsEv7 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv7 === void 0 ? void 0 : _this$fireAnalyticsEv7.call(this, fetchErrorPayload(error.message));
414
- }
362
+ (_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, fetchErrorPayload(error.message, resourceId));
415
363
  });
416
364
  }
417
365
  return () => {
@@ -492,11 +440,11 @@ export class ReferenceSyncBlockStoreManager {
492
440
  }
493
441
  return this.subscribeToSyncBlock(resourceId, localId, callback);
494
442
  } catch (error) {
495
- var _this$fireAnalyticsEv8;
443
+ var _this$fireAnalyticsEv1;
496
444
  logException(error, {
497
445
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
498
446
  });
499
- (_this$fireAnalyticsEv8 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv8 === void 0 ? void 0 : _this$fireAnalyticsEv8.call(this, fetchErrorPayload(error.message));
447
+ (_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 ? void 0 : _this$fireAnalyticsEv1.call(this, fetchErrorPayload(error.message));
500
448
  return () => {};
501
449
  }
502
450
  }
@@ -516,12 +464,12 @@ export class ReferenceSyncBlockStoreManager {
516
464
  }
517
465
  getProviderFactory(resourceId) {
518
466
  if (!this.dataProvider) {
519
- var _this$fireAnalyticsEv9;
467
+ var _this$fireAnalyticsEv10;
520
468
  const error = new Error('Data provider not set');
521
469
  logException(error, {
522
470
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
523
471
  });
524
- (_this$fireAnalyticsEv9 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv9 === void 0 ? void 0 : _this$fireAnalyticsEv9.call(this, fetchErrorPayload(error.message));
472
+ (_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 ? void 0 : _this$fireAnalyticsEv10.call(this, fetchErrorPayload(error.message));
525
473
  return undefined;
526
474
  }
527
475
  const {
@@ -551,11 +499,11 @@ export class ReferenceSyncBlockStoreManager {
551
499
  try {
552
500
  this.retrieveDynamicProviders(resourceId, providerFactory, providerCreator);
553
501
  } catch (error) {
554
- var _this$fireAnalyticsEv0;
502
+ var _this$fireAnalyticsEv11;
555
503
  logException(error, {
556
504
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
557
505
  });
558
- (_this$fireAnalyticsEv0 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv0 === void 0 ? void 0 : _this$fireAnalyticsEv0.call(this, fetchErrorPayload(error.message));
506
+ (_this$fireAnalyticsEv11 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv11 === void 0 ? void 0 : _this$fireAnalyticsEv11.call(this, fetchErrorPayload(error.message, resourceId));
559
507
  }
560
508
  }
561
509
  return providerFactory;
@@ -610,9 +558,12 @@ export class ReferenceSyncBlockStoreManager {
610
558
  return;
611
559
  }
612
560
  const syncBlock = this.getFromCache(resourceId);
613
- if (!syncBlock || !((_syncBlock$data2 = syncBlock.data) !== null && _syncBlock$data2 !== void 0 && _syncBlock$data2.sourceAri) || !((_syncBlock$data3 = syncBlock.data) !== null && _syncBlock$data3 !== void 0 && _syncBlock$data3.product)) {
614
- var _this$fireAnalyticsEv1;
615
- (_this$fireAnalyticsEv1 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv1 === void 0 ? void 0 : _this$fireAnalyticsEv1.call(this, fetchErrorPayload('Sync block or source ari or product not found'));
561
+ if (!syncBlock) {
562
+ return;
563
+ }
564
+ 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)) {
565
+ var _this$fireAnalyticsEv12;
566
+ (_this$fireAnalyticsEv12 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv12 === void 0 ? void 0 : _this$fireAnalyticsEv12.call(this, fetchErrorPayload('Sync block source ari or product not found'));
616
567
  return;
617
568
  }
618
569
  const 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);
@@ -681,10 +632,6 @@ export class ReferenceSyncBlockStoreManager {
681
632
  this.isCacheDirty = false;
682
633
  return true;
683
634
  }
684
- if (fg('platform_synced_block_dogfooding')) {
685
- var _this$saveExperience;
686
- (_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 ? void 0 : _this$saveExperience.start();
687
- }
688
635
  if (!this.dataProvider) {
689
636
  throw new Error('Data provider not set');
690
637
  }
@@ -695,20 +642,24 @@ export class ReferenceSyncBlockStoreManager {
695
642
  // is still making changes, the new changes might not be saved if they all happen
696
643
  // exactly at a time when the updateReferenceData is being executed asynchronously.
697
644
  this.isCacheDirty = false;
645
+ if (fg('platform_synced_block_dogfooding')) {
646
+ var _this$saveExperience;
647
+ (_this$saveExperience = this.saveExperience) === null || _this$saveExperience === void 0 ? void 0 : _this$saveExperience.start();
648
+ }
698
649
  const updateResult = await this.dataProvider.updateReferenceData(blocks);
699
650
  if (!updateResult.success) {
651
+ var _this$fireAnalyticsEv13;
700
652
  success = false;
701
653
  if (fg('platform_synced_block_dogfooding')) {
702
654
  var _this$saveExperience2;
703
655
  (_this$saveExperience2 = this.saveExperience) === null || _this$saveExperience2 === void 0 ? void 0 : _this$saveExperience2.failure({
704
656
  reason: updateResult.error || 'Failed to update reference synced blocks on the document'
705
657
  });
706
- } else {
707
- var _this$fireAnalyticsEv10;
708
- (_this$fireAnalyticsEv10 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv10 === void 0 ? void 0 : _this$fireAnalyticsEv10.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document'));
709
658
  }
659
+ (_this$fireAnalyticsEv13 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv13 === void 0 ? void 0 : _this$fireAnalyticsEv13.call(this, updateReferenceErrorPayload(updateResult.error || 'Failed to update reference synced blocks on the document'));
710
660
  }
711
661
  } catch (error) {
662
+ var _this$fireAnalyticsEv14;
712
663
  success = false;
713
664
  logException(error, {
714
665
  location: 'editor-synced-block-provider/referenceSyncBlockStoreManager'
@@ -718,10 +669,8 @@ export class ReferenceSyncBlockStoreManager {
718
669
  (_this$saveExperience3 = this.saveExperience) === null || _this$saveExperience3 === void 0 ? void 0 : _this$saveExperience3.failure({
719
670
  reason: error.message
720
671
  });
721
- } else {
722
- var _this$fireAnalyticsEv11;
723
- (_this$fireAnalyticsEv11 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv11 === void 0 ? void 0 : _this$fireAnalyticsEv11.call(this, updateReferenceErrorPayload(error.message));
724
672
  }
673
+ (_this$fireAnalyticsEv14 = this.fireAnalyticsEvent) === null || _this$fireAnalyticsEv14 === void 0 ? void 0 : _this$fireAnalyticsEv14.call(this, updateReferenceErrorPayload(error.message));
725
674
  } finally {
726
675
  if (!success) {
727
676
  // set isCacheDirty back to true for cases where it failed to update the reference synced blocks on the BE
@@ -734,6 +683,7 @@ export class ReferenceSyncBlockStoreManager {
734
683
  return success;
735
684
  }
736
685
  destroy() {
686
+ var _this$saveExperience5, _this$fetchExperience5, _this$fetchSourceInfo6;
737
687
  this.dataProvider = undefined;
738
688
  this.syncBlockCache.clear();
739
689
  this.subscriptions.clear();
@@ -747,6 +697,15 @@ export class ReferenceSyncBlockStoreManager {
747
697
  providerFactory.destroy();
748
698
  });
749
699
  this.providerFactories.clear();
700
+ (_this$saveExperience5 = this.saveExperience) === null || _this$saveExperience5 === void 0 ? void 0 : _this$saveExperience5.abort({
701
+ reason: 'editor-destroyed'
702
+ });
703
+ (_this$fetchExperience5 = this.fetchExperience) === null || _this$fetchExperience5 === void 0 ? void 0 : _this$fetchExperience5.abort({
704
+ reason: 'editor-destroyed'
705
+ });
706
+ (_this$fetchSourceInfo6 = this.fetchSourceInfoExperience) === null || _this$fetchSourceInfo6 === void 0 ? void 0 : _this$fetchSourceInfo6.abort({
707
+ reason: 'editor-destroyed'
708
+ });
750
709
  this.fireAnalyticsEvent = undefined;
751
710
  }
752
711
  }