@atlaskit/smart-card 21.1.4 → 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 (105) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/cjs/extractors/block/index.js +3 -2
  3. package/dist/cjs/extractors/common/actions/extractPreviewAction.js +12 -2
  4. package/dist/cjs/state/actions/index.js +54 -10
  5. package/dist/cjs/state/analytics/types.js +5 -0
  6. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +386 -109
  7. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +12 -2
  8. package/dist/cjs/utils/analytics/analytics.js +239 -72
  9. package/dist/cjs/utils/analytics/index.js +32 -5
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/cjs/view/BlockCard/actions/PreviewAction.js +1 -1
  12. package/dist/cjs/view/BlockCard/index.js +10 -0
  13. package/dist/cjs/view/CardWithUrl/component.js +26 -4
  14. package/dist/cjs/view/CardWithUrl/loader.js +6 -1
  15. package/dist/cjs/view/EmbedModal/components/size-experiment/index.js +41 -0
  16. package/dist/cjs/view/EmbedModal/components/size-experiment/types.js +5 -0
  17. package/dist/cjs/view/EmbedModal/index.js +7 -3
  18. package/dist/cjs/view/FlexibleCard/components/blocks/block/index.js +17 -3
  19. package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/index.js +5 -2
  20. package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +20 -8
  21. package/dist/cjs/view/FlexibleCard/components/common/image-icon/index.js +4 -2
  22. package/dist/cjs/view/FlexibleCard/components/common/loading-skeleton/index.js +1 -2
  23. package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +5 -2
  24. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +9 -2
  25. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +36 -8
  26. package/dist/cjs/view/HoverCard/components/SnippetOrPreview.js +74 -0
  27. package/dist/cjs/view/HoverCard/index.js +6 -1
  28. package/dist/cjs/view/HoverCard/styled.js +11 -3
  29. package/dist/es2019/extractors/block/index.js +2 -1
  30. package/dist/es2019/extractors/common/actions/extractPreviewAction.js +12 -3
  31. package/dist/es2019/state/actions/index.js +54 -10
  32. package/dist/es2019/state/analytics/types.js +1 -0
  33. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +379 -39
  34. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +11 -2
  35. package/dist/es2019/utils/analytics/analytics.js +253 -78
  36. package/dist/es2019/utils/analytics/index.js +32 -4
  37. package/dist/es2019/version.json +1 -1
  38. package/dist/es2019/view/BlockCard/actions/PreviewAction.js +1 -1
  39. package/dist/es2019/view/BlockCard/index.js +9 -0
  40. package/dist/es2019/view/CardWithUrl/component.js +26 -4
  41. package/dist/es2019/view/CardWithUrl/loader.js +6 -1
  42. package/dist/es2019/view/EmbedModal/components/size-experiment/index.js +28 -0
  43. package/dist/es2019/view/EmbedModal/components/size-experiment/types.js +1 -0
  44. package/dist/es2019/view/EmbedModal/index.js +5 -3
  45. package/dist/es2019/view/FlexibleCard/components/blocks/block/index.js +17 -7
  46. package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/index.js +4 -1
  47. package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +17 -6
  48. package/dist/es2019/view/FlexibleCard/components/common/image-icon/index.js +4 -2
  49. package/dist/es2019/view/FlexibleCard/components/common/loading-skeleton/index.js +2 -3
  50. package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +5 -2
  51. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +9 -2
  52. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +36 -10
  53. package/dist/es2019/view/HoverCard/components/SnippetOrPreview.js +42 -0
  54. package/dist/es2019/view/HoverCard/index.js +6 -1
  55. package/dist/es2019/view/HoverCard/styled.js +8 -0
  56. package/dist/esm/extractors/block/index.js +3 -2
  57. package/dist/esm/extractors/common/actions/extractPreviewAction.js +12 -2
  58. package/dist/esm/state/actions/index.js +54 -10
  59. package/dist/esm/state/analytics/types.js +1 -0
  60. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +383 -109
  61. package/dist/esm/state/hooks-external/useSmartLinkActions.js +11 -2
  62. package/dist/esm/utils/analytics/analytics.js +239 -72
  63. package/dist/esm/utils/analytics/index.js +31 -4
  64. package/dist/esm/version.json +1 -1
  65. package/dist/esm/view/BlockCard/actions/PreviewAction.js +1 -1
  66. package/dist/esm/view/BlockCard/index.js +9 -0
  67. package/dist/esm/view/CardWithUrl/component.js +26 -4
  68. package/dist/esm/view/CardWithUrl/loader.js +6 -1
  69. package/dist/esm/view/EmbedModal/components/size-experiment/index.js +28 -0
  70. package/dist/esm/view/EmbedModal/components/size-experiment/types.js +1 -0
  71. package/dist/esm/view/EmbedModal/index.js +6 -3
  72. package/dist/esm/view/FlexibleCard/components/blocks/block/index.js +11 -3
  73. package/dist/esm/view/FlexibleCard/components/blocks/preview-block/index.js +5 -2
  74. package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +18 -8
  75. package/dist/esm/view/FlexibleCard/components/common/image-icon/index.js +4 -2
  76. package/dist/esm/view/FlexibleCard/components/common/loading-skeleton/index.js +1 -2
  77. package/dist/esm/view/FlexibleCard/components/elements/media/index.js +5 -2
  78. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +9 -2
  79. package/dist/esm/view/HoverCard/components/HoverCardContent.js +36 -10
  80. package/dist/esm/view/HoverCard/components/SnippetOrPreview.js +53 -0
  81. package/dist/esm/view/HoverCard/index.js +6 -1
  82. package/dist/esm/view/HoverCard/styled.js +6 -2
  83. package/dist/types/extractors/block/types.d.ts +2 -0
  84. package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +2 -1
  85. package/dist/types/state/analytics/types.d.ts +9 -0
  86. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +18 -23
  87. package/dist/types/state/hooks/useSmartLink.d.ts +17 -18
  88. package/dist/types/utils/analytics/analytics.d.ts +19 -21
  89. package/dist/types/utils/analytics/index.d.ts +2 -2
  90. package/dist/types/utils/analytics/types.d.ts +91 -0
  91. package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +4 -2
  92. package/dist/types/view/Card/index.d.ts +1 -1
  93. package/dist/types/view/EmbedModal/components/size-experiment/index.d.ts +6 -0
  94. package/dist/types/view/EmbedModal/components/size-experiment/types.d.ts +4 -0
  95. package/dist/types/view/EmbedModal/index.d.ts +1 -1
  96. package/dist/types/view/EmbedModal/types.d.ts +4 -0
  97. package/dist/types/view/FlexibleCard/components/blocks/preview-block/types.d.ts +7 -1
  98. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +15 -0
  99. package/dist/types/view/FlexibleCard/components/common/image-icon/types.d.ts +1 -0
  100. package/dist/types/view/FlexibleCard/components/elements/media/types.d.ts +5 -0
  101. package/dist/types/view/HoverCard/components/SnippetOrPreview.d.ts +4 -0
  102. package/dist/types/view/HoverCard/styled.d.ts +2 -0
  103. package/dist/types/view/HoverCard/types.d.ts +5 -0
  104. package/package.json +2 -2
  105. package/report.api.md +294 -110
@@ -1,5 +1,6 @@
1
1
  import { useEffect, useMemo, useState } from 'react';
2
2
  import uuid from 'uuid';
3
+ import { useFeatureFlag } from '@atlaskit/link-provider';
3
4
  import { extractBlockProps as extractCardProps } from '../../extractors/block';
4
5
  import { useSmartCardActions as useLinkActions } from '../actions';
5
6
  import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
@@ -15,13 +16,21 @@ export function useSmartLinkActions({
15
16
  const [actions, setActions] = useState([]);
16
17
  const linkState = useLinkState(url);
17
18
  const linkAnalytics = useLinkAnalytics(url, analyticsHandler, id);
18
- const linkActions = useLinkActions(id, url, linkAnalytics);
19
+ const linkActions = useLinkActions(id, url, linkAnalytics); // Actions do not have access to the react tree, so we need to obtain
20
+ // feature flags here where we still can access SmartLinkContext context
21
+ // and pass the flags down to the extractor. See PreviewAction.tsx for details.
22
+
23
+ const embedModalSize = useFeatureFlag('embedModalSize');
19
24
  useEffect(() => {
20
25
  if (!linkState.details) {
21
26
  return;
22
27
  }
23
28
 
29
+ const featureFlags = {
30
+ embedModalSize
31
+ };
24
32
  const cardProperties = extractCardProps(linkState.details.data, linkState.details.meta, {
33
+ featureFlags,
25
34
  handleInvoke: opts => linkActions.invoke(opts, appearance),
26
35
  handleAnalytics: analyticsHandler,
27
36
  extensionKey: getExtensionKey(linkState.details),
@@ -38,6 +47,6 @@ export function useSmartLinkActions({
38
47
  invoke: action.promise
39
48
  }));
40
49
  setActions(cardActions);
41
- }, [linkState, linkActions, analyticsHandler, appearance, platform]);
50
+ }, [linkState, linkActions, analyticsHandler, appearance, platform, embedModalSize]);
42
51
  return actions;
43
52
  }
@@ -32,25 +32,25 @@ export const fireSmartLinkEvent = (payload, createAnalyticsEvent) => {
32
32
  createAnalyticsEvent(payload).fire(ANALYTICS_CHANNEL);
33
33
  }
34
34
  };
35
- export const resolvedEvent = (id, definitionId, extensionKey, resourceType) => ({
35
+ export const resolvedEvent = props => ({
36
36
  action: 'resolved',
37
37
  actionSubject: 'smartLink',
38
38
  eventType: 'operational',
39
- attributes: {
40
- id,
41
- ...context,
42
- ...(definitionId ? {
43
- definitionId
44
- } : {}),
45
- ...(extensionKey ? {
46
- extensionKey
47
- } : {}),
48
- ...(resourceType ? {
49
- resourceType
50
- } : {})
39
+ attributes: { ...props,
40
+ ...context
51
41
  }
52
42
  });
53
- export const unresolvedEvent = (id, status, definitionId, extensionKey, resourceType, error) => ({
43
+ export const unresolvedEvent = ({
44
+ id,
45
+ definitionId,
46
+ extensionKey,
47
+ resourceType,
48
+ destinationSubproduct,
49
+ destinationProduct,
50
+ error,
51
+ status,
52
+ location
53
+ }) => ({
54
54
  action: 'unresolved',
55
55
  actionSubject: 'smartLink',
56
56
  eventType: 'operational',
@@ -66,15 +66,33 @@ export const unresolvedEvent = (id, status, definitionId, extensionKey, resource
66
66
  ...(resourceType ? {
67
67
  resourceType
68
68
  } : {}),
69
+ ...(destinationSubproduct ? {
70
+ destinationSubproduct
71
+ } : {}),
72
+ ...(destinationProduct ? {
73
+ destinationProduct
74
+ } : {}),
75
+ ...(location ? {
76
+ location
77
+ } : {}),
69
78
  reason: status,
70
79
  error: error ? {
71
- message: error.message,
72
- kind: error.kind,
73
- type: error.type
80
+ message: error === null || error === void 0 ? void 0 : error.message,
81
+ kind: error === null || error === void 0 ? void 0 : error.kind,
82
+ type: error === null || error === void 0 ? void 0 : error.type
74
83
  } : undefined
75
84
  }
76
85
  });
77
- export const invokeSucceededEvent = (id, actionType, display, extensionKey) => {
86
+ export const invokeSucceededEvent = ({
87
+ id,
88
+ actionType,
89
+ display,
90
+ extensionKey,
91
+ definitionId,
92
+ destinationProduct,
93
+ destinationSubproduct,
94
+ location
95
+ }) => {
78
96
  const measure = getMeasure(id, 'resolved') || {
79
97
  duration: undefined
80
98
  };
@@ -86,12 +104,26 @@ export const invokeSucceededEvent = (id, actionType, display, extensionKey) => {
86
104
  id,
87
105
  actionType,
88
106
  display,
89
- extensionKey: extensionKey || '',
107
+ definitionId,
108
+ destinationProduct,
109
+ destinationSubproduct,
110
+ location,
111
+ extensionKey,
90
112
  duration: measure.duration
91
113
  }
92
114
  };
93
115
  };
94
- export const invokeFailedEvent = (id, actionType, display, reason, extensionKey) => {
116
+ export const invokeFailedEvent = ({
117
+ id,
118
+ actionType,
119
+ display,
120
+ reason,
121
+ extensionKey,
122
+ definitionId,
123
+ destinationProduct,
124
+ destinationSubproduct,
125
+ location
126
+ }) => {
95
127
  const measure = getMeasure(id, 'errored') || {
96
128
  duration: undefined
97
129
  };
@@ -103,78 +135,127 @@ export const invokeFailedEvent = (id, actionType, display, reason, extensionKey)
103
135
  id,
104
136
  actionType,
105
137
  display,
106
- extensionKey: extensionKey || '',
138
+ extensionKey,
139
+ definitionId,
140
+ destinationProduct,
141
+ destinationSubproduct,
142
+ location,
107
143
  duration: measure.duration,
108
144
  reason
109
145
  }
110
146
  };
111
147
  };
112
- export const connectSucceededEvent = (definitionId, extensionKey) => ({
148
+ export const connectSucceededEvent = ({
149
+ definitionId,
150
+ extensionKey,
151
+ destinationProduct,
152
+ destinationSubproduct,
153
+ location
154
+ }) => ({
113
155
  action: 'connectSucceeded',
114
156
  actionSubject: 'smartLink',
115
157
  eventType: 'operational',
116
158
  attributes: { ...context,
117
- ...(definitionId ? {
118
- definitionId
119
- } : {}),
120
- ...(extensionKey ? {
121
- extensionKey
122
- } : {})
159
+ definitionId,
160
+ extensionKey,
161
+ destinationProduct,
162
+ destinationSubproduct,
163
+ location
123
164
  }
124
165
  });
125
- export const connectFailedEvent = (definitionId, extensionKey, reason) => ({
166
+ export const connectFailedEvent = ({
167
+ definitionId,
168
+ extensionKey,
169
+ destinationProduct,
170
+ destinationSubproduct,
171
+ location,
172
+ reason
173
+ }) => ({
126
174
  action: 'connectFailed',
127
175
  actionSubject: 'smartLink',
128
176
  actionSubjectId: reason,
129
177
  eventType: 'operational',
130
178
  attributes: { ...context,
131
- ...(reason ? {
132
- reason: reason
133
- } : {}),
134
- ...(definitionId ? {
135
- definitionId
136
- } : {}),
137
- ...(extensionKey ? {
138
- extensionKey
139
- } : {})
179
+ reason,
180
+ extensionKey,
181
+ definitionId,
182
+ destinationProduct,
183
+ destinationSubproduct,
184
+ location
140
185
  }
141
186
  });
142
- export const trackAppAccountConnected = (definitionId, extensionKey) => ({
187
+ export const trackAppAccountConnected = ({
188
+ definitionId,
189
+ extensionKey,
190
+ destinationProduct,
191
+ destinationSubproduct,
192
+ location
193
+ }) => ({
143
194
  action: 'connected',
144
195
  actionSubject: 'applicationAccount',
145
196
  eventType: 'track',
146
197
  attributes: { ...context,
147
- ...(definitionId ? {
148
- definitionId
149
- } : {}),
150
- ...(extensionKey ? {
151
- extensionKey
152
- } : {})
198
+ definitionId,
199
+ extensionKey,
200
+ destinationProduct,
201
+ destinationSubproduct,
202
+ location
153
203
  }
154
204
  });
155
- export const uiAuthEvent = (display, definitionId, extensionKey) => ({
205
+ export const uiAuthEvent = ({
206
+ definitionId,
207
+ extensionKey,
208
+ destinationProduct,
209
+ destinationSubproduct,
210
+ location,
211
+ display
212
+ }) => ({
156
213
  action: 'clicked',
157
214
  actionSubject: 'button',
158
215
  actionSubjectId: 'connectAccount',
159
216
  eventType: 'ui',
160
217
  attributes: { ...context,
161
- definitionId: definitionId || '',
162
- extensionKey: extensionKey || '',
218
+ definitionId,
219
+ extensionKey,
220
+ destinationProduct,
221
+ destinationSubproduct,
222
+ location,
163
223
  display
164
224
  }
165
225
  });
166
- export const uiAuthAlternateAccountEvent = (display, definitionId, extensionKey) => ({
226
+ export const uiAuthAlternateAccountEvent = ({
227
+ definitionId,
228
+ extensionKey,
229
+ destinationProduct,
230
+ destinationSubproduct,
231
+ location,
232
+ display
233
+ }) => ({
167
234
  action: 'clicked',
168
235
  actionSubject: 'smartLink',
169
236
  actionSubjectId: 'tryAnotherAccount',
170
237
  eventType: 'ui',
171
238
  attributes: { ...context,
172
- definitionId: definitionId || '',
173
- extensionKey: extensionKey || '',
239
+ definitionId,
240
+ extensionKey,
241
+ destinationProduct,
242
+ destinationSubproduct,
243
+ location,
174
244
  display
175
245
  }
176
246
  });
177
- export const uiCardClickedEvent = (id, display, status, definitionId, extensionKey, isModifierKeyPressed, location, destinationProduct, destinationSubproduct, actionSubjectId) => ({
247
+ export const uiCardClickedEvent = ({
248
+ id,
249
+ display,
250
+ status,
251
+ definitionId,
252
+ extensionKey,
253
+ isModifierKeyPressed,
254
+ location,
255
+ destinationProduct,
256
+ destinationSubproduct,
257
+ actionSubjectId
258
+ }) => ({
178
259
  action: 'clicked',
179
260
  actionSubject: 'smartLink',
180
261
  actionSubjectId,
@@ -182,8 +263,8 @@ export const uiCardClickedEvent = (id, display, status, definitionId, extensionK
182
263
  attributes: { ...context,
183
264
  id,
184
265
  status,
185
- definitionId: definitionId || '',
186
- extensionKey: extensionKey || '',
266
+ definitionId,
267
+ extensionKey,
187
268
  display,
188
269
  isModifierKeyPressed,
189
270
  location,
@@ -191,7 +272,16 @@ export const uiCardClickedEvent = (id, display, status, definitionId, extensionK
191
272
  destinationSubproduct
192
273
  }
193
274
  });
194
- export const uiActionClickedEvent = (id, actionType, extensionKey, display) => ({
275
+ export const uiActionClickedEvent = ({
276
+ id,
277
+ actionType,
278
+ extensionKey,
279
+ display,
280
+ definitionId,
281
+ destinationProduct,
282
+ destinationSubproduct,
283
+ location
284
+ }) => ({
195
285
  action: 'clicked',
196
286
  actionSubject: 'button',
197
287
  actionSubjectId: uiActionSubjectIds[actionType],
@@ -199,84 +289,169 @@ export const uiActionClickedEvent = (id, actionType, extensionKey, display) => (
199
289
  attributes: { ...context,
200
290
  id,
201
291
  display,
202
- extensionKey: extensionKey || '',
203
- actionType: actionType
292
+ actionType: actionType,
293
+ extensionKey: extensionKey,
294
+ definitionId,
295
+ destinationProduct,
296
+ destinationSubproduct,
297
+ location
204
298
  }
205
299
  });
206
- export const uiClosedAuthEvent = (display, definitionId, extensionKey) => ({
300
+ export const uiClosedAuthEvent = ({
301
+ display,
302
+ extensionKey,
303
+ definitionId,
304
+ destinationProduct,
305
+ destinationSubproduct,
306
+ location
307
+ }) => ({
207
308
  action: 'closed',
208
309
  actionSubject: 'consentModal',
209
310
  eventType: 'ui',
210
311
  attributes: { ...context,
211
- definitionId: definitionId || '',
212
- extensionKey: extensionKey || '',
312
+ extensionKey,
313
+ definitionId,
314
+ destinationProduct,
315
+ destinationSubproduct,
316
+ location,
213
317
  display
214
318
  }
215
319
  });
216
- export const screenAuthPopupEvent = (definitionId, extensionKey) => ({
320
+ export const screenAuthPopupEvent = ({
321
+ extensionKey,
322
+ definitionId,
323
+ destinationProduct,
324
+ destinationSubproduct,
325
+ location
326
+ }) => ({
217
327
  actionSubject: 'consentModal',
218
328
  eventType: 'screen',
219
329
  attributes: { ...context,
220
- definitionId: definitionId || '',
221
- extensionKey: extensionKey || ''
330
+ extensionKey,
331
+ definitionId,
332
+ destinationProduct,
333
+ destinationSubproduct,
334
+ location
222
335
  }
223
336
  });
224
- export const uiRenderSuccessEvent = (display, status, definitionId, extensionKey) => ({
337
+ export const uiRenderSuccessEvent = ({
338
+ display,
339
+ status,
340
+ extensionKey,
341
+ definitionId,
342
+ destinationProduct,
343
+ destinationSubproduct,
344
+ location
345
+ }) => ({
225
346
  action: 'renderSuccess',
226
347
  actionSubject: 'smartLink',
227
348
  eventType: 'ui',
228
349
  attributes: { ...context,
229
350
  status,
230
- definitionId: definitionId || '',
231
- extensionKey: extensionKey || '',
351
+ extensionKey,
352
+ definitionId,
353
+ destinationProduct,
354
+ destinationSubproduct,
355
+ location,
232
356
  display
233
357
  }
234
358
  });
235
- export const uiRenderFailedEvent = (display, error, errorInfo) => ({
359
+ export const uiRenderFailedEvent = ({
360
+ display,
361
+ error,
362
+ errorInfo,
363
+ extensionKey,
364
+ definitionId,
365
+ destinationProduct,
366
+ destinationSubproduct,
367
+ location
368
+ }) => ({
236
369
  actionSubject: 'smartLink',
237
370
  action: 'renderFailed',
238
371
  eventType: 'ui',
239
372
  attributes: {
240
373
  error,
241
374
  errorInfo,
242
- display
375
+ display,
376
+ extensionKey,
377
+ definitionId,
378
+ destinationProduct,
379
+ destinationSubproduct,
380
+ location
243
381
  }
244
382
  });
245
- export const uiHoverCardViewedEvent = (id, previewDisplay, definitionId, extensionKey, previewInvokeMethod) => ({
383
+ export const uiHoverCardViewedEvent = ({
384
+ id,
385
+ previewDisplay,
386
+ extensionKey,
387
+ definitionId,
388
+ destinationProduct,
389
+ destinationSubproduct,
390
+ location,
391
+ previewInvokeMethod
392
+ }) => ({
246
393
  action: 'viewed',
247
394
  actionSubject: 'hoverCard',
248
395
  eventType: 'ui',
249
396
  attributes: { ...context,
250
397
  id,
251
- definitionId: definitionId || '',
252
- extensionKey: extensionKey || '',
253
398
  previewDisplay,
399
+ extensionKey,
400
+ definitionId,
401
+ destinationProduct,
402
+ destinationSubproduct,
403
+ location,
254
404
  previewInvokeMethod
255
405
  }
256
406
  });
257
- export const uiHoverCardDismissedEvent = (id, previewDisplay, hoverTime, definitionId, extensionKey, previewInvokeMethod) => ({
407
+ export const uiHoverCardDismissedEvent = ({
408
+ id,
409
+ previewDisplay,
410
+ hoverTime,
411
+ extensionKey,
412
+ definitionId,
413
+ destinationProduct,
414
+ destinationSubproduct,
415
+ location,
416
+ previewInvokeMethod
417
+ }) => ({
258
418
  action: 'dismissed',
259
419
  actionSubject: 'hoverCard',
260
420
  eventType: 'ui',
261
421
  attributes: { ...context,
262
422
  id,
263
- definitionId: definitionId || '',
264
- extensionKey: extensionKey || '',
265
- hoverTime,
266
423
  previewDisplay,
424
+ hoverTime,
425
+ extensionKey,
426
+ definitionId,
427
+ destinationProduct,
428
+ destinationSubproduct,
429
+ location,
267
430
  previewInvokeMethod
268
431
  }
269
432
  });
270
- export const uiHoverCardOpenLinkClickedEvent = (id, previewDisplay, definitionId, extensionKey, previewInvokeMethod) => ({
433
+ export const uiHoverCardOpenLinkClickedEvent = ({
434
+ id,
435
+ previewDisplay,
436
+ extensionKey,
437
+ definitionId,
438
+ destinationProduct,
439
+ destinationSubproduct,
440
+ location,
441
+ previewInvokeMethod
442
+ }) => ({
271
443
  action: 'clicked',
272
444
  actionSubject: 'button',
273
445
  actionSubjectId: 'shortcutGoToLink',
274
446
  eventType: 'ui',
275
447
  attributes: { ...context,
276
448
  id,
277
- definitionId: definitionId || '',
278
- extensionKey: extensionKey || '',
279
449
  previewDisplay,
450
+ extensionKey,
451
+ definitionId,
452
+ destinationProduct,
453
+ destinationSubproduct,
454
+ location,
280
455
  previewInvokeMethod
281
456
  }
282
457
  });
@@ -1,13 +1,31 @@
1
- import { resolvedEvent, unresolvedEvent } from './analytics';
2
1
  import { getMeasure } from '../performance';
2
+ import { resolvedEvent, unresolvedEvent } from './analytics';
3
3
  export { ANALYTICS_CHANNEL, context, fireSmartLinkEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountConnected, uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, screenAuthPopupEvent, uiRenderSuccessEvent, uiRenderFailedEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent } from './analytics';
4
- export const instrumentEvent = (id, status, definitionId, extensionKey, resourceType, error) => {
4
+ export const instrumentEvent = ({
5
+ id,
6
+ status,
7
+ extensionKey,
8
+ definitionId,
9
+ resourceType,
10
+ destinationProduct,
11
+ destinationSubproduct,
12
+ location,
13
+ error
14
+ }) => {
5
15
  const measure = getMeasure(id, status) || {
6
16
  duration: undefined
7
17
  };
8
18
 
9
19
  if (status === 'resolved') {
10
- const event = resolvedEvent(id, definitionId, extensionKey, resourceType);
20
+ const event = resolvedEvent({
21
+ id,
22
+ extensionKey,
23
+ definitionId,
24
+ resourceType,
25
+ destinationProduct,
26
+ destinationSubproduct,
27
+ location
28
+ });
11
29
  return { ...event,
12
30
  attributes: { ...event.attributes,
13
31
  duration: measure.duration
@@ -15,7 +33,17 @@ export const instrumentEvent = (id, status, definitionId, extensionKey, resource
15
33
  };
16
34
  } else {
17
35
  if ((error === null || error === void 0 ? void 0 : error.type) !== 'ResolveUnsupportedError') {
18
- const event = unresolvedEvent(id, status, definitionId, extensionKey, resourceType, error);
36
+ const event = unresolvedEvent({
37
+ id,
38
+ status,
39
+ extensionKey,
40
+ definitionId,
41
+ resourceType,
42
+ destinationProduct,
43
+ destinationSubproduct,
44
+ location,
45
+ error
46
+ });
19
47
  return { ...event,
20
48
  attributes: { ...event.attributes,
21
49
  duration: measure.duration
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "21.1.4",
3
+ "version": "22.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -32,7 +32,7 @@ export async function previewFunction({
32
32
  document.body.appendChild(popupMountPoint);
33
33
  }
34
34
 
35
- let Modal = await import('../../common/Modal');
35
+ let Modal = await import('../../EmbedModal');
36
36
  ReactDOM.render( /*#__PURE__*/React.createElement(IntlProvider, {
37
37
  locale: "en"
38
38
  }, /*#__PURE__*/React.createElement(Modal.default, _extends({}, rest, {
@@ -14,6 +14,7 @@ import { ResolvingView as BlockCardResolvingView } from './views/ResolvingView';
14
14
  import { UnauthorizedView as BlockCardUnauthorisedView } from './views/UnauthorizedView';
15
15
  import { ForbiddenView as BlockCardForbiddenView } from './views/ForbiddenView';
16
16
  import { ErroredView as BlockCardErroredView } from './views/ErroredView';
17
+ import { useFeatureFlag } from '@atlaskit/link-provider';
17
18
  export { ForbiddenAction, AuthorizeAction, BlockCardResolvedView, BlockCardResolvingView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardErroredView, BlockCardNotFoundView };
18
19
  export const BlockCard = ({
19
20
  url,
@@ -37,9 +38,17 @@ export const BlockCard = ({
37
38
  }) => {
38
39
  var _details$meta, _forbiddenViewProps$c;
39
40
 
41
+ // Actions do not have access to the react tree, so we need to obtain
42
+ // feature flags here where we still can access SmartLinkContext context
43
+ // and pass the flags down to the extractor. See PreviewAction.tsx for details.
44
+ const embedModalSize = useFeatureFlag('embedModalSize');
45
+ const featureFlags = {
46
+ embedModalSize
47
+ };
40
48
  const data = details && details.data || getEmptyJsonLd();
41
49
  const meta = details && details.meta;
42
50
  const extractorOpts = {
51
+ featureFlags,
43
52
  handleAnalytics,
44
53
  handleInvoke,
45
54
  extensionKey: getExtensionKey(details)
@@ -51,7 +51,7 @@ export function CardWithUrlContent({
51
51
  const showHoverPreviewFlag = useFeatureFlag('showHoverPreview');
52
52
 
53
53
  if (showHoverPreview === undefined && showHoverPreviewFlag !== undefined) {
54
- showHoverPreview = showHoverPreviewFlag;
54
+ showHoverPreview = Boolean(showHoverPreviewFlag);
55
55
  } // Setup UI handlers.
56
56
 
57
57
 
@@ -61,7 +61,16 @@ export function CardWithUrlContent({
61
61
  }, [state.details, url]);
62
62
  const handleClickWrapper = useCallback(event => {
63
63
  const isModifierKeyPressed = isSpecialEvent(event);
64
- analytics.ui.cardClickedEvent(id, isFlexibleUi ? 'flexible' : appearance, state.status, definitionId, extensionKey, isModifierKeyPressed, undefined, product, subproduct);
64
+ analytics.ui.cardClickedEvent({
65
+ id,
66
+ display: isFlexibleUi ? 'flexible' : appearance,
67
+ status: state.status,
68
+ definitionId,
69
+ extensionKey,
70
+ isModifierKeyPressed,
71
+ destinationProduct: product,
72
+ destinationSubproduct: subproduct
73
+ });
65
74
 
66
75
  if (onClick) {
67
76
  onClick(event);
@@ -81,7 +90,14 @@ export function CardWithUrlContent({
81
90
 
82
91
  if (state.status !== 'pending') {
83
92
  measure.create(id, state.status);
84
- analytics.operational.instrument(id, state.status, definitionId, extensionKey, resourceType, state.error);
93
+ analytics.operational.instrument({
94
+ id,
95
+ status: state.status,
96
+ definitionId,
97
+ extensionKey,
98
+ resourceType,
99
+ error: state.error
100
+ });
85
101
  }
86
102
  }, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType, analytics.operational]); // NB: once the smart-card has rendered into an end state, we capture
87
103
  // this as a successful render. These can be one of:
@@ -90,7 +106,13 @@ export function CardWithUrlContent({
90
106
 
91
107
  useEffect(() => {
92
108
  if (isFinalState(state.status)) {
93
- analytics.ui.renderSuccessEvent(appearance, state.status, id, definitionId, extensionKey);
109
+ analytics.ui.renderSuccessEvent({
110
+ display: appearance,
111
+ status: state.status,
112
+ id,
113
+ definitionId,
114
+ extensionKey
115
+ });
94
116
  }
95
117
  }, [appearance, state.status, url, definitionId, extensionKey, analytics.ui, id]);
96
118
 
@@ -68,7 +68,12 @@ export function CardWithURLRenderer(props) {
68
68
  const errorInfo = {
69
69
  componentStack
70
70
  };
71
- analytics.ui.renderFailedEvent(appearance, id, error, errorInfo);
71
+ analytics.ui.renderFailedEvent({
72
+ display: appearance,
73
+ id,
74
+ error,
75
+ errorInfo
76
+ });
72
77
  }
73
78
  }, [analytics.ui, appearance, id]);
74
79