@atlaskit/smart-card 32.7.8 → 32.7.9

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 (49) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/analytics.spec.yaml +31 -5
  3. package/dist/cjs/extractors/action/extract-invoke-preview-action.js +7 -6
  4. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +5 -1
  5. package/dist/cjs/utils/analytics/LinkAnalyticsContext.js +2 -7
  6. package/dist/cjs/utils/analytics/SmartLinkAnalyticsContext.js +99 -6
  7. package/dist/cjs/utils/analytics/analytics.js +1 -1
  8. package/dist/cjs/view/CardWithUrl/component.js +0 -1
  9. package/dist/cjs/view/CardWithUrl/loader.js +14 -5
  10. package/dist/cjs/view/EmbedModal/components/analytics/index.js +88 -32
  11. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +2 -2
  12. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +0 -1
  13. package/dist/cjs/view/HoverCard/index.js +15 -8
  14. package/dist/cjs/view/LinkUrl/index.js +1 -1
  15. package/dist/es2019/extractors/action/extract-invoke-preview-action.js +8 -7
  16. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +5 -1
  17. package/dist/es2019/utils/analytics/LinkAnalyticsContext.js +0 -3
  18. package/dist/es2019/utils/analytics/SmartLinkAnalyticsContext.js +97 -2
  19. package/dist/es2019/utils/analytics/analytics.js +1 -1
  20. package/dist/es2019/view/CardWithUrl/component.js +0 -1
  21. package/dist/es2019/view/CardWithUrl/loader.js +9 -1
  22. package/dist/es2019/view/EmbedModal/components/analytics/index.js +88 -32
  23. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +1 -1
  24. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +0 -1
  25. package/dist/es2019/view/HoverCard/index.js +10 -2
  26. package/dist/es2019/view/LinkUrl/index.js +1 -1
  27. package/dist/esm/extractors/action/extract-invoke-preview-action.js +8 -7
  28. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +5 -1
  29. package/dist/esm/utils/analytics/LinkAnalyticsContext.js +2 -7
  30. package/dist/esm/utils/analytics/SmartLinkAnalyticsContext.js +95 -5
  31. package/dist/esm/utils/analytics/analytics.js +1 -1
  32. package/dist/esm/view/CardWithUrl/component.js +0 -1
  33. package/dist/esm/view/CardWithUrl/loader.js +14 -5
  34. package/dist/esm/view/EmbedModal/components/analytics/index.js +88 -32
  35. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +1 -1
  36. package/dist/esm/view/HoverCard/components/views/resolved/index.js +0 -1
  37. package/dist/esm/view/HoverCard/index.js +14 -4
  38. package/dist/esm/view/LinkUrl/index.js +1 -1
  39. package/dist/types/common/analytics/generated/analytics.types.d.ts +16 -2
  40. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +5 -1
  41. package/dist/types/utils/analytics/SmartLinkAnalyticsContext.d.ts +14 -0
  42. package/dist/types/view/EmbedModal/components/analytics/types.d.ts +1 -0
  43. package/dist/types/view/HoverCard/components/HoverCardComponent.d.ts +1 -0
  44. package/dist/types-ts4.5/common/analytics/generated/analytics.types.d.ts +16 -2
  45. package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +5 -1
  46. package/dist/types-ts4.5/utils/analytics/SmartLinkAnalyticsContext.d.ts +14 -0
  47. package/dist/types-ts4.5/view/EmbedModal/components/analytics/types.d.ts +1 -0
  48. package/dist/types-ts4.5/view/HoverCard/components/HoverCardComponent.d.ts +1 -0
  49. package/package.json +1 -1
@@ -68,6 +68,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
68
68
  * This fires an event that represents when a user
69
69
  * click a button.
70
70
  * @param data A partial analytics event payload
71
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
71
72
  */
72
73
  buttonClickedEvent: function buttonClickedEvent(data) {
73
74
  return dispatchAnalytics(applyCommonAttributes({
@@ -113,6 +114,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
113
114
  /**
114
115
  * This fires an event that represents when a user close a modal.
115
116
  * @param data A partial analytics event payload
117
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
116
118
  */
117
119
  modalClosedEvent: function modalClosedEvent(data) {
118
120
  return dispatchAnalytics(applyCommonAttributes({
@@ -131,6 +133,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
131
133
  * @param definitionId The definitionId of the Smart Link resolver invoked.
132
134
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
133
135
  * @param canBeDatasource An indicator that shows that a smart link can be converted to a datasource
136
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
134
137
  */
135
138
  renderSuccessEvent: function renderSuccessEvent(_ref2) {
136
139
  var display = _ref2.display,
@@ -172,6 +175,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
172
175
  * @param id The unique ID for this Smart Link.
173
176
  * @param error: An error representing why the Smart Link render failed.
174
177
  * @param errorInfo: Additional details about the error including the stack trace.
178
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
175
179
  */
176
180
  renderFailedEvent: function renderFailedEvent(_ref3) {
177
181
  var display = _ref3.display,
@@ -277,7 +281,7 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defau
277
281
  return {
278
282
  /**
279
283
  * This fires an event that represents when a user view a modal.
280
- * @param data A partial analytics event payload
284
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
281
285
  */
282
286
  modalViewedEvent: function modalViewedEvent(data) {
283
287
  return dispatchAnalytics(applyCommonAttributes({
@@ -1,10 +1,5 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
1
  import React from 'react';
5
2
  import { AnalyticsContext } from '@atlaskit/analytics-next';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
- import { context } from './analytics';
8
3
  /**
9
4
  * Provides an analytics context to supply attributes to events based on a URL
10
5
  */
@@ -17,11 +12,11 @@ export var LinkAnalyticsContext = function LinkAnalyticsContext(_ref) {
17
12
  return /*#__PURE__*/React.createElement(AnalyticsContext, {
18
13
  data: {
19
14
  source: source,
20
- attributes: _objectSpread(_objectSpread({}, fg('platform-smart-card-migrate-embed-modal-analytics') ? context : {}), {}, {
15
+ attributes: {
21
16
  displayCategory: displayCategory,
22
17
  display: display,
23
18
  id: id
24
- })
19
+ }
25
20
  }
26
21
  }, children);
27
22
  };
@@ -1,20 +1,102 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ import React, { useMemo } from 'react';
3
6
  import { AnalyticsContext } from '@atlaskit/analytics-next';
4
7
  import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
8
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
9
+ import { getUrl } from '@atlaskit/linking-common';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
5
11
  import { useSmartCardState as useSmartLinkState } from '../../state/store';
12
+ import { context } from './analytics';
6
13
  import { LinkAnalyticsContext } from './LinkAnalyticsContext';
14
+ var getExtendedResolvedAttributes = function getExtendedResolvedAttributes(linkDetails, details, linkStatus) {
15
+ var _details$meta$definit, _details$meta, _details$meta$resourc, _details$meta2;
16
+ return _objectSpread({
17
+ definitionId: (_details$meta$definit = details === null || details === void 0 || (_details$meta = details.meta) === null || _details$meta === void 0 ? void 0 : _details$meta.definitionId) !== null && _details$meta$definit !== void 0 ? _details$meta$definit : null,
18
+ resourceType: (_details$meta$resourc = details === null || details === void 0 || (_details$meta2 = details.meta) === null || _details$meta2 === void 0 ? void 0 : _details$meta2.resourceType) !== null && _details$meta$resourc !== void 0 ? _details$meta$resourc : null
19
+ }, getResolvedAttributes(linkDetails, details, linkStatus));
20
+ };
21
+ var getSmartLinkAnalyticsContext = function getSmartLinkAnalyticsContext(_ref) {
22
+ var display = _ref.display,
23
+ id = _ref.id,
24
+ response = _ref.response,
25
+ source = _ref.source,
26
+ status = _ref.status,
27
+ url = _ref.url;
28
+ var resolvedAttributes = getExtendedResolvedAttributes({
29
+ url: url
30
+ }, response, status);
31
+ return {
32
+ source: source,
33
+ attributes: _objectSpread(_objectSpread({}, context), {}, {
34
+ display: display,
35
+ id: id
36
+ }, resolvedAttributes)
37
+ };
38
+ };
39
+ /**
40
+ * Provides an analytics context data to supply attributes to events based on a URL
41
+ * and the link state in the store
42
+ */
43
+ export var useSmartLinkAnalyticsContext = function useSmartLinkAnalyticsContext(_ref2) {
44
+ var display = _ref2.display,
45
+ id = _ref2.id,
46
+ source = _ref2.source,
47
+ url = _ref2.url;
48
+ var _useSmartLinkContext = useSmartLinkContext(),
49
+ store = _useSmartLinkContext.store;
50
+ var state = store ? getUrl(store, url) : undefined;
51
+ return useMemo(function () {
52
+ return fg('platform-smart-card-migrate-embed-modal-analytics') ? getSmartLinkAnalyticsContext({
53
+ display: display,
54
+ id: id,
55
+ response: state === null || state === void 0 ? void 0 : state.details,
56
+ source: source,
57
+ status: state === null || state === void 0 ? void 0 : state.status,
58
+ url: url
59
+ }) : {};
60
+ }, [display, id, source, state === null || state === void 0 ? void 0 : state.details, state === null || state === void 0 ? void 0 : state.status, url]);
61
+ };
62
+
7
63
  /**
8
64
  * Provides an analytics context to supply attributes to events based on a URL
9
65
  * and the link state in the store
10
66
  */
11
- export var SmartLinkAnalyticsContext = function SmartLinkAnalyticsContext(props) {
12
- var children = props.children,
13
- url = props.url,
14
- display = props.display;
67
+ var ExtendedSmartLinkAnalyticsContext = function ExtendedSmartLinkAnalyticsContext(_ref3) {
68
+ var children = _ref3.children,
69
+ display = _ref3.display,
70
+ id = _ref3.id,
71
+ source = _ref3.source,
72
+ url = _ref3.url;
15
73
  var _useSmartLinkState = useSmartLinkState(url),
16
74
  details = _useSmartLinkState.details,
17
75
  status = _useSmartLinkState.status;
76
+ var data = getSmartLinkAnalyticsContext({
77
+ display: display,
78
+ id: id,
79
+ response: details,
80
+ source: source,
81
+ status: status,
82
+ url: url
83
+ });
84
+ return /*#__PURE__*/React.createElement(AnalyticsContext, {
85
+ data: data
86
+ }, children);
87
+ };
88
+
89
+ /**
90
+ * Provides an analytics context to supply attributes to events based on a URL
91
+ * and the link state in the store
92
+ */
93
+ var LegacySmartLinkAnalyticsContext = function LegacySmartLinkAnalyticsContext(props) {
94
+ var children = props.children,
95
+ url = props.url,
96
+ display = props.display;
97
+ var _useSmartLinkState2 = useSmartLinkState(url),
98
+ details = _useSmartLinkState2.details,
99
+ status = _useSmartLinkState2.status;
18
100
  var attributes = getResolvedAttributes({
19
101
  url: url
20
102
  }, details, status);
@@ -25,4 +107,12 @@ export var SmartLinkAnalyticsContext = function SmartLinkAnalyticsContext(props)
25
107
  attributes: attributes
26
108
  }
27
109
  }, children));
110
+ };
111
+
112
+ /**
113
+ * Provides an analytics context to supply attributes to events based on a URL
114
+ * and the link state in the store
115
+ */
116
+ export var SmartLinkAnalyticsContext = function SmartLinkAnalyticsContext(props) {
117
+ return fg('platform-smart-card-migrate-embed-modal-analytics') ? /*#__PURE__*/React.createElement(ExtendedSmartLinkAnalyticsContext, props) : /*#__PURE__*/React.createElement(LegacySmartLinkAnalyticsContext, props);
28
118
  };
@@ -8,7 +8,7 @@ export var ANALYTICS_CHANNEL = 'media';
8
8
  export var context = {
9
9
  componentName: 'smart-cards',
10
10
  packageName: "@atlaskit/smart-card",
11
- packageVersion: "32.7.8"
11
+ packageVersion: "32.7.9"
12
12
  };
13
13
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
14
14
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -153,7 +153,6 @@ function Component(_ref) {
153
153
  display: isFlexibleUi ? 'flexible' : appearance
154
154
  });
155
155
  fireEvent('ui.smartLink.renderSuccess', {
156
- definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
157
156
  display: isFlexibleUi ? 'flexible' : appearance
158
157
  });
159
158
  } else {
@@ -1,4 +1,7 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
5
  import React, { lazy, Suspense, useCallback, useEffect, useState } from 'react';
3
6
  import { ErrorBoundary } from 'react-error-boundary';
4
7
  import { di } from 'react-magnetic-di';
@@ -8,6 +11,7 @@ import { useAnalyticsEvents } from '../../common/analytics/generated/use-analyti
8
11
  import { useSmartLinkAnalytics } from '../../state';
9
12
  import { failUfoExperience, startUfoExperience } from '../../state/analytics';
10
13
  import { importWithRetry } from '../../utils';
14
+ import { useSmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
11
15
  import { isFlexibleUiCard } from '../../utils/flexible';
12
16
  import { clearMarks, clearMeasures } from '../../utils/performance';
13
17
  import { LoadingCardLink } from './component-lazy/LoadingCardLink';
@@ -59,6 +63,11 @@ export function CardWithURLRenderer(props) {
59
63
  truncateInline = props.truncateInline;
60
64
  var analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', id);
61
65
  var isFlexibleUi = isFlexibleUiCard(children);
66
+ var analyticsContext = useSmartLinkAnalyticsContext({
67
+ display: isFlexibleUi ? 'flexible' : appearance,
68
+ id: id,
69
+ url: url !== null && url !== void 0 ? url : ''
70
+ });
62
71
  var errorHandler = useCallback(function (error, info) {
63
72
  var componentStack = info.componentStack;
64
73
  var errorInfo = {
@@ -70,23 +79,23 @@ export function CardWithURLRenderer(props) {
70
79
  // to the reliability of the smart-card front-end components.
71
80
  // Likewise, chunk loading errors are not caused by a failure of smart-card rendering.
72
81
  if (error.name === 'ChunkLoadError') {
73
- fireEvent('operational.smartLink.chunkLoadFailed', {
82
+ fireEvent('operational.smartLink.chunkLoadFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
74
83
  display: appearance,
75
84
  error: error,
76
85
  errorInfo: errorInfo,
77
86
  definitionId: null
78
- });
87
+ }));
79
88
  } else if (error.name !== 'APIError') {
80
89
  if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
81
90
  startUfoExperience('smart-link-rendered', id || 'NULL');
82
91
  failUfoExperience('smart-link-rendered', id || 'NULL');
83
92
  failUfoExperience('smart-link-authenticated', id || 'NULL');
84
- fireEvent('ui.smartLink.renderFailed', {
93
+ fireEvent('ui.smartLink.renderFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
85
94
  display: isFlexibleUi ? 'flexible' : appearance,
86
95
  id: id !== null && id !== void 0 ? id : null,
87
96
  error: error,
88
97
  errorInfo: errorInfo
89
- });
98
+ }));
90
99
  } else {
91
100
  analytics.ui.renderFailedEvent({
92
101
  display: isFlexibleUi ? 'flexible' : appearance,
@@ -101,7 +110,7 @@ export function CardWithURLRenderer(props) {
101
110
  url: url !== null && url !== void 0 ? url : '',
102
111
  err: error
103
112
  });
104
- }, [analytics.ui, appearance, id, onError, url, isFlexibleUi, fireEvent]);
113
+ }, [analytics.ui, analyticsContext, appearance, id, onError, url, isFlexibleUi, fireEvent]);
105
114
  if (!url) {
106
115
  throw new Error('@atlaskit/smart-card: url property is missing.');
107
116
  }
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback } from 'react';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  import { CardDisplay } from '../../../../constants';
5
+ import { failUfoExperience, startUfoExperience, succeedUfoExperience } from '../../../../state/analytics';
4
6
  import { EmbedModalSize } from '../../types';
5
7
  var getResizeFrom = function getResizeFrom(size) {
6
8
  return size === EmbedModalSize.Small ? EmbedModalSize.Large : EmbedModalSize.Small;
@@ -8,63 +10,117 @@ var getResizeFrom = function getResizeFrom(size) {
8
10
  var withAnalytics = function withAnalytics(Component) {
9
11
  return function (props) {
10
12
  var analytics = props.analytics,
13
+ fireEvent = props.fireEvent,
14
+ extensionKey = props.extensionKey,
15
+ id = props.id,
11
16
  onClose = props.onClose,
12
17
  onOpen = props.onOpen,
13
18
  onOpenFailed = props.onOpenFailed,
14
19
  onResize = props.onResize,
15
20
  origin = props.origin;
16
21
  var handleOnOpen = useCallback(function (context) {
17
- analytics === null || analytics === void 0 || analytics.screen.modalViewedEvent({
18
- name: 'embedPreviewModal',
19
- attributes: {
20
- origin: origin,
22
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
23
+ fireEvent === null || fireEvent === void 0 || fireEvent('screen.embedPreviewModal.viewed', {
24
+ origin: origin !== null && origin !== void 0 ? origin : null,
21
25
  size: context.size
22
- }
23
- });
24
- analytics === null || analytics === void 0 || analytics.ui.renderSuccessEvent({
25
- status: 'resolved',
26
- display: CardDisplay.EmbedPreview
27
- });
26
+ });
27
+ } else {
28
+ analytics === null || analytics === void 0 || analytics.screen.modalViewedEvent({
29
+ name: 'embedPreviewModal',
30
+ attributes: {
31
+ origin: origin,
32
+ size: context.size
33
+ }
34
+ });
35
+ }
36
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
37
+ succeedUfoExperience('smart-link-rendered', id || 'NULL', {
38
+ extensionKey: extensionKey,
39
+ display: CardDisplay.EmbedPreview
40
+ });
41
+
42
+ // UFO will disregard this if authentication experience has not yet been started
43
+ succeedUfoExperience('smart-link-authenticated', id || 'NULL', {
44
+ display: CardDisplay.EmbedPreview
45
+ });
46
+ fireEvent === null || fireEvent === void 0 || fireEvent('ui.smartLink.renderSuccess', {
47
+ display: CardDisplay.EmbedPreview
48
+ });
49
+ } else {
50
+ analytics === null || analytics === void 0 || analytics.ui.renderSuccessEvent({
51
+ status: 'resolved',
52
+ display: CardDisplay.EmbedPreview
53
+ });
54
+ }
28
55
  if (onOpen) {
29
56
  onOpen(context);
30
57
  }
31
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.screen, analytics === null || analytics === void 0 ? void 0 : analytics.ui, onOpen, origin]);
58
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.screen, analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, extensionKey, id, onOpen, origin]);
32
59
  var handleOnOpenFailed = useCallback(function (error, errorInfo) {
33
- analytics === null || analytics === void 0 || analytics.ui.renderFailedEvent({
34
- display: CardDisplay.EmbedPreview,
35
- error: error,
36
- errorInfo: errorInfo
37
- });
60
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
61
+ startUfoExperience('smart-link-rendered', id || 'NULL');
62
+ failUfoExperience('smart-link-rendered', id || 'NULL');
63
+ failUfoExperience('smart-link-authenticated', id || 'NULL');
64
+ fireEvent === null || fireEvent === void 0 || fireEvent('ui.smartLink.renderFailed', {
65
+ display: CardDisplay.EmbedPreview,
66
+ error: error,
67
+ errorInfo: errorInfo,
68
+ id: id !== null && id !== void 0 ? id : null
69
+ });
70
+ } else {
71
+ analytics === null || analytics === void 0 || analytics.ui.renderFailedEvent({
72
+ display: CardDisplay.EmbedPreview,
73
+ error: error,
74
+ errorInfo: errorInfo
75
+ });
76
+ }
38
77
  if (onOpenFailed) {
39
78
  onOpenFailed(error, errorInfo);
40
79
  }
41
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onOpenFailed]);
80
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, id, onOpenFailed]);
42
81
  var handleOnClose = useCallback(function (context) {
43
- analytics === null || analytics === void 0 || analytics.ui.modalClosedEvent({
44
- actionSubjectId: 'embedPreview',
45
- attributes: {
46
- origin: origin,
47
- previewTime: context.duration,
82
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
83
+ var _context$duration;
84
+ fireEvent === null || fireEvent === void 0 || fireEvent('ui.modal.closed.embedPreview', {
85
+ origin: origin !== null && origin !== void 0 ? origin : null,
86
+ previewTime: (_context$duration = context.duration) !== null && _context$duration !== void 0 ? _context$duration : null,
48
87
  size: context.size
49
- }
50
- });
88
+ });
89
+ } else {
90
+ analytics === null || analytics === void 0 || analytics.ui.modalClosedEvent({
91
+ actionSubjectId: 'embedPreview',
92
+ attributes: {
93
+ origin: origin,
94
+ previewTime: context.duration,
95
+ size: context.size
96
+ }
97
+ });
98
+ }
51
99
  if (onClose) {
52
100
  onClose(context);
53
101
  }
54
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onClose, origin]);
102
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, onClose, origin]);
55
103
  var handleOnResize = useCallback(function (context) {
56
- analytics === null || analytics === void 0 || analytics.ui.buttonClickedEvent({
57
- actionSubjectId: 'embedPreviewResize',
58
- attributes: {
104
+ if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
105
+ fireEvent === null || fireEvent === void 0 || fireEvent('ui.button.clicked.embedPreviewResize', {
59
106
  newSize: context.size,
60
- origin: origin,
107
+ origin: origin !== null && origin !== void 0 ? origin : null,
61
108
  previousSize: getResizeFrom(context.size)
62
- }
63
- });
109
+ });
110
+ } else {
111
+ analytics === null || analytics === void 0 || analytics.ui.buttonClickedEvent({
112
+ actionSubjectId: 'embedPreviewResize',
113
+ attributes: {
114
+ newSize: context.size,
115
+ origin: origin,
116
+ previousSize: getResizeFrom(context.size)
117
+ }
118
+ });
119
+ }
64
120
  if (onResize) {
65
121
  onResize(context);
66
122
  }
67
- }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, onResize, origin]);
123
+ }, [analytics === null || analytics === void 0 ? void 0 : analytics.ui, fireEvent, onResize, origin]);
68
124
  return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
69
125
  onClose: handleOnClose,
70
126
  onOpen: handleOnOpen,
@@ -20,7 +20,7 @@ import { SmartLinkAnalyticsContext } from '../../../utils/analytics/SmartLinkAna
20
20
  import CustomPopupContainer from '../components/CustomPopupContainer';
21
21
  import HoverCardContent from '../components/HoverCardContent';
22
22
  import { CARD_GAP_PX, HOVER_CARD_Z_INDEX } from '../styled';
23
- var HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
23
+ export var HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
24
24
  var FADE_IN_DELAY = 500;
25
25
  var FADE_OUT_DELAY = 300;
26
26
  var RESOLVE_DELAY = 100;
@@ -42,7 +42,6 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
42
42
  display: CardDisplay.HoverCardPreview
43
43
  });
44
44
  fireEvent('ui.smartLink.renderSuccess', {
45
- definitionId: definitionId !== null && definitionId !== void 0 ? definitionId : null,
46
45
  display: CardDisplay.HoverCardPreview
47
46
  });
48
47
  } else {
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  /**
2
5
  * @jsxRuntime classic
3
6
  * @jsx jsx
@@ -15,7 +18,8 @@ import { CardDisplay } from '../../constants';
15
18
  import { useSmartLinkAnalytics } from '../../state';
16
19
  import { failUfoExperience, startUfoExperience } from '../../state/analytics';
17
20
  import { SmartLinkModalProvider } from '../../state/modal';
18
- import { HoverCardComponent } from './components/HoverCardComponent';
21
+ import { useSmartLinkAnalyticsContext } from '../../utils/analytics/SmartLinkAnalyticsContext';
22
+ import { HOVER_CARD_SOURCE, HoverCardComponent } from './components/HoverCardComponent';
19
23
  var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
20
24
  var _useAnalyticsEvents = useAnalyticsEvents(),
21
25
  fireEvent = _useAnalyticsEvents.fireEvent;
@@ -23,17 +27,23 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
23
27
  id = props.id,
24
28
  children = props.children;
25
29
  var analytics = useSmartLinkAnalytics(url, id);
30
+ var analyticsContext = useSmartLinkAnalyticsContext({
31
+ display: CardDisplay.HoverCardPreview,
32
+ id: id,
33
+ source: HOVER_CARD_SOURCE,
34
+ url: url
35
+ });
26
36
  var onError = useCallback(function (error, info) {
27
37
  if (fg('platform-smart-card-migrate-embed-modal-analytics')) {
28
38
  startUfoExperience('smart-link-rendered', id || 'NULL');
29
39
  failUfoExperience('smart-link-rendered', id || 'NULL');
30
40
  failUfoExperience('smart-link-authenticated', id || 'NULL');
31
- fireEvent('ui.smartLink.renderFailed', {
41
+ fireEvent('ui.smartLink.renderFailed', _objectSpread(_objectSpread({}, analyticsContext === null || analyticsContext === void 0 ? void 0 : analyticsContext.attributes), {}, {
32
42
  display: CardDisplay.HoverCardPreview,
33
43
  id: id !== null && id !== void 0 ? id : null,
34
44
  error: error,
35
45
  errorInfo: info
36
- });
46
+ }));
37
47
  } else {
38
48
  analytics.ui.renderFailedEvent({
39
49
  display: CardDisplay.HoverCardPreview,
@@ -42,7 +52,7 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
42
52
  errorInfo: info
43
53
  });
44
54
  }
45
- }, [analytics.ui, id, fireEvent]);
55
+ }, [analytics.ui, analyticsContext, id, fireEvent]);
46
56
  return jsx(ErrorBoundary, {
47
57
  fallback: children,
48
58
  onError: onError
@@ -13,7 +13,7 @@ import LinkWarningModal from './LinkWarningModal';
13
13
  import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
14
14
  var PACKAGE_DATA = {
15
15
  packageName: "@atlaskit/smart-card",
16
- packageVersion: "32.7.8",
16
+ packageVersion: "32.7.9",
17
17
  componentName: 'linkUrl'
18
18
  };
19
19
  var Anchor = withLinkClickedEvent('a');
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates Typescript types for analytics events from analytics.spec.yaml
5
5
  *
6
- * @codegen <<SignedSource::1e6835b50307a44a077c38d864a2c66e>>
6
+ * @codegen <<SignedSource::84c7074821df29c52dd13557dab19219>>
7
7
  * @codegenCommand yarn workspace @atlassian/analytics-tooling run analytics:codegen smart-card
8
8
  */
9
9
  export type PackageMetaDataContextType = {
@@ -126,6 +126,10 @@ export type SmartLinkQuickActionFailedAttributesType = {
126
126
  export type ConsentModalViewedAttributesType = {
127
127
  definitionId: string | null;
128
128
  };
129
+ export type EmbedPreviewModalViewedAttributesType = {
130
+ origin: 'smartLinkCard' | 'smartLinkEmbed' | 'smartLinkInline' | 'smartLinkPreviewHoverCard' | null;
131
+ size: 'large' | 'small' | null;
132
+ };
129
133
  export type SmartLinkConnectSucceededAttributesType = {
130
134
  definitionId: string | null;
131
135
  };
@@ -200,6 +204,11 @@ export type ConsentModalClosedAttributesType = {
200
204
  display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview';
201
205
  definitionId: string | null;
202
206
  };
207
+ export type ModalClosedEmbedPreviewAttributesType = {
208
+ origin: 'smartLinkCard' | 'smartLinkEmbed' | 'smartLinkInline' | 'smartLinkPreviewHoverCard' | null;
209
+ previewTime: number | null;
210
+ size: 'large' | 'small' | null;
211
+ };
203
212
  export type ButtonClickedLearnMoreAttributesType = {};
204
213
  export type ButtonClickedSmartLinkStatusLozengeAttributesType = {};
205
214
  export type ButtonClickedSmartLinkStatusListItemAttributesType = {};
@@ -214,7 +223,6 @@ export type ButtonClickedEmbedPreviewResizeAttributesType = {
214
223
  };
215
224
  export type SmartLinkRenderSuccessAttributesType = {
216
225
  display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview';
217
- definitionId: string | null;
218
226
  };
219
227
  export type SmartLinkRenderFailedAttributesType = {
220
228
  display: 'inline' | 'block' | 'embed' | 'embedPreview' | 'flexible' | 'hoverCardPreview';
@@ -301,6 +309,9 @@ export type AnalyticsEventAttributes = {
301
309
  /**
302
310
  * fires an event which represents the connect account page being opened. */
303
311
  'screen.consentModal.viewed': ConsentModalViewedAttributesType;
312
+ /**
313
+ * Fires an event that represents when a user view a modal. */
314
+ 'screen.embedPreviewModal.viewed': EmbedPreviewModalViewedAttributesType;
304
315
  /**
305
316
  * fires an event that represents an account successfully being connected via a Smart Link. */
306
317
  'operational.smartLink.connectSucceeded': SmartLinkConnectSucceededAttributesType;
@@ -343,6 +354,9 @@ export type AnalyticsEventAttributes = {
343
354
  /**
344
355
  * fires an event that represents when a user closed the authentication window without authenticating after opening it. */
345
356
  'ui.consentModal.closed': ConsentModalClosedAttributesType;
357
+ /**
358
+ * Fires an event that represents when a user close a modal. */
359
+ 'ui.modal.closed.embedPreview': ModalClosedEmbedPreviewAttributesType;
346
360
  /**
347
361
  * fires an event that signifies that a "Learn More" link was clicked on an unauthenticated card */
348
362
  'ui.button.clicked.learnMore': ButtonClickedLearnMoreAttributesType;
@@ -15,6 +15,7 @@ export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLo
15
15
  * This fires an event that represents when a user
16
16
  * click a button.
17
17
  * @param data A partial analytics event payload
18
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
18
19
  */
19
20
  buttonClickedEvent: (data: Partial<AnalyticsPayload> & {
20
21
  actionSubjectId: Required<string>;
@@ -32,6 +33,7 @@ export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLo
32
33
  /**
33
34
  * This fires an event that represents when a user close a modal.
34
35
  * @param data A partial analytics event payload
36
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
35
37
  */
36
38
  modalClosedEvent: (data: Partial<AnalyticsPayload> & {
37
39
  actionSubjectId: Required<string>;
@@ -44,6 +46,7 @@ export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLo
44
46
  * @param definitionId The definitionId of the Smart Link resolver invoked.
45
47
  * @param extensionKey The extensionKey of the Smart Link resovler invoked.
46
48
  * @param canBeDatasource An indicator that shows that a smart link can be converted to a datasource
49
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
47
50
  */
48
51
  renderSuccessEvent: ({ display, status, id, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, canBeDatasource, }: UiRenderSuccessEventProps) => void;
49
52
  /**
@@ -52,6 +55,7 @@ export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLo
52
55
  * @param id The unique ID for this Smart Link.
53
56
  * @param error: An error representing why the Smart Link render failed.
54
57
  * @param errorInfo: Additional details about the error including the stack trace.
58
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
55
59
  */
56
60
  renderFailedEvent: ({ display, id, error, errorInfo, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: UiRenderFailedEventProps) => void;
57
61
  };
@@ -77,7 +81,7 @@ export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLo
77
81
  screen: {
78
82
  /**
79
83
  * This fires an event that represents when a user view a modal.
80
- * @param data A partial analytics event payload
84
+ * @deprecated consider removing when cleaning up FF platform-smart-card-migrate-embed-modal-analytics
81
85
  */
82
86
  modalViewedEvent: (data: Partial<AnalyticsPayload> & {
83
87
  name: Extract<AnalyticsName, 'embedPreviewModal'>;
@@ -1,4 +1,6 @@
1
1
  import React from 'react';
2
+ import { getResolvedAttributes } from '@atlaskit/link-analytics/resolved-attributes';
3
+ import { context } from './analytics';
2
4
  type SmartLinkAnalyticsContextProps = {
3
5
  url: string;
4
6
  display?: string;
@@ -6,6 +8,18 @@ type SmartLinkAnalyticsContextProps = {
6
8
  source?: string;
7
9
  children?: React.ReactNode;
8
10
  };
11
+ type SmartLinkAnalyticsContextType = {
12
+ source?: string;
13
+ attributes?: typeof context & ReturnType<typeof getResolvedAttributes> & {
14
+ display?: string;
15
+ id?: string;
16
+ };
17
+ };
18
+ /**
19
+ * Provides an analytics context data to supply attributes to events based on a URL
20
+ * and the link state in the store
21
+ */
22
+ export declare const useSmartLinkAnalyticsContext: ({ display, id, source, url, }: Exclude<SmartLinkAnalyticsContextProps, 'children'>) => SmartLinkAnalyticsContextType | undefined;
9
23
  /**
10
24
  * Provides an analytics context to supply attributes to events based on a URL
11
25
  * and the link state in the store
@@ -3,5 +3,6 @@ import { type AnalyticsOrigin } from '../../../../utils/types';
3
3
  export type WithAnalytics = {
4
4
  analytics?: AnalyticsFacade;
5
5
  extensionKey?: string;
6
+ id?: string;
6
7
  origin?: AnalyticsOrigin;
7
8
  };
@@ -1,3 +1,4 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import { type HoverCardComponentProps } from '../types';
3
+ export declare const HOVER_CARD_SOURCE = "smartLinkPreviewHoverCard";
3
4
  export declare const HoverCardComponent: ({ children, url, id, canOpen, closeOnChildClick, actionOptions, allowEventPropagation, zIndex, noFadeDelay, hoverPreviewOptions, }: HoverCardComponentProps) => jsx.JSX.Element;