@atlaskit/collab-provider 8.4.0 → 8.6.0
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 +53 -0
- package/dist/cjs/analytics/analytics-helper.js +135 -0
- package/dist/cjs/analytics/performance.js +6 -5
- package/dist/cjs/channel.js +242 -223
- package/dist/cjs/document/catchup.js +142 -0
- package/dist/cjs/document/document-service.js +587 -0
- package/dist/cjs/document/step-queue-state.js +56 -0
- package/dist/cjs/errors/error-code-mapper.js +86 -67
- package/dist/cjs/errors/error-types.js +329 -21
- package/dist/cjs/helpers/utils.js +1 -12
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/metadata/metadata-service.js +82 -0
- package/dist/cjs/participants/participants-helper.js +52 -0
- package/dist/cjs/participants/participants-service.js +259 -0
- package/dist/cjs/participants/participants-state.js +56 -0
- package/dist/cjs/{provider/telepointers.js → participants/telepointers-helper.js} +6 -6
- package/dist/cjs/provider/commit-step.js +14 -6
- package/dist/cjs/provider/index.js +291 -780
- package/dist/cjs/types.js +6 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/{index.js → analytics-helper.js} +15 -4
- package/dist/es2019/analytics/performance.js +5 -6
- package/dist/es2019/channel.js +140 -113
- package/dist/es2019/{provider → document}/catchup.js +6 -4
- package/dist/es2019/document/document-service.js +472 -0
- package/dist/es2019/document/step-queue-state.js +35 -0
- package/dist/es2019/errors/error-code-mapper.js +87 -63
- package/dist/es2019/errors/error-types.js +221 -5
- package/dist/es2019/helpers/utils.js +0 -10
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/metadata/metadata-service.js +61 -0
- package/dist/es2019/participants/participants-helper.js +25 -0
- package/dist/es2019/participants/participants-service.js +207 -0
- package/dist/es2019/participants/participants-state.js +30 -0
- package/dist/es2019/{provider/telepointers.js → participants/telepointers-helper.js} +2 -2
- package/dist/es2019/provider/commit-step.js +12 -5
- package/dist/es2019/provider/index.js +240 -640
- package/dist/es2019/types.js +8 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/analytics-helper.js +128 -0
- package/dist/esm/analytics/performance.js +5 -6
- package/dist/esm/channel.js +243 -224
- package/dist/esm/document/catchup.js +133 -0
- package/dist/esm/document/document-service.js +579 -0
- package/dist/esm/document/step-queue-state.js +48 -0
- package/dist/esm/errors/error-code-mapper.js +87 -64
- package/dist/esm/errors/error-types.js +321 -18
- package/dist/esm/helpers/utils.js +0 -10
- package/dist/esm/index.js +2 -1
- package/dist/esm/metadata/metadata-service.js +74 -0
- package/dist/esm/participants/participants-helper.js +44 -0
- package/dist/esm/participants/participants-service.js +251 -0
- package/dist/esm/participants/participants-state.js +48 -0
- package/dist/esm/{provider/telepointers.js → participants/telepointers-helper.js} +4 -4
- package/dist/esm/provider/commit-step.js +12 -5
- package/dist/esm/provider/index.js +291 -779
- package/dist/esm/types.js +8 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/{index.d.ts → analytics-helper.d.ts} +3 -1
- package/dist/types/analytics/performance.d.ts +3 -1
- package/dist/types/analytics/ufo.d.ts +1 -1
- package/dist/types/channel.d.ts +13 -6
- package/dist/types/document/document-service.d.ts +86 -0
- package/dist/types/document/step-queue-state.d.ts +16 -0
- package/dist/types/errors/error-code-mapper.d.ts +2 -36
- package/dist/types/errors/error-types.d.ts +439 -4
- package/dist/types/helpers/const.d.ts +2 -2
- package/dist/types/helpers/utils.d.ts +0 -6
- package/dist/types/index.d.ts +3 -1
- package/dist/types/metadata/metadata-service.d.ts +25 -0
- package/dist/types/participants/participants-helper.d.ts +15 -0
- package/dist/types/participants/participants-service.d.ts +74 -0
- package/dist/types/participants/participants-state.d.ts +13 -0
- package/dist/types/participants/telepointers-helper.d.ts +4 -0
- package/dist/types/provider/commit-step.d.ts +17 -6
- package/dist/types/provider/index.d.ts +81 -78
- package/dist/types/types.d.ts +56 -31
- package/package.json +6 -6
- package/report.api.md +187 -21
- package/dist/cjs/analytics/index.js +0 -95
- package/dist/cjs/provider/catchup.js +0 -139
- package/dist/esm/analytics/index.js +0 -88
- package/dist/esm/provider/catchup.js +0 -130
- package/dist/types/provider/telepointers.d.ts +0 -5
- /package/dist/types/{provider → document}/catchup.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 8.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`1547aa8e377`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1547aa8e377) - skipping document update with initial draft on reconnection
|
|
8
|
+
- [`76eded42866`](https://bitbucket.org/atlassian/atlassian-frontend/commits/76eded42866) - [ESS-3441] Added Confluence integration tests for collab provider, don't emit empty participants left events
|
|
9
|
+
- [`33cab158f01`](https://bitbucket.org/atlassian/atlassian-frontend/commits/33cab158f01) - ESS-3478 Fix public interface `getUnconfirmedSteps` from being removed
|
|
10
|
+
- [`02520373358`](https://bitbucket.org/atlassian/atlassian-frontend/commits/02520373358) - passing initial draft to NCS collab provider and adding flag to bypass BE draft fetch.
|
|
11
|
+
- [`56779259eab`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56779259eab) - ESS-2900: add confluence integration tests + add error handling to provider init
|
|
12
|
+
- [`f9257ff1a63`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f9257ff1a63) - NO-ISSUE Changed the type export to a normal export for PROVIDER_ERROR_CODE
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`2e01c9c74b5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2e01c9c74b5) - DUMMY remove before merging to master; dupe adf-schema via adf-utils
|
|
17
|
+
- [`945162380e3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/945162380e3) - Functional changes to document service.
|
|
18
|
+
- [`937ff19a47d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/937ff19a47d) - ESS-3240: moved throttledCommitStep function from index to commit-step file in collab-provider & add unit tests for commitStep
|
|
19
|
+
- [`0693d8fcab1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0693d8fcab1) - ESS-3446: clear all continuous timers when the provider disconnects or is destroyed
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
22
|
+
## 8.5.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- [`2192c9417d7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2192c9417d7) - [ESS-3335] Review Collab Provider API error handling & types
|
|
27
|
+
- [`c75fcb75c4e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c75fcb75c4e) - ESS-3241 Added unit tests for document restore.
|
|
28
|
+
ESS-3238 Internal refactor of collab provider, split document code from provider to document service.
|
|
29
|
+
Remove unused userId field from CollabInitPayload, it is never sent as part of the CollabInitPayload.
|
|
30
|
+
- [`27b106a736b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/27b106a736b) - ESS-3274 Refactor participant logic our of Provider class
|
|
31
|
+
- [`bdd8d88cad0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bdd8d88cad0) - [ESS-3332] Improved error mapping
|
|
32
|
+
- [`1d52016f25d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1d52016f25d) - Refactor collab-provider to accept a getAnalyticsClient Promise. And resolve when sending event.
|
|
33
|
+
Ticket: https://product-fabric.atlassian.net/browse/CCP-2863
|
|
34
|
+
- [`dfd96d6b48a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dfd96d6b48a) - [ESS-3333] Update to the structure of errors emitted on the collab provider
|
|
35
|
+
|
|
36
|
+
Upgrade instructions:
|
|
37
|
+
|
|
38
|
+
- Change the type of the errors emitted on the provider from `CollabEventError` to `ProviderError`
|
|
39
|
+
- Remove the reliance on the `status` field of the emitted errors, switch to using either the error code (exported as enum `PROVIDER_ERROR_CODE`) or the error flag `recoverable` indicating whether the provider can recover from the emitted error or not
|
|
40
|
+
|
|
41
|
+
The mapping from the old status codes to the error codes is:
|
|
42
|
+
|
|
43
|
+
- Status 403: PROVIDER_ERROR_CODE.NO_PERMISSION_ERROR, PROVIDER_ERROR_CODE.INVALID_USER_TOKEN
|
|
44
|
+
- Status 404: PROVIDER_ERROR_CODE.DOCUMENT_NOT_FOUND
|
|
45
|
+
- Status 423: PROVIDER_ERROR_CODE.LOCKED
|
|
46
|
+
- Status 500: PROVIDER_ERROR_CODE.FAIL_TO_SAVE, PROVIDER_ERROR_CODE.DOCUMENT_RESTORE_ERROR, PROVIDER_ERROR_CODE.INTERNAL_SERVICE_ERROR
|
|
47
|
+
|
|
48
|
+
- [`078a6d029f0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/078a6d029f0) - ESS-3333 temporarily re-add error status to fix product fabric from breaking changes
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- [`8217befcee0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8217befcee0) - logs the ignoring of steps for data versions older than current version in DocumentService.onStepsAdded()
|
|
53
|
+
- [`66f07c721c4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/66f07c721c4) - Add JSDoc to provider errors that are emitted to editor
|
|
54
|
+
- Updated dependencies
|
|
55
|
+
|
|
3
56
|
## 8.4.0
|
|
4
57
|
|
|
5
58
|
### Minor Changes
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _const = require("../helpers/const");
|
|
14
|
+
var _versionWrapper = require("../version-wrapper");
|
|
15
|
+
var _singleton = require("../connectivity/singleton");
|
|
16
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
var EVENT_SUBJECT = 'collab';
|
|
20
|
+
var COLLAB_SERVICE;
|
|
21
|
+
(function (COLLAB_SERVICE) {
|
|
22
|
+
COLLAB_SERVICE["NCS"] = "ncs";
|
|
23
|
+
COLLAB_SERVICE["SYNCHRONY"] = "synchrony";
|
|
24
|
+
})(COLLAB_SERVICE || (COLLAB_SERVICE = {}));
|
|
25
|
+
var triggerAnalyticsEvent = function triggerAnalyticsEvent(analyticsEvent, analyticsClient) {
|
|
26
|
+
if (!analyticsClient) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
var payload = {
|
|
30
|
+
actionSubject: EVENT_SUBJECT,
|
|
31
|
+
attributes: _objectSpread({
|
|
32
|
+
packageName: _versionWrapper.name,
|
|
33
|
+
packageVersion: _versionWrapper.version,
|
|
34
|
+
collabService: COLLAB_SERVICE.NCS,
|
|
35
|
+
network: {
|
|
36
|
+
status: _singleton.network.getStatus()
|
|
37
|
+
}
|
|
38
|
+
}, analyticsEvent.attributes),
|
|
39
|
+
tags: ['editor'],
|
|
40
|
+
action: analyticsEvent.eventAction,
|
|
41
|
+
source: 'unknown' // Adds zero analytics value, but event validation throws an error if you don't add it :-(
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (analyticsEvent.eventAction === _const.EVENT_ACTION.ERROR) {
|
|
45
|
+
payload.nonPrivacySafeAttributes = analyticsEvent.nonPrivacySafeAttributes;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Let the browser figure out
|
|
49
|
+
// when it should send those events
|
|
50
|
+
try {
|
|
51
|
+
var requestIdleCallbackFunction = window.requestIdleCallback;
|
|
52
|
+
var runItLater = typeof requestIdleCallbackFunction === 'function' ? requestIdleCallbackFunction : window.requestAnimationFrame;
|
|
53
|
+
runItLater(function () {
|
|
54
|
+
analyticsClient.sendOperationalEvent(payload);
|
|
55
|
+
});
|
|
56
|
+
} catch (error) {
|
|
57
|
+
// silently fail for now https://product-fabric.atlassian.net/browse/ESS-3112
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
var AnalyticsHelper = /*#__PURE__*/function () {
|
|
61
|
+
function AnalyticsHelper(documentAri, analyticsClient, getAnalyticsClient) {
|
|
62
|
+
(0, _classCallCheck2.default)(this, AnalyticsHelper);
|
|
63
|
+
this.documentAri = documentAri;
|
|
64
|
+
this.analyticsClient = analyticsClient;
|
|
65
|
+
this.getAnalyticsClient = getAnalyticsClient;
|
|
66
|
+
}
|
|
67
|
+
(0, _createClass2.default)(AnalyticsHelper, [{
|
|
68
|
+
key: "sendErrorEvent",
|
|
69
|
+
value: function sendErrorEvent(error, errorMessage) {
|
|
70
|
+
var errorAnalyticsEvent = {
|
|
71
|
+
eventAction: _const.EVENT_ACTION.ERROR,
|
|
72
|
+
attributes: {
|
|
73
|
+
documentAri: this.documentAri,
|
|
74
|
+
errorMessage: errorMessage,
|
|
75
|
+
errorName: error instanceof Error ? error.name : undefined
|
|
76
|
+
},
|
|
77
|
+
nonPrivacySafeAttributes: {
|
|
78
|
+
error: error
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
this.sendEvent(errorAnalyticsEvent);
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "sendActionEvent",
|
|
85
|
+
value: function sendActionEvent(action, status, attributes // This breaks discriminated unions, because there is no obvious field to discriminate against any more
|
|
86
|
+
) {
|
|
87
|
+
var analyticsEvent = {
|
|
88
|
+
eventAction: action,
|
|
89
|
+
attributes: _objectSpread({
|
|
90
|
+
documentAri: this.documentAri,
|
|
91
|
+
eventStatus: status
|
|
92
|
+
}, attributes)
|
|
93
|
+
};
|
|
94
|
+
this.sendEvent(analyticsEvent);
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "sendEvent",
|
|
98
|
+
value: function () {
|
|
99
|
+
var _sendEvent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
100
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
101
|
+
while (1) {
|
|
102
|
+
switch (_context.prev = _context.next) {
|
|
103
|
+
case 0:
|
|
104
|
+
if (!(this.getAnalyticsClient && !this.analyticsClient)) {
|
|
105
|
+
_context.next = 9;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
_context.prev = 1;
|
|
109
|
+
_context.next = 4;
|
|
110
|
+
return this.getAnalyticsClient;
|
|
111
|
+
case 4:
|
|
112
|
+
this.analyticsClient = _context.sent;
|
|
113
|
+
_context.next = 9;
|
|
114
|
+
break;
|
|
115
|
+
case 7:
|
|
116
|
+
_context.prev = 7;
|
|
117
|
+
_context.t0 = _context["catch"](1);
|
|
118
|
+
case 9:
|
|
119
|
+
triggerAnalyticsEvent(event, this.analyticsClient);
|
|
120
|
+
case 10:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context.stop();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}, _callee, this, [[1, 7]]);
|
|
126
|
+
}));
|
|
127
|
+
function sendEvent(_x) {
|
|
128
|
+
return _sendEvent.apply(this, arguments);
|
|
129
|
+
}
|
|
130
|
+
return sendEvent;
|
|
131
|
+
}()
|
|
132
|
+
}]);
|
|
133
|
+
return AnalyticsHelper;
|
|
134
|
+
}();
|
|
135
|
+
exports.default = AnalyticsHelper;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.MEASURE_NAME = void 0;
|
|
6
|
+
exports.measureMap = exports.isPerformanceAPIAvailable = exports.MEASURE_NAME = void 0;
|
|
7
7
|
exports.startMeasure = startMeasure;
|
|
8
8
|
exports.stopMeasure = stopMeasure;
|
|
9
9
|
var MEASURE_NAME;
|
|
@@ -20,11 +20,12 @@ var isPerformanceAPIAvailable = function isPerformanceAPIAvailable() {
|
|
|
20
20
|
return !!performance[api];
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
exports.isPerformanceAPIAvailable = isPerformanceAPIAvailable;
|
|
24
24
|
var measureMap = new Map();
|
|
25
|
+
exports.measureMap = measureMap;
|
|
25
26
|
function startMeasure(measureName, analyticsHelper) {
|
|
26
27
|
try {
|
|
27
|
-
if (!
|
|
28
|
+
if (!isPerformanceAPIAvailable()) {
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
performance.mark("".concat(measureName, "::start"));
|
|
@@ -36,7 +37,7 @@ function startMeasure(measureName, analyticsHelper) {
|
|
|
36
37
|
function stopMeasure(measureName, analyticsHelper, onMeasureComplete) {
|
|
37
38
|
var start;
|
|
38
39
|
try {
|
|
39
|
-
if (!
|
|
40
|
+
if (!isPerformanceAPIAvailable()) {
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -74,7 +75,7 @@ function stopMeasure(measureName, analyticsHelper, onMeasureComplete) {
|
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
function clearMeasure(measureName) {
|
|
77
|
-
if (!
|
|
78
|
+
if (!isPerformanceAPIAvailable()) {
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
80
81
|
measureMap.delete(measureName);
|