@atlaskit/editor-plugin-analytics 5.3.0 → 6.1.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 CHANGED
@@ -1,5 +1,40 @@
1
1
  # @atlaskit/editor-plugin-analytics
2
2
 
3
+ ## 6.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`e3780960bb0ae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3780960bb0ae) - ##
8
+ What Update `EditorAnalyticsAPI` to allow for `fireAnalyticsEvent` to use a custom payload if an
9
+ explicit type parameter is used. This is mostly used by the analytics plugin
10
+
11
+ ```ts
12
+ // Example
13
+ api?.analytics.actions.fireAnalyticsEvent<CustomPayload, 'customEventType'>({ ... });
14
+ ```
15
+
16
+ ## Why
17
+
18
+ The current Payload structure is not extensible. There are times we don't want to update the base
19
+ analytics types (and increase bundle size) and scope them only to a specific package. This
20
+ provides an escape hatch but still enforces some level of type safety (currently there are some
21
+ examples of using `ts-expect-error` to side step this).
22
+
23
+ ## How to upgrade
24
+
25
+ In most scenarios this should not cause any breaking change but can be breaking if you are side
26
+ stepping type safety here with `ts-expect-error`.
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies
31
+
32
+ ## 6.0.0
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies
37
+
3
38
  ## 5.3.0
4
39
 
5
40
  ### Minor Changes
@@ -167,8 +167,14 @@ var analyticsPlugin = exports.analyticsPlugin = function analyticsPlugin(_ref3)
167
167
  });
168
168
  return;
169
169
  }
170
+
171
+ // This cast is needed to satisfy TS when using custom payloads which is only allowed by
172
+ // the fireAnalyticsEvent function in EditorAnalyticsAPI for now.
173
+ // createAnalyticsEvent actually fires our standard AnalyticsEventPayload type which is less strict
174
+ // so this is safe.
175
+ var firedPayload = payload;
170
176
  (0, _analytics.fireAnalyticsEvent)(createAnalyticsEvent, options)({
171
- payload: payload,
177
+ payload: firedPayload,
172
178
  channel: channel
173
179
  });
174
180
  }
@@ -129,7 +129,7 @@ const analyticsPlugin = ({
129
129
  });
130
130
  return true;
131
131
  },
132
- fireAnalyticsEvent: (payload, channel = editorAnalyticsChannel, options) => {
132
+ fireAnalyticsEvent(payload, channel = editorAnalyticsChannel, options) {
133
133
  var _api$analytics$shared2, _api$analytics2;
134
134
  const {
135
135
  createAnalyticsEvent
@@ -144,8 +144,14 @@ const analyticsPlugin = ({
144
144
  });
145
145
  return;
146
146
  }
147
+
148
+ // This cast is needed to satisfy TS when using custom payloads which is only allowed by
149
+ // the fireAnalyticsEvent function in EditorAnalyticsAPI for now.
150
+ // createAnalyticsEvent actually fires our standard AnalyticsEventPayload type which is less strict
151
+ // so this is safe.
152
+ const firedPayload = payload;
147
153
  fireAnalyticsEvent(createAnalyticsEvent, options)({
148
- payload,
154
+ payload: firedPayload,
149
155
  channel
150
156
  });
151
157
  }
@@ -160,8 +160,14 @@ var analyticsPlugin = function analyticsPlugin(_ref3) {
160
160
  });
161
161
  return;
162
162
  }
163
+
164
+ // This cast is needed to satisfy TS when using custom payloads which is only allowed by
165
+ // the fireAnalyticsEvent function in EditorAnalyticsAPI for now.
166
+ // createAnalyticsEvent actually fires our standard AnalyticsEventPayload type which is less strict
167
+ // so this is safe.
168
+ var firedPayload = payload;
163
169
  _fireAnalyticsEvent(createAnalyticsEvent, options)({
164
- payload: payload,
170
+ payload: firedPayload,
165
171
  channel: channel
166
172
  });
167
173
  }
@@ -1,8 +1,8 @@
1
1
  import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
2
- import { SELECTION_POSITION, SELECTION_TYPE } from '@atlaskit/editor-common/analytics';
2
+ import { SELECTION_POSITION, SELECTION_TYPE, type BaseEventPayload } from '@atlaskit/editor-common/analytics';
3
3
  import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  export declare function getSelectionType(selection: Selection): {
5
5
  position?: SELECTION_POSITION;
6
6
  type: SELECTION_TYPE;
7
7
  };
8
- export declare function getStateContext(selection: Selection, payload: AnalyticsEventPayload, tr?: Transaction): AnalyticsEventPayload;
8
+ export declare function getStateContext<Payload extends BaseEventPayload = AnalyticsEventPayload>(selection: Selection, payload: Payload, tr?: Transaction): Payload;
@@ -1,8 +1,8 @@
1
1
  import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
2
- import { SELECTION_POSITION, SELECTION_TYPE } from '@atlaskit/editor-common/analytics';
2
+ import { SELECTION_POSITION, SELECTION_TYPE, type BaseEventPayload } from '@atlaskit/editor-common/analytics';
3
3
  import type { Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  export declare function getSelectionType(selection: Selection): {
5
5
  position?: SELECTION_POSITION;
6
6
  type: SELECTION_TYPE;
7
7
  };
8
- export declare function getStateContext(selection: Selection, payload: AnalyticsEventPayload, tr?: Transaction): AnalyticsEventPayload;
8
+ export declare function getStateContext<Payload extends BaseEventPayload = AnalyticsEventPayload>(selection: Selection, payload: Payload, tr?: Transaction): Payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-analytics",
3
- "version": "5.3.0",
3
+ "version": "6.1.0",
4
4
  "description": "Analytics plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,15 +28,15 @@
28
28
  "atlaskit:src": "src/index.ts",
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^51.2.0",
31
- "@atlaskit/analytics-listeners": "^9.0.0",
31
+ "@atlaskit/analytics-listeners": "^9.1.0",
32
32
  "@atlaskit/analytics-next": "^11.1.0",
33
- "@atlaskit/editor-plugin-feature-flags": "^4.0.0",
33
+ "@atlaskit/editor-plugin-feature-flags": "^5.0.0",
34
34
  "@atlaskit/editor-prosemirror": "7.0.0",
35
35
  "@atlaskit/editor-tables": "^2.9.0",
36
36
  "@babel/runtime": "^7.0.0"
37
37
  },
38
38
  "peerDependencies": {
39
- "@atlaskit/editor-common": "^109.16.0",
39
+ "@atlaskit/editor-common": "^110.3.0",
40
40
  "react": "^18.2.0"
41
41
  },
42
42
  "techstack": {