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