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