@atlaskit/editor-plugin-analytics 6.0.0 → 6.2.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,45 @@
1
1
  # @atlaskit/editor-plugin-analytics
2
2
 
3
+ ## 6.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`5167552fe1a93`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5167552fe1a93) -
8
+ [EDITOR-2339] Bump @atlaskit/adf-schema to 51.3.0
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 6.1.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [`e3780960bb0ae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3780960bb0ae) - ##
19
+ What Update `EditorAnalyticsAPI` to allow for `fireAnalyticsEvent` to use a custom payload if an
20
+ explicit type parameter is used. This is mostly used by the analytics plugin
21
+
22
+ ```ts
23
+ // Example
24
+ api?.analytics.actions.fireAnalyticsEvent<CustomPayload, 'customEventType'>({ ... });
25
+ ```
26
+
27
+ ## Why
28
+
29
+ The current Payload structure is not extensible. There are times we don't want to update the base
30
+ analytics types (and increase bundle size) and scope them only to a specific package. This
31
+ provides an escape hatch but still enforces some level of type safety (currently there are some
32
+ examples of using `ts-expect-error` to side step this).
33
+
34
+ ## How to upgrade
35
+
36
+ In most scenarios this should not cause any breaking change but can be breaking if you are side
37
+ stepping type safety here with `ts-expect-error`.
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies
42
+
3
43
  ## 6.0.0
4
44
 
5
45
  ### Patch Changes
@@ -118,7 +158,6 @@
118
158
  shared context or singletons.
119
159
 
120
160
  **HOW TO ADJUST:**
121
-
122
161
  - Consumers must now explicitly install `@atlaskit/editor-common` in their own project if they use
123
162
  any of these editor plugins.
124
163
  - Ensure the version you install matches the version required by the plugins.
@@ -869,7 +908,6 @@
869
908
  - [#43646](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43646)
870
909
  [`d43f8e9402f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d43f8e9402f) - Make
871
910
  feature flags plugin optional in all plugins including:
872
-
873
911
  - analytics
874
912
  - base
875
913
  - card
@@ -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": "6.0.0",
3
+ "version": "6.2.0",
4
4
  "description": "Analytics plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,7 +27,7 @@
27
27
  "sideEffects": false,
28
28
  "atlaskit:src": "src/index.ts",
29
29
  "dependencies": {
30
- "@atlaskit/adf-schema": "^51.2.0",
30
+ "@atlaskit/adf-schema": "^51.3.0",
31
31
  "@atlaskit/analytics-listeners": "^9.1.0",
32
32
  "@atlaskit/analytics-next": "^11.1.0",
33
33
  "@atlaskit/editor-plugin-feature-flags": "^5.0.0",
@@ -36,7 +36,7 @@
36
36
  "@babel/runtime": "^7.0.0"
37
37
  },
38
38
  "peerDependencies": {
39
- "@atlaskit/editor-common": "^110.0.0",
39
+ "@atlaskit/editor-common": "^110.14.0",
40
40
  "react": "^18.2.0"
41
41
  },
42
42
  "techstack": {