@atlaskit/editor-plugin-analytics 0.3.6 → 0.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/editor-plugin-analytics
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#58246](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58246) [`a381b2599716`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a381b2599716) - ED-21371 Update adf-schema to 35.1.0
8
+
9
+ ## 0.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#59421](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/59421) [`3747754f8ab0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3747754f8ab0) - NO-ISSUE Added the capability to directly trigger an analytics event as an action to the editor analytics plugin
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 0.3.6
4
20
 
5
21
  ### Patch Changes
@@ -143,10 +143,21 @@ var analyticsPlugin = exports.analyticsPlugin = function analyticsPlugin(_ref3)
143
143
  });
144
144
  return true;
145
145
  };
146
+ },
147
+ fireAnalyticsEvent: function fireAnalyticsEvent(payload) {
148
+ var _api$analytics$shared2, _api$analytics2;
149
+ var _ref6 = (_api$analytics$shared2 = api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.sharedState.currentState()) !== null && _api$analytics$shared2 !== void 0 ? _api$analytics$shared2 : {},
150
+ createAnalyticsEvent = _ref6.createAnalyticsEvent;
151
+ if (!createAnalyticsEvent) {
152
+ return;
153
+ }
154
+ (0, _analytics.fireAnalyticsEvent)(createAnalyticsEvent)({
155
+ payload: payload
156
+ });
146
157
  }
147
158
  },
148
- usePluginHook: function usePluginHook(_ref6) {
149
- var editorView = _ref6.editorView;
159
+ usePluginHook: function usePluginHook(_ref7) {
160
+ var editorView = _ref7.editorView;
150
161
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
151
162
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
152
163
  (0, _react.useLayoutEffect)(function () {
@@ -166,10 +177,10 @@ var analyticsPlugin = exports.analyticsPlugin = function analyticsPlugin(_ref3)
166
177
  }
167
178
  }];
168
179
  },
169
- onEditorViewStateUpdated: function onEditorViewStateUpdated(_ref7) {
170
- var originalTransaction = _ref7.originalTransaction,
171
- transactions = _ref7.transactions,
172
- newEditorState = _ref7.newEditorState;
180
+ onEditorViewStateUpdated: function onEditorViewStateUpdated(_ref8) {
181
+ var originalTransaction = _ref8.originalTransaction,
182
+ transactions = _ref8.transactions,
183
+ newEditorState = _ref8.newEditorState;
173
184
  var pluginState = _pluginKey.analyticsPluginKey.getState(newEditorState);
174
185
  if (!pluginState || !pluginState.createAnalyticsEvent) {
175
186
  return;
@@ -190,9 +201,9 @@ var analyticsPlugin = exports.analyticsPlugin = function analyticsPlugin(_ref3)
190
201
  }
191
202
  var createAnalyticsEvent = pluginState.createAnalyticsEvent;
192
203
  var undoAnaltyicsEventTransformer = (0, _undoRedoInputSource.generateUndoRedoInputSoucePayload)(originalTransaction);
193
- steps.forEach(function (_ref8) {
194
- var payload = _ref8.payload,
195
- channel = _ref8.channel;
204
+ steps.forEach(function (_ref9) {
205
+ var payload = _ref9.payload,
206
+ channel = _ref9.channel;
196
207
  var nextPayload = undoAnaltyicsEventTransformer(payload);
197
208
  (0, _analytics.fireAnalyticsEvent)(createAnalyticsEvent)({
198
209
  payload: nextPayload,
@@ -202,10 +213,10 @@ var analyticsPlugin = exports.analyticsPlugin = function analyticsPlugin(_ref3)
202
213
  }
203
214
  };
204
215
  };
205
- function extendPayload(_ref9) {
206
- var payload = _ref9.payload,
207
- duration = _ref9.duration,
208
- distortedDuration = _ref9.distortedDuration;
216
+ function extendPayload(_ref10) {
217
+ var payload = _ref10.payload,
218
+ duration = _ref10.duration,
219
+ distortedDuration = _ref10.distortedDuration;
209
220
  return _objectSpread(_objectSpread({}, payload), {}, {
210
221
  attributes: _objectSpread(_objectSpread({}, payload.attributes), {}, {
211
222
  duration: duration,
@@ -120,6 +120,18 @@ const analyticsPlugin = ({
120
120
  channel
121
121
  });
122
122
  return true;
123
+ },
124
+ fireAnalyticsEvent: payload => {
125
+ var _api$analytics$shared2, _api$analytics2;
126
+ const {
127
+ createAnalyticsEvent
128
+ } = (_api$analytics$shared2 = api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.sharedState.currentState()) !== null && _api$analytics$shared2 !== void 0 ? _api$analytics$shared2 : {};
129
+ if (!createAnalyticsEvent) {
130
+ return;
131
+ }
132
+ fireAnalyticsEvent(createAnalyticsEvent)({
133
+ payload
134
+ });
123
135
  }
124
136
  },
125
137
  usePluginHook({
@@ -9,7 +9,7 @@ import { useLayoutEffect } from 'react';
9
9
  import { AnalyticsStep } from '@atlaskit/adf-schema/steps';
10
10
  import { FabricChannel } from '@atlaskit/analytics-listeners';
11
11
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
12
- import { ACTION, EVENT_TYPE, fireAnalyticsEvent, getAnalyticsEventsFromTransaction } from '@atlaskit/editor-common/analytics';
12
+ import { ACTION, EVENT_TYPE, fireAnalyticsEvent as _fireAnalyticsEvent, getAnalyticsEventsFromTransaction } from '@atlaskit/editor-common/analytics';
13
13
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
14
14
  import { isPerformanceAPIAvailable, measureRender } from '@atlaskit/editor-common/utils';
15
15
  import { createAttachPayloadIntoTransaction } from './analytics-api/attach-payload-into-transaction';
@@ -25,7 +25,7 @@ function createPlugin(options, featureFlags) {
25
25
  state: {
26
26
  init: function init() {
27
27
  return _objectSpread(_objectSpread({}, options), {}, {
28
- fireAnalytics: fireAnalyticsEvent(options.createAnalyticsEvent)
28
+ fireAnalytics: _fireAnalyticsEvent(options.createAnalyticsEvent)
29
29
  });
30
30
  },
31
31
  apply: function apply(tr, pluginState, _, state) {
@@ -61,7 +61,7 @@ function createPlugin(options, featureFlags) {
61
61
  measureName, function (_ref2) {
62
62
  var duration = _ref2.duration,
63
63
  distortedDuration = _ref2.distortedDuration;
64
- fireAnalyticsEvent(pluginState.createAnalyticsEvent)({
64
+ _fireAnalyticsEvent(pluginState.createAnalyticsEvent)({
65
65
  payload: extendPayload({
66
66
  payload: payload,
67
67
  duration: duration,
@@ -135,10 +135,21 @@ var analyticsPlugin = function analyticsPlugin(_ref3) {
135
135
  });
136
136
  return true;
137
137
  };
138
+ },
139
+ fireAnalyticsEvent: function fireAnalyticsEvent(payload) {
140
+ var _api$analytics$shared2, _api$analytics2;
141
+ var _ref6 = (_api$analytics$shared2 = api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.sharedState.currentState()) !== null && _api$analytics$shared2 !== void 0 ? _api$analytics$shared2 : {},
142
+ createAnalyticsEvent = _ref6.createAnalyticsEvent;
143
+ if (!createAnalyticsEvent) {
144
+ return;
145
+ }
146
+ _fireAnalyticsEvent(createAnalyticsEvent)({
147
+ payload: payload
148
+ });
138
149
  }
139
150
  },
140
- usePluginHook: function usePluginHook(_ref6) {
141
- var editorView = _ref6.editorView;
151
+ usePluginHook: function usePluginHook(_ref7) {
152
+ var editorView = _ref7.editorView;
142
153
  var _useAnalyticsEvents = useAnalyticsEvents(),
143
154
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
144
155
  useLayoutEffect(function () {
@@ -158,10 +169,10 @@ var analyticsPlugin = function analyticsPlugin(_ref3) {
158
169
  }
159
170
  }];
160
171
  },
161
- onEditorViewStateUpdated: function onEditorViewStateUpdated(_ref7) {
162
- var originalTransaction = _ref7.originalTransaction,
163
- transactions = _ref7.transactions,
164
- newEditorState = _ref7.newEditorState;
172
+ onEditorViewStateUpdated: function onEditorViewStateUpdated(_ref8) {
173
+ var originalTransaction = _ref8.originalTransaction,
174
+ transactions = _ref8.transactions,
175
+ newEditorState = _ref8.newEditorState;
165
176
  var pluginState = analyticsPluginKey.getState(newEditorState);
166
177
  if (!pluginState || !pluginState.createAnalyticsEvent) {
167
178
  return;
@@ -182,11 +193,11 @@ var analyticsPlugin = function analyticsPlugin(_ref3) {
182
193
  }
183
194
  var createAnalyticsEvent = pluginState.createAnalyticsEvent;
184
195
  var undoAnaltyicsEventTransformer = generateUndoRedoInputSoucePayload(originalTransaction);
185
- steps.forEach(function (_ref8) {
186
- var payload = _ref8.payload,
187
- channel = _ref8.channel;
196
+ steps.forEach(function (_ref9) {
197
+ var payload = _ref9.payload,
198
+ channel = _ref9.channel;
188
199
  var nextPayload = undoAnaltyicsEventTransformer(payload);
189
- fireAnalyticsEvent(createAnalyticsEvent)({
200
+ _fireAnalyticsEvent(createAnalyticsEvent)({
190
201
  payload: nextPayload,
191
202
  channel: channel
192
203
  });
@@ -194,10 +205,10 @@ var analyticsPlugin = function analyticsPlugin(_ref3) {
194
205
  }
195
206
  };
196
207
  };
197
- export function extendPayload(_ref9) {
198
- var payload = _ref9.payload,
199
- duration = _ref9.duration,
200
- distortedDuration = _ref9.distortedDuration;
208
+ export function extendPayload(_ref10) {
209
+ var payload = _ref10.payload,
210
+ duration = _ref10.duration,
211
+ distortedDuration = _ref10.distortedDuration;
201
212
  return _objectSpread(_objectSpread({}, payload), {}, {
202
213
  attributes: _objectSpread(_objectSpread({}, payload.attributes), {}, {
203
214
  duration: duration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-analytics",
3
- "version": "0.3.6",
3
+ "version": "0.4.1",
4
4
  "description": "Analytics plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,10 +31,10 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@atlaskit/adf-schema": "^35.0.0",
34
+ "@atlaskit/adf-schema": "^35.1.0",
35
35
  "@atlaskit/analytics-listeners": "^8.6.0",
36
36
  "@atlaskit/analytics-next": "^9.0.0",
37
- "@atlaskit/editor-common": "^76.25.0",
37
+ "@atlaskit/editor-common": "^76.26.0",
38
38
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
39
39
  "@atlaskit/editor-prosemirror": "1.1.0",
40
40
  "@atlaskit/editor-tables": "^2.2.0",