@atlaskit/editor-common 74.7.2 → 74.7.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 74.7.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1259df9a9ef`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1259df9a9ef) - converted some of block-type's analytics to use new EditorAnalyticsAPI
8
+
3
9
  ## 74.7.2
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "withAnalytics", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _withAnalytics.withAnalytics;
10
+ }
11
+ });
12
+ var _withAnalytics = require("./withAnalytics");
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withAnalytics = withAnalytics;
7
+ /**
8
+ * Callback accepts EditorState
9
+ *
10
+ * @remarks
11
+ * The plugin using the Analytics may using an Optional<Analytics> dependency
12
+ * It can be undefined during testing, we may not have included analytics
13
+ * Also in cases where Analytics fails to load, the editor doesn't crash.
14
+ *
15
+ * @param state - EditorState, passed to the callback
16
+ */
17
+
18
+ /**
19
+ * Analytics API
20
+ * @example
21
+ * ```
22
+ * withAnalytics({
23
+ * eventType: EVENT_TYPE.TRACK,
24
+ * action: ACTION.REPLACED_ONE,
25
+ * actionSubject: ACTION_SUBJECT.TEXT,
26
+ * attributes: {
27
+ * triggerMethod,
28
+ * },
29
+ * })(replace(replaceText))
30
+ * ```
31
+ *
32
+ * @param analyticsApi - EditorAnalyticsAPI, undefined in tests or if analytics fails to load
33
+ * @param payload - AnalyticsEventPayload | AnalyticsEventPayloadCallback - payload to be attached to the transaction
34
+ * @param channel - string - channel to be used for analytics
35
+ */
36
+ function withAnalytics(analyticsApi, payload, channel) {
37
+ return function (command) {
38
+ return function (state, dispatch, view) {
39
+ return command(state, function (tr) {
40
+ if (dispatch) {
41
+ if (payload instanceof Function) {
42
+ var dynamicPayload = payload(state);
43
+ if (dynamicPayload) {
44
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(dynamicPayload, channel)(tr);
45
+ dispatch(tr);
46
+ }
47
+ } else {
48
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(payload, channel)(tr);
49
+ dispatch(tr);
50
+ }
51
+ }
52
+ }, view);
53
+ };
54
+ };
55
+ }
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "74.7.2";
19
+ var packageVersion = "74.7.3";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
24
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "74.7.2";
27
+ var packageVersion = "74.7.3";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.7.2",
3
+ "version": "74.7.3",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1 @@
1
+ export { withAnalytics } from './withAnalytics';
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Callback accepts EditorState
3
+ *
4
+ * @remarks
5
+ * The plugin using the Analytics may using an Optional<Analytics> dependency
6
+ * It can be undefined during testing, we may not have included analytics
7
+ * Also in cases where Analytics fails to load, the editor doesn't crash.
8
+ *
9
+ * @param state - EditorState, passed to the callback
10
+ */
11
+
12
+ /**
13
+ * Analytics API
14
+ * @example
15
+ * ```
16
+ * withAnalytics({
17
+ * eventType: EVENT_TYPE.TRACK,
18
+ * action: ACTION.REPLACED_ONE,
19
+ * actionSubject: ACTION_SUBJECT.TEXT,
20
+ * attributes: {
21
+ * triggerMethod,
22
+ * },
23
+ * })(replace(replaceText))
24
+ * ```
25
+ *
26
+ * @param analyticsApi - EditorAnalyticsAPI, undefined in tests or if analytics fails to load
27
+ * @param payload - AnalyticsEventPayload | AnalyticsEventPayloadCallback - payload to be attached to the transaction
28
+ * @param channel - string - channel to be used for analytics
29
+ */
30
+ export function withAnalytics(analyticsApi, payload, channel) {
31
+ return command => (state, dispatch, view) => command(state, tr => {
32
+ if (dispatch) {
33
+ if (payload instanceof Function) {
34
+ const dynamicPayload = payload(state);
35
+ if (dynamicPayload) {
36
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(dynamicPayload, channel)(tr);
37
+ dispatch(tr);
38
+ }
39
+ } else {
40
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(payload, channel)(tr);
41
+ dispatch(tr);
42
+ }
43
+ }
44
+ }, view);
45
+ }
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "74.7.2";
3
+ const packageVersion = "74.7.3";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -8,7 +8,7 @@ import { themed } from '@atlaskit/theme/components';
8
8
  import { borderRadius } from '@atlaskit/theme/constants';
9
9
  import Layer from '../Layer';
10
10
  const packageName = "@atlaskit/editor-common";
11
- const packageVersion = "74.7.2";
11
+ const packageVersion = "74.7.3";
12
12
  const halfFocusRing = 1;
13
13
  const dropOffset = '0, 8';
14
14
  class DropList extends Component {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.7.2",
3
+ "version": "74.7.3",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1 @@
1
+ export { withAnalytics } from './withAnalytics';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Callback accepts EditorState
3
+ *
4
+ * @remarks
5
+ * The plugin using the Analytics may using an Optional<Analytics> dependency
6
+ * It can be undefined during testing, we may not have included analytics
7
+ * Also in cases where Analytics fails to load, the editor doesn't crash.
8
+ *
9
+ * @param state - EditorState, passed to the callback
10
+ */
11
+
12
+ /**
13
+ * Analytics API
14
+ * @example
15
+ * ```
16
+ * withAnalytics({
17
+ * eventType: EVENT_TYPE.TRACK,
18
+ * action: ACTION.REPLACED_ONE,
19
+ * actionSubject: ACTION_SUBJECT.TEXT,
20
+ * attributes: {
21
+ * triggerMethod,
22
+ * },
23
+ * })(replace(replaceText))
24
+ * ```
25
+ *
26
+ * @param analyticsApi - EditorAnalyticsAPI, undefined in tests or if analytics fails to load
27
+ * @param payload - AnalyticsEventPayload | AnalyticsEventPayloadCallback - payload to be attached to the transaction
28
+ * @param channel - string - channel to be used for analytics
29
+ */
30
+ export function withAnalytics(analyticsApi, payload, channel) {
31
+ return function (command) {
32
+ return function (state, dispatch, view) {
33
+ return command(state, function (tr) {
34
+ if (dispatch) {
35
+ if (payload instanceof Function) {
36
+ var dynamicPayload = payload(state);
37
+ if (dynamicPayload) {
38
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(dynamicPayload, channel)(tr);
39
+ dispatch(tr);
40
+ }
41
+ } else {
42
+ analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent(payload, channel)(tr);
43
+ dispatch(tr);
44
+ }
45
+ }
46
+ }, view);
47
+ };
48
+ };
49
+ }
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  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) { _defineProperty(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; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "74.7.2";
9
+ var packageVersion = "74.7.3";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
18
18
  import { borderRadius } from '@atlaskit/theme/constants';
19
19
  import Layer from '../Layer';
20
20
  var packageName = "@atlaskit/editor-common";
21
- var packageVersion = "74.7.2";
21
+ var packageVersion = "74.7.3";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = '0, 8';
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.7.2",
3
+ "version": "74.7.3",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1 @@
1
+ export { withAnalytics } from './withAnalytics';
@@ -0,0 +1,34 @@
1
+ import type { EditorState } from 'prosemirror-state';
2
+ import type { AnalyticsEventPayload, EditorAnalyticsAPI } from '../analytics';
3
+ import type { HigherOrderCommand } from '../types';
4
+ /**
5
+ * Callback accepts EditorState
6
+ *
7
+ * @remarks
8
+ * The plugin using the Analytics may using an Optional<Analytics> dependency
9
+ * It can be undefined during testing, we may not have included analytics
10
+ * Also in cases where Analytics fails to load, the editor doesn't crash.
11
+ *
12
+ * @param state - EditorState, passed to the callback
13
+ */
14
+ type AnalyticsEventPayloadCallback = (state: EditorState) => AnalyticsEventPayload | undefined;
15
+ /**
16
+ * Analytics API
17
+ * @example
18
+ * ```
19
+ * withAnalytics({
20
+ * eventType: EVENT_TYPE.TRACK,
21
+ * action: ACTION.REPLACED_ONE,
22
+ * actionSubject: ACTION_SUBJECT.TEXT,
23
+ * attributes: {
24
+ * triggerMethod,
25
+ * },
26
+ * })(replace(replaceText))
27
+ * ```
28
+ *
29
+ * @param analyticsApi - EditorAnalyticsAPI, undefined in tests or if analytics fails to load
30
+ * @param payload - AnalyticsEventPayload | AnalyticsEventPayloadCallback - payload to be attached to the transaction
31
+ * @param channel - string - channel to be used for analytics
32
+ */
33
+ export declare function withAnalytics(analyticsApi: EditorAnalyticsAPI | undefined, payload: AnalyticsEventPayload | AnalyticsEventPayloadCallback, channel?: string): HigherOrderCommand;
34
+ export {};
@@ -0,0 +1 @@
1
+ export { withAnalytics } from './withAnalytics';
@@ -0,0 +1,34 @@
1
+ import type { EditorState } from 'prosemirror-state';
2
+ import type { AnalyticsEventPayload, EditorAnalyticsAPI } from '../analytics';
3
+ import type { HigherOrderCommand } from '../types';
4
+ /**
5
+ * Callback accepts EditorState
6
+ *
7
+ * @remarks
8
+ * The plugin using the Analytics may using an Optional<Analytics> dependency
9
+ * It can be undefined during testing, we may not have included analytics
10
+ * Also in cases where Analytics fails to load, the editor doesn't crash.
11
+ *
12
+ * @param state - EditorState, passed to the callback
13
+ */
14
+ type AnalyticsEventPayloadCallback = (state: EditorState) => AnalyticsEventPayload | undefined;
15
+ /**
16
+ * Analytics API
17
+ * @example
18
+ * ```
19
+ * withAnalytics({
20
+ * eventType: EVENT_TYPE.TRACK,
21
+ * action: ACTION.REPLACED_ONE,
22
+ * actionSubject: ACTION_SUBJECT.TEXT,
23
+ * attributes: {
24
+ * triggerMethod,
25
+ * },
26
+ * })(replace(replaceText))
27
+ * ```
28
+ *
29
+ * @param analyticsApi - EditorAnalyticsAPI, undefined in tests or if analytics fails to load
30
+ * @param payload - AnalyticsEventPayload | AnalyticsEventPayloadCallback - payload to be attached to the transaction
31
+ * @param channel - string - channel to be used for analytics
32
+ */
33
+ export declare function withAnalytics(analyticsApi: EditorAnalyticsAPI | undefined, payload: AnalyticsEventPayload | AnalyticsEventPayloadCallback, channel?: string): HigherOrderCommand;
34
+ export {};
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/editor-analytics",
3
+ "main": "../dist/cjs/editor-analytics/index.js",
4
+ "module": "../dist/esm/editor-analytics/index.js",
5
+ "module:es2019": "../dist/es2019/editor-analytics/index.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/editor-analytics/index.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <4.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/editor-analytics/index.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.7.2",
3
+ "version": "74.7.3",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -66,7 +66,8 @@
66
66
  "./hooks": "./src/hooks/index.ts",
67
67
  "./monitoring": "./src/monitoring/index.ts",
68
68
  "./paste": "./src/paste/index.ts",
69
- "./resizer": "./src/resizer/index.ts"
69
+ "./resizer": "./src/resizer/index.ts",
70
+ "./editor-analytics": "./src/editor-analytics/index.ts"
70
71
  },
71
72
  "dependencies": {
72
73
  "@atlaskit/activity-provider": "^2.4.0",