@atlaskit/editor-plugin-analytics 0.0.5 → 0.1.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 +12 -0
- package/dist/cjs/analytics-api/editor-state-context.js +5 -5
- package/dist/cjs/plugin-key.js +2 -2
- package/dist/cjs/plugin.js +43 -23
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics-api/editor-state-context.js +2 -2
- package/dist/es2019/plugin-key.js +1 -1
- package/dist/es2019/plugin.js +31 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics-api/editor-state-context.js +2 -2
- package/dist/esm/plugin-key.js +1 -1
- package/dist/esm/plugin.js +43 -23
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics-api/attach-payload-into-transaction.d.ts +1 -1
- package/dist/types/analytics-api/editor-state-context.d.ts +1 -1
- package/dist/types/plugin-key.d.ts +1 -1
- package/dist/types/undo-redo-input-source.d.ts +1 -1
- package/dist/types-ts4.5/analytics-api/attach-payload-into-transaction.d.ts +1 -1
- package/dist/types-ts4.5/analytics-api/editor-state-context.d.ts +1 -1
- package/dist/types-ts4.5/plugin-key.d.ts +1 -1
- package/dist/types-ts4.5/undo-redo-input-source.d.ts +1 -1
- package/package.json +6 -7
- package/report.api.md +1 -1
- package/tmp/api-report-tmp.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-analytics
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4e6f1bf8511`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4e6f1bf8511) - [ED-19233] Import prosemirror libraries from internal facade package
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`91c4edcea5a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/91c4edcea5a) - The analytics plugin (`editor-plugin-analytics`) now creates the `createAnalyticsEvent` if none is supplied and shares it with other plugins internally.
|
|
14
|
+
|
|
3
15
|
## 0.0.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.findInsertLocation = findInsertLocation;
|
|
7
7
|
exports.getSelectionType = getSelectionType;
|
|
8
8
|
exports.getStateContext = getStateContext;
|
|
9
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
10
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
11
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
12
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
13
13
|
function getSelectionType(selection) {
|
|
14
14
|
var _selection$constructo;
|
|
@@ -19,7 +19,7 @@ function getSelectionType(selection) {
|
|
|
19
19
|
position = selection.side;
|
|
20
20
|
} else if (selection instanceof _cellSelection.CellSelection) {
|
|
21
21
|
type = _analytics.SELECTION_TYPE.CELL;
|
|
22
|
-
} else if (selection instanceof
|
|
22
|
+
} else if (selection instanceof _state.NodeSelection) {
|
|
23
23
|
type = _analytics.SELECTION_TYPE.NODE;
|
|
24
24
|
} else if (selection.from !== selection.to) {
|
|
25
25
|
type = _analytics.SELECTION_TYPE.RANGED;
|
|
@@ -44,7 +44,7 @@ function findInsertLocation(selection) {
|
|
|
44
44
|
var _selection$$from$doc$ = selection.$from.doc.type,
|
|
45
45
|
schema = _selection$$from$doc$.schema,
|
|
46
46
|
name = _selection$$from$doc$.name;
|
|
47
|
-
if (selection instanceof
|
|
47
|
+
if (selection instanceof _state.NodeSelection) {
|
|
48
48
|
return selection.node.type.name;
|
|
49
49
|
}
|
|
50
50
|
if (selection instanceof _cellSelection.CellSelection) {
|
|
@@ -52,7 +52,7 @@ function findInsertLocation(selection) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// Text selection
|
|
55
|
-
var parentNodeInfo = (0,
|
|
55
|
+
var parentNodeInfo = (0, _utils.findParentNode)(function (node) {
|
|
56
56
|
return node.type !== schema.nodes.paragraph;
|
|
57
57
|
})(selection);
|
|
58
58
|
return parentNodeInfo ? parentNodeInfo.node.type.name : name;
|
package/dist/cjs/plugin-key.js
CHANGED
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.analyticsPluginKey = void 0;
|
|
7
|
-
var
|
|
8
|
-
var analyticsPluginKey = new
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var analyticsPluginKey = new _state.PluginKey('analyticsPlugin');
|
|
9
9
|
exports.analyticsPluginKey = analyticsPluginKey;
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -8,8 +8,10 @@ exports.analyticsPlugin = void 0;
|
|
|
8
8
|
exports.extendPayload = extendPayload;
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _react = require("react");
|
|
11
12
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
12
13
|
var _analyticsListeners = require("@atlaskit/analytics-listeners");
|
|
14
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
13
15
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
14
16
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
15
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -22,7 +24,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
22
24
|
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; }
|
|
23
25
|
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; }
|
|
24
26
|
function createPlugin(options, featureFlags) {
|
|
25
|
-
if (!options
|
|
27
|
+
if (!options) {
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
28
30
|
var hasRequiredPerformanceAPIs = (0, _utils.isPerformanceAPIAvailable)();
|
|
@@ -35,10 +37,15 @@ function createPlugin(options, featureFlags) {
|
|
|
35
37
|
});
|
|
36
38
|
},
|
|
37
39
|
apply: function apply(tr, pluginState, _, state) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
var _tr$getMeta;
|
|
41
|
+
var _ref = (_tr$getMeta = tr.getMeta(_pluginKey.analyticsPluginKey)) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : {},
|
|
42
|
+
createAnalyticsEvent = _ref.createAnalyticsEvent;
|
|
43
|
+
|
|
44
|
+
// When the createAnalyticsEvent is reconfigured
|
|
45
|
+
if (options.createAnalyticsEvent && options.createAnalyticsEvent !== pluginState.createAnalyticsEvent || pluginState.createAnalyticsEvent !== createAnalyticsEvent && createAnalyticsEvent) {
|
|
46
|
+
var _options$createAnalyt;
|
|
40
47
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
41
|
-
createAnalyticsEvent: options.createAnalyticsEvent
|
|
48
|
+
createAnalyticsEvent: (_options$createAnalyt = options.createAnalyticsEvent) !== null && _options$createAnalyt !== void 0 ? _options$createAnalyt : createAnalyticsEvent
|
|
42
49
|
});
|
|
43
50
|
}
|
|
44
51
|
if (featureFlags.catchAllTracking) {
|
|
@@ -59,9 +66,9 @@ function createPlugin(options, featureFlags) {
|
|
|
59
66
|
// NOTE this name could be resulting in misleading data -- where if multiple payloads are
|
|
60
67
|
// received before a render completes -- the measurement value will be inaccurate (this is
|
|
61
68
|
// due to measureRender requiring unique measureNames)
|
|
62
|
-
measureName, function (
|
|
63
|
-
var duration =
|
|
64
|
-
distortedDuration =
|
|
69
|
+
measureName, function (_ref2) {
|
|
70
|
+
var duration = _ref2.duration,
|
|
71
|
+
distortedDuration = _ref2.distortedDuration;
|
|
65
72
|
(0, _analytics.fireAnalyticsEvent)(pluginState.createAnalyticsEvent)({
|
|
66
73
|
payload: extendPayload({
|
|
67
74
|
payload: payload,
|
|
@@ -101,8 +108,8 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
101
108
|
attachAnalyticsEvent: null
|
|
102
109
|
};
|
|
103
110
|
}
|
|
104
|
-
var
|
|
105
|
-
createAnalyticsEvent =
|
|
111
|
+
var _ref3 = (_analyticsPluginKey$g = _pluginKey.analyticsPluginKey.getState(editorState)) !== null && _analyticsPluginKey$g !== void 0 ? _analyticsPluginKey$g : {},
|
|
112
|
+
createAnalyticsEvent = _ref3.createAnalyticsEvent;
|
|
106
113
|
return {
|
|
107
114
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
108
115
|
attachAnalyticsEvent: (0, _attachPayloadIntoTransaction.createAttachPayloadIntoTransaction)(editorState.selection)
|
|
@@ -113,9 +120,9 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
113
120
|
var channel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analyticsListeners.FabricChannel.editor;
|
|
114
121
|
return function (tr) {
|
|
115
122
|
var _api$dependencies$ana, _api$dependencies$ana2;
|
|
116
|
-
var
|
|
117
|
-
createAnalyticsEvent =
|
|
118
|
-
attachAnalyticsEvent =
|
|
123
|
+
var _ref4 = (_api$dependencies$ana = api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.sharedState.currentState()) !== null && _api$dependencies$ana !== void 0 ? _api$dependencies$ana : {},
|
|
124
|
+
createAnalyticsEvent = _ref4.createAnalyticsEvent,
|
|
125
|
+
attachAnalyticsEvent = _ref4.attachAnalyticsEvent;
|
|
119
126
|
if (!tr || !createAnalyticsEvent || !attachAnalyticsEvent) {
|
|
120
127
|
return false;
|
|
121
128
|
}
|
|
@@ -128,6 +135,19 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
128
135
|
};
|
|
129
136
|
}
|
|
130
137
|
},
|
|
138
|
+
usePluginHook: function usePluginHook(_ref5) {
|
|
139
|
+
var editorView = _ref5.editorView;
|
|
140
|
+
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
141
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
142
|
+
(0, _react.useLayoutEffect)(function () {
|
|
143
|
+
var dispatch = editorView.dispatch,
|
|
144
|
+
tr = editorView.state.tr;
|
|
145
|
+
tr.setMeta(_pluginKey.analyticsPluginKey, {
|
|
146
|
+
createAnalyticsEvent: createAnalyticsEvent
|
|
147
|
+
});
|
|
148
|
+
dispatch(tr);
|
|
149
|
+
}, [createAnalyticsEvent, editorView]);
|
|
150
|
+
},
|
|
131
151
|
pmPlugins: function pmPlugins() {
|
|
132
152
|
return [{
|
|
133
153
|
name: 'analyticsPlugin',
|
|
@@ -136,10 +156,10 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
136
156
|
}
|
|
137
157
|
}];
|
|
138
158
|
},
|
|
139
|
-
onEditorViewStateUpdated: function onEditorViewStateUpdated(
|
|
140
|
-
var originalTransaction =
|
|
141
|
-
transactions =
|
|
142
|
-
newEditorState =
|
|
159
|
+
onEditorViewStateUpdated: function onEditorViewStateUpdated(_ref6) {
|
|
160
|
+
var originalTransaction = _ref6.originalTransaction,
|
|
161
|
+
transactions = _ref6.transactions,
|
|
162
|
+
newEditorState = _ref6.newEditorState;
|
|
143
163
|
var pluginState = _pluginKey.analyticsPluginKey.getState(newEditorState);
|
|
144
164
|
if (!pluginState || !pluginState.createAnalyticsEvent) {
|
|
145
165
|
return;
|
|
@@ -160,9 +180,9 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
160
180
|
}
|
|
161
181
|
var createAnalyticsEvent = pluginState.createAnalyticsEvent;
|
|
162
182
|
var undoAnaltyicsEventTransformer = (0, _undoRedoInputSource.generateUndoRedoInputSoucePayload)(originalTransaction);
|
|
163
|
-
steps.forEach(function (
|
|
164
|
-
var payload =
|
|
165
|
-
channel =
|
|
183
|
+
steps.forEach(function (_ref7) {
|
|
184
|
+
var payload = _ref7.payload,
|
|
185
|
+
channel = _ref7.channel;
|
|
166
186
|
var nextPayload = undoAnaltyicsEventTransformer(payload);
|
|
167
187
|
(0, _analytics.fireAnalyticsEvent)(createAnalyticsEvent)({
|
|
168
188
|
payload: nextPayload,
|
|
@@ -173,10 +193,10 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
173
193
|
};
|
|
174
194
|
};
|
|
175
195
|
exports.analyticsPlugin = analyticsPlugin;
|
|
176
|
-
function extendPayload(
|
|
177
|
-
var payload =
|
|
178
|
-
duration =
|
|
179
|
-
distortedDuration =
|
|
196
|
+
function extendPayload(_ref8) {
|
|
197
|
+
var payload = _ref8.payload,
|
|
198
|
+
duration = _ref8.duration,
|
|
199
|
+
distortedDuration = _ref8.distortedDuration;
|
|
180
200
|
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
181
201
|
attributes: _objectSpread(_objectSpread({}, payload.attributes), {}, {
|
|
182
202
|
duration: duration,
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NodeSelection } from 'prosemirror-state';
|
|
2
|
-
import { findParentNode } from 'prosemirror-utils';
|
|
3
1
|
import { ACTION, ACTION_SUBJECT, SELECTION_POSITION, SELECTION_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
5
|
export function getSelectionType(selection) {
|
|
6
6
|
var _selection$constructo;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export const analyticsPluginKey = new PluginKey('analyticsPlugin');
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
1
2
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
2
3
|
import { FabricChannel } from '@atlaskit/analytics-listeners';
|
|
4
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
5
|
import { ACTION, EVENT_TYPE, fireAnalyticsEvent, getAnalyticsEventsFromTransaction } from '@atlaskit/editor-common/analytics';
|
|
4
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
7
|
import { isPerformanceAPIAvailable, measureRender } from '@atlaskit/editor-common/utils';
|
|
@@ -7,7 +9,7 @@ import { createAttachPayloadIntoTransaction } from './analytics-api/attach-paylo
|
|
|
7
9
|
import { analyticsPluginKey } from './plugin-key';
|
|
8
10
|
import { generateUndoRedoInputSoucePayload } from './undo-redo-input-source';
|
|
9
11
|
function createPlugin(options, featureFlags) {
|
|
10
|
-
if (!options
|
|
12
|
+
if (!options) {
|
|
11
13
|
return;
|
|
12
14
|
}
|
|
13
15
|
const hasRequiredPerformanceAPIs = isPerformanceAPIAvailable();
|
|
@@ -21,11 +23,17 @@ function createPlugin(options, featureFlags) {
|
|
|
21
23
|
};
|
|
22
24
|
},
|
|
23
25
|
apply: (tr, pluginState, _, state) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
var _tr$getMeta;
|
|
27
|
+
const {
|
|
28
|
+
createAnalyticsEvent
|
|
29
|
+
} = (_tr$getMeta = tr.getMeta(analyticsPluginKey)) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : {};
|
|
30
|
+
|
|
31
|
+
// When the createAnalyticsEvent is reconfigured
|
|
32
|
+
if (options.createAnalyticsEvent && options.createAnalyticsEvent !== pluginState.createAnalyticsEvent || pluginState.createAnalyticsEvent !== createAnalyticsEvent && createAnalyticsEvent) {
|
|
33
|
+
var _options$createAnalyt;
|
|
26
34
|
return {
|
|
27
35
|
...pluginState,
|
|
28
|
-
createAnalyticsEvent: options.createAnalyticsEvent
|
|
36
|
+
createAnalyticsEvent: (_options$createAnalyt = options.createAnalyticsEvent) !== null && _options$createAnalyt !== void 0 ? _options$createAnalyt : createAnalyticsEvent
|
|
29
37
|
};
|
|
30
38
|
}
|
|
31
39
|
if (featureFlags.catchAllTracking) {
|
|
@@ -104,6 +112,25 @@ const analyticsPlugin = (options, api) => {
|
|
|
104
112
|
return true;
|
|
105
113
|
}
|
|
106
114
|
},
|
|
115
|
+
usePluginHook({
|
|
116
|
+
editorView
|
|
117
|
+
}) {
|
|
118
|
+
const {
|
|
119
|
+
createAnalyticsEvent
|
|
120
|
+
} = useAnalyticsEvents();
|
|
121
|
+
useLayoutEffect(() => {
|
|
122
|
+
const {
|
|
123
|
+
dispatch,
|
|
124
|
+
state: {
|
|
125
|
+
tr
|
|
126
|
+
}
|
|
127
|
+
} = editorView;
|
|
128
|
+
tr.setMeta(analyticsPluginKey, {
|
|
129
|
+
createAnalyticsEvent
|
|
130
|
+
});
|
|
131
|
+
dispatch(tr);
|
|
132
|
+
}, [createAnalyticsEvent, editorView]);
|
|
133
|
+
},
|
|
107
134
|
pmPlugins() {
|
|
108
135
|
return [{
|
|
109
136
|
name: 'analyticsPlugin',
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NodeSelection } from 'prosemirror-state';
|
|
2
|
-
import { findParentNode } from 'prosemirror-utils';
|
|
3
1
|
import { ACTION, ACTION_SUBJECT, SELECTION_POSITION, SELECTION_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
4
4
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
5
|
export function getSelectionType(selection) {
|
|
6
6
|
var _selection$constructo;
|
package/dist/esm/plugin-key.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export var analyticsPluginKey = new PluginKey('analyticsPlugin');
|
package/dist/esm/plugin.js
CHANGED
|
@@ -5,8 +5,10 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
5
5
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
6
|
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; }
|
|
7
7
|
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; }
|
|
8
|
+
import { useLayoutEffect } from 'react';
|
|
8
9
|
import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
|
|
9
10
|
import { FabricChannel } from '@atlaskit/analytics-listeners';
|
|
11
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
10
12
|
import { ACTION, EVENT_TYPE, fireAnalyticsEvent, getAnalyticsEventsFromTransaction } from '@atlaskit/editor-common/analytics';
|
|
11
13
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
12
14
|
import { isPerformanceAPIAvailable, measureRender } from '@atlaskit/editor-common/utils';
|
|
@@ -14,7 +16,7 @@ import { createAttachPayloadIntoTransaction } from './analytics-api/attach-paylo
|
|
|
14
16
|
import { analyticsPluginKey } from './plugin-key';
|
|
15
17
|
import { generateUndoRedoInputSoucePayload } from './undo-redo-input-source';
|
|
16
18
|
function createPlugin(options, featureFlags) {
|
|
17
|
-
if (!options
|
|
19
|
+
if (!options) {
|
|
18
20
|
return;
|
|
19
21
|
}
|
|
20
22
|
var hasRequiredPerformanceAPIs = isPerformanceAPIAvailable();
|
|
@@ -27,10 +29,15 @@ function createPlugin(options, featureFlags) {
|
|
|
27
29
|
});
|
|
28
30
|
},
|
|
29
31
|
apply: function apply(tr, pluginState, _, state) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
var _tr$getMeta;
|
|
33
|
+
var _ref = (_tr$getMeta = tr.getMeta(analyticsPluginKey)) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : {},
|
|
34
|
+
createAnalyticsEvent = _ref.createAnalyticsEvent;
|
|
35
|
+
|
|
36
|
+
// When the createAnalyticsEvent is reconfigured
|
|
37
|
+
if (options.createAnalyticsEvent && options.createAnalyticsEvent !== pluginState.createAnalyticsEvent || pluginState.createAnalyticsEvent !== createAnalyticsEvent && createAnalyticsEvent) {
|
|
38
|
+
var _options$createAnalyt;
|
|
32
39
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
33
|
-
createAnalyticsEvent: options.createAnalyticsEvent
|
|
40
|
+
createAnalyticsEvent: (_options$createAnalyt = options.createAnalyticsEvent) !== null && _options$createAnalyt !== void 0 ? _options$createAnalyt : createAnalyticsEvent
|
|
34
41
|
});
|
|
35
42
|
}
|
|
36
43
|
if (featureFlags.catchAllTracking) {
|
|
@@ -51,9 +58,9 @@ function createPlugin(options, featureFlags) {
|
|
|
51
58
|
// NOTE this name could be resulting in misleading data -- where if multiple payloads are
|
|
52
59
|
// received before a render completes -- the measurement value will be inaccurate (this is
|
|
53
60
|
// due to measureRender requiring unique measureNames)
|
|
54
|
-
measureName, function (
|
|
55
|
-
var duration =
|
|
56
|
-
distortedDuration =
|
|
61
|
+
measureName, function (_ref2) {
|
|
62
|
+
var duration = _ref2.duration,
|
|
63
|
+
distortedDuration = _ref2.distortedDuration;
|
|
57
64
|
fireAnalyticsEvent(pluginState.createAnalyticsEvent)({
|
|
58
65
|
payload: extendPayload({
|
|
59
66
|
payload: payload,
|
|
@@ -93,8 +100,8 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
93
100
|
attachAnalyticsEvent: null
|
|
94
101
|
};
|
|
95
102
|
}
|
|
96
|
-
var
|
|
97
|
-
createAnalyticsEvent =
|
|
103
|
+
var _ref3 = (_analyticsPluginKey$g = analyticsPluginKey.getState(editorState)) !== null && _analyticsPluginKey$g !== void 0 ? _analyticsPluginKey$g : {},
|
|
104
|
+
createAnalyticsEvent = _ref3.createAnalyticsEvent;
|
|
98
105
|
return {
|
|
99
106
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
100
107
|
attachAnalyticsEvent: createAttachPayloadIntoTransaction(editorState.selection)
|
|
@@ -105,9 +112,9 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
105
112
|
var channel = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : FabricChannel.editor;
|
|
106
113
|
return function (tr) {
|
|
107
114
|
var _api$dependencies$ana, _api$dependencies$ana2;
|
|
108
|
-
var
|
|
109
|
-
createAnalyticsEvent =
|
|
110
|
-
attachAnalyticsEvent =
|
|
115
|
+
var _ref4 = (_api$dependencies$ana = api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.sharedState.currentState()) !== null && _api$dependencies$ana !== void 0 ? _api$dependencies$ana : {},
|
|
116
|
+
createAnalyticsEvent = _ref4.createAnalyticsEvent,
|
|
117
|
+
attachAnalyticsEvent = _ref4.attachAnalyticsEvent;
|
|
111
118
|
if (!tr || !createAnalyticsEvent || !attachAnalyticsEvent) {
|
|
112
119
|
return false;
|
|
113
120
|
}
|
|
@@ -120,6 +127,19 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
120
127
|
};
|
|
121
128
|
}
|
|
122
129
|
},
|
|
130
|
+
usePluginHook: function usePluginHook(_ref5) {
|
|
131
|
+
var editorView = _ref5.editorView;
|
|
132
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
133
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
134
|
+
useLayoutEffect(function () {
|
|
135
|
+
var dispatch = editorView.dispatch,
|
|
136
|
+
tr = editorView.state.tr;
|
|
137
|
+
tr.setMeta(analyticsPluginKey, {
|
|
138
|
+
createAnalyticsEvent: createAnalyticsEvent
|
|
139
|
+
});
|
|
140
|
+
dispatch(tr);
|
|
141
|
+
}, [createAnalyticsEvent, editorView]);
|
|
142
|
+
},
|
|
123
143
|
pmPlugins: function pmPlugins() {
|
|
124
144
|
return [{
|
|
125
145
|
name: 'analyticsPlugin',
|
|
@@ -128,10 +148,10 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
128
148
|
}
|
|
129
149
|
}];
|
|
130
150
|
},
|
|
131
|
-
onEditorViewStateUpdated: function onEditorViewStateUpdated(
|
|
132
|
-
var originalTransaction =
|
|
133
|
-
transactions =
|
|
134
|
-
newEditorState =
|
|
151
|
+
onEditorViewStateUpdated: function onEditorViewStateUpdated(_ref6) {
|
|
152
|
+
var originalTransaction = _ref6.originalTransaction,
|
|
153
|
+
transactions = _ref6.transactions,
|
|
154
|
+
newEditorState = _ref6.newEditorState;
|
|
135
155
|
var pluginState = analyticsPluginKey.getState(newEditorState);
|
|
136
156
|
if (!pluginState || !pluginState.createAnalyticsEvent) {
|
|
137
157
|
return;
|
|
@@ -152,9 +172,9 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
152
172
|
}
|
|
153
173
|
var createAnalyticsEvent = pluginState.createAnalyticsEvent;
|
|
154
174
|
var undoAnaltyicsEventTransformer = generateUndoRedoInputSoucePayload(originalTransaction);
|
|
155
|
-
steps.forEach(function (
|
|
156
|
-
var payload =
|
|
157
|
-
channel =
|
|
175
|
+
steps.forEach(function (_ref7) {
|
|
176
|
+
var payload = _ref7.payload,
|
|
177
|
+
channel = _ref7.channel;
|
|
158
178
|
var nextPayload = undoAnaltyicsEventTransformer(payload);
|
|
159
179
|
fireAnalyticsEvent(createAnalyticsEvent)({
|
|
160
180
|
payload: nextPayload,
|
|
@@ -164,10 +184,10 @@ var analyticsPlugin = function analyticsPlugin(options, api) {
|
|
|
164
184
|
}
|
|
165
185
|
};
|
|
166
186
|
};
|
|
167
|
-
export function extendPayload(
|
|
168
|
-
var payload =
|
|
169
|
-
duration =
|
|
170
|
-
distortedDuration =
|
|
187
|
+
export function extendPayload(_ref8) {
|
|
188
|
+
var payload = _ref8.payload,
|
|
189
|
+
duration = _ref8.duration,
|
|
190
|
+
distortedDuration = _ref8.distortedDuration;
|
|
171
191
|
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
172
192
|
attributes: _objectSpread(_objectSpread({}, payload.attributes), {}, {
|
|
173
193
|
duration: duration,
|
package/dist/esm/version.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Selection, Transaction } from 'prosemirror-state';
|
|
2
1
|
import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
type AttachPayloadIntoTransaction = (props: {
|
|
4
4
|
payload: AnalyticsEventPayload;
|
|
5
5
|
selection: Selection;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Selection } from 'prosemirror-state';
|
|
2
1
|
import { AnalyticsEventPayload, SELECTION_POSITION, SELECTION_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
export declare function getSelectionType(selection: Selection): {
|
|
4
4
|
type: SELECTION_TYPE;
|
|
5
5
|
position?: SELECTION_POSITION;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const analyticsPluginKey: PluginKey<any>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Transaction } from 'prosemirror-state';
|
|
2
1
|
import { AnalyticsPayload } from '@atlaskit/adf-schema/steps';
|
|
2
|
+
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
export declare const generateUndoRedoInputSoucePayload: (tr: Readonly<Transaction>) => <T extends AnalyticsPayload>(payload: T) => T;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Selection, Transaction } from 'prosemirror-state';
|
|
2
1
|
import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
type AttachPayloadIntoTransaction = (props: {
|
|
4
4
|
payload: AnalyticsEventPayload;
|
|
5
5
|
selection: Selection;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Selection } from 'prosemirror-state';
|
|
2
1
|
import { AnalyticsEventPayload, SELECTION_POSITION, SELECTION_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
export declare function getSelectionType(selection: Selection): {
|
|
4
4
|
type: SELECTION_TYPE;
|
|
5
5
|
position?: SELECTION_POSITION;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const analyticsPluginKey: PluginKey<any>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Transaction } from 'prosemirror-state';
|
|
2
1
|
import { AnalyticsPayload } from '@atlaskit/adf-schema/steps';
|
|
2
|
+
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
export declare const generateUndoRedoInputSoucePayload: (tr: Readonly<Transaction>) => <T extends AnalyticsPayload>(payload: T) => T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-analytics",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Analytics plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,21 +31,20 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/adf-schema": "^26.
|
|
34
|
+
"@atlaskit/adf-schema": "^26.4.0",
|
|
35
35
|
"@atlaskit/analytics-listeners": "^8.6.0",
|
|
36
36
|
"@atlaskit/analytics-next": "^9.0.0",
|
|
37
|
-
"@atlaskit/editor-common": "^74.
|
|
37
|
+
"@atlaskit/editor-common": "^74.29.0",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^0.1.0",
|
|
39
|
+
"@atlaskit/editor-prosemirror": "1.0.2",
|
|
39
40
|
"@atlaskit/editor-tables": "^2.2.0",
|
|
40
|
-
"@babel/runtime": "^7.0.0"
|
|
41
|
-
"prosemirror-state": "1.3.4",
|
|
42
|
-
"prosemirror-utils": "^1.0.0-0"
|
|
41
|
+
"@babel/runtime": "^7.0.0"
|
|
43
42
|
},
|
|
44
43
|
"peerDependencies": {
|
|
45
44
|
"react": "^16.8.0"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
|
-
"@atlaskit/editor-test-helpers": "^18.
|
|
47
|
+
"@atlaskit/editor-test-helpers": "^18.10.0",
|
|
49
48
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
50
49
|
"@testing-library/react": "^12.1.5",
|
|
51
50
|
"react-dom": "^16.8.0",
|
package/report.api.md
CHANGED
|
@@ -21,7 +21,7 @@ import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
21
21
|
import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
22
22
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
23
23
|
import type { PerformanceTracking } from '@atlaskit/editor-common/types';
|
|
24
|
-
import type { Transaction } from 'prosemirror
|
|
24
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
25
25
|
|
|
26
26
|
// @public (undocumented)
|
|
27
27
|
export const analyticsPlugin: NextEditorPlugin<
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
10
10
|
import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
11
11
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
12
12
|
import type { PerformanceTracking } from '@atlaskit/editor-common/types';
|
|
13
|
-
import type { Transaction } from 'prosemirror
|
|
13
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
14
14
|
|
|
15
15
|
// @public (undocumented)
|
|
16
16
|
export const analyticsPlugin: NextEditorPlugin<'analytics', {
|