@atlaskit/smart-card 26.3.4 → 26.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.3.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 26.3.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [`36b440f8c7f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/36b440f8c7f) - Disable prop-drilling of analytics dispatch function
14
+
3
15
  ## 26.3.4
4
16
 
5
17
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.3.4",
3
+ "version": "26.3.6",
4
4
  "sideEffects": false
5
5
  }
@@ -9,6 +9,7 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
  var _uuid = _interopRequireDefault(require("uuid"));
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
12
13
  var _analytics = require("../../utils/analytics");
13
14
  var _performance = require("../../utils/performance");
14
15
  var _reactErrorBoundary = require("react-error-boundary");
@@ -63,15 +64,29 @@ function CardWithURLRenderer(props) {
63
64
  placeholder = props.placeholder;
64
65
 
65
66
  // Wrapper around analytics.
66
- var dispatchAnalytics = (0, _react.useCallback)(function (analyticsPayload) {
67
- if (analyticsPayload && analyticsPayload.attributes) {
68
- // Update if we haven't already set the display - possible
69
- // in the case of `preview` which is rendered differently.
70
- if (!analyticsPayload.attributes.display) {
71
- analyticsPayload.attributes.display = appearance;
72
- }
67
+ var dispatchAnalytics = (0, _react.useMemo)(function () {
68
+ /**
69
+ * If feature flag is on, return `undefined` for dispatch, which will be passed down
70
+ * to the components as undefined and the fallback method will be used instead to dispatch
71
+ * analytics events:
72
+ * packages/linking-platform/smart-card/src/state/analytics/useDispatchAnalytics.ts
73
+ *
74
+ * For FF cleanup, we should be able to remove the prop from all the places where this is
75
+ * being passed down to.
76
+ */
77
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop')) {
78
+ return undefined;
73
79
  }
74
- (0, _analytics.fireSmartLinkEvent)(analyticsPayload, createAnalyticsEvent);
80
+ return function (analyticsPayload) {
81
+ if (analyticsPayload && analyticsPayload.attributes) {
82
+ // Update if we haven't already set the display - possible
83
+ // in the case of `preview` which is rendered differently.
84
+ if (!analyticsPayload.attributes.display) {
85
+ analyticsPayload.attributes.display = appearance;
86
+ }
87
+ }
88
+ (0, _analytics.fireSmartLinkEvent)(analyticsPayload, createAnalyticsEvent);
89
+ };
75
90
  }, [appearance, createAnalyticsEvent]);
76
91
  var analytics = (0, _analytics2.useSmartLinkAnalytics)(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
77
92
  var logError = (0, _react.useCallback)(function (error, info) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.3.4",
3
+ "version": "26.3.6",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,6 @@
1
- import React, { lazy, useEffect, useState, Suspense, useCallback } from 'react';
1
+ import React, { lazy, useEffect, useState, Suspense, useCallback, useMemo } from 'react';
2
2
  import uuid from 'uuid';
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
4
  import { fireSmartLinkEvent } from '../../utils/analytics';
4
5
  import { clearMarks, clearMeasures } from '../../utils/performance';
5
6
  import { ErrorBoundary } from 'react-error-boundary';
@@ -44,15 +45,29 @@ export function CardWithURLRenderer(props) {
44
45
  } = props;
45
46
 
46
47
  // Wrapper around analytics.
47
- const dispatchAnalytics = useCallback(analyticsPayload => {
48
- if (analyticsPayload && analyticsPayload.attributes) {
49
- // Update if we haven't already set the display - possible
50
- // in the case of `preview` which is rendered differently.
51
- if (!analyticsPayload.attributes.display) {
52
- analyticsPayload.attributes.display = appearance;
53
- }
48
+ const dispatchAnalytics = useMemo(() => {
49
+ /**
50
+ * If feature flag is on, return `undefined` for dispatch, which will be passed down
51
+ * to the components as undefined and the fallback method will be used instead to dispatch
52
+ * analytics events:
53
+ * packages/linking-platform/smart-card/src/state/analytics/useDispatchAnalytics.ts
54
+ *
55
+ * For FF cleanup, we should be able to remove the prop from all the places where this is
56
+ * being passed down to.
57
+ */
58
+ if (getBooleanFF('platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop')) {
59
+ return undefined;
54
60
  }
55
- fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
61
+ return analyticsPayload => {
62
+ if (analyticsPayload && analyticsPayload.attributes) {
63
+ // Update if we haven't already set the display - possible
64
+ // in the case of `preview` which is rendered differently.
65
+ if (!analyticsPayload.attributes.display) {
66
+ analyticsPayload.attributes.display = appearance;
67
+ }
68
+ }
69
+ fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
70
+ };
56
71
  }, [appearance, createAnalyticsEvent]);
57
72
  const analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
58
73
  const logError = useCallback((error, info) => {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.3.4",
3
+ "version": "26.3.6",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { lazy, useEffect, useState, Suspense, useCallback } from 'react';
2
+ import React, { lazy, useEffect, useState, Suspense, useCallback, useMemo } from 'react';
3
3
  import uuid from 'uuid';
4
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
5
  import { fireSmartLinkEvent } from '../../utils/analytics';
5
6
  import { clearMarks, clearMeasures } from '../../utils/performance';
6
7
  import { ErrorBoundary } from 'react-error-boundary';
@@ -51,15 +52,29 @@ export function CardWithURLRenderer(props) {
51
52
  placeholder = props.placeholder;
52
53
 
53
54
  // Wrapper around analytics.
54
- var dispatchAnalytics = useCallback(function (analyticsPayload) {
55
- if (analyticsPayload && analyticsPayload.attributes) {
56
- // Update if we haven't already set the display - possible
57
- // in the case of `preview` which is rendered differently.
58
- if (!analyticsPayload.attributes.display) {
59
- analyticsPayload.attributes.display = appearance;
60
- }
55
+ var dispatchAnalytics = useMemo(function () {
56
+ /**
57
+ * If feature flag is on, return `undefined` for dispatch, which will be passed down
58
+ * to the components as undefined and the fallback method will be used instead to dispatch
59
+ * analytics events:
60
+ * packages/linking-platform/smart-card/src/state/analytics/useDispatchAnalytics.ts
61
+ *
62
+ * For FF cleanup, we should be able to remove the prop from all the places where this is
63
+ * being passed down to.
64
+ */
65
+ if (getBooleanFF('platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop')) {
66
+ return undefined;
61
67
  }
62
- fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
68
+ return function (analyticsPayload) {
69
+ if (analyticsPayload && analyticsPayload.attributes) {
70
+ // Update if we haven't already set the display - possible
71
+ // in the case of `preview` which is rendered differently.
72
+ if (!analyticsPayload.attributes.display) {
73
+ analyticsPayload.attributes.display = appearance;
74
+ }
75
+ }
76
+ fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
77
+ };
63
78
  }, [appearance, createAnalyticsEvent]);
64
79
  var analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
65
80
  var logError = useCallback(function (error, info) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.3.4",
3
+ "version": "26.3.6",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -47,7 +47,7 @@
47
47
  "@atlaskit/linking-types": "^3.0.0",
48
48
  "@atlaskit/logo": "^13.14.0",
49
49
  "@atlaskit/lozenge": "^11.4.0",
50
- "@atlaskit/media-common": "^4.1.0",
50
+ "@atlaskit/media-common": "^5.0.0",
51
51
  "@atlaskit/modal-dialog": "^12.5.0",
52
52
  "@atlaskit/outbound-auth-flow-client": "^3.4.0",
53
53
  "@atlaskit/platform-feature-flags": "^0.2.1",
@@ -144,6 +144,9 @@
144
144
  },
145
145
  "platform.linking-platform.smart-card.refactor-hover-card-analytics": {
146
146
  "type": "boolean"
147
+ },
148
+ "platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop": {
149
+ "type": "boolean"
147
150
  }
148
151
  },
149
152
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1",