@atlaskit/smart-card 33.2.0 → 33.3.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 (152) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/state/actions/index.js +2 -4
  3. package/dist/cjs/state/analytics/index.js +1 -8
  4. package/dist/cjs/state/flexible-ui-context/index.js +1 -10
  5. package/dist/cjs/state/hooks/useSmartLink.js +1 -4
  6. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +1 -3
  7. package/dist/cjs/state/hooks-external/useSmartLinkReload.js +1 -3
  8. package/dist/cjs/state/index.js +1 -8
  9. package/dist/cjs/utils/analytics/analytics.js +2 -144
  10. package/dist/cjs/utils/analytics/index.js +0 -30
  11. package/dist/cjs/utils/analytics/types.js +1 -5
  12. package/dist/cjs/utils/mocks.js +1 -23
  13. package/dist/cjs/view/BlockCard/index.js +1 -3
  14. package/dist/cjs/view/BlockCard/views/ResolvedView.js +1 -3
  15. package/dist/cjs/view/BlockCard/views/UnauthorisedView.js +2 -4
  16. package/dist/cjs/view/CardWithUrl/component.js +1 -8
  17. package/dist/cjs/view/EmbedCard/index.js +0 -4
  18. package/dist/cjs/view/EmbedCard/views/unauthorized-view/index.js +3 -5
  19. package/dist/cjs/view/EmbedModal/index.js +1 -3
  20. package/dist/cjs/view/FlexibleCard/components/actions/copy-link-action/index.js +1 -4
  21. package/dist/cjs/view/FlexibleCard/components/actions/download-action/index.js +1 -4
  22. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +1 -4
  23. package/dist/cjs/view/FlexibleCard/index.js +3 -17
  24. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +1 -3
  25. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +1 -8
  26. package/dist/cjs/view/HoverCard/components/views/unauthorised/index.js +3 -5
  27. package/dist/cjs/view/InlineCard/index.js +1 -3
  28. package/dist/cjs/view/LinkUrl/index.js +1 -1
  29. package/dist/es2019/state/actions/index.js +2 -4
  30. package/dist/es2019/state/analytics/index.js +1 -2
  31. package/dist/es2019/state/flexible-ui-context/index.js +0 -7
  32. package/dist/es2019/state/hooks/useSmartLink.js +1 -4
  33. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +1 -3
  34. package/dist/es2019/state/hooks-external/useSmartLinkReload.js +1 -3
  35. package/dist/es2019/state/index.js +1 -2
  36. package/dist/es2019/utils/analytics/analytics.js +2 -145
  37. package/dist/es2019/utils/analytics/index.js +1 -1
  38. package/dist/es2019/utils/analytics/types.js +0 -1
  39. package/dist/es2019/utils/mocks.js +1 -23
  40. package/dist/es2019/view/BlockCard/index.js +1 -3
  41. package/dist/es2019/view/BlockCard/views/ResolvedView.js +1 -3
  42. package/dist/es2019/view/BlockCard/views/UnauthorisedView.js +1 -3
  43. package/dist/es2019/view/CardWithUrl/component.js +1 -8
  44. package/dist/es2019/view/EmbedCard/index.js +0 -4
  45. package/dist/es2019/view/EmbedCard/views/unauthorized-view/index.js +1 -3
  46. package/dist/es2019/view/EmbedModal/index.js +0 -2
  47. package/dist/es2019/view/FlexibleCard/components/actions/copy-link-action/index.js +2 -5
  48. package/dist/es2019/view/FlexibleCard/components/actions/download-action/index.js +2 -5
  49. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +2 -5
  50. package/dist/es2019/view/FlexibleCard/index.js +3 -15
  51. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +1 -3
  52. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +1 -8
  53. package/dist/es2019/view/HoverCard/components/views/unauthorised/index.js +2 -4
  54. package/dist/es2019/view/InlineCard/index.js +0 -2
  55. package/dist/es2019/view/LinkUrl/index.js +1 -1
  56. package/dist/esm/state/actions/index.js +2 -4
  57. package/dist/esm/state/analytics/index.js +1 -2
  58. package/dist/esm/state/flexible-ui-context/index.js +0 -9
  59. package/dist/esm/state/hooks/useSmartLink.js +1 -4
  60. package/dist/esm/state/hooks-external/useSmartLinkActions.js +1 -3
  61. package/dist/esm/state/hooks-external/useSmartLinkReload.js +1 -3
  62. package/dist/esm/state/index.js +1 -2
  63. package/dist/esm/utils/analytics/analytics.js +1 -143
  64. package/dist/esm/utils/analytics/index.js +1 -1
  65. package/dist/esm/utils/analytics/types.js +0 -1
  66. package/dist/esm/utils/mocks.js +0 -22
  67. package/dist/esm/view/BlockCard/index.js +1 -3
  68. package/dist/esm/view/BlockCard/views/ResolvedView.js +1 -3
  69. package/dist/esm/view/BlockCard/views/UnauthorisedView.js +2 -4
  70. package/dist/esm/view/CardWithUrl/component.js +1 -8
  71. package/dist/esm/view/EmbedCard/index.js +0 -4
  72. package/dist/esm/view/EmbedCard/views/unauthorized-view/index.js +3 -5
  73. package/dist/esm/view/EmbedModal/index.js +1 -3
  74. package/dist/esm/view/FlexibleCard/components/actions/copy-link-action/index.js +2 -5
  75. package/dist/esm/view/FlexibleCard/components/actions/download-action/index.js +2 -5
  76. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +2 -5
  77. package/dist/esm/view/FlexibleCard/index.js +4 -18
  78. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +1 -3
  79. package/dist/esm/view/HoverCard/components/HoverCardContent.js +1 -8
  80. package/dist/esm/view/HoverCard/components/views/unauthorised/index.js +3 -5
  81. package/dist/esm/view/InlineCard/index.js +1 -3
  82. package/dist/esm/view/LinkUrl/index.js +1 -1
  83. package/dist/types/extractors/common/actions/types.d.ts +0 -2
  84. package/dist/types/state/actions/index.d.ts +1 -2
  85. package/dist/types/state/analytics/index.d.ts +0 -2
  86. package/dist/types/state/flexible-ui-context/index.d.ts +1 -7
  87. package/dist/types/state/flexible-ui-context/types.d.ts +0 -6
  88. package/dist/types/state/hooks/use-invoke-client-action/types.d.ts +0 -6
  89. package/dist/types/state/hooks/useSmartLink.d.ts +0 -7
  90. package/dist/types/state/index.d.ts +0 -1
  91. package/dist/types/utils/analytics/analytics.d.ts +0 -6
  92. package/dist/types/utils/analytics/index.d.ts +1 -1
  93. package/dist/types/utils/analytics/types.d.ts +0 -42
  94. package/dist/types/utils/mocks.d.ts +0 -7
  95. package/dist/types/view/BlockCard/index.d.ts +1 -1
  96. package/dist/types/view/BlockCard/types.d.ts +0 -2
  97. package/dist/types/view/BlockCard/views/types.d.ts +1 -1
  98. package/dist/types/view/CardWithUrl/types.d.ts +0 -2
  99. package/dist/types/view/EmbedCard/types.d.ts +0 -2
  100. package/dist/types/view/EmbedCard/views/unauthorized-view/index.d.ts +1 -1
  101. package/dist/types/view/EmbedCard/views/unauthorized-view/types.d.ts +0 -2
  102. package/dist/types/view/EmbedModal/components/analytics/types.d.ts +0 -2
  103. package/dist/types/view/FlexibleCard/index.d.ts +1 -1
  104. package/dist/types/view/FlexibleCard/types.d.ts +0 -6
  105. package/dist/types/view/HoverCard/components/HoverCardContent.d.ts +1 -1
  106. package/dist/types/view/HoverCard/components/views/resolved/types.d.ts +0 -2
  107. package/dist/types/view/HoverCard/components/views/unauthorised/index.d.ts +1 -1
  108. package/dist/types/view/HoverCard/components/views/unauthorised/types.d.ts +0 -5
  109. package/dist/types/view/HoverCard/types.d.ts +0 -3
  110. package/dist/types/view/InlineCard/UnauthorisedView/index.d.ts +0 -3
  111. package/dist/types/view/InlineCard/index.d.ts +1 -1
  112. package/dist/types/view/InlineCard/types.d.ts +0 -2
  113. package/dist/types/view/common/UnauthorisedViewContent.d.ts +0 -6
  114. package/dist/types-ts4.5/extractors/common/actions/types.d.ts +0 -2
  115. package/dist/types-ts4.5/state/actions/index.d.ts +1 -2
  116. package/dist/types-ts4.5/state/analytics/index.d.ts +0 -2
  117. package/dist/types-ts4.5/state/flexible-ui-context/index.d.ts +1 -7
  118. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +0 -6
  119. package/dist/types-ts4.5/state/hooks/use-invoke-client-action/types.d.ts +0 -6
  120. package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +0 -7
  121. package/dist/types-ts4.5/state/index.d.ts +0 -1
  122. package/dist/types-ts4.5/utils/analytics/analytics.d.ts +0 -6
  123. package/dist/types-ts4.5/utils/analytics/index.d.ts +1 -1
  124. package/dist/types-ts4.5/utils/analytics/types.d.ts +0 -42
  125. package/dist/types-ts4.5/utils/mocks.d.ts +0 -7
  126. package/dist/types-ts4.5/view/BlockCard/index.d.ts +1 -1
  127. package/dist/types-ts4.5/view/BlockCard/types.d.ts +0 -2
  128. package/dist/types-ts4.5/view/BlockCard/views/types.d.ts +1 -1
  129. package/dist/types-ts4.5/view/CardWithUrl/types.d.ts +0 -2
  130. package/dist/types-ts4.5/view/EmbedCard/types.d.ts +0 -2
  131. package/dist/types-ts4.5/view/EmbedCard/views/unauthorized-view/index.d.ts +1 -1
  132. package/dist/types-ts4.5/view/EmbedCard/views/unauthorized-view/types.d.ts +0 -2
  133. package/dist/types-ts4.5/view/EmbedModal/components/analytics/types.d.ts +0 -2
  134. package/dist/types-ts4.5/view/FlexibleCard/index.d.ts +1 -1
  135. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +0 -6
  136. package/dist/types-ts4.5/view/HoverCard/components/HoverCardContent.d.ts +1 -1
  137. package/dist/types-ts4.5/view/HoverCard/components/views/resolved/types.d.ts +0 -2
  138. package/dist/types-ts4.5/view/HoverCard/components/views/unauthorised/index.d.ts +1 -1
  139. package/dist/types-ts4.5/view/HoverCard/components/views/unauthorised/types.d.ts +0 -5
  140. package/dist/types-ts4.5/view/HoverCard/types.d.ts +0 -3
  141. package/dist/types-ts4.5/view/InlineCard/UnauthorisedView/index.d.ts +0 -3
  142. package/dist/types-ts4.5/view/InlineCard/index.d.ts +1 -1
  143. package/dist/types-ts4.5/view/InlineCard/types.d.ts +0 -2
  144. package/dist/types-ts4.5/view/common/UnauthorisedViewContent.d.ts +0 -6
  145. package/package.json +1 -1
  146. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +0 -139
  147. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +0 -126
  148. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +0 -132
  149. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +0 -33
  150. package/dist/types/utils/analytics/__mocks__/analytics.d.ts +0 -2
  151. package/dist/types-ts4.5/state/analytics/useSmartLinkAnalytics.d.ts +0 -33
  152. package/dist/types-ts4.5/utils/analytics/__mocks__/analytics.d.ts +0 -2
@@ -1,6 +1,5 @@
1
1
  import { type EventHandler, type KeyboardEvent, type MouseEvent } from 'react';
2
2
  import { type CardProviderRenderers } from '@atlaskit/link-provider';
3
- import { type AnalyticsFacade } from '../../state/analytics';
4
3
  import { type CardState } from '../../state/types';
5
4
  import type { CardActionOptions } from '../Card/types';
6
5
  import { type HoverPreviewOptions } from '../HoverCard/types';
@@ -24,7 +23,6 @@ export type InlineCardProps = {
24
23
  showHoverPreview?: boolean;
25
24
  hoverPreviewOptions?: HoverPreviewOptions;
26
25
  actionOptions?: CardActionOptions;
27
- analytics: AnalyticsFacade;
28
26
  removeTextHighlightingFromTitle?: boolean;
29
27
  resolvingPlaceholder?: string;
30
28
  truncateInline?: boolean;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { type AnalyticsFacade } from '../../state/analytics';
3
2
  type UnauthorisedViewContentProps = {
4
3
  /**
5
4
  * Is the name of the provider for the account that needs to be connected
@@ -17,11 +16,6 @@ type UnauthorisedViewContentProps = {
17
16
  * serving as a hook for automated tests
18
17
  */
19
18
  testId?: string;
20
- /**
21
- * An analytics facade object which will be used to send analytics.
22
- * @internal
23
- */
24
- analytics?: AnalyticsFacade;
25
19
  };
26
20
  /**
27
21
  * This component is used in unauthorized views of a smart link.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "33.2.0",
3
+ "version": "33.3.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -1,139 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.useSmartLinkAnalytics = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _react = require("react");
10
- var _linkProvider = require("@atlaskit/link-provider");
11
- var _linkingCommon = require("@atlaskit/linking-common");
12
- var _analytics = require("../../utils/analytics");
13
- var _helpers = require("../helpers");
14
- var _useDispatchAnalytics2 = require("./useDispatchAnalytics");
15
- var applyCommonAttributes = function applyCommonAttributes(event, commonAttributes) {
16
- if (event && event.attributes) {
17
- for (var _i = 0, _Object$entries = Object.entries(commonAttributes); _i < _Object$entries.length; _i++) {
18
- var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
19
- key = _Object$entries$_i[0],
20
- value = _Object$entries$_i[1];
21
- if (event.attributes[key] === undefined) {
22
- event.attributes[key] = value;
23
- }
24
- }
25
- }
26
- return event;
27
- };
28
-
29
- /**
30
- * This hook provides usage of Smart Link analytics outside of the Card component.
31
- * Can be provided to Card via the analyticsEvents prop to change the analytics events.
32
- *
33
- * @param url URL of the link
34
- * @param id fallback id of the events sent if no id is available
35
- * @param defaultLocation location attribute to be used
36
- * @returns
37
- */
38
- var useSmartLinkAnalytics = exports.useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defaultLocation) {
39
- var _useDispatchAnalytics = (0, _useDispatchAnalytics2.useDispatchAnalytics)(),
40
- dispatchAnalytics = _useDispatchAnalytics.dispatchAnalytics;
41
- var defaultId = id || 'NULL';
42
- // We don't want to trigger a re-render by using useSmartCardState
43
- var _useSmartLinkContext = (0, _linkProvider.useSmartLinkContext)(),
44
- store = _useSmartLinkContext.store;
45
- var state = store ? (0, _linkingCommon.getUrl)(store, url) : undefined;
46
- var details = state ? state.details : undefined;
47
- var extractedDefinitionId = (0, _helpers.getDefinitionId)(details);
48
- var extractedExtensionKey = (0, _helpers.getExtensionKey)(details);
49
- var extractedResourceType = (0, _helpers.getResourceType)(details);
50
- var extractedSubproduct = (0, _helpers.getSubproduct)(details);
51
- var extractedProduct = (0, _helpers.getProduct)(details);
52
- var extractedStatusDetails = (0, _helpers.getStatusDetails)(details);
53
- var commonAttributes = (0, _react.useMemo)(function () {
54
- return {
55
- id: defaultId,
56
- definitionId: extractedDefinitionId,
57
- extensionKey: extractedExtensionKey,
58
- resourceType: extractedResourceType,
59
- destinationObjectType: extractedResourceType,
60
- destinationSubproduct: extractedSubproduct,
61
- destinationProduct: extractedProduct,
62
- location: defaultLocation,
63
- statusDetails: extractedStatusDetails
64
- };
65
- }, [defaultId, extractedDefinitionId, extractedExtensionKey, extractedResourceType, extractedSubproduct, extractedProduct, defaultLocation, extractedStatusDetails]);
66
-
67
- /** Contains all operational analytics events */
68
- var operational = (0, _react.useMemo)(function () {
69
- return {
70
- /**
71
- * This fires an event that represents an action being successfully invoked.
72
- * @param id The unique ID for this Smart Link.
73
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
74
- * @param actionType The type of action invoked, e.g. PreviewAction
75
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
76
- */
77
- invokeSucceededEvent: function invokeSucceededEvent(_ref) {
78
- var id = _ref.id,
79
- actionType = _ref.actionType,
80
- display = _ref.display,
81
- extensionKey = _ref.extensionKey,
82
- definitionId = _ref.definitionId,
83
- resourceType = _ref.resourceType,
84
- destinationProduct = _ref.destinationProduct,
85
- destinationSubproduct = _ref.destinationSubproduct,
86
- location = _ref.location;
87
- dispatchAnalytics(applyCommonAttributes((0, _analytics.invokeSucceededEvent)({
88
- id: id !== null && id !== void 0 ? id : defaultId,
89
- actionType: actionType,
90
- display: display,
91
- extensionKey: extensionKey,
92
- definitionId: definitionId,
93
- resourceType: resourceType,
94
- destinationProduct: destinationProduct,
95
- destinationSubproduct: destinationSubproduct,
96
- location: location
97
- }), commonAttributes));
98
- },
99
- /**
100
- * This fires an event that represents an action being unsuccessfully invoked.
101
- * @param id The unique ID for this Smart Link.
102
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
103
- * @param actionType The type of action invoked, e.g. PreviewAction
104
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
105
- * @param reason The reason the invocation failed.
106
- */
107
- invokeFailedEvent: function invokeFailedEvent(_ref2) {
108
- var id = _ref2.id,
109
- actionType = _ref2.actionType,
110
- display = _ref2.display,
111
- reason = _ref2.reason,
112
- extensionKey = _ref2.extensionKey,
113
- definitionId = _ref2.definitionId,
114
- resourceType = _ref2.resourceType,
115
- destinationProduct = _ref2.destinationProduct,
116
- destinationSubproduct = _ref2.destinationSubproduct,
117
- location = _ref2.location;
118
- dispatchAnalytics(applyCommonAttributes((0, _analytics.invokeFailedEvent)({
119
- id: id !== null && id !== void 0 ? id : defaultId,
120
- actionType: actionType,
121
- display: display,
122
- reason: reason,
123
- extensionKey: extensionKey,
124
- definitionId: definitionId,
125
- resourceType: resourceType,
126
- destinationProduct: destinationProduct,
127
- destinationSubproduct: destinationSubproduct,
128
- location: location
129
- }), commonAttributes));
130
- }
131
- };
132
- }, [defaultId, commonAttributes, dispatchAnalytics]);
133
- return (0, _react.useMemo)(function () {
134
- return {
135
- operational: operational,
136
- screen: screen
137
- };
138
- }, [operational]);
139
- };
@@ -1,126 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { useSmartLinkContext } from '@atlaskit/link-provider';
3
- import { getUrl } from '@atlaskit/linking-common';
4
- import { invokeFailedEvent, invokeSucceededEvent } from '../../utils/analytics';
5
- import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getStatusDetails, getSubproduct } from '../helpers';
6
- import { useDispatchAnalytics } from './useDispatchAnalytics';
7
- const applyCommonAttributes = (event, commonAttributes) => {
8
- if (event && event.attributes) {
9
- for (const [key, value] of Object.entries(commonAttributes)) {
10
- if (event.attributes[key] === undefined) {
11
- event.attributes[key] = value;
12
- }
13
- }
14
- }
15
- return event;
16
- };
17
-
18
- /**
19
- * This hook provides usage of Smart Link analytics outside of the Card component.
20
- * Can be provided to Card via the analyticsEvents prop to change the analytics events.
21
- *
22
- * @param url URL of the link
23
- * @param id fallback id of the events sent if no id is available
24
- * @param defaultLocation location attribute to be used
25
- * @returns
26
- */
27
- export const useSmartLinkAnalytics = (url, id, defaultLocation) => {
28
- const {
29
- dispatchAnalytics
30
- } = useDispatchAnalytics();
31
- const defaultId = id || 'NULL';
32
- // We don't want to trigger a re-render by using useSmartCardState
33
- const {
34
- store
35
- } = useSmartLinkContext();
36
- const state = store ? getUrl(store, url) : undefined;
37
- const details = state ? state.details : undefined;
38
- const extractedDefinitionId = getDefinitionId(details);
39
- const extractedExtensionKey = getExtensionKey(details);
40
- const extractedResourceType = getResourceType(details);
41
- const extractedSubproduct = getSubproduct(details);
42
- const extractedProduct = getProduct(details);
43
- const extractedStatusDetails = getStatusDetails(details);
44
- const commonAttributes = useMemo(() => ({
45
- id: defaultId,
46
- definitionId: extractedDefinitionId,
47
- extensionKey: extractedExtensionKey,
48
- resourceType: extractedResourceType,
49
- destinationObjectType: extractedResourceType,
50
- destinationSubproduct: extractedSubproduct,
51
- destinationProduct: extractedProduct,
52
- location: defaultLocation,
53
- statusDetails: extractedStatusDetails
54
- }), [defaultId, extractedDefinitionId, extractedExtensionKey, extractedResourceType, extractedSubproduct, extractedProduct, defaultLocation, extractedStatusDetails]);
55
-
56
- /** Contains all operational analytics events */
57
- const operational = useMemo(() => ({
58
- /**
59
- * This fires an event that represents an action being successfully invoked.
60
- * @param id The unique ID for this Smart Link.
61
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
62
- * @param actionType The type of action invoked, e.g. PreviewAction
63
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
64
- */
65
- invokeSucceededEvent: ({
66
- id,
67
- actionType,
68
- display,
69
- extensionKey,
70
- definitionId,
71
- resourceType,
72
- destinationProduct,
73
- destinationSubproduct,
74
- location
75
- }) => {
76
- dispatchAnalytics(applyCommonAttributes(invokeSucceededEvent({
77
- id: id !== null && id !== void 0 ? id : defaultId,
78
- actionType,
79
- display,
80
- extensionKey,
81
- definitionId,
82
- resourceType,
83
- destinationProduct,
84
- destinationSubproduct,
85
- location
86
- }), commonAttributes));
87
- },
88
- /**
89
- * This fires an event that represents an action being unsuccessfully invoked.
90
- * @param id The unique ID for this Smart Link.
91
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
92
- * @param actionType The type of action invoked, e.g. PreviewAction
93
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
94
- * @param reason The reason the invocation failed.
95
- */
96
- invokeFailedEvent: ({
97
- id,
98
- actionType,
99
- display,
100
- reason,
101
- extensionKey,
102
- definitionId,
103
- resourceType,
104
- destinationProduct,
105
- destinationSubproduct,
106
- location
107
- }) => {
108
- dispatchAnalytics(applyCommonAttributes(invokeFailedEvent({
109
- id: id !== null && id !== void 0 ? id : defaultId,
110
- actionType,
111
- display,
112
- reason,
113
- extensionKey,
114
- definitionId,
115
- resourceType,
116
- destinationProduct,
117
- destinationSubproduct,
118
- location
119
- }), commonAttributes));
120
- }
121
- }), [defaultId, commonAttributes, dispatchAnalytics]);
122
- return useMemo(() => ({
123
- operational,
124
- screen
125
- }), [operational]);
126
- };
@@ -1,132 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { useMemo } from 'react';
3
- import { useSmartLinkContext } from '@atlaskit/link-provider';
4
- import { getUrl } from '@atlaskit/linking-common';
5
- import { invokeFailedEvent as _invokeFailedEvent, invokeSucceededEvent as _invokeSucceededEvent } from '../../utils/analytics';
6
- import { getDefinitionId, getExtensionKey, getProduct, getResourceType, getStatusDetails, getSubproduct } from '../helpers';
7
- import { useDispatchAnalytics } from './useDispatchAnalytics';
8
- var applyCommonAttributes = function applyCommonAttributes(event, commonAttributes) {
9
- if (event && event.attributes) {
10
- for (var _i = 0, _Object$entries = Object.entries(commonAttributes); _i < _Object$entries.length; _i++) {
11
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
12
- key = _Object$entries$_i[0],
13
- value = _Object$entries$_i[1];
14
- if (event.attributes[key] === undefined) {
15
- event.attributes[key] = value;
16
- }
17
- }
18
- }
19
- return event;
20
- };
21
-
22
- /**
23
- * This hook provides usage of Smart Link analytics outside of the Card component.
24
- * Can be provided to Card via the analyticsEvents prop to change the analytics events.
25
- *
26
- * @param url URL of the link
27
- * @param id fallback id of the events sent if no id is available
28
- * @param defaultLocation location attribute to be used
29
- * @returns
30
- */
31
- export var useSmartLinkAnalytics = function useSmartLinkAnalytics(url, id, defaultLocation) {
32
- var _useDispatchAnalytics = useDispatchAnalytics(),
33
- dispatchAnalytics = _useDispatchAnalytics.dispatchAnalytics;
34
- var defaultId = id || 'NULL';
35
- // We don't want to trigger a re-render by using useSmartCardState
36
- var _useSmartLinkContext = useSmartLinkContext(),
37
- store = _useSmartLinkContext.store;
38
- var state = store ? getUrl(store, url) : undefined;
39
- var details = state ? state.details : undefined;
40
- var extractedDefinitionId = getDefinitionId(details);
41
- var extractedExtensionKey = getExtensionKey(details);
42
- var extractedResourceType = getResourceType(details);
43
- var extractedSubproduct = getSubproduct(details);
44
- var extractedProduct = getProduct(details);
45
- var extractedStatusDetails = getStatusDetails(details);
46
- var commonAttributes = useMemo(function () {
47
- return {
48
- id: defaultId,
49
- definitionId: extractedDefinitionId,
50
- extensionKey: extractedExtensionKey,
51
- resourceType: extractedResourceType,
52
- destinationObjectType: extractedResourceType,
53
- destinationSubproduct: extractedSubproduct,
54
- destinationProduct: extractedProduct,
55
- location: defaultLocation,
56
- statusDetails: extractedStatusDetails
57
- };
58
- }, [defaultId, extractedDefinitionId, extractedExtensionKey, extractedResourceType, extractedSubproduct, extractedProduct, defaultLocation, extractedStatusDetails]);
59
-
60
- /** Contains all operational analytics events */
61
- var operational = useMemo(function () {
62
- return {
63
- /**
64
- * This fires an event that represents an action being successfully invoked.
65
- * @param id The unique ID for this Smart Link.
66
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
67
- * @param actionType The type of action invoked, e.g. PreviewAction
68
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
69
- */
70
- invokeSucceededEvent: function invokeSucceededEvent(_ref) {
71
- var id = _ref.id,
72
- actionType = _ref.actionType,
73
- display = _ref.display,
74
- extensionKey = _ref.extensionKey,
75
- definitionId = _ref.definitionId,
76
- resourceType = _ref.resourceType,
77
- destinationProduct = _ref.destinationProduct,
78
- destinationSubproduct = _ref.destinationSubproduct,
79
- location = _ref.location;
80
- dispatchAnalytics(applyCommonAttributes(_invokeSucceededEvent({
81
- id: id !== null && id !== void 0 ? id : defaultId,
82
- actionType: actionType,
83
- display: display,
84
- extensionKey: extensionKey,
85
- definitionId: definitionId,
86
- resourceType: resourceType,
87
- destinationProduct: destinationProduct,
88
- destinationSubproduct: destinationSubproduct,
89
- location: location
90
- }), commonAttributes));
91
- },
92
- /**
93
- * This fires an event that represents an action being unsuccessfully invoked.
94
- * @param id The unique ID for this Smart Link.
95
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
96
- * @param actionType The type of action invoked, e.g. PreviewAction
97
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
98
- * @param reason The reason the invocation failed.
99
- */
100
- invokeFailedEvent: function invokeFailedEvent(_ref2) {
101
- var id = _ref2.id,
102
- actionType = _ref2.actionType,
103
- display = _ref2.display,
104
- reason = _ref2.reason,
105
- extensionKey = _ref2.extensionKey,
106
- definitionId = _ref2.definitionId,
107
- resourceType = _ref2.resourceType,
108
- destinationProduct = _ref2.destinationProduct,
109
- destinationSubproduct = _ref2.destinationSubproduct,
110
- location = _ref2.location;
111
- dispatchAnalytics(applyCommonAttributes(_invokeFailedEvent({
112
- id: id !== null && id !== void 0 ? id : defaultId,
113
- actionType: actionType,
114
- display: display,
115
- reason: reason,
116
- extensionKey: extensionKey,
117
- definitionId: definitionId,
118
- resourceType: resourceType,
119
- destinationProduct: destinationProduct,
120
- destinationSubproduct: destinationSubproduct,
121
- location: location
122
- }), commonAttributes));
123
- }
124
- };
125
- }, [defaultId, commonAttributes, dispatchAnalytics]);
126
- return useMemo(function () {
127
- return {
128
- operational: operational,
129
- screen: screen
130
- };
131
- }, [operational]);
132
- };
@@ -1,33 +0,0 @@
1
- import { type InvokeFailedEventProps, type InvokeSucceededEventProps } from '../../utils/analytics/types';
2
- /**
3
- * This hook provides usage of Smart Link analytics outside of the Card component.
4
- * Can be provided to Card via the analyticsEvents prop to change the analytics events.
5
- *
6
- * @param url URL of the link
7
- * @param id fallback id of the events sent if no id is available
8
- * @param defaultLocation location attribute to be used
9
- * @returns
10
- */
11
- export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLocation?: string) => {
12
- operational: {
13
- /**
14
- * This fires an event that represents an action being successfully invoked.
15
- * @param id The unique ID for this Smart Link.
16
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
17
- * @param actionType The type of action invoked, e.g. PreviewAction
18
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
19
- */
20
- invokeSucceededEvent: ({ id, actionType, display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: InvokeSucceededEventProps) => void;
21
- /**
22
- * This fires an event that represents an action being unsuccessfully invoked.
23
- * @param id The unique ID for this Smart Link.
24
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
25
- * @param actionType The type of action invoked, e.g. PreviewAction
26
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
27
- * @param reason The reason the invocation failed.
28
- */
29
- invokeFailedEvent: ({ id, actionType, display, reason, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: InvokeFailedEventProps) => void;
30
- };
31
- screen: Screen;
32
- };
33
- export type AnalyticsFacade = ReturnType<typeof useSmartLinkAnalytics>;
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,33 +0,0 @@
1
- import { type InvokeFailedEventProps, type InvokeSucceededEventProps } from '../../utils/analytics/types';
2
- /**
3
- * This hook provides usage of Smart Link analytics outside of the Card component.
4
- * Can be provided to Card via the analyticsEvents prop to change the analytics events.
5
- *
6
- * @param url URL of the link
7
- * @param id fallback id of the events sent if no id is available
8
- * @param defaultLocation location attribute to be used
9
- * @returns
10
- */
11
- export declare const useSmartLinkAnalytics: (url: string, id?: string, defaultLocation?: string) => {
12
- operational: {
13
- /**
14
- * This fires an event that represents an action being successfully invoked.
15
- * @param id The unique ID for this Smart Link.
16
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
17
- * @param actionType The type of action invoked, e.g. PreviewAction
18
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
19
- */
20
- invokeSucceededEvent: ({ id, actionType, display, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: InvokeSucceededEventProps) => void;
21
- /**
22
- * This fires an event that represents an action being unsuccessfully invoked.
23
- * @param id The unique ID for this Smart Link.
24
- * @param extensionKey The extensionKey of the Smart Link resovler invoked.
25
- * @param actionType The type of action invoked, e.g. PreviewAction
26
- * @param display Whether the card was an Inline, Block, Embed or Flexible UI.
27
- * @param reason The reason the invocation failed.
28
- */
29
- invokeFailedEvent: ({ id, actionType, display, reason, extensionKey, definitionId, resourceType, destinationProduct, destinationSubproduct, location, }: InvokeFailedEventProps) => void;
30
- };
31
- screen: Screen;
32
- };
33
- export type AnalyticsFacade = ReturnType<typeof useSmartLinkAnalytics>;
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;