@atlaskit/smart-card 21.3.0 → 22.0.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/cjs/extractors/common/actions/extractPreviewAction.js +10 -2
  3. package/dist/cjs/state/actions/index.js +54 -10
  4. package/dist/cjs/state/analytics/types.js +5 -0
  5. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +386 -109
  6. package/dist/cjs/utils/analytics/analytics.js +239 -72
  7. package/dist/cjs/utils/analytics/index.js +32 -5
  8. package/dist/cjs/version.json +1 -1
  9. package/dist/cjs/view/CardWithUrl/component.js +25 -3
  10. package/dist/cjs/view/CardWithUrl/loader.js +6 -1
  11. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +9 -2
  12. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +15 -4
  13. package/dist/cjs/view/HoverCard/index.js +6 -1
  14. package/dist/es2019/extractors/common/actions/extractPreviewAction.js +10 -2
  15. package/dist/es2019/state/actions/index.js +54 -10
  16. package/dist/es2019/state/analytics/types.js +1 -0
  17. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +379 -39
  18. package/dist/es2019/utils/analytics/analytics.js +253 -78
  19. package/dist/es2019/utils/analytics/index.js +32 -4
  20. package/dist/es2019/version.json +1 -1
  21. package/dist/es2019/view/CardWithUrl/component.js +25 -3
  22. package/dist/es2019/view/CardWithUrl/loader.js +6 -1
  23. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +9 -2
  24. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +15 -4
  25. package/dist/es2019/view/HoverCard/index.js +6 -1
  26. package/dist/esm/extractors/common/actions/extractPreviewAction.js +10 -2
  27. package/dist/esm/state/actions/index.js +54 -10
  28. package/dist/esm/state/analytics/types.js +1 -0
  29. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +383 -109
  30. package/dist/esm/utils/analytics/analytics.js +239 -72
  31. package/dist/esm/utils/analytics/index.js +31 -4
  32. package/dist/esm/version.json +1 -1
  33. package/dist/esm/view/CardWithUrl/component.js +25 -3
  34. package/dist/esm/view/CardWithUrl/loader.js +6 -1
  35. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +9 -2
  36. package/dist/esm/view/HoverCard/components/HoverCardContent.js +15 -4
  37. package/dist/esm/view/HoverCard/index.js +6 -1
  38. package/dist/types/state/analytics/types.d.ts +9 -0
  39. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +18 -23
  40. package/dist/types/state/hooks/useSmartLink.d.ts +17 -18
  41. package/dist/types/utils/analytics/analytics.d.ts +19 -21
  42. package/dist/types/utils/analytics/index.d.ts +2 -2
  43. package/dist/types/utils/analytics/types.d.ts +91 -0
  44. package/package.json +1 -1
  45. package/report.api.md +271 -108
@@ -1,9 +1,32 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+
4
+ 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; }
5
+
6
+ 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; }
7
+
1
8
  import { useMemo } from 'react';
2
9
  import { getUrl } from '@atlaskit/linking-common';
3
10
  import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, invokeSucceededEvent as _invokeSucceededEvent, invokeFailedEvent as _invokeFailedEvent, connectSucceededEvent as _connectSucceededEvent, connectFailedEvent as _connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
4
11
  import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
5
12
  import { getDefinitionId, getExtensionKey, getResourceType, getSubproduct, getProduct } from '../helpers';
6
13
  import { useSmartLinkContext } from '@atlaskit/link-provider';
14
+
15
+ var applyCommonAttributes = function applyCommonAttributes(event, commonAttributes) {
16
+ if (event && event.attributes) {
17
+ for (var _i = 0, _Object$entries = Object.entries(commonAttributes); _i < _Object$entries.length; _i++) {
18
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
19
+ key = _Object$entries$_i[0],
20
+ value = _Object$entries$_i[1];
21
+
22
+ if (event.attributes[key] === undefined) {
23
+ event.attributes[key] = value;
24
+ }
25
+ }
26
+ }
27
+
28
+ return event;
29
+ };
7
30
  /**
8
31
  * This hook provides usage of Smart Link analytics outside of the Card component.
9
32
  * Can be provided to Card via the analyticsEvents prop to change the analytics events.
@@ -14,6 +37,7 @@ import { useSmartLinkContext } from '@atlaskit/link-provider';
14
37
  * @returns
15
38
  */
16
39
 
40
+
17
41
  export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchAnalytics, id, defaultLocation) {
18
42
  var defaultId = id || 'NULL'; // We don't want to trigger a re-render by using useSmartCardState
19
43
 
@@ -27,6 +51,17 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
27
51
  var extractedResourceType = getResourceType(details);
28
52
  var extractedSubproduct = getSubproduct(details);
29
53
  var extractedProduct = getProduct(details);
54
+ var commonAttributes = useMemo(function () {
55
+ return {
56
+ id: defaultId,
57
+ definitionId: extractedDefinitionId,
58
+ extensionKey: extractedExtensionKey,
59
+ resourceType: extractedResourceType,
60
+ destinationSubproduct: extractedSubproduct,
61
+ destinationProduct: extractedProduct,
62
+ location: defaultLocation
63
+ };
64
+ }, [defaultId, extractedDefinitionId, extractedExtensionKey, extractedResourceType, extractedSubproduct, extractedProduct, defaultLocation]);
30
65
  /** Contains all ui analytics events */
31
66
 
32
67
  var ui = useMemo(function () {
@@ -39,10 +74,23 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
39
74
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
40
75
  * @returns
41
76
  */
42
- authEvent: function authEvent(display) {
43
- var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
44
- var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
45
- return dispatchAnalytics(uiAuthEvent(display, definitionId, extensionKey));
77
+ authEvent: function authEvent(_ref) {
78
+ var display = _ref.display,
79
+ extensionKey = _ref.extensionKey,
80
+ definitionId = _ref.definitionId,
81
+ resourceType = _ref.resourceType,
82
+ destinationProduct = _ref.destinationProduct,
83
+ destinationSubproduct = _ref.destinationSubproduct,
84
+ location = _ref.location;
85
+ return dispatchAnalytics(applyCommonAttributes(uiAuthEvent({
86
+ display: display,
87
+ extensionKey: extensionKey,
88
+ definitionId: definitionId,
89
+ resourceType: resourceType,
90
+ destinationProduct: destinationProduct,
91
+ destinationSubproduct: destinationSubproduct,
92
+ location: location
93
+ }), commonAttributes));
46
94
  },
47
95
 
48
96
  /**
@@ -53,10 +101,23 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
53
101
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
54
102
  * @returns
55
103
  */
56
- authAlternateAccountEvent: function authAlternateAccountEvent(display) {
57
- var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
58
- var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
59
- return dispatchAnalytics(uiAuthAlternateAccountEvent(display, definitionId, extensionKey));
104
+ authAlternateAccountEvent: function authAlternateAccountEvent(_ref2) {
105
+ var display = _ref2.display,
106
+ extensionKey = _ref2.extensionKey,
107
+ definitionId = _ref2.definitionId,
108
+ resourceType = _ref2.resourceType,
109
+ destinationProduct = _ref2.destinationProduct,
110
+ destinationSubproduct = _ref2.destinationSubproduct,
111
+ location = _ref2.location;
112
+ return dispatchAnalytics(applyCommonAttributes(uiAuthAlternateAccountEvent({
113
+ display: display,
114
+ extensionKey: extensionKey,
115
+ definitionId: definitionId,
116
+ resourceType: resourceType,
117
+ destinationProduct: destinationProduct,
118
+ destinationSubproduct: destinationSubproduct,
119
+ location: location
120
+ }), commonAttributes));
60
121
  },
61
122
 
62
123
  /**
@@ -71,18 +132,29 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
71
132
  * @param destinationProduct The product the Smart Link is linked to.
72
133
  * @returns
73
134
  */
74
- cardClickedEvent: function cardClickedEvent() {
75
- var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
76
- var display = arguments.length > 1 ? arguments[1] : undefined;
77
- var status = arguments.length > 2 ? arguments[2] : undefined;
78
- var definitionId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedDefinitionId;
79
- var extensionKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedExtensionKey;
80
- var isModifierKeyPressed = arguments.length > 5 ? arguments[5] : undefined;
81
- var location = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : defaultLocation;
82
- var destinationProduct = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : extractedProduct;
83
- var destinationSubproduct = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : extractedSubproduct;
84
- var actionSubjectId = arguments.length > 9 ? arguments[9] : undefined;
85
- return dispatchAnalytics(uiCardClickedEvent(id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct, actionSubjectId));
135
+ cardClickedEvent: function cardClickedEvent(_ref3) {
136
+ var id = _ref3.id,
137
+ display = _ref3.display,
138
+ status = _ref3.status,
139
+ definitionId = _ref3.definitionId,
140
+ extensionKey = _ref3.extensionKey,
141
+ isModifierKeyPressed = _ref3.isModifierKeyPressed,
142
+ location = _ref3.location,
143
+ destinationProduct = _ref3.destinationProduct,
144
+ destinationSubproduct = _ref3.destinationSubproduct,
145
+ actionSubjectId = _ref3.actionSubjectId;
146
+ return dispatchAnalytics(applyCommonAttributes(uiCardClickedEvent({
147
+ id: id,
148
+ display: display,
149
+ status: status,
150
+ definitionId: definitionId,
151
+ extensionKey: extensionKey,
152
+ isModifierKeyPressed: isModifierKeyPressed,
153
+ location: location,
154
+ destinationProduct: destinationProduct,
155
+ destinationSubproduct: destinationSubproduct,
156
+ actionSubjectId: actionSubjectId
157
+ }), commonAttributes));
86
158
  },
87
159
 
88
160
  /**
@@ -95,19 +167,34 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
95
167
  * @param invokeType Whether the action invoked made a call to a server.
96
168
  * @returns
97
169
  */
98
- actionClickedEvent: function actionClickedEvent() {
99
- var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
100
- var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
101
- var actionType = arguments.length > 2 ? arguments[2] : undefined;
102
- var display = arguments.length > 3 ? arguments[3] : undefined;
103
- var invokeType = arguments.length > 4 ? arguments[4] : undefined;
170
+ actionClickedEvent: function actionClickedEvent(_ref4) {
171
+ var id = _ref4.id,
172
+ actionType = _ref4.actionType,
173
+ display = _ref4.display,
174
+ invokeType = _ref4.invokeType,
175
+ extensionKey = _ref4.extensionKey,
176
+ definitionId = _ref4.definitionId,
177
+ resourceType = _ref4.resourceType,
178
+ destinationProduct = _ref4.destinationProduct,
179
+ destinationSubproduct = _ref4.destinationSubproduct,
180
+ location = _ref4.location;
104
181
  startUfoExperience('smart-link-action-invocation', id, {
105
182
  actionType: actionType,
106
183
  display: display,
107
184
  extensionKey: extensionKey,
108
185
  invokeType: invokeType
109
186
  });
110
- dispatchAnalytics(uiActionClickedEvent(id, actionType, extensionKey, display));
187
+ dispatchAnalytics(applyCommonAttributes(uiActionClickedEvent({
188
+ id: id,
189
+ actionType: actionType,
190
+ display: display,
191
+ extensionKey: extensionKey,
192
+ definitionId: definitionId,
193
+ resourceType: resourceType,
194
+ destinationProduct: destinationProduct,
195
+ destinationSubproduct: destinationSubproduct,
196
+ location: location
197
+ }), commonAttributes));
111
198
  },
112
199
 
113
200
  /**
@@ -118,11 +205,24 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
118
205
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
119
206
  * @param previewInvokeMethod How the preview was triggered.
120
207
  */
121
- hoverCardOpenLinkClickedEvent: function hoverCardOpenLinkClickedEvent(previewDisplay) {
122
- var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
123
- var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
124
- var previewInvokeMethod = arguments.length > 3 ? arguments[3] : undefined;
125
- dispatchAnalytics(uiHoverCardOpenLinkClickedEvent(defaultId, previewDisplay, definitionId, extensionKey, previewInvokeMethod));
208
+ hoverCardOpenLinkClickedEvent: function hoverCardOpenLinkClickedEvent(_ref5) {
209
+ var previewDisplay = _ref5.previewDisplay,
210
+ definitionId = _ref5.definitionId,
211
+ extensionKey = _ref5.extensionKey,
212
+ destinationProduct = _ref5.destinationProduct,
213
+ destinationSubproduct = _ref5.destinationSubproduct,
214
+ location = _ref5.location,
215
+ previewInvokeMethod = _ref5.previewInvokeMethod;
216
+ dispatchAnalytics(applyCommonAttributes(uiHoverCardOpenLinkClickedEvent({
217
+ id: defaultId,
218
+ previewDisplay: previewDisplay,
219
+ definitionId: definitionId,
220
+ extensionKey: extensionKey,
221
+ destinationProduct: destinationProduct,
222
+ destinationSubproduct: destinationSubproduct,
223
+ location: location,
224
+ previewInvokeMethod: previewInvokeMethod
225
+ }), commonAttributes));
126
226
  },
127
227
 
128
228
  /**
@@ -132,10 +232,23 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
132
232
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
133
233
  * @returns
134
234
  */
135
- closedAuthEvent: function closedAuthEvent(display) {
136
- var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
137
- var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
138
- return dispatchAnalytics(uiClosedAuthEvent(display, definitionId, extensionKey));
235
+ closedAuthEvent: function closedAuthEvent(_ref6) {
236
+ var display = _ref6.display,
237
+ extensionKey = _ref6.extensionKey,
238
+ definitionId = _ref6.definitionId,
239
+ resourceType = _ref6.resourceType,
240
+ destinationProduct = _ref6.destinationProduct,
241
+ destinationSubproduct = _ref6.destinationSubproduct,
242
+ location = _ref6.location;
243
+ return dispatchAnalytics(applyCommonAttributes(uiClosedAuthEvent({
244
+ display: display,
245
+ extensionKey: extensionKey,
246
+ definitionId: definitionId,
247
+ resourceType: resourceType,
248
+ destinationProduct: destinationProduct,
249
+ destinationSubproduct: destinationSubproduct,
250
+ location: location
251
+ }), commonAttributes));
139
252
  },
140
253
 
141
254
  /**
@@ -146,19 +259,35 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
146
259
  * @param definitionId The definitionId of the Smart Link resolver invoked.
147
260
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
148
261
  */
149
- renderSuccessEvent: function renderSuccessEvent(display, status) {
150
- var id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultId;
151
- var definitionId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedDefinitionId;
152
- var extensionKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedExtensionKey;
153
- succeedUfoExperience('smart-link-rendered', id, {
262
+ renderSuccessEvent: function renderSuccessEvent(_ref7) {
263
+ var display = _ref7.display,
264
+ status = _ref7.status,
265
+ id = _ref7.id,
266
+ extensionKey = _ref7.extensionKey,
267
+ definitionId = _ref7.definitionId,
268
+ resourceType = _ref7.resourceType,
269
+ destinationProduct = _ref7.destinationProduct,
270
+ destinationSubproduct = _ref7.destinationSubproduct,
271
+ location = _ref7.location;
272
+ var experienceId = id ? id : defaultId;
273
+ succeedUfoExperience('smart-link-rendered', experienceId, {
154
274
  extensionKey: extensionKey,
155
275
  display: display
156
276
  }); // UFO will disregard this if authentication experience has not yet been started
157
277
 
158
- succeedUfoExperience('smart-link-authenticated', id, {
278
+ succeedUfoExperience('smart-link-authenticated', experienceId, {
159
279
  display: display
160
280
  });
161
- dispatchAnalytics(uiRenderSuccessEvent(display, status, definitionId, extensionKey));
281
+ dispatchAnalytics(applyCommonAttributes(uiRenderSuccessEvent({
282
+ display: display,
283
+ status: status,
284
+ extensionKey: extensionKey,
285
+ definitionId: definitionId,
286
+ resourceType: resourceType,
287
+ destinationProduct: destinationProduct,
288
+ destinationSubproduct: destinationSubproduct,
289
+ location: location
290
+ }), commonAttributes));
162
291
  },
163
292
 
164
293
  /**
@@ -168,16 +297,34 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
168
297
  * @param error: An error representing why the Smart Link render failed.
169
298
  * @param errorInfo: Additional details about the error including the stack trace.
170
299
  */
171
- renderFailedEvent: function renderFailedEvent(display) {
172
- var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultId;
173
- var error = arguments.length > 2 ? arguments[2] : undefined;
174
- var errorInfo = arguments.length > 3 ? arguments[3] : undefined;
175
- // Start and fail the smart-link-rendered experience. If it has already
300
+ renderFailedEvent: function renderFailedEvent(_ref8) {
301
+ var display = _ref8.display,
302
+ id = _ref8.id,
303
+ error = _ref8.error,
304
+ errorInfo = _ref8.errorInfo,
305
+ extensionKey = _ref8.extensionKey,
306
+ definitionId = _ref8.definitionId,
307
+ resourceType = _ref8.resourceType,
308
+ destinationProduct = _ref8.destinationProduct,
309
+ destinationSubproduct = _ref8.destinationSubproduct,
310
+ location = _ref8.location;
311
+ var experienceId = id ? id : defaultId; // Start and fail the smart-link-rendered experience. If it has already
176
312
  // been started nothing happens.
177
- startUfoExperience('smart-link-rendered', id);
178
- failUfoExperience('smart-link-rendered', id);
179
- failUfoExperience('smart-link-authenticated', id);
180
- dispatchAnalytics(uiRenderFailedEvent(display, error, errorInfo));
313
+
314
+ startUfoExperience('smart-link-rendered', experienceId);
315
+ failUfoExperience('smart-link-rendered', experienceId);
316
+ failUfoExperience('smart-link-authenticated', experienceId);
317
+ dispatchAnalytics(applyCommonAttributes(uiRenderFailedEvent({
318
+ display: display,
319
+ error: error,
320
+ errorInfo: errorInfo,
321
+ extensionKey: extensionKey,
322
+ definitionId: definitionId,
323
+ resourceType: resourceType,
324
+ destinationProduct: destinationProduct,
325
+ destinationSubproduct: destinationSubproduct,
326
+ location: location
327
+ }), commonAttributes));
181
328
  },
182
329
 
183
330
  /**
@@ -188,11 +335,27 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
188
335
  * @param previewInvokeMethod How the preview was triggered.
189
336
  * @returns
190
337
  */
191
- hoverCardViewedEvent: function hoverCardViewedEvent(previewDisplay, previewInvokeMethod) {
192
- var id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultId;
193
- var definitionId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedDefinitionId;
194
- var extensionKey = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedExtensionKey;
195
- return dispatchAnalytics(uiHoverCardViewedEvent(id, previewDisplay, definitionId, extensionKey, previewInvokeMethod));
338
+ hoverCardViewedEvent: function hoverCardViewedEvent(_ref9) {
339
+ var previewDisplay = _ref9.previewDisplay,
340
+ previewInvokeMethod = _ref9.previewInvokeMethod,
341
+ id = _ref9.id,
342
+ extensionKey = _ref9.extensionKey,
343
+ definitionId = _ref9.definitionId,
344
+ resourceType = _ref9.resourceType,
345
+ destinationProduct = _ref9.destinationProduct,
346
+ destinationSubproduct = _ref9.destinationSubproduct,
347
+ location = _ref9.location;
348
+ return dispatchAnalytics(applyCommonAttributes(uiHoverCardViewedEvent({
349
+ id: id,
350
+ previewDisplay: previewDisplay,
351
+ extensionKey: extensionKey,
352
+ definitionId: definitionId,
353
+ resourceType: resourceType,
354
+ destinationProduct: destinationProduct,
355
+ destinationSubproduct: destinationSubproduct,
356
+ location: location,
357
+ previewInvokeMethod: previewInvokeMethod
358
+ }), commonAttributes));
196
359
  },
197
360
 
198
361
  /**
@@ -204,14 +367,32 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
204
367
  * @param previewInvokeMethod How the preview was triggered.
205
368
  * @returns
206
369
  */
207
- hoverCardDismissedEvent: function hoverCardDismissedEvent(previewDisplay, hoverTime, previewInvokeMethod) {
208
- var id = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : defaultId;
209
- var definitionId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedDefinitionId;
210
- var extensionKey = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : extractedExtensionKey;
211
- return dispatchAnalytics(uiHoverCardDismissedEvent(id, previewDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod));
370
+ hoverCardDismissedEvent: function hoverCardDismissedEvent(_ref10) {
371
+ var id = _ref10.id,
372
+ previewDisplay = _ref10.previewDisplay,
373
+ hoverTime = _ref10.hoverTime,
374
+ previewInvokeMethod = _ref10.previewInvokeMethod,
375
+ extensionKey = _ref10.extensionKey,
376
+ definitionId = _ref10.definitionId,
377
+ resourceType = _ref10.resourceType,
378
+ destinationProduct = _ref10.destinationProduct,
379
+ destinationSubproduct = _ref10.destinationSubproduct,
380
+ location = _ref10.location;
381
+ return dispatchAnalytics(applyCommonAttributes(uiHoverCardDismissedEvent({
382
+ previewDisplay: previewDisplay,
383
+ id: id,
384
+ hoverTime: hoverTime,
385
+ extensionKey: extensionKey,
386
+ definitionId: definitionId,
387
+ resourceType: resourceType,
388
+ destinationProduct: destinationProduct,
389
+ destinationSubproduct: destinationSubproduct,
390
+ location: location,
391
+ previewInvokeMethod: previewInvokeMethod
392
+ }), commonAttributes));
212
393
  }
213
394
  };
214
- }, [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics, defaultId, defaultLocation, extractedProduct, extractedSubproduct]);
395
+ }, [defaultId, commonAttributes, dispatchAnalytics]);
215
396
  /** Contains all operational analytics events */
216
397
 
217
398
  var operational = useMemo(function () {
@@ -223,13 +404,28 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
223
404
  * @param actionType The type of action invoked, e.g. PreviewAction
224
405
  * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
225
406
  */
226
- invokeSucceededEvent: function invokeSucceededEvent() {
227
- var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
228
- var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
229
- var actionType = arguments.length > 2 ? arguments[2] : undefined;
230
- var display = arguments.length > 3 ? arguments[3] : undefined;
407
+ invokeSucceededEvent: function invokeSucceededEvent(_ref11) {
408
+ var id = _ref11.id,
409
+ actionType = _ref11.actionType,
410
+ display = _ref11.display,
411
+ extensionKey = _ref11.extensionKey,
412
+ definitionId = _ref11.definitionId,
413
+ resourceType = _ref11.resourceType,
414
+ destinationProduct = _ref11.destinationProduct,
415
+ destinationSubproduct = _ref11.destinationSubproduct,
416
+ location = _ref11.location;
231
417
  succeedUfoExperience('smart-link-action-invocation', id);
232
- dispatchAnalytics(_invokeSucceededEvent(id, actionType, display, extensionKey));
418
+ dispatchAnalytics(applyCommonAttributes(_invokeSucceededEvent({
419
+ id: id,
420
+ actionType: actionType,
421
+ display: display,
422
+ extensionKey: extensionKey,
423
+ definitionId: definitionId,
424
+ resourceType: resourceType,
425
+ destinationProduct: destinationProduct,
426
+ destinationSubproduct: destinationSubproduct,
427
+ location: location
428
+ }), commonAttributes));
233
429
  },
234
430
 
235
431
  /**
@@ -240,14 +436,30 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
240
436
  * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
241
437
  * @param reason The reason the invocation failed.
242
438
  */
243
- invokeFailedEvent: function invokeFailedEvent() {
244
- var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
245
- var providerKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
246
- var actionType = arguments.length > 2 ? arguments[2] : undefined;
247
- var display = arguments.length > 3 ? arguments[3] : undefined;
248
- var reason = arguments.length > 4 ? arguments[4] : undefined;
439
+ invokeFailedEvent: function invokeFailedEvent(_ref12) {
440
+ var id = _ref12.id,
441
+ actionType = _ref12.actionType,
442
+ display = _ref12.display,
443
+ reason = _ref12.reason,
444
+ extensionKey = _ref12.extensionKey,
445
+ definitionId = _ref12.definitionId,
446
+ resourceType = _ref12.resourceType,
447
+ destinationProduct = _ref12.destinationProduct,
448
+ destinationSubproduct = _ref12.destinationSubproduct,
449
+ location = _ref12.location;
249
450
  failUfoExperience('smart-link-action-invocation', id);
250
- dispatchAnalytics(_invokeFailedEvent(id, actionType, display, reason, providerKey));
451
+ dispatchAnalytics(applyCommonAttributes(_invokeFailedEvent({
452
+ id: id,
453
+ actionType: actionType,
454
+ display: display,
455
+ reason: reason,
456
+ extensionKey: extensionKey,
457
+ definitionId: definitionId,
458
+ resourceType: resourceType,
459
+ destinationProduct: destinationProduct,
460
+ destinationSubproduct: destinationSubproduct,
461
+ location: location
462
+ }), commonAttributes));
251
463
  },
252
464
 
253
465
  /**
@@ -256,15 +468,28 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
256
468
  * @param definitionId The definitionId of the Smart Link resolver invoked.
257
469
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
258
470
  */
259
- connectSucceededEvent: function connectSucceededEvent() {
260
- var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
261
- var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
262
- var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
263
- startUfoExperience('smart-link-authenticated', id, {
471
+ connectSucceededEvent: function connectSucceededEvent(_ref13) {
472
+ var id = _ref13.id,
473
+ extensionKey = _ref13.extensionKey,
474
+ definitionId = _ref13.definitionId,
475
+ resourceType = _ref13.resourceType,
476
+ destinationProduct = _ref13.destinationProduct,
477
+ destinationSubproduct = _ref13.destinationSubproduct,
478
+ location = _ref13.location;
479
+ var experienceId = id ? id : defaultId;
480
+ startUfoExperience('smart-link-authenticated', experienceId, {
264
481
  extensionKey: extensionKey,
265
482
  status: 'success'
266
483
  });
267
- dispatchAnalytics(_connectSucceededEvent(definitionId, extensionKey));
484
+ dispatchAnalytics(applyCommonAttributes(_connectSucceededEvent(_objectSpread(_objectSpread({}, commonAttributes), {}, {
485
+ id: experienceId,
486
+ extensionKey: extensionKey,
487
+ definitionId: definitionId,
488
+ resourceType: resourceType,
489
+ destinationProduct: destinationProduct,
490
+ destinationSubproduct: destinationSubproduct,
491
+ location: location
492
+ })), commonAttributes));
268
493
  },
269
494
 
270
495
  /**
@@ -274,16 +499,30 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
274
499
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
275
500
  * @param reason The reason why the Smart Link connect account failed.
276
501
  */
277
- connectFailedEvent: function connectFailedEvent() {
278
- var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
279
- var definitionId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedDefinitionId;
280
- var extensionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedExtensionKey;
281
- var reason = arguments.length > 3 ? arguments[3] : undefined;
282
- startUfoExperience('smart-link-authenticated', id, {
502
+ connectFailedEvent: function connectFailedEvent(_ref14) {
503
+ var id = _ref14.id,
504
+ reason = _ref14.reason,
505
+ extensionKey = _ref14.extensionKey,
506
+ definitionId = _ref14.definitionId,
507
+ resourceType = _ref14.resourceType,
508
+ destinationProduct = _ref14.destinationProduct,
509
+ destinationSubproduct = _ref14.destinationSubproduct,
510
+ location = _ref14.location;
511
+ var experienceId = id ? id : defaultId;
512
+ startUfoExperience('smart-link-authenticated', experienceId, {
283
513
  extensionKey: extensionKey,
284
514
  status: reason
285
515
  });
286
- dispatchAnalytics(_connectFailedEvent(definitionId, extensionKey, reason));
516
+ dispatchAnalytics(applyCommonAttributes(_connectFailedEvent(_objectSpread(_objectSpread({}, commonAttributes), {}, {
517
+ id: experienceId,
518
+ reason: reason,
519
+ extensionKey: extensionKey,
520
+ definitionId: definitionId,
521
+ resourceType: resourceType,
522
+ destinationProduct: destinationProduct,
523
+ destinationSubproduct: destinationSubproduct,
524
+ location: location
525
+ })), commonAttributes));
287
526
  },
288
527
 
289
528
  /**
@@ -295,21 +534,34 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
295
534
  * @param resourceType The type of resource that was invoked. This is provider specific (e.g. File, PullRequest).
296
535
  * @param error An error representing why the Smart Link request failed.
297
536
  */
298
- instrument: function instrument() {
299
- var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultId;
300
- var status = arguments.length > 1 ? arguments[1] : undefined;
301
- var definitionId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extractedDefinitionId;
302
- var extensionKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : extractedExtensionKey;
303
- var resourceType = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : extractedResourceType;
304
- var error = arguments.length > 5 ? arguments[5] : undefined;
305
- var event = instrumentEvent(id, status, definitionId, extensionKey, resourceType, error);
537
+ instrument: function instrument(_ref15) {
538
+ var id = _ref15.id,
539
+ status = _ref15.status,
540
+ extensionKey = _ref15.extensionKey,
541
+ definitionId = _ref15.definitionId,
542
+ resourceType = _ref15.resourceType,
543
+ destinationProduct = _ref15.destinationProduct,
544
+ destinationSubproduct = _ref15.destinationSubproduct,
545
+ location = _ref15.location,
546
+ error = _ref15.error;
547
+ var event = instrumentEvent(_objectSpread(_objectSpread({}, commonAttributes), {}, {
548
+ id: id,
549
+ status: status,
550
+ extensionKey: extensionKey,
551
+ definitionId: definitionId,
552
+ resourceType: resourceType,
553
+ destinationProduct: destinationProduct,
554
+ destinationSubproduct: destinationSubproduct,
555
+ location: location,
556
+ error: error
557
+ }));
306
558
 
307
559
  if (event) {
308
- dispatchAnalytics(event);
560
+ dispatchAnalytics(applyCommonAttributes(event, commonAttributes));
309
561
  }
310
562
  }
311
563
  };
312
- }, [defaultId, extractedResourceType, extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
564
+ }, [defaultId, commonAttributes, dispatchAnalytics]);
313
565
  /** Contains all track analytics events */
314
566
 
315
567
  var track = useMemo(function () {
@@ -320,13 +572,24 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
320
572
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
321
573
  * @returns
322
574
  */
323
- appAccountConnected: function appAccountConnected() {
324
- var definitionId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : extractedDefinitionId;
325
- var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
326
- return dispatchAnalytics(trackAppAccountConnected(definitionId, extensionKey));
575
+ appAccountConnected: function appAccountConnected(_ref16) {
576
+ var extensionKey = _ref16.extensionKey,
577
+ definitionId = _ref16.definitionId,
578
+ resourceType = _ref16.resourceType,
579
+ destinationProduct = _ref16.destinationProduct,
580
+ destinationSubproduct = _ref16.destinationSubproduct,
581
+ location = _ref16.location;
582
+ return dispatchAnalytics(applyCommonAttributes(trackAppAccountConnected(_objectSpread(_objectSpread({}, commonAttributes), {}, {
583
+ extensionKey: extensionKey,
584
+ definitionId: definitionId,
585
+ resourceType: resourceType,
586
+ destinationProduct: destinationProduct,
587
+ destinationSubproduct: destinationSubproduct,
588
+ location: location
589
+ })), commonAttributes));
327
590
  }
328
591
  };
329
- }, [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
592
+ }, [commonAttributes, dispatchAnalytics]);
330
593
  /** Contains all screen analytics events */
331
594
 
332
595
  var screen = useMemo(function () {
@@ -337,13 +600,24 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, dispatchA
337
600
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
338
601
  * @returns
339
602
  */
340
- authPopupEvent: function authPopupEvent() {
341
- var definitionId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : extractedDefinitionId;
342
- var extensionKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : extractedExtensionKey;
343
- return dispatchAnalytics(screenAuthPopupEvent(definitionId, extensionKey));
603
+ authPopupEvent: function authPopupEvent(_ref17) {
604
+ var extensionKey = _ref17.extensionKey,
605
+ definitionId = _ref17.definitionId,
606
+ resourceType = _ref17.resourceType,
607
+ destinationProduct = _ref17.destinationProduct,
608
+ destinationSubproduct = _ref17.destinationSubproduct,
609
+ location = _ref17.location;
610
+ return dispatchAnalytics(applyCommonAttributes(screenAuthPopupEvent(_objectSpread(_objectSpread({}, commonAttributes), {}, {
611
+ extensionKey: extensionKey,
612
+ definitionId: definitionId,
613
+ resourceType: resourceType,
614
+ destinationProduct: destinationProduct,
615
+ destinationSubproduct: destinationSubproduct,
616
+ location: location
617
+ })), commonAttributes));
344
618
  }
345
619
  };
346
- }, [extractedDefinitionId, extractedExtensionKey, dispatchAnalytics]);
620
+ }, [commonAttributes, dispatchAnalytics]);
347
621
  return useMemo(function () {
348
622
  return {
349
623
  ui: ui,