@atlaskit/smart-card 19.1.13 → 19.1.14

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/cjs/extractors/common/actions/extractPreviewAction.js +1 -1
  3. package/dist/cjs/index.js +6 -0
  4. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +255 -34
  5. package/dist/cjs/state/hooks/useSmartLink.js +1 -1
  6. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +1 -1
  7. package/dist/cjs/state/hooks-external/useSmartLinkReload.js +1 -1
  8. package/dist/cjs/state/index.js +9 -1
  9. package/dist/cjs/utils/analytics/analytics.js +14 -9
  10. package/dist/cjs/utils/analytics/types.js +5 -0
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/cjs/view/CardWithData/loader.js +2 -0
  13. package/dist/cjs/view/CardWithUrl/component.js +12 -8
  14. package/dist/cjs/view/CardWithUrl/loader.js +5 -3
  15. package/dist/cjs/view/HoverCard/index.js +3 -1
  16. package/dist/cjs/view/HoverCard/utils.js +3 -1
  17. package/dist/cjs/view/InlineCard/ResolvedView/index.js +2 -0
  18. package/dist/cjs/view/InlineCard/index.js +3 -1
  19. package/dist/es2019/extractors/common/actions/extractPreviewAction.js +1 -1
  20. package/dist/es2019/index.js +1 -1
  21. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +196 -30
  22. package/dist/es2019/state/hooks/useSmartLink.js +1 -1
  23. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +1 -1
  24. package/dist/es2019/state/hooks-external/useSmartLinkReload.js +1 -1
  25. package/dist/es2019/state/index.js +2 -1
  26. package/dist/es2019/utils/analytics/analytics.js +14 -9
  27. package/dist/es2019/utils/analytics/types.js +1 -0
  28. package/dist/es2019/version.json +1 -1
  29. package/dist/es2019/view/CardWithData/loader.js +2 -0
  30. package/dist/es2019/view/CardWithUrl/component.js +12 -8
  31. package/dist/es2019/view/CardWithUrl/loader.js +5 -3
  32. package/dist/es2019/view/HoverCard/index.js +3 -1
  33. package/dist/es2019/view/HoverCard/utils.js +1 -1
  34. package/dist/es2019/view/InlineCard/ResolvedView/index.js +2 -0
  35. package/dist/es2019/view/InlineCard/index.js +2 -0
  36. package/dist/esm/extractors/common/actions/extractPreviewAction.js +1 -1
  37. package/dist/esm/index.js +1 -1
  38. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +254 -35
  39. package/dist/esm/state/hooks/useSmartLink.js +1 -1
  40. package/dist/esm/state/hooks-external/useSmartLinkActions.js +1 -1
  41. package/dist/esm/state/hooks-external/useSmartLinkReload.js +1 -1
  42. package/dist/esm/state/index.js +2 -1
  43. package/dist/esm/utils/analytics/analytics.js +14 -9
  44. package/dist/esm/utils/analytics/types.js +1 -0
  45. package/dist/esm/version.json +1 -1
  46. package/dist/esm/view/CardWithData/loader.js +2 -0
  47. package/dist/esm/view/CardWithUrl/component.js +12 -8
  48. package/dist/esm/view/CardWithUrl/loader.js +5 -3
  49. package/dist/esm/view/HoverCard/index.js +3 -1
  50. package/dist/esm/view/HoverCard/utils.js +3 -1
  51. package/dist/esm/view/InlineCard/ResolvedView/index.js +2 -0
  52. package/dist/esm/view/InlineCard/index.js +3 -1
  53. package/dist/types/index.d.ts +1 -1
  54. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +144 -11
  55. package/dist/types/state/helpers.d.ts +2 -2
  56. package/dist/types/state/hooks/useSmartLink.d.ts +8 -10
  57. package/dist/types/state/index.d.ts +1 -0
  58. package/dist/types/utils/analytics/analytics.d.ts +6 -6
  59. package/dist/types/utils/analytics/types.d.ts +1 -0
  60. package/dist/types/utils/performance.d.ts +1 -1
  61. package/dist/types/utils/types.d.ts +1 -1
  62. package/dist/types/view/BlockCard/types.d.ts +1 -0
  63. package/dist/types/view/Card/index.d.ts +1 -1
  64. package/dist/types/view/Card/types.d.ts +3 -0
  65. package/dist/types/view/CardWithData/types.d.ts +1 -0
  66. package/dist/types/view/CardWithUrl/component.d.ts +1 -1
  67. package/dist/types/view/CardWithUrl/types.d.ts +2 -0
  68. package/dist/types/view/EmbedCard/types.d.ts +1 -0
  69. package/dist/types/view/FlexibleCard/types.d.ts +4 -0
  70. package/dist/types/view/HoverCard/index.d.ts +1 -1
  71. package/dist/types/view/HoverCard/types.d.ts +1 -0
  72. package/dist/types/view/HoverCard/utils.d.ts +1 -1
  73. package/dist/types/view/InlineCard/ResolvedView/index.d.ts +2 -0
  74. package/dist/types/view/InlineCard/types.d.ts +1 -0
  75. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 19.1.14
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d57264a033`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d57264a033) - This update adds an exposed analytics hook, which will pave the way for future usage of Smart Link analytics outside of the smart-card component.
8
+
9
+ # Usage of `useSmartLinkAnalytics`
10
+
11
+ You can now use `useSmartLinkAnalytics` to create and modify a set of analytics events for the `Card` component to consume.
12
+
13
+ ```Typescript
14
+
15
+ const CardComponentWithDifferentAnalytics = () => {
16
+
17
+ // You can now supply a location, and this will be used in all events.
18
+ const location = 'this-is-a-test-product';
19
+
20
+ // id is optional, but with CRUD operations, you can persist this to keep analytics events related to one link.
21
+ const id = 'test-id';
22
+
23
+ // By default, all events will be supplied with location and id as a fallback.
24
+ // Calling an event will send it with the default Smart Links analytics channel
25
+ const analytics = useSmartLinkAnalytics(
26
+ url,
27
+ analyticsHandler,
28
+ id,
29
+ location,
30
+ );
31
+
32
+ // You can now use all the analytics that Smart Links uses like so:
33
+ analytics.ui.cardClickedEvent(id, "block", "resolved");
34
+
35
+ // You can also override an existing event:
36
+ // WARNING: Please reach out to #help-linking-platform before modifying events!
37
+ analytics.ui.renderSuccessEvent = () => {console.log("spaghetti rendered!")};
38
+
39
+ // Finally, pass your props in as below!
40
+ return (
41
+ <Card id={id} url={url} appearance="block" analyticsEvents={analytics} />
42
+ );
43
+ }
44
+
45
+ ```
46
+
47
+ This update also contains a minor update regarding `location` and `status` for two events. They are now as follows:
48
+
49
+ #### `ui.cardClickedEvent`
50
+
51
+ - Now contains `location` as described by the `useSmartLinkAnalytics` hook.
52
+ - Now is fired in `unauthorized`, `errored` and `forbidden` states, with the `status` attribute representing the state of the event.
53
+
54
+ #### `ui.renderSuccessEvent`
55
+
56
+ - Now contains the `status` attribute, representing the state of the event (`unauthorized`, `errored`, `resolved`, etc.)
57
+
3
58
  ## 19.1.13
4
59
 
5
60
  ### Patch Changes
@@ -86,7 +86,7 @@ var extractPreviewAction = function extractPreviewAction() {
86
86
  var previewAction = (0, _BlockCard.PreviewAction)(_objectSpread(_objectSpread({}, metadata), {}, {
87
87
  testId: testId,
88
88
  onOpen: function onOpen() {
89
- handleAnalytics((0, _analytics.uiRenderSuccessEvent)('preview', key));
89
+ handleAnalytics((0, _analytics.uiRenderSuccessEvent)('preview', 'resolved', key));
90
90
  },
91
91
  onOpenFailed: function onOpenFailed(error, errorInfo) {
92
92
  handleAnalytics((0, _analytics.uiRenderFailedEvent)('preview', error, errorInfo));
package/dist/cjs/index.js CHANGED
@@ -219,6 +219,12 @@ Object.defineProperty(exports, "metadataListClassName", {
219
219
  return _classNames.metadataListClassName;
220
220
  }
221
221
  });
222
+ Object.defineProperty(exports, "useSmartLinkAnalytics", {
223
+ enumerable: true,
224
+ get: function get() {
225
+ return _state.useSmartLinkAnalytics;
226
+ }
227
+ });
222
228
  Object.defineProperty(exports, "useSmartLinkEvents", {
223
229
  enumerable: true,
224
230
  get: function get() {
@@ -7,38 +7,155 @@ exports.useSmartLinkAnalytics = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
+ var _linkingCommon = require("@atlaskit/linking-common");
11
+
10
12
  var _analytics = require("../../utils/analytics");
11
13
 
12
14
  var _ufoExperiences = require("./ufoExperiences");
13
15
 
14
- var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalytics) {
16
+ var _helpers = require("../helpers");
17
+
18
+ var _linkProvider = require("@atlaskit/link-provider");
19
+
20
+ /**
21
+ * This hook provides usage of Smart Link analytics outside of the Card component.
22
+ * Can be provided to Card via the analyticsEvents prop to change the analytics events.
23
+ * @param url URL of the link
24
+ * @param dispatchAnalytics dispatchAnalytics function
25
+ * @param id fallback id of the events sent if no id is available
26
+ * @param defaultLocation location attribute to be used
27
+ * @returns
28
+ */
29
+ var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchAnalytics, id, defaultLocation) {
30
+ var defaultId = id || 'NULL'; // We don't want to trigger a re-render by using useSmartCardState
31
+
32
+ var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
33
+ store = _useSmartLinkContext.store;
34
+
35
+ var state = (0, _linkingCommon.getUrl)(store, url);
36
+ var extractedDefinitionId = (0, _helpers.getDefinitionId)(state.details);
37
+ var extractedExtensionKey = (0, _helpers.getExtensionKey)(state.details);
38
+ var extractedResourceType = (0, _helpers.getResourceType)(state.details);
39
+ /** Contains all ui analytics events */
40
+
15
41
  var ui = (0, _react.useMemo)(function () {
16
42
  return {
17
- authEvent: function authEvent(display, definitionId, extensionKey) {
43
+ /**
44
+ * This fires an event that represents when a user clicks on the authentication
45
+ * call to action with no current authenticated account. (i.e. Connect to Preview).
46
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
47
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
48
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
49
+ * @returns
50
+ */
51
+ authEvent: function authEvent(display) {
52
+ var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
53
+ var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
18
54
  return dispatchAnalytics((0, _analytics.uiAuthEvent)(display, definitionId, extensionKey));
19
55
  },
20
- authAlternateAccountEvent: function authAlternateAccountEvent(display, definitionId, extensionKey) {
56
+
57
+ /**
58
+ * This fires an event that represents when a user clicks on the authentication
59
+ * call to action with a forbidden authenticated account. (i.e. Try another account).
60
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
61
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
62
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
63
+ * @returns
64
+ */
65
+ authAlternateAccountEvent: function authAlternateAccountEvent(display) {
66
+ var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
67
+ var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
21
68
  return dispatchAnalytics((0, _analytics.uiAuthAlternateAccountEvent)(display, definitionId, extensionKey));
22
69
  },
23
- cardClickedEvent: function cardClickedEvent(display, definitionId, extensionKey, isModifierKeyPressed) {
24
- return dispatchAnalytics((0, _analytics.uiCardClickedEvent)(display, definitionId, extensionKey, isModifierKeyPressed));
70
+
71
+ /**
72
+ * This fires an event that represents when a user clicks on a Smart Link.
73
+ * @param id The unique ID for this Smart Link.
74
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
75
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
76
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
77
+ * @param isModifierKeyPressed Whether a modifier key was pressed when clicking the Smart Link.
78
+ * @param location Where the Smart Link is currently rendered.
79
+ * @param destinationProduct The product the Smart Link is linked to.
80
+ * @returns
81
+ */
82
+ cardClickedEvent: function cardClickedEvent() {
83
+ var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
84
+ var display = arguments.length > 1 ? arguments[1] : undefined;
85
+ var status = arguments.length > 2 ? arguments[2] : undefined;
86
+ var definitionId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedDefinitionId;
87
+ var extensionKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedExtensionKey;
88
+ var isModifierKeyPressed = arguments.length > 5 ? arguments[5] : undefined;
89
+ var location = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : defaultLocation;
90
+ var destinationProduct = arguments.length > 7 ? arguments[7] : undefined;
91
+ return dispatchAnalytics((0, _analytics.uiCardClickedEvent)(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct));
25
92
  },
26
- actionClickedEvent: function actionClickedEvent(id, extensionKey, actionType, display, invokeType) {
93
+
94
+ /**
95
+ * This fires an event that represents when a user clicks on a Smart Link action.
96
+ * Note: This also starts the UFO smart-link-action-invocation experience.
97
+ * @param id The unique ID for this Smart Link.
98
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
99
+ * @param actionType The type of the action that was clicked, e.g. PreviewAction
100
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
101
+ * @param invokeType Whether the action invoked made a call to a server.
102
+ * @returns
103
+ */
104
+ actionClickedEvent: function actionClickedEvent() {
105
+ var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
106
+ var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
107
+ var actionType = arguments.length > 2 ? arguments[2] : undefined;
108
+ var display = arguments.length > 3 ? arguments[3] : undefined;
109
+ var invokeType = arguments.length > 4 ? arguments[4] : undefined;
27
110
  (0, _ufoExperiences.startUfoExperience)('smart-link-action-invocation', id, {
28
111
  actionType: actionType,
29
112
  display: display,
30
113
  extensionKey: extensionKey,
31
114
  invokeType: invokeType
32
115
  });
33
- dispatchAnalytics((0, _analytics.uiActionClickedEvent)(extensionKey, actionType, display));
116
+ dispatchAnalytics((0, _analytics.uiActionClickedEvent)(actionType, extensionKey, display));
34
117
  },
35
- hoverCardOpenLinkClickedEvent: function hoverCardOpenLinkClickedEvent(previewDisplay, definitionId, extensionKey, previewInvokeMethod) {
118
+
119
+ /**
120
+ * This fires an event that represents when a user clicks on a hover preview's "navigate to link" button.
121
+ * https://product-fabric.atlassian.net/wiki/spaces/EM/pages/3206743323/Analytics+Metrics+-+Hover+Previews
122
+ * @param previewDisplay What format the preview is in.
123
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
124
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
125
+ * @param previewInvokeMethod How the preview was triggered.
126
+ */
127
+ hoverCardOpenLinkClickedEvent: function hoverCardOpenLinkClickedEvent(previewDisplay) {
128
+ var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
129
+ var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
130
+ var previewInvokeMethod = arguments.length > 3 ? arguments[3] : undefined;
36
131
  dispatchAnalytics((0, _analytics.uiHoverCardOpenLinkClickedEvent)(previewDisplay, definitionId, extensionKey, previewInvokeMethod));
37
132
  },
38
- closedAuthEvent: function closedAuthEvent(display, definitionId, extensionKey) {
133
+
134
+ /**
135
+ * This fires an event that represents when a user closed the authentication window without authenticating after opening it.
136
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
137
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
138
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
139
+ * @returns
140
+ */
141
+ closedAuthEvent: function closedAuthEvent(display) {
142
+ var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
143
+ var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
39
144
  return dispatchAnalytics((0, _analytics.uiClosedAuthEvent)(display, definitionId, extensionKey));
40
145
  },
41
- renderSuccessEvent: function renderSuccessEvent(display, id, definitionId, extensionKey) {
146
+
147
+ /**
148
+ * This fires an event that represents when a Smart Link was rendered successfully.
149
+ * Note: this fires even if the Smart Link request errored out.
150
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
151
+ * @param id The unique ID for this Smart Link.
152
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
153
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
154
+ */
155
+ renderSuccessEvent: function renderSuccessEvent(display, status) {
156
+ var id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultId;
157
+ var definitionId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedDefinitionId;
158
+ var extensionKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedExtensionKey;
42
159
  (0, _ufoExperiences.succeedUfoExperience)('smart-link-rendered', id, {
43
160
  extensionKey: extensionKey,
44
161
  display: display
@@ -47,47 +164,131 @@ var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalytics) {
47
164
  (0, _ufoExperiences.succeedUfoExperience)('smart-link-authenticated', id, {
48
165
  display: display
49
166
  });
50
- dispatchAnalytics((0, _analytics.uiRenderSuccessEvent)(display, definitionId, extensionKey));
167
+ dispatchAnalytics((0, _analytics.uiRenderSuccessEvent)(display, status, definitionId, extensionKey));
51
168
  },
52
- hoverCardViewedEvent: function hoverCardViewedEvent(hoverDisplay, definitionId, extensionKey, previewInvokeMethod) {
169
+
170
+ /**
171
+ * This fires an event that represents a hover preview being opened.
172
+ * @param hoverDisplay Whether the hover preview was displayed as a card or embed.
173
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
174
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
175
+ * @param previewInvokeMethod How the preview was triggered.
176
+ * @returns
177
+ */
178
+ hoverCardViewedEvent: function hoverCardViewedEvent(hoverDisplay) {
179
+ var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
180
+ var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
181
+ var previewInvokeMethod = arguments.length > 3 ? arguments[3] : undefined;
53
182
  return dispatchAnalytics((0, _analytics.uiHoverCardViewedEvent)(hoverDisplay, definitionId, extensionKey, previewInvokeMethod));
54
183
  },
55
- hoverCardDismissedEvent: function hoverCardDismissedEvent(hoverDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod) {
184
+
185
+ /**
186
+ * This fires an event that represents a hover preview being dismissed.
187
+ * @param hoverDisplay Whether the hover preview was displayed as a card or embed.
188
+ * @param hoverTime The duration that the user hovered over a Smart Link before the preview was dismissed.
189
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
190
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
191
+ * @param previewInvokeMethod How the preview was triggered.
192
+ * @returns
193
+ */
194
+ hoverCardDismissedEvent: function hoverCardDismissedEvent(hoverDisplay, hoverTime) {
195
+ var definitionId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedDefinitionId;
196
+ var extensionKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedExtensionKey;
197
+ var previewInvokeMethod = arguments.length > 4 ? arguments[4] : undefined;
56
198
  return dispatchAnalytics((0, _analytics.uiHoverCardDismissedEvent)(hoverDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod));
57
199
  }
58
200
  };
59
- }, [dispatchAnalytics]);
201
+ }, [defaultId, defaultLocation, extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
202
+ /** Contains all operational analytics events */
203
+
60
204
  var operational = (0, _react.useMemo)(function () {
61
205
  return {
62
- resolvedEvent: function resolvedEvent(id, definitionId, extensionKey, resourceType) {
63
- return dispatchAnalytics((0, _analytics.resolvedEvent)(id, definitionId, extensionKey, resourceType));
64
- },
65
- unresolvedEvent: function unresolvedEvent(id, status, definitionId, extensionKey, resourceType) {
66
- return dispatchAnalytics((0, _analytics.unresolvedEvent)(id, status, definitionId, extensionKey, resourceType));
67
- },
68
- invokeSucceededEvent: function invokeSucceededEvent(id, providerKey, actionType, display) {
206
+ /**
207
+ * This fires an event that represents an action being successfully invoked.
208
+ * @param id The unique ID for this Smart Link.
209
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
210
+ * @param actionType The type of action invoked, e.g. PreviewAction
211
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
212
+ */
213
+ invokeSucceededEvent: function invokeSucceededEvent() {
214
+ var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
215
+ var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
216
+ var actionType = arguments.length > 2 ? arguments[2] : undefined;
217
+ var display = arguments.length > 3 ? arguments[3] : undefined;
69
218
  (0, _ufoExperiences.succeedUfoExperience)('smart-link-action-invocation', id);
70
- dispatchAnalytics((0, _analytics.invokeSucceededEvent)(id, providerKey, actionType, display));
219
+ dispatchAnalytics((0, _analytics.invokeSucceededEvent)(id, actionType, display, extensionKey));
71
220
  },
72
- invokeFailedEvent: function invokeFailedEvent(id, providerKey, actionType, display, reason) {
221
+
222
+ /**
223
+ * This fires an event that represents an action being unsuccessfully invoked.
224
+ * @param id The unique ID for this Smart Link.
225
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
226
+ * @param actionType The type of action invoked, e.g. PreviewAction
227
+ * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
228
+ * @param reason The reason the invocation failed.
229
+ */
230
+ invokeFailedEvent: function invokeFailedEvent() {
231
+ var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
232
+ var providerKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
233
+ var actionType = arguments.length > 2 ? arguments[2] : undefined;
234
+ var display = arguments.length > 3 ? arguments[3] : undefined;
235
+ var reason = arguments.length > 4 ? arguments[4] : undefined;
73
236
  (0, _ufoExperiences.failUfoExperience)('smart-link-action-invocation', id);
74
- dispatchAnalytics((0, _analytics.invokeFailedEvent)(id, providerKey, actionType, display, reason));
237
+ dispatchAnalytics((0, _analytics.invokeFailedEvent)(id, actionType, display, reason, providerKey));
75
238
  },
76
- connectSucceededEvent: function connectSucceededEvent(id, definitionId, extensionKey) {
239
+
240
+ /**
241
+ * This fires an event that represents an account successfully being connected via a Smart Link.
242
+ * @param id The unique ID for this Smart Link.
243
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
244
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
245
+ */
246
+ connectSucceededEvent: function connectSucceededEvent() {
247
+ var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
248
+ var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
249
+ var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
77
250
  (0, _ufoExperiences.startUfoExperience)('smart-link-authenticated', id, {
78
251
  extensionKey: extensionKey,
79
252
  status: 'success'
80
253
  });
81
254
  dispatchAnalytics((0, _analytics.connectSucceededEvent)(definitionId, extensionKey));
82
255
  },
83
- connectFailedEvent: function connectFailedEvent(id, definitionId, extensionKey, status) {
256
+
257
+ /**
258
+ * This fires an event that represents an account unsuccessfully being connected.
259
+ * @param id The unique ID for this Smart Link.
260
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
261
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
262
+ * @param reason The reason why the Smart Link connect account failed.
263
+ */
264
+ connectFailedEvent: function connectFailedEvent() {
265
+ var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
266
+ var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
267
+ var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
268
+ var reason = arguments.length > 3 ? arguments[3] : undefined;
84
269
  (0, _ufoExperiences.startUfoExperience)('smart-link-authenticated', id, {
85
270
  extensionKey: extensionKey,
86
- status: status
271
+ status: reason
87
272
  });
88
- dispatchAnalytics((0, _analytics.connectFailedEvent)(definitionId, extensionKey, status));
273
+ dispatchAnalytics((0, _analytics.connectFailedEvent)(definitionId, extensionKey, reason));
89
274
  },
90
- instrument: function instrument(id, status, definitionId, extensionKey, resourceType, error) {
275
+
276
+ /**
277
+ * This fires an event which represents a Smart Link request succeeding or failing based on the status.
278
+ * @param id The unique ID for this Smart Link.
279
+ * @param status The status of the Smart Link.
280
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
281
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
282
+ * @param resourceType The type of resource that was invoked. This is provider specific (e.g. File, PullRequest).
283
+ * @param error An error representing why the Smart Link request failed.
284
+ */
285
+ instrument: function instrument() {
286
+ var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
287
+ var status = arguments.length > 1 ? arguments[1] : undefined;
288
+ var definitionId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedDefinitionId;
289
+ var extensionKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedExtensionKey;
290
+ var resourceType = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedResourceType;
291
+ var error = arguments.length > 5 ? arguments[5] : undefined;
91
292
  var event = (0, _analytics.instrumentEvent)(id, status, definitionId, extensionKey, resourceType, error);
92
293
 
93
294
  if (event) {
@@ -95,21 +296,41 @@ var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalytics) {
95
296
  }
96
297
  }
97
298
  };
98
- }, [dispatchAnalytics]);
299
+ }, [defaultId, extractedResourceType, extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
300
+ /** Contains all track analytics events */
301
+
99
302
  var track = (0, _react.useMemo)(function () {
100
303
  return {
101
- appAccountConnected: function appAccountConnected(definitionId, extensionKey) {
304
+ /**
305
+ * This fires an event which represents a user starting the Smart Link connect account process.
306
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
307
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
308
+ * @returns
309
+ */
310
+ appAccountConnected: function appAccountConnected() {
311
+ var definitionId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : extractedDefinitionId;
312
+ var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
102
313
  return dispatchAnalytics((0, _analytics.trackAppAccountConnected)(definitionId, extensionKey));
103
314
  }
104
315
  };
105
- }, [dispatchAnalytics]);
316
+ }, [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
317
+ /** Contains all screen analytics events */
318
+
106
319
  var screen = (0, _react.useMemo)(function () {
107
320
  return {
108
- authPopupEvent: function authPopupEvent(definitionId, extensionKey) {
321
+ /**
322
+ * This fires an event which represents the connect account page being opened.
323
+ * @param definitionId The definitionId of the Smart Link resolver invoked.
324
+ * @param extensionKey The extensionKey of the Smart Link resovler invoked.
325
+ * @returns
326
+ */
327
+ authPopupEvent: function authPopupEvent() {
328
+ var definitionId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : extractedDefinitionId;
329
+ var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
109
330
  return dispatchAnalytics((0, _analytics.screenAuthPopupEvent)(definitionId, extensionKey));
110
331
  }
111
332
  };
112
- }, [dispatchAnalytics]);
333
+ }, [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
113
334
  return (0, _react.useMemo)(function () {
114
335
  return {
115
336
  ui: ui,
@@ -23,7 +23,7 @@ var _renderers = require("../renderers");
23
23
 
24
24
  function useSmartLink(id, url, dispatchAnalytics) {
25
25
  var state = (0, _store.useSmartCardState)(url);
26
- var analytics = (0, _analytics.useSmartLinkAnalytics)(dispatchAnalytics);
26
+ var analytics = (0, _analytics.useSmartLinkAnalytics)(url, dispatchAnalytics, id);
27
27
  var actions = (0, _actions.useSmartCardActions)(id, url, analytics);
28
28
  var config = (0, _config.useSmartLinkConfig)();
29
29
  var renderers = (0, _renderers.useSmartLinkRenderers)(); // NB: used to propagate errors from hooks to error boundaries.
@@ -39,7 +39,7 @@ function useSmartLinkActions(_ref) {
39
39
  setActions = _useState2[1];
40
40
 
41
41
  var linkState = (0, _store.useSmartCardState)(url);
42
- var linkAnalytics = (0, _analytics.useSmartLinkAnalytics)(analyticsHandler);
42
+ var linkAnalytics = (0, _analytics.useSmartLinkAnalytics)(url, analyticsHandler, id);
43
43
  var linkActions = (0, _actions.useSmartCardActions)(id, url, linkAnalytics);
44
44
  (0, _react.useEffect)(function () {
45
45
  if (!linkState.details) {
@@ -26,7 +26,7 @@ function useSmartLinkReload(_ref) {
26
26
  var id = (0, _react.useMemo)(function () {
27
27
  return (0, _uuid.default)();
28
28
  }, []);
29
- var linkAnalytics = (0, _analytics.useSmartLinkAnalytics)(analyticsHandler);
29
+ var linkAnalytics = (0, _analytics.useSmartLinkAnalytics)(url, analyticsHandler, id);
30
30
  var linkActions = (0, _actions.useSmartCardActions)(id, url, linkAnalytics);
31
31
  return linkActions.reload;
32
32
  }
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "useSmartLink", {
27
27
  return _hooks.useSmartLink;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "useSmartLinkAnalytics", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _analytics.useSmartLinkAnalytics;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "useSmartLinkContext", {
31
37
  enumerable: true,
32
38
  get: function get() {
@@ -36,4 +42,6 @@ Object.defineProperty(exports, "useSmartLinkContext", {
36
42
 
37
43
  var _linkProvider = require("@atlaskit/link-provider");
38
44
 
39
- var _hooks = require("./hooks");
45
+ var _hooks = require("./hooks");
46
+
47
+ var _analytics = require("./analytics");
@@ -109,7 +109,7 @@ var unresolvedEvent = function unresolvedEvent(id, status, definitionId, extensi
109
109
 
110
110
  exports.unresolvedEvent = unresolvedEvent;
111
111
 
112
- var invokeSucceededEvent = function invokeSucceededEvent(id, extensionKey, actionType, display) {
112
+ var invokeSucceededEvent = function invokeSucceededEvent(id, actionType, display, extensionKey) {
113
113
  var measure = (0, _performance.getMeasure)(id, 'resolved') || {
114
114
  duration: undefined
115
115
  };
@@ -121,7 +121,7 @@ var invokeSucceededEvent = function invokeSucceededEvent(id, extensionKey, actio
121
121
  id: id,
122
122
  actionType: actionType,
123
123
  display: display,
124
- extensionKey: extensionKey,
124
+ extensionKey: extensionKey || '',
125
125
  duration: measure.duration
126
126
  })
127
127
  };
@@ -129,7 +129,7 @@ var invokeSucceededEvent = function invokeSucceededEvent(id, extensionKey, actio
129
129
 
130
130
  exports.invokeSucceededEvent = invokeSucceededEvent;
131
131
 
132
- var invokeFailedEvent = function invokeFailedEvent(id, extensionKey, actionType, display, reason) {
132
+ var invokeFailedEvent = function invokeFailedEvent(id, actionType, display, reason, extensionKey) {
133
133
  var measure = (0, _performance.getMeasure)(id, 'errored') || {
134
134
  duration: undefined
135
135
  };
@@ -141,7 +141,7 @@ var invokeFailedEvent = function invokeFailedEvent(id, extensionKey, actionType,
141
141
  id: id,
142
142
  actionType: actionType,
143
143
  display: display,
144
- extensionKey: extensionKey,
144
+ extensionKey: extensionKey || '',
145
145
  duration: measure.duration,
146
146
  reason: reason
147
147
  })
@@ -230,30 +230,34 @@ var uiAuthAlternateAccountEvent = function uiAuthAlternateAccountEvent(display,
230
230
 
231
231
  exports.uiAuthAlternateAccountEvent = uiAuthAlternateAccountEvent;
232
232
 
233
- var uiCardClickedEvent = function uiCardClickedEvent(display, definitionId, extensionKey, isModifierKeyPressed) {
233
+ var uiCardClickedEvent = function uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct) {
234
234
  return {
235
235
  action: 'clicked',
236
236
  actionSubject: 'smartLink',
237
237
  eventType: 'ui',
238
238
  attributes: _objectSpread(_objectSpread({}, context), {}, {
239
+ id: id,
240
+ status: status,
239
241
  definitionId: definitionId || '',
240
242
  extensionKey: extensionKey || '',
241
243
  display: display,
242
- isModifierKeyPressed: isModifierKeyPressed
244
+ isModifierKeyPressed: isModifierKeyPressed,
245
+ location: location,
246
+ destinationProduct: destinationProduct
243
247
  })
244
248
  };
245
249
  };
246
250
 
247
251
  exports.uiCardClickedEvent = uiCardClickedEvent;
248
252
 
249
- var uiActionClickedEvent = function uiActionClickedEvent(extensionKey, actionType, display) {
253
+ var uiActionClickedEvent = function uiActionClickedEvent(actionType, extensionKey, display) {
250
254
  return {
251
255
  action: 'clicked',
252
256
  actionSubject: 'smartLinkAction',
253
257
  eventType: 'ui',
254
258
  attributes: _objectSpread(_objectSpread({}, context), {}, {
255
259
  display: display,
256
- extensionKey: extensionKey,
260
+ extensionKey: extensionKey || '',
257
261
  actionType: actionType
258
262
  })
259
263
  };
@@ -289,12 +293,13 @@ var screenAuthPopupEvent = function screenAuthPopupEvent(definitionId, extension
289
293
 
290
294
  exports.screenAuthPopupEvent = screenAuthPopupEvent;
291
295
 
292
- var uiRenderSuccessEvent = function uiRenderSuccessEvent(display, definitionId, extensionKey) {
296
+ var uiRenderSuccessEvent = function uiRenderSuccessEvent(display, status, definitionId, extensionKey) {
293
297
  return {
294
298
  action: 'renderSuccess',
295
299
  actionSubject: 'smartLink',
296
300
  eventType: 'ui',
297
301
  attributes: _objectSpread(_objectSpread({}, context), {}, {
302
+ status: status,
298
303
  definitionId: definitionId || '',
299
304
  extensionKey: extensionKey || '',
300
305
  display: display
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.13",
3
+ "version": "19.1.14",
4
4
  "sideEffects": false
5
5
  }
@@ -52,6 +52,7 @@ var CardWithDataRenderer = /*#__PURE__*/function (_React$PureComponent) {
52
52
  key: "render",
53
53
  value: function render() {
54
54
  var _this$props = this.props,
55
+ id = _this$props.id,
55
56
  appearance = _this$props.appearance,
56
57
  data = _this$props.data,
57
58
  isSelected = _this$props.isSelected,
@@ -67,6 +68,7 @@ var CardWithDataRenderer = /*#__PURE__*/function (_React$PureComponent) {
67
68
 
68
69
  if (CardWithDataRenderer.CardContent) {
69
70
  return /*#__PURE__*/_react.default.createElement(CardWithDataRenderer.CardContent, {
71
+ id: id,
70
72
  inlinePreloaderStyle: inlinePreloaderStyle,
71
73
  appearance: appearance,
72
74
  data: data,