@atlaskit/collab-provider 10.4.0 → 10.4.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 +8 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +6 -0
- package/dist/cjs/analytics/analytics-helper.js +0 -2
- package/dist/cjs/api/api.js +26 -14
- package/dist/cjs/channel.js +0 -2
- package/dist/cjs/document/catchupv2.js +1 -4
- package/dist/cjs/document/document-service.js +33 -32
- package/dist/cjs/helpers/utils.js +80 -1
- package/dist/cjs/participants/participants-service.js +0 -2
- package/dist/cjs/provider/commit-step.js +12 -1
- package/dist/cjs/provider/index.js +69 -33
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/analytics/analytics-helper.js +0 -2
- package/dist/es2019/api/api.js +13 -1
- package/dist/es2019/channel.js +0 -2
- package/dist/es2019/document/catchupv2.js +1 -4
- package/dist/es2019/document/document-service.js +6 -5
- package/dist/es2019/helpers/utils.js +30 -1
- package/dist/es2019/participants/participants-service.js +0 -2
- package/dist/es2019/provider/commit-step.js +13 -1
- package/dist/es2019/provider/index.js +40 -17
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/analytics/analytics-helper.js +0 -2
- package/dist/esm/api/api.js +26 -14
- package/dist/esm/channel.js +0 -2
- package/dist/esm/document/catchupv2.js +1 -4
- package/dist/esm/document/document-service.js +33 -32
- package/dist/esm/helpers/utils.js +78 -1
- package/dist/esm/participants/participants-service.js +0 -2
- package/dist/esm/provider/commit-step.js +12 -1
- package/dist/esm/provider/index.js +71 -35
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/document/document-service.d.ts +1 -0
- package/dist/types/errors/custom-errors.d.ts +1 -1
- package/dist/types/helpers/utils.d.ts +9 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/provider/commit-step.d.ts +2 -1
- package/dist/types-ts4.5/document/document-service.d.ts +1 -0
- package/dist/types-ts4.5/errors/custom-errors.d.ts +1 -1
- package/dist/types-ts4.5/helpers/utils.d.ts +9 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/provider/commit-step.d.ts +2 -1
- package/package.json +12 -2
|
@@ -58,8 +58,6 @@ const triggerAnalyticsEvent = (analyticsEvent, analyticsClient) => {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
export default class AnalyticsHelper {
|
|
61
|
-
// Ignored via go/ees005
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
63
61
|
constructor(documentAri, subProduct, analyticsClient, getAnalyticsClient) {
|
|
64
62
|
this.documentAri = documentAri;
|
|
65
63
|
this.subProduct = subProduct;
|
package/dist/es2019/api/api.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { getProduct, getSubProduct, createLogger } from '../helpers/utils';
|
|
3
|
+
import { getActiveTraceHttpRequestHeaders } from '@atlaskit/react-ufo/experience-trace-id-context';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { addFeatureFlagAccessed } from '@atlaskit/react-ufo/feature-flags-accessed';
|
|
3
6
|
const logger = createLogger('Api', 'blue');
|
|
4
7
|
class AddCommentError extends Error {
|
|
5
8
|
constructor(message, status, meta) {
|
|
@@ -27,6 +30,14 @@ export class Api {
|
|
|
27
30
|
});
|
|
28
31
|
const url = `${this.config.url}/document/${encodeURIComponent(this.config.documentAri)}/comment`;
|
|
29
32
|
logger(`Request url: `, url);
|
|
33
|
+
|
|
34
|
+
//Get tracing headers from UFO
|
|
35
|
+
const tracingHeaderEnabled = fg('platform_collab_provider_tracingheaders');
|
|
36
|
+
addFeatureFlagAccessed('platform_collab_provider_tracingheaders', tracingHeaderEnabled);
|
|
37
|
+
let tracingHeaders = {};
|
|
38
|
+
if (tracingHeaderEnabled) {
|
|
39
|
+
tracingHeaders = getActiveTraceHttpRequestHeaders(url);
|
|
40
|
+
}
|
|
30
41
|
const fetchOptions = {
|
|
31
42
|
credentials: 'include',
|
|
32
43
|
headers: {
|
|
@@ -35,7 +46,8 @@ export class Api {
|
|
|
35
46
|
} : {}),
|
|
36
47
|
'x-product': getProduct(this.config.productInfo),
|
|
37
48
|
'x-subproduct': getSubProduct(this.config.productInfo),
|
|
38
|
-
'Content-Type': 'application/json'
|
|
49
|
+
'Content-Type': 'application/json',
|
|
50
|
+
...tracingHeaders
|
|
39
51
|
},
|
|
40
52
|
method: 'POST',
|
|
41
53
|
body: reqBody
|
package/dist/es2019/channel.js
CHANGED
|
@@ -173,8 +173,6 @@ export class Channel extends Emitter {
|
|
|
173
173
|
this.emit('steps:added', data);
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
|
-
// Ignored via go/ees005
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
178
176
|
_defineProperty(this, "fetchCatchupv2", async (fromVersion, clientId, catchUpOutofSync, reason) => {
|
|
179
177
|
try {
|
|
180
178
|
const {
|
|
@@ -68,9 +68,6 @@ const logObfuscatedSteps = (steps, opt) => {
|
|
|
68
68
|
* @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
|
|
69
69
|
* @returns True if we're out of sync, false if not.
|
|
70
70
|
*/
|
|
71
|
-
export const isOutOfSync = (fromVersion, currentVersion, steps, clientId
|
|
72
|
-
// Ignored via go/ees005
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
74
|
-
) =>
|
|
71
|
+
export const isOutOfSync = (fromVersion, currentVersion, steps, clientId) =>
|
|
75
72
|
// If version number hasn't increased, and steps are not from our client, we're out of sync
|
|
76
73
|
Boolean(fromVersion >= currentVersion && steps.some(step => step.clientId !== clientId));
|
|
@@ -34,8 +34,6 @@ export class DocumentService {
|
|
|
34
34
|
* @param enableErrorOnFailedDocumentApply - Enable failed document update exceptions.
|
|
35
35
|
* @param getConnected - if the channel is currently connected
|
|
36
36
|
*/
|
|
37
|
-
// Ignored via go/ees005
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
39
37
|
constructor(participantsService, analyticsHelper, fetchCatchupv2, fetchReconcile,
|
|
40
38
|
// Ignored via go/ees005
|
|
41
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -46,6 +44,7 @@ export class DocumentService {
|
|
|
46
44
|
_defineProperty(this, "stepRejectCounter", 0);
|
|
47
45
|
_defineProperty(this, "aggressiveCatchup", false);
|
|
48
46
|
_defineProperty(this, "catchUpOutofSync", false);
|
|
47
|
+
_defineProperty(this, "hasRecovered", false);
|
|
49
48
|
/**
|
|
50
49
|
* To prevent calling catchup to often, use lodash throttle to reduce the frequency
|
|
51
50
|
* @param reason - optional reason to attach.
|
|
@@ -283,6 +282,9 @@ export class DocumentService {
|
|
|
283
282
|
metadata,
|
|
284
283
|
targetClientId
|
|
285
284
|
}) => {
|
|
285
|
+
if (!targetClientId) {
|
|
286
|
+
this.hasRecovered = true;
|
|
287
|
+
}
|
|
286
288
|
if (targetClientId && this.clientId !== targetClientId) {
|
|
287
289
|
return;
|
|
288
290
|
}
|
|
@@ -704,8 +706,6 @@ export class DocumentService {
|
|
|
704
706
|
* Send steps from transaction to other participants
|
|
705
707
|
* It needs the superfluous arguments because we keep the interface of the send API the same as the Synchrony plugin
|
|
706
708
|
*/
|
|
707
|
-
// Ignored via go/ees005
|
|
708
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
709
709
|
send(_tr, _oldState, newState, sendAnalyticsEvent) {
|
|
710
710
|
const unconfirmedStepsData = sendableSteps(newState);
|
|
711
711
|
const version = this.getVersionFromCollabState(newState, 'collab-provider: send');
|
|
@@ -763,7 +763,8 @@ export class DocumentService {
|
|
|
763
763
|
onErrorHandled: this.onErrorHandled,
|
|
764
764
|
analyticsHelper: this.analyticsHelper,
|
|
765
765
|
emit: this.providerEmitCallback,
|
|
766
|
-
__livePage: this.options.__livePage
|
|
766
|
+
__livePage: this.options.__livePage,
|
|
767
|
+
hasRecovered: this.hasRecovered
|
|
767
768
|
});
|
|
768
769
|
}
|
|
769
770
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { scrubAdf } from '@atlaskit/adf-utils/scrub';
|
|
2
|
+
import { sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
3
|
+
import { CustomError } from '../errors/custom-errors';
|
|
2
4
|
export const createLogger = (prefix, color = 'blue') =>
|
|
3
5
|
// Ignored via go/ees005
|
|
4
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -179,4 +181,31 @@ const stepToAdf = step => {
|
|
|
179
181
|
});
|
|
180
182
|
}
|
|
181
183
|
return [];
|
|
182
|
-
};
|
|
184
|
+
};
|
|
185
|
+
export async function logObfuscatedSteps(oldState, newState) {
|
|
186
|
+
try {
|
|
187
|
+
var _states$new, _states$old;
|
|
188
|
+
let stepsFromOldState = '',
|
|
189
|
+
stepsFromNewState = '';
|
|
190
|
+
const states = {
|
|
191
|
+
old: oldState ? sendableSteps(oldState) : null,
|
|
192
|
+
new: sendableSteps(newState)
|
|
193
|
+
};
|
|
194
|
+
if ((_states$new = states.new) !== null && _states$new !== void 0 && _states$new.steps) {
|
|
195
|
+
stepsFromNewState = await toObfuscatedSteps(states.new.steps);
|
|
196
|
+
}
|
|
197
|
+
if ((_states$old = states.old) !== null && _states$old !== void 0 && _states$old.steps) {
|
|
198
|
+
stepsFromOldState = await toObfuscatedSteps(states.old.steps);
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
stepsFromOldState,
|
|
202
|
+
stepsFromNewState
|
|
203
|
+
};
|
|
204
|
+
} catch (err) {
|
|
205
|
+
return new CustomError('Failed to obfuscate steps', err);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
export async function toObfuscatedSteps(steps) {
|
|
209
|
+
const _steps = await Promise.resolve(steps.slice().map(s => s.toJSON()));
|
|
210
|
+
return JSON.stringify(getObfuscatedSteps(_steps));
|
|
211
|
+
}
|
|
@@ -18,8 +18,6 @@ const SEND_PRESENCE_INTERVAL = 150 * 1000; // 150 seconds
|
|
|
18
18
|
* @param sendPresenceJoined Callback to Channel class
|
|
19
19
|
*/
|
|
20
20
|
export class ParticipantsService {
|
|
21
|
-
// Ignored via go/ees005
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
23
21
|
constructor(analyticsHelper, participantsState = new ParticipantsState(), emit, getUser, channelBroadcast, sendPresenceJoined, getPresenceData, setUserId, getAIProviderActiveIds) {
|
|
24
22
|
_defineProperty(this, "sendAIProviderChanged", payload => {
|
|
25
23
|
if (payload.providerId) {
|
|
@@ -17,7 +17,8 @@ export const commitStepQueue = ({
|
|
|
17
17
|
onErrorHandled,
|
|
18
18
|
analyticsHelper,
|
|
19
19
|
emit,
|
|
20
|
-
__livePage
|
|
20
|
+
__livePage,
|
|
21
|
+
hasRecovered
|
|
21
22
|
}) => {
|
|
22
23
|
if (!readyToCommit) {
|
|
23
24
|
logger('Not ready to commit, skip');
|
|
@@ -60,6 +61,17 @@ export const commitStepQueue = ({
|
|
|
60
61
|
return step;
|
|
61
62
|
});
|
|
62
63
|
}
|
|
64
|
+
|
|
65
|
+
// tag unconfirmed steps sent after page has been recovered during client's editing session
|
|
66
|
+
if (hasRecovered && fg('tag_unconfirmed_steps_after_recovery')) {
|
|
67
|
+
stepsWithClientAndUserId = stepsWithClientAndUserId.map(step => {
|
|
68
|
+
step.metadata = {
|
|
69
|
+
...step.metadata,
|
|
70
|
+
unconfirmedStepAfterRecovery: true
|
|
71
|
+
};
|
|
72
|
+
return step;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
63
75
|
const start = new Date().getTime();
|
|
64
76
|
emit('commit-status', {
|
|
65
77
|
status: 'attempt',
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { Emitter } from '../emitter';
|
|
4
5
|
import { Channel } from '../channel';
|
|
5
|
-
import { createLogger } from '../helpers/utils';
|
|
6
|
+
import { createLogger, logObfuscatedSteps } from '../helpers/utils';
|
|
6
7
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
7
8
|
import { telepointerCallback } from '../participants/telepointers-helper';
|
|
8
|
-
import { DestroyError, GetCurrentStateError, GetFinalAcknowledgedStateError, ProviderInitialisationError, SendTransactionError, SetEditorWidthError, SetMetadataError, SetTitleError } from '../errors/custom-errors';
|
|
9
|
+
import { CustomError, DestroyError, GetCurrentStateError, GetFinalAcknowledgedStateError, ProviderInitialisationError, SendTransactionError, SetEditorWidthError, SetMetadataError, SetTitleError } from '../errors/custom-errors';
|
|
9
10
|
import { NCS_ERROR_CODE } from '../errors/ncs-errors';
|
|
10
11
|
import { MetadataService } from '../metadata/metadata-service';
|
|
11
12
|
import { DocumentService } from '../document/document-service';
|
|
@@ -140,7 +141,13 @@ export class Provider extends Emitter {
|
|
|
140
141
|
}).on('restore', this.documentService.onRestore).on('permission', permit => {
|
|
141
142
|
this.permit = Object.assign(this.permit, permit);
|
|
142
143
|
this.emit('permission', permit);
|
|
143
|
-
}).on('steps:added', this.documentService.onStepsAdded).on('metadata:changed', this.metadataService.onMetadataChanged).on('participant:telepointer', payload => this.participantsService.onParticipantTelepointer(payload, this.sessionId)).on('participant:activity-join', this.participantsService.onParticipantActivityJoin).on('participant:activity-ack', this.participantsService.onParticipantActivityAck).on('presence:joined', this.participantsService.onPresenceJoined).on('presence', this.participantsService.onPresence).on('participant:left', this.participantsService.onParticipantLeft).on('participant:updated', this.participantsService.onParticipantUpdated).on('disconnect', this.onDisconnected.bind(this)).on('error', this.onErrorHandled).on('status',
|
|
144
|
+
}).on('steps:added', this.documentService.onStepsAdded).on('metadata:changed', this.metadataService.onMetadataChanged).on('participant:telepointer', payload => this.participantsService.onParticipantTelepointer(payload, this.sessionId)).on('participant:activity-join', this.participantsService.onParticipantActivityJoin).on('participant:activity-ack', this.participantsService.onParticipantActivityAck).on('presence:joined', this.participantsService.onPresenceJoined).on('presence', this.participantsService.onPresence).on('participant:left', this.participantsService.onParticipantLeft).on('participant:updated', this.participantsService.onParticipantUpdated).on('disconnect', this.onDisconnected.bind(this)).on('error', this.onErrorHandled).on('status', async status => {
|
|
145
|
+
await this.namespaceService.onNamespaceStatusChanged(status);
|
|
146
|
+
const isLocked = this.namespaceService.getIsNamespaceLocked();
|
|
147
|
+
this.emit('namespace-lock:check', {
|
|
148
|
+
isLocked
|
|
149
|
+
});
|
|
150
|
+
}).connect(shouldSkipDocumentInit);
|
|
144
151
|
});
|
|
145
152
|
_defineProperty(this, "setUserId", id => {
|
|
146
153
|
this.userId = id;
|
|
@@ -398,14 +405,30 @@ export class Provider extends Emitter {
|
|
|
398
405
|
send(_tr, _oldState, newState) {
|
|
399
406
|
try {
|
|
400
407
|
if (this.isViewOnly()) {
|
|
401
|
-
var _this$analyticsHelper10;
|
|
402
408
|
const error = {
|
|
403
409
|
message: 'Attempted to send steps in view only mode',
|
|
404
410
|
data: {
|
|
405
411
|
code: INTERNAL_ERROR_CODE.VIEW_ONLY_STEPS_ERROR
|
|
406
412
|
}
|
|
407
413
|
};
|
|
408
|
-
(
|
|
414
|
+
if (fg('log_obfuscated_steps_for_view_only')) {
|
|
415
|
+
logObfuscatedSteps(_oldState, newState).then(attributes => {
|
|
416
|
+
var _this$analyticsHelper10;
|
|
417
|
+
const stepAttributes = attributes instanceof CustomError ? {} : {
|
|
418
|
+
...attributes
|
|
419
|
+
};
|
|
420
|
+
const stepsError = new CustomError(error.message, error, {
|
|
421
|
+
...stepAttributes
|
|
422
|
+
});
|
|
423
|
+
(_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(stepsError, stepsError.message);
|
|
424
|
+
}).catch(err => {
|
|
425
|
+
var _this$analyticsHelper11;
|
|
426
|
+
return (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendErrorEvent(err, err.message);
|
|
427
|
+
});
|
|
428
|
+
} else {
|
|
429
|
+
var _this$analyticsHelper12;
|
|
430
|
+
(_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendErrorEvent(error, error.message);
|
|
431
|
+
}
|
|
409
432
|
return;
|
|
410
433
|
}
|
|
411
434
|
// Don't send steps while the document is locked (eg. when restoring the document)
|
|
@@ -415,8 +438,8 @@ export class Provider extends Emitter {
|
|
|
415
438
|
}
|
|
416
439
|
this.documentService.send(_tr, _oldState, newState);
|
|
417
440
|
} catch (error) {
|
|
418
|
-
var _this$
|
|
419
|
-
(_this$
|
|
441
|
+
var _this$analyticsHelper13;
|
|
442
|
+
(_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(error, 'Error while sending steps for a transaction');
|
|
420
443
|
throw new SendTransactionError('Error while sending steps for a transaction', error);
|
|
421
444
|
}
|
|
422
445
|
}
|
|
@@ -468,9 +491,9 @@ export class Provider extends Emitter {
|
|
|
468
491
|
});
|
|
469
492
|
}
|
|
470
493
|
} catch (error) {
|
|
471
|
-
var _this$
|
|
494
|
+
var _this$analyticsHelper14;
|
|
472
495
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
473
|
-
(_this$
|
|
496
|
+
(_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendErrorEvent(error, 'Error while sending message - telepointer');
|
|
474
497
|
}
|
|
475
498
|
}
|
|
476
499
|
setAIProviderActiveIds(ids = []) {
|
|
@@ -511,8 +534,8 @@ export class Provider extends Emitter {
|
|
|
511
534
|
this.sendStepsTimer = undefined;
|
|
512
535
|
}
|
|
513
536
|
} catch (error) {
|
|
514
|
-
var _this$
|
|
515
|
-
(_this$
|
|
537
|
+
var _this$analyticsHelper15;
|
|
538
|
+
(_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendErrorEvent(error, 'Error while shutting down the collab provider');
|
|
516
539
|
throw new DestroyError('Error while shutting down the collab provider', error);
|
|
517
540
|
}
|
|
518
541
|
this.clearTimers();
|
|
@@ -534,8 +557,8 @@ export class Provider extends Emitter {
|
|
|
534
557
|
}
|
|
535
558
|
this.metadataService.setTitle(title, broadcast);
|
|
536
559
|
} catch (error) {
|
|
537
|
-
var _this$
|
|
538
|
-
(_this$
|
|
560
|
+
var _this$analyticsHelper16;
|
|
561
|
+
(_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendErrorEvent(error, 'Error while setting title');
|
|
539
562
|
throw new SetTitleError('Error while setting title', error);
|
|
540
563
|
}
|
|
541
564
|
}
|
|
@@ -552,8 +575,8 @@ export class Provider extends Emitter {
|
|
|
552
575
|
try {
|
|
553
576
|
this.metadataService.setEditorWidth(editorWidth, broadcast);
|
|
554
577
|
} catch (error) {
|
|
555
|
-
var _this$
|
|
556
|
-
(_this$
|
|
578
|
+
var _this$analyticsHelper17;
|
|
579
|
+
(_this$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendErrorEvent(error, 'Error while setting editor width');
|
|
557
580
|
throw new SetEditorWidthError('Error while setting editor width', error);
|
|
558
581
|
}
|
|
559
582
|
}
|
|
@@ -570,8 +593,8 @@ export class Provider extends Emitter {
|
|
|
570
593
|
}
|
|
571
594
|
this.metadataService.setMetadata(metadata);
|
|
572
595
|
} catch (error) {
|
|
573
|
-
var _this$
|
|
574
|
-
(_this$
|
|
596
|
+
var _this$analyticsHelper18;
|
|
597
|
+
(_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent(error, 'Error while setting metadata');
|
|
575
598
|
throw new SetMetadataError('Error while setting metadata', error);
|
|
576
599
|
}
|
|
577
600
|
}
|
|
@@ -64,8 +64,6 @@ var triggerAnalyticsEvent = function triggerAnalyticsEvent(analyticsEvent, analy
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
var AnalyticsHelper = /*#__PURE__*/function () {
|
|
67
|
-
// Ignored via go/ees005
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
69
67
|
function AnalyticsHelper(documentAri, subProduct, analyticsClient, getAnalyticsClient) {
|
|
70
68
|
_classCallCheck(this, AnalyticsHelper);
|
|
71
69
|
this.documentAri = documentAri;
|
package/dist/esm/api/api.js
CHANGED
|
@@ -12,6 +12,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
12
12
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
13
13
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
14
|
import { getProduct, getSubProduct, createLogger } from '../helpers/utils';
|
|
15
|
+
import { getActiveTraceHttpRequestHeaders } from '@atlaskit/react-ufo/experience-trace-id-context';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
|
+
import { addFeatureFlagAccessed } from '@atlaskit/react-ufo/feature-flags-accessed';
|
|
15
18
|
var logger = createLogger('Api', 'blue');
|
|
16
19
|
var AddCommentError = /*#__PURE__*/function (_Error) {
|
|
17
20
|
function AddCommentError(message, status, meta) {
|
|
@@ -39,7 +42,7 @@ export var Api = /*#__PURE__*/function () {
|
|
|
39
42
|
_classCallCheck(this, Api);
|
|
40
43
|
_defineProperty(this, "submitComment", /*#__PURE__*/function () {
|
|
41
44
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(steps, version) {
|
|
42
|
-
var reqBody, url, fetchOptions;
|
|
45
|
+
var reqBody, url, tracingHeaderEnabled, tracingHeaders, fetchOptions;
|
|
43
46
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
44
47
|
while (1) switch (_context.prev = _context.next) {
|
|
45
48
|
case 0:
|
|
@@ -50,25 +53,33 @@ export var Api = /*#__PURE__*/function () {
|
|
|
50
53
|
});
|
|
51
54
|
url = "".concat(_this2.config.url, "/document/").concat(encodeURIComponent(_this2.config.documentAri), "/comment");
|
|
52
55
|
logger("Request url: ", url);
|
|
56
|
+
|
|
57
|
+
//Get tracing headers from UFO
|
|
58
|
+
tracingHeaderEnabled = fg('platform_collab_provider_tracingheaders');
|
|
59
|
+
addFeatureFlagAccessed('platform_collab_provider_tracingheaders', tracingHeaderEnabled);
|
|
60
|
+
tracingHeaders = {};
|
|
61
|
+
if (tracingHeaderEnabled) {
|
|
62
|
+
tracingHeaders = getActiveTraceHttpRequestHeaders(url);
|
|
63
|
+
}
|
|
53
64
|
_context.t0 = _objectSpread;
|
|
54
65
|
_context.t1 = _objectSpread;
|
|
55
66
|
_context.t2 = {};
|
|
56
67
|
if (!_this2.config.permissionTokenRefresh) {
|
|
57
|
-
_context.next =
|
|
68
|
+
_context.next = 17;
|
|
58
69
|
break;
|
|
59
70
|
}
|
|
60
|
-
_context.next =
|
|
71
|
+
_context.next = 13;
|
|
61
72
|
return _this2.channel.getChannelToken();
|
|
62
|
-
case
|
|
73
|
+
case 13:
|
|
63
74
|
_context.t4 = _context.sent;
|
|
64
75
|
_context.t3 = {
|
|
65
76
|
'x-token': _context.t4
|
|
66
77
|
};
|
|
67
|
-
_context.next =
|
|
78
|
+
_context.next = 18;
|
|
68
79
|
break;
|
|
69
|
-
case
|
|
80
|
+
case 17:
|
|
70
81
|
_context.t3 = {};
|
|
71
|
-
case
|
|
82
|
+
case 18:
|
|
72
83
|
_context.t5 = _context.t3;
|
|
73
84
|
_context.t6 = (0, _context.t1)(_context.t2, _context.t5);
|
|
74
85
|
_context.t7 = {};
|
|
@@ -77,19 +88,20 @@ export var Api = /*#__PURE__*/function () {
|
|
|
77
88
|
'x-subproduct': getSubProduct(_this2.config.productInfo),
|
|
78
89
|
'Content-Type': 'application/json'
|
|
79
90
|
};
|
|
80
|
-
_context.t9 =
|
|
81
|
-
_context.t10 =
|
|
91
|
+
_context.t9 = tracingHeaders;
|
|
92
|
+
_context.t10 = (0, _context.t0)(_context.t6, _context.t7, _context.t8, _context.t9);
|
|
93
|
+
_context.t11 = reqBody;
|
|
82
94
|
fetchOptions = {
|
|
83
95
|
credentials: 'include',
|
|
84
|
-
headers: _context.
|
|
96
|
+
headers: _context.t10,
|
|
85
97
|
method: 'POST',
|
|
86
|
-
body: _context.
|
|
98
|
+
body: _context.t11
|
|
87
99
|
};
|
|
88
|
-
_context.next =
|
|
100
|
+
_context.next = 28;
|
|
89
101
|
return fetch(url, fetchOptions);
|
|
90
|
-
case
|
|
102
|
+
case 28:
|
|
91
103
|
return _context.abrupt("return", _context.sent);
|
|
92
|
-
case
|
|
104
|
+
case 29:
|
|
93
105
|
case "end":
|
|
94
106
|
return _context.stop();
|
|
95
107
|
}
|
package/dist/esm/channel.js
CHANGED
|
@@ -228,8 +228,6 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
228
228
|
_this.emit('steps:added', data);
|
|
229
229
|
}
|
|
230
230
|
});
|
|
231
|
-
// Ignored via go/ees005
|
|
232
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
233
231
|
_defineProperty(_this, "fetchCatchupv2", /*#__PURE__*/function () {
|
|
234
232
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(fromVersion, clientId, catchUpOutofSync, reason) {
|
|
235
233
|
var _yield$utils$requestS, steps, metadata, errorNotFound, errorCatchupv2;
|
|
@@ -89,10 +89,7 @@ var logObfuscatedSteps = function logObfuscatedSteps(steps, opt) {
|
|
|
89
89
|
* @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
|
|
90
90
|
* @returns True if we're out of sync, false if not.
|
|
91
91
|
*/
|
|
92
|
-
export var isOutOfSync = function isOutOfSync(fromVersion, currentVersion, steps, clientId
|
|
93
|
-
// Ignored via go/ees005
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
95
|
-
) {
|
|
92
|
+
export var isOutOfSync = function isOutOfSync(fromVersion, currentVersion, steps, clientId) {
|
|
96
93
|
return (
|
|
97
94
|
// If version number hasn't increased, and steps are not from our client, we're out of sync
|
|
98
95
|
Boolean(fromVersion >= currentVersion && steps.some(function (step) {
|
|
@@ -40,8 +40,6 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
40
40
|
* @param enableErrorOnFailedDocumentApply - Enable failed document update exceptions.
|
|
41
41
|
* @param getConnected - if the channel is currently connected
|
|
42
42
|
*/
|
|
43
|
-
// Ignored via go/ees005
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
45
43
|
function DocumentService(participantsService, analyticsHelper, fetchCatchupv2, fetchReconcile,
|
|
46
44
|
// Ignored via go/ees005
|
|
47
45
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -57,6 +55,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
57
55
|
_defineProperty(this, "stepRejectCounter", 0);
|
|
58
56
|
_defineProperty(this, "aggressiveCatchup", false);
|
|
59
57
|
_defineProperty(this, "catchUpOutofSync", false);
|
|
58
|
+
_defineProperty(this, "hasRecovered", false);
|
|
60
59
|
/**
|
|
61
60
|
* To prevent calling catchup to often, use lodash throttle to reduce the frequency
|
|
62
61
|
* @param reason - optional reason to attach.
|
|
@@ -308,21 +307,24 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
308
307
|
while (1) switch (_context3.prev = _context3.next) {
|
|
309
308
|
case 0:
|
|
310
309
|
doc = _ref6.doc, version = _ref6.version, metadata = _ref6.metadata, targetClientId = _ref6.targetClientId;
|
|
310
|
+
if (!targetClientId) {
|
|
311
|
+
_this.hasRecovered = true;
|
|
312
|
+
}
|
|
311
313
|
if (!(targetClientId && _this.clientId !== targetClientId)) {
|
|
312
|
-
_context3.next =
|
|
314
|
+
_context3.next = 4;
|
|
313
315
|
break;
|
|
314
316
|
}
|
|
315
317
|
return _context3.abrupt("return");
|
|
316
|
-
case
|
|
318
|
+
case 4:
|
|
317
319
|
// We preserve these as they will be lost apon this.updateDocument. This is because we are using document recovery.
|
|
318
320
|
// We can then reconcile the document with the preserved state.
|
|
319
321
|
unconfirmedSteps = _this.getUnconfirmedSteps();
|
|
320
|
-
_context3.next =
|
|
322
|
+
_context3.next = 7;
|
|
321
323
|
return _this.getCurrentState();
|
|
322
|
-
case
|
|
324
|
+
case 7:
|
|
323
325
|
currentState = _context3.sent;
|
|
324
326
|
useReconcile = Boolean((unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) && currentState && !targetClientId);
|
|
325
|
-
_context3.prev =
|
|
327
|
+
_context3.prev = 9;
|
|
326
328
|
// Reset the editor,
|
|
327
329
|
// - Replace the document, keep in sync with the server
|
|
328
330
|
// - Replace the version number, so editor is in sync with NCS server and can commit new changes.
|
|
@@ -337,10 +339,10 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
337
339
|
});
|
|
338
340
|
_this.metadataService.updateMetadata(metadata);
|
|
339
341
|
if (!fg('restore_localstep_fallback_reconcile')) {
|
|
340
|
-
_context3.next =
|
|
342
|
+
_context3.next = 26;
|
|
341
343
|
break;
|
|
342
344
|
}
|
|
343
|
-
_context3.prev =
|
|
345
|
+
_context3.prev = 13;
|
|
344
346
|
(_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
|
|
345
347
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
346
348
|
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
@@ -351,35 +353,35 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
351
353
|
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
352
354
|
_this.applyLocalSteps(unconfirmedSteps);
|
|
353
355
|
}
|
|
354
|
-
_context3.next =
|
|
356
|
+
_context3.next = 24;
|
|
355
357
|
break;
|
|
356
|
-
case
|
|
357
|
-
_context3.prev =
|
|
358
|
-
_context3.t0 = _context3["catch"](
|
|
358
|
+
case 18:
|
|
359
|
+
_context3.prev = 18;
|
|
360
|
+
_context3.t0 = _context3["catch"](13);
|
|
359
361
|
(_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(_context3.t0, "Error while onRestore with applyLocalSteps. Will fallback to fetchReconcile");
|
|
360
362
|
useReconcile = true;
|
|
361
|
-
_context3.next =
|
|
363
|
+
_context3.next = 24;
|
|
362
364
|
return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
363
|
-
case
|
|
364
|
-
_context3.next =
|
|
365
|
+
case 24:
|
|
366
|
+
_context3.next = 32;
|
|
365
367
|
break;
|
|
366
|
-
case
|
|
368
|
+
case 26:
|
|
367
369
|
if (!(useReconcile && currentState)) {
|
|
368
|
-
_context3.next =
|
|
370
|
+
_context3.next = 31;
|
|
369
371
|
break;
|
|
370
372
|
}
|
|
371
|
-
_context3.next =
|
|
373
|
+
_context3.next = 29;
|
|
372
374
|
return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
373
|
-
case
|
|
374
|
-
_context3.next =
|
|
375
|
+
case 29:
|
|
376
|
+
_context3.next = 32;
|
|
375
377
|
break;
|
|
376
|
-
case
|
|
378
|
+
case 31:
|
|
377
379
|
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
378
380
|
// we don't want to use reconcile for restore triggered by catchup client out of sync (when targetClientId is provided)
|
|
379
381
|
// as this results in all changes made while the client was out of sync being lost
|
|
380
382
|
_this.applyLocalSteps(unconfirmedSteps);
|
|
381
383
|
}
|
|
382
|
-
case
|
|
384
|
+
case 32:
|
|
383
385
|
(_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
384
386
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
385
387
|
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
@@ -388,11 +390,11 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
388
390
|
targetClientId: targetClientId,
|
|
389
391
|
triggeredByCatchup: targetClientId ? true : false
|
|
390
392
|
});
|
|
391
|
-
_context3.next =
|
|
393
|
+
_context3.next = 40;
|
|
392
394
|
break;
|
|
393
|
-
case
|
|
394
|
-
_context3.prev =
|
|
395
|
-
_context3.t1 = _context3["catch"](
|
|
395
|
+
case 35:
|
|
396
|
+
_context3.prev = 35;
|
|
397
|
+
_context3.t1 = _context3["catch"](9);
|
|
396
398
|
(_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
|
|
397
399
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
398
400
|
useReconcile: useReconcile,
|
|
@@ -409,11 +411,11 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
409
411
|
code: INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR
|
|
410
412
|
}
|
|
411
413
|
});
|
|
412
|
-
case
|
|
414
|
+
case 40:
|
|
413
415
|
case "end":
|
|
414
416
|
return _context3.stop();
|
|
415
417
|
}
|
|
416
|
-
}, _callee3, null, [[
|
|
418
|
+
}, _callee3, null, [[9, 35], [13, 18]]);
|
|
417
419
|
}));
|
|
418
420
|
return function (_x3) {
|
|
419
421
|
return _ref7.apply(this, arguments);
|
|
@@ -824,8 +826,6 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
824
826
|
* Send steps from transaction to other participants
|
|
825
827
|
* It needs the superfluous arguments because we keep the interface of the send API the same as the Synchrony plugin
|
|
826
828
|
*/
|
|
827
|
-
// Ignored via go/ees005
|
|
828
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
829
829
|
function send(_tr, _oldState, newState, sendAnalyticsEvent) {
|
|
830
830
|
var unconfirmedStepsData = sendableSteps(newState);
|
|
831
831
|
var version = this.getVersionFromCollabState(newState, 'collab-provider: send');
|
|
@@ -883,7 +883,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
883
883
|
onErrorHandled: this.onErrorHandled,
|
|
884
884
|
analyticsHelper: this.analyticsHelper,
|
|
885
885
|
emit: this.providerEmitCallback,
|
|
886
|
-
__livePage: this.options.__livePage
|
|
886
|
+
__livePage: this.options.__livePage,
|
|
887
|
+
hasRecovered: this.hasRecovered
|
|
887
888
|
});
|
|
888
889
|
}
|
|
889
890
|
}]);
|