@atlaskit/profilecard 16.12.1 → 17.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 (74) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/client/ProfileCardClient.js +2 -2
  3. package/dist/cjs/client/TeamProfileCardClient.js +13 -12
  4. package/dist/cjs/client/UserProfileCardClient.js +25 -2
  5. package/dist/cjs/client/errorUtils.js +25 -0
  6. package/dist/cjs/components/Error/ErrorMessage.js +40 -77
  7. package/dist/cjs/components/Team/TeamLoadingState.js +1 -1
  8. package/dist/cjs/components/Team/TeamProfileCard.js +4 -4
  9. package/dist/cjs/components/Team/TeamProfileCardTrigger.js +3 -3
  10. package/dist/cjs/components/User/OverflowProfileCardButtons.js +44 -10
  11. package/dist/cjs/components/User/ProfileCard.js +195 -362
  12. package/dist/cjs/components/User/ProfileCardDetails.js +142 -0
  13. package/dist/cjs/components/User/ProfileCardResourced.js +25 -20
  14. package/dist/cjs/components/User/ProfileCardTrigger.js +35 -7
  15. package/dist/cjs/components/User/ReportingLinesDetails.js +13 -13
  16. package/dist/cjs/components/User/UserLoadingState.js +14 -2
  17. package/dist/cjs/util/analytics.js +31 -16
  18. package/dist/cjs/version.json +1 -1
  19. package/dist/es2019/client/ProfileCardClient.js +2 -2
  20. package/dist/es2019/client/TeamProfileCardClient.js +3 -9
  21. package/dist/es2019/client/UserProfileCardClient.js +23 -2
  22. package/dist/es2019/client/errorUtils.js +17 -0
  23. package/dist/es2019/components/Error/ErrorMessage.js +38 -42
  24. package/dist/es2019/components/Team/TeamLoadingState.js +2 -2
  25. package/dist/es2019/components/Team/TeamProfileCard.js +5 -5
  26. package/dist/es2019/components/Team/TeamProfileCardTrigger.js +4 -4
  27. package/dist/es2019/components/User/OverflowProfileCardButtons.js +30 -4
  28. package/dist/es2019/components/User/ProfileCard.js +161 -292
  29. package/dist/es2019/components/User/ProfileCardDetails.js +118 -0
  30. package/dist/es2019/components/User/ProfileCardResourced.js +21 -21
  31. package/dist/es2019/components/User/ProfileCardTrigger.js +32 -6
  32. package/dist/es2019/components/User/ReportingLinesDetails.js +10 -11
  33. package/dist/es2019/components/User/UserLoadingState.js +10 -2
  34. package/dist/es2019/util/analytics.js +13 -8
  35. package/dist/es2019/version.json +1 -1
  36. package/dist/esm/client/ProfileCardClient.js +2 -2
  37. package/dist/esm/client/TeamProfileCardClient.js +11 -12
  38. package/dist/esm/client/UserProfileCardClient.js +22 -2
  39. package/dist/esm/client/errorUtils.js +17 -0
  40. package/dist/esm/components/Error/ErrorMessage.js +35 -80
  41. package/dist/esm/components/Team/TeamLoadingState.js +2 -2
  42. package/dist/esm/components/Team/TeamProfileCard.js +5 -5
  43. package/dist/esm/components/Team/TeamProfileCardTrigger.js +4 -4
  44. package/dist/esm/components/User/OverflowProfileCardButtons.js +39 -9
  45. package/dist/esm/components/User/ProfileCard.js +180 -362
  46. package/dist/esm/components/User/ProfileCardDetails.js +120 -0
  47. package/dist/esm/components/User/ProfileCardResourced.js +17 -17
  48. package/dist/esm/components/User/ProfileCardTrigger.js +33 -7
  49. package/dist/esm/components/User/ReportingLinesDetails.js +12 -12
  50. package/dist/esm/components/User/UserLoadingState.js +7 -2
  51. package/dist/esm/util/analytics.js +21 -12
  52. package/dist/esm/version.json +1 -1
  53. package/dist/types/client/ProfileCardClient.d.ts +3 -2
  54. package/dist/types/client/TeamProfileCardClient.d.ts +2 -1
  55. package/dist/types/client/UserProfileCardClient.d.ts +2 -1
  56. package/dist/types/client/errorUtils.d.ts +6 -0
  57. package/dist/types/components/Error/ErrorMessage.d.ts +6 -15
  58. package/dist/types/components/Team/TeamProfileCardTrigger.d.ts +5 -11
  59. package/dist/types/components/User/OverflowProfileCardButtons.d.ts +4 -3
  60. package/dist/types/components/User/ProfileCard.d.ts +5 -29
  61. package/dist/types/components/User/ProfileCardDetails.d.ts +3 -0
  62. package/dist/types/components/User/ProfileCardResourced.d.ts +7 -3
  63. package/dist/types/components/User/ProfileCardTrigger.d.ts +3 -40
  64. package/dist/types/components/User/ReportingLinesDetails.d.ts +2 -4
  65. package/dist/types/components/User/UserLoadingState.d.ts +5 -1
  66. package/dist/types/components/User/lazyProfileCard.d.ts +1 -1
  67. package/dist/types/types.d.ts +11 -10
  68. package/dist/types/util/analytics.d.ts +22 -13
  69. package/package.json +8 -8
  70. package/report.api.md +71 -124
  71. package/dist/cjs/internal/analytics.js +0 -15
  72. package/dist/es2019/internal/analytics.js +0 -8
  73. package/dist/esm/internal/analytics.js +0 -8
  74. package/dist/types/internal/analytics.d.ts +0 -8
@@ -0,0 +1,120 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["text"];
4
+ import React from 'react';
5
+ import { FormattedMessage } from 'react-intl-next';
6
+ import Lozenge from '@atlaskit/lozenge';
7
+ import relativeDate from '../../internal/relative-date';
8
+ import messages from '../../messages';
9
+ import { AppTitleLabel, CustomLozengeContainer, DetailsGroup, DisabledInfo, FullNameLabel, JobTitleLabel, LozengeWrapper } from '../../styled/Card';
10
+ import { IconLabel } from '../Icon';
11
+ import ReportingLinesDetails from './ReportingLinesDetails';
12
+
13
+ var renderName = function renderName(nickname, fullName, meta) {
14
+ if (!fullName && !nickname) {
15
+ return null;
16
+ }
17
+
18
+ var isNicknameRedundant = !nickname || nickname === fullName;
19
+ var shownNickname = " (".concat(nickname, ") ");
20
+ var displayName = isNicknameRedundant ? fullName : "".concat(fullName).concat(shownNickname);
21
+ return /*#__PURE__*/React.createElement(FullNameLabel, {
22
+ noMeta: !meta,
23
+ "data-testid": "profilecard-name"
24
+ }, displayName);
25
+ };
26
+
27
+ var disabledAccountDesc = function disabledAccountDesc(statusModifiedDate, disabledAccountMessage) {
28
+ var status = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'closed';
29
+
30
+ // consumer does not want to use built-in message
31
+ if (disabledAccountMessage) {
32
+ return disabledAccountMessage;
33
+ }
34
+
35
+ var date = statusModifiedDate ? new Date(statusModifiedDate * 1000) : null;
36
+ var relativeDateKey = relativeDate(date);
37
+ var msgKey = relativeDateKey ? "".concat(status, "AccountDescMsgHasDate").concat(relativeDateKey) : "".concat(status, "AccountDescMsgNoDate");
38
+ var secondSentence = /*#__PURE__*/React.createElement(FormattedMessage, messages[msgKey]);
39
+ return /*#__PURE__*/React.createElement("p", {
40
+ "data-testid": "profilecard-disabled-account"
41
+ }, /*#__PURE__*/React.createElement(FormattedMessage, messages.generalDescMsgForDisabledUser), ' ', secondSentence);
42
+ };
43
+
44
+ var CustomLozenges = function CustomLozenges(_ref) {
45
+ var _ref$lozenges = _ref.lozenges,
46
+ lozenges = _ref$lozenges === void 0 ? [] : _ref$lozenges;
47
+
48
+ if (lozenges.length === 0) {
49
+ return null;
50
+ }
51
+
52
+ return /*#__PURE__*/React.createElement(CustomLozengeContainer, null, lozenges.map(function (_ref2, index) {
53
+ var text = _ref2.text,
54
+ otherProps = _objectWithoutProperties(_ref2, _excluded);
55
+
56
+ return /*#__PURE__*/React.createElement(Lozenge, _extends({}, otherProps, {
57
+ key: index
58
+ }), text);
59
+ }));
60
+ };
61
+
62
+ var BotProfileCardDetails = function BotProfileCardDetails(props) {
63
+ var fullName = props.fullName,
64
+ nickname = props.nickname;
65
+ return /*#__PURE__*/React.createElement(DetailsGroup, null, renderName(nickname, fullName), /*#__PURE__*/React.createElement(AppTitleLabel, null, "App"));
66
+ };
67
+
68
+ var DisabledProfileCardDetails = function DisabledProfileCardDetails(props) {
69
+ var companyName = props.companyName,
70
+ disabledAccountMessage = props.disabledAccountMessage,
71
+ fullName = props.fullName,
72
+ _props$hasDisabledAcc = props.hasDisabledAccountLozenge,
73
+ hasDisabledAccountLozenge = _props$hasDisabledAcc === void 0 ? true : _props$hasDisabledAcc,
74
+ nickname = props.nickname,
75
+ status = props.status,
76
+ statusModifiedDate = props.statusModifiedDate;
77
+ var name = status === 'inactive' ? fullName || nickname : nickname || /*#__PURE__*/React.createElement(FormattedMessage, messages.disabledAccountDefaultName);
78
+ return /*#__PURE__*/React.createElement(DetailsGroup, null, /*#__PURE__*/React.createElement(FullNameLabel, {
79
+ noMeta: true,
80
+ isDisabledAccount: true,
81
+ "data-testid": "profilecard-name"
82
+ }, name), hasDisabledAccountLozenge && /*#__PURE__*/React.createElement(LozengeWrapper, null, /*#__PURE__*/React.createElement(Lozenge, {
83
+ appearance: "default",
84
+ isBold: true
85
+ }, status === 'inactive' ? /*#__PURE__*/React.createElement(FormattedMessage, messages.inactiveAccountMsg) : /*#__PURE__*/React.createElement(FormattedMessage, messages.closedAccountMsg))), /*#__PURE__*/React.createElement(DisabledInfo, null, disabledAccountDesc(statusModifiedDate, disabledAccountMessage, status)), status === 'inactive' && /*#__PURE__*/React.createElement(IconLabel, {
86
+ icon: "companyName"
87
+ }, companyName));
88
+ };
89
+
90
+ export var ProfileCardDetails = function ProfileCardDetails(props) {
91
+ var meta = props.meta,
92
+ status = props.status;
93
+
94
+ if (props.isBot) {
95
+ return /*#__PURE__*/React.createElement(BotProfileCardDetails, props);
96
+ }
97
+
98
+ if (status === 'inactive' || status === 'closed') {
99
+ return /*#__PURE__*/React.createElement(DisabledProfileCardDetails, _extends({}, props, {
100
+ status: status
101
+ }));
102
+ }
103
+
104
+ return /*#__PURE__*/React.createElement(DetailsGroup, null, renderName(props.nickname, props.fullName, meta), meta && /*#__PURE__*/React.createElement(JobTitleLabel, null, meta), /*#__PURE__*/React.createElement(CustomLozenges, {
105
+ lozenges: props.customLozenges
106
+ }), /*#__PURE__*/React.createElement(IconLabel, {
107
+ icon: "email"
108
+ }, props.email), /*#__PURE__*/React.createElement(IconLabel, {
109
+ icon: "time"
110
+ }, props.timestring), /*#__PURE__*/React.createElement(IconLabel, {
111
+ icon: "companyName"
112
+ }, props.companyName), /*#__PURE__*/React.createElement(IconLabel, {
113
+ icon: "location"
114
+ }, props.location), /*#__PURE__*/React.createElement(ReportingLinesDetails, {
115
+ reportingLines: props.reportingLines,
116
+ reportingLinesProfileUrl: props.reportingLinesProfileUrl,
117
+ onReportingLinesClick: props.onReportingLinesClick,
118
+ fireAnalyticsWithDuration: props.fireAnalyticsWithDuration
119
+ }));
120
+ };
@@ -17,10 +17,11 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
17
17
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
18
 
19
19
  import React, { Suspense } from 'react';
20
+ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
20
21
  import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
21
- import { AnalyticsName } from '../../internal/analytics';
22
22
  import filterActions from '../../internal/filterActions';
23
23
  import { CardWrapper } from '../../styled/Card';
24
+ import { fireEvent } from '../../util/analytics';
24
25
  import { ErrorMessage } from '../Error';
25
26
  import ProfileCard from './ProfileCard';
26
27
  import UserLoadingState from './UserLoadingState';
@@ -54,12 +55,14 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
54
55
  kudosDrawerOpen: false
55
56
  });
56
57
 
57
- _defineProperty(_assertThisInitialized(_this), "callAnalytics", function (id) {
58
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
59
- var analytics = _this.props.analytics;
58
+ _defineProperty(_assertThisInitialized(_this), "fireAnalytics", function (payload) {
59
+ // Don't fire analytics if the component is unmounted
60
+ if (!_this._isMounted) {
61
+ return;
62
+ }
60
63
 
61
- if (analytics) {
62
- analytics(id, options);
64
+ if (_this.props.createAnalyticsEvent) {
65
+ fireEvent(_this.props.createAnalyticsEvent, payload);
63
66
  }
64
67
  });
65
68
 
@@ -79,7 +82,7 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
79
82
  hasError: false,
80
83
  data: null
81
84
  }, function () {
82
- var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId, userId), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos()]);
85
+ var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId, userId, _this.fireAnalytics), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos()]);
83
86
  requests.then(function (res) {
84
87
  var _this2;
85
88
 
@@ -124,17 +127,12 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
124
127
  userId = _this$props2.userId,
125
128
  cloudId = _this$props2.cloudId,
126
129
  resourceClient = _this$props2.resourceClient;
127
- var hasError = this.state.hasError;
128
130
 
129
131
  if (userId !== prevProps.userId || cloudId !== prevProps.cloudId || resourceClient !== prevProps.resourceClient) {
130
132
  this.setState({
131
133
  isLoading: undefined
132
134
  }, this.clientFetchProfile);
133
135
  }
134
-
135
- if (hasError !== prevState.hasError && hasError) {
136
- this.callAnalytics(AnalyticsName.PROFILE_CARD_RESOURCED_ERROR);
137
- }
138
136
  }
139
137
  }, {
140
138
  key: "componentWillUnmount",
@@ -180,7 +178,6 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
180
178
  reportingLinesData = _this$state.reportingLinesData,
181
179
  isKudosEnabled = _this$state.isKudosEnabled;
182
180
  var _this$props3 = this.props,
183
- analytics = _this$props3.analytics,
184
181
  onReportingLinesClick = _this$props3.onReportingLinesClick,
185
182
  cloudId = _this$props3.cloudId,
186
183
  userId = _this$props3.userId,
@@ -188,11 +185,14 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
188
185
  var isFetchingOrNotStartToFetchYet = isLoading === true || isLoading === undefined;
189
186
 
190
187
  if (isFetchingOrNotStartToFetchYet) {
191
- return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(UserLoadingState, null));
188
+ return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(UserLoadingState, {
189
+ fireAnalytics: this.fireAnalytics
190
+ }));
192
191
  } else if (hasError) {
193
192
  return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
194
193
  errorType: error,
195
- reload: this.clientFetchProfile
194
+ reload: this.clientFetchProfile,
195
+ fireAnalytics: this.fireAnalytics
196
196
  }));
197
197
  }
198
198
 
@@ -200,7 +200,6 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
200
200
  hasError: hasError,
201
201
  errorType: error,
202
202
  clientFetchProfile: this.clientFetchProfile,
203
- analytics: analytics,
204
203
  reportingLines: reportingLinesData,
205
204
  onReportingLinesClick: onReportingLinesClick,
206
205
  cloudId: cloudId,
@@ -238,4 +237,5 @@ _defineProperty(ProfileCardResourced, "defaultProps", {
238
237
  actions: []
239
238
  });
240
239
 
241
- export { ProfileCardResourced as default };
240
+ export var ProfileCardResourcedInternal = ProfileCardResourced;
241
+ export default withAnalyticsEvents()(ProfileCardResourced);
@@ -19,11 +19,13 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
19
19
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
20
 
21
21
  import React, { Suspense } from 'react';
22
+ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
22
23
  import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
23
24
  import Popup from '@atlaskit/popup';
24
25
  import { layers } from '@atlaskit/theme/constants';
25
26
  import _filterActions from '../../internal/filterActions';
26
27
  import { CardWrapper } from '../../styled/Card';
28
+ import { cardTriggered, fireEvent } from '../../util/analytics';
27
29
  import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
28
30
  import { ProfileCardLazy } from './lazyProfileCard';
29
31
  import UserLoadingState from './UserLoadingState';
@@ -54,6 +56,17 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
54
56
 
55
57
  _defineProperty(_assertThisInitialized(_this), "hideTimer", 0);
56
58
 
59
+ _defineProperty(_assertThisInitialized(_this), "fireAnalytics", function (payload) {
60
+ // Don't fire any analytics if the component is unmounted
61
+ if (!_this._isMounted) {
62
+ return;
63
+ }
64
+
65
+ if (_this.props.createAnalyticsEvent) {
66
+ fireEvent(_this.props.createAnalyticsEvent, payload);
67
+ }
68
+ });
69
+
57
70
  _defineProperty(_assertThisInitialized(_this), "hideProfilecard", function () {
58
71
  clearTimeout(_this.showTimer);
59
72
  clearTimeout(_this.hideTimer);
@@ -85,10 +98,22 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
85
98
  event.stopPropagation();
86
99
 
87
100
  _this.showProfilecard();
101
+
102
+ if (!_this.state.visible) {
103
+ _this.fireAnalytics(cardTriggered('user', 'click'));
104
+ }
105
+ });
106
+
107
+ _defineProperty(_assertThisInitialized(_this), "onMouseEnter", function () {
108
+ _this.showProfilecard();
109
+
110
+ if (!_this.state.visible) {
111
+ _this.fireAnalytics(cardTriggered('user', 'hover'));
112
+ }
88
113
  });
89
114
 
90
115
  _defineProperty(_assertThisInitialized(_this), "containerListeners", _this.props.trigger === 'hover' ? {
91
- onMouseEnter: _this.showProfilecard,
116
+ onMouseEnter: _this.onMouseEnter,
92
117
  onMouseLeave: _this.hideProfilecard
93
118
  } : {
94
119
  onClick: _this.onClick
@@ -131,7 +156,7 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
131
156
  hasError: false,
132
157
  data: null
133
158
  }, function () {
134
- var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId || '', userId), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos()]);
159
+ var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId || '', userId, _this.fireAnalytics), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos()]);
135
160
  requests.then(function (res) {
136
161
  var _this2;
137
162
 
@@ -162,7 +187,9 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
162
187
  var isLoading = _this.state.isLoading;
163
188
 
164
189
  if (isLoading === true || isLoading === undefined) {
165
- return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(UserLoadingState, null));
190
+ return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(UserLoadingState, {
191
+ fireAnalytics: _this.fireAnalytics
192
+ }));
166
193
  } else {
167
194
  return _this.renderProfileCard();
168
195
  }
@@ -239,8 +266,7 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
239
266
  var newProps = _objectSpread(_objectSpread({
240
267
  userId: this.props.userId,
241
268
  isCurrentUser: (_this$state$data = this.state.data) === null || _this$state$data === void 0 ? void 0 : _this$state$data.isCurrentUser,
242
- clientFetchProfile: this.clientFetchProfile,
243
- analytics: this.props.analytics
269
+ clientFetchProfile: this.clientFetchProfile
244
270
  }, this.state.data), {}, {
245
271
  reportingLines: this.state.reportingLinesData,
246
272
  onReportingLinesClick: this.props.onReportingLinesClick,
@@ -251,7 +277,7 @@ var ProfilecardTrigger = /*#__PURE__*/function (_React$PureComponent) {
251
277
  });
252
278
 
253
279
  var wrapperProps = this.props.trigger === 'hover' ? {
254
- onMouseEnter: this.showProfilecard,
280
+ onMouseEnter: this.onMouseEnter,
255
281
  onMouseLeave: this.hideProfilecard
256
282
  } : {};
257
283
  return /*#__PURE__*/React.createElement("div", wrapperProps, this.state.visible && /*#__PURE__*/React.createElement(Suspense, {
@@ -319,4 +345,4 @@ _defineProperty(ProfilecardTrigger, "defaultProps", {
319
345
  position: 'bottom-start'
320
346
  });
321
347
 
322
- export default ProfilecardTrigger;
348
+ export default withAnalyticsEvents()(ProfilecardTrigger);
@@ -3,9 +3,9 @@ import { FormattedMessage } from 'react-intl-next';
3
3
  import Avatar from '@atlaskit/avatar';
4
4
  import AvatarGroup from '@atlaskit/avatar-group';
5
5
  import Button from '@atlaskit/button/custom-theme-button';
6
- import { AnalyticsName } from '../../internal/analytics';
7
6
  import messages from '../../messages';
8
7
  import { ManagerName, ManagerSection, OffsetWrapper, ReportingLinesHeading, ReportingLinesSection } from '../../styled/ReportingLines';
8
+ import { reportingLinesClicked } from '../../util/analytics';
9
9
 
10
10
  function getProfileHref(userId, profileUrl) {
11
11
  return profileUrl ? profileUrl + userId : undefined;
@@ -14,13 +14,11 @@ function getProfileHref(userId, profileUrl) {
14
14
  var ReportingLinesDetails = function ReportingLinesDetails(props) {
15
15
  var _manager$pii, _manager$pii2;
16
16
 
17
- var _props$reportingLines = props.reportingLines,
17
+ var fireAnalyticsWithDuration = props.fireAnalyticsWithDuration,
18
+ _props$reportingLines = props.reportingLines,
18
19
  reportingLines = _props$reportingLines === void 0 ? {} : _props$reportingLines,
19
20
  reportingLinesProfileUrl = props.reportingLinesProfileUrl,
20
- onReportingLinesClick = props.onReportingLinesClick,
21
- _props$analytics = props.analytics,
22
- analytics = _props$analytics === void 0 ? function () {} : _props$analytics,
23
- getDuration = props.getDuration;
21
+ onReportingLinesClick = props.onReportingLinesClick;
24
22
  var _reportingLines$manag = reportingLines.managers,
25
23
  managers = _reportingLines$manag === void 0 ? [] : _reportingLines$manag,
26
24
  _reportingLines$repor = reportingLines.reports,
@@ -28,11 +26,13 @@ var ReportingLinesDetails = function ReportingLinesDetails(props) {
28
26
  var manager = managers.length >= 1 ? managers[0] : undefined;
29
27
  var hasReports = reports.length > 0;
30
28
 
31
- var getReportingLinesOnClick = function getReportingLinesOnClick(user, analyticsId) {
29
+ var getReportingLinesOnClick = function getReportingLinesOnClick(user, userType) {
32
30
  return onReportingLinesClick ? function () {
33
- analytics(AnalyticsName.PROFILE_CARD_CLICK, {
34
- id: analyticsId,
35
- duration: getDuration()
31
+ fireAnalyticsWithDuration(function (duration) {
32
+ return reportingLinesClicked({
33
+ duration: duration,
34
+ userType: userType
35
+ });
36
36
  });
37
37
  onReportingLinesClick(user);
38
38
  } : undefined;
@@ -46,7 +46,7 @@ var ReportingLinesDetails = function ReportingLinesDetails(props) {
46
46
  appearance: "subtle",
47
47
  spacing: "none",
48
48
  href: getProfileHref(manager.accountIdentifier, reportingLinesProfileUrl),
49
- onClick: getReportingLinesOnClick(manager, 'reporting-lines-manager'),
49
+ onClick: getReportingLinesOnClick(manager, 'manager'),
50
50
  isDisabled: !onReportingLinesClick
51
51
  }, /*#__PURE__*/React.createElement(ManagerSection, null, /*#__PURE__*/React.createElement(Avatar, {
52
52
  size: "xsmall",
@@ -62,7 +62,7 @@ var ReportingLinesDetails = function ReportingLinesDetails(props) {
62
62
  name: ((_member$pii = member.pii) === null || _member$pii === void 0 ? void 0 : _member$pii.name) || '',
63
63
  src: (_member$pii2 = member.pii) === null || _member$pii2 === void 0 ? void 0 : _member$pii2.picture,
64
64
  href: getProfileHref(member.accountIdentifier, reportingLinesProfileUrl),
65
- onClick: getReportingLinesOnClick(member, 'reporting-lines-direct-report')
65
+ onClick: getReportingLinesOnClick(member, 'direct-report')
66
66
  };
67
67
  }),
68
68
  maxCount: 5,
@@ -1,8 +1,13 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import AkSpinner from '@atlaskit/spinner';
3
3
  import { SpinnerContainer } from '../../styled/Card';
4
+ import { profileCardRendered } from '../../util/analytics';
4
5
 
5
- var UserLoadingState = function UserLoadingState() {
6
+ var UserLoadingState = function UserLoadingState(_ref) {
7
+ var fireAnalytics = _ref.fireAnalytics;
8
+ useEffect(function () {
9
+ fireAnalytics(profileCardRendered('user', 'spinner'));
10
+ }, [fireAnalytics]);
6
11
  return /*#__PURE__*/React.createElement(SpinnerContainer, null, /*#__PURE__*/React.createElement(AkSpinner, null));
7
12
  };
8
13
 
@@ -10,8 +10,10 @@ import { getPageTime } from './performance';
10
10
  var ANALYTICS_CHANNEL = 'peopleTeams';
11
11
 
12
12
  var runItLater = function runItLater(cb) {
13
- if (window.requestIdleCallback === 'function') {
14
- return window.requestIdleCallback(cb);
13
+ var requestIdleCallback = window.requestIdleCallback;
14
+
15
+ if (typeof requestIdleCallback === 'function') {
16
+ return requestIdleCallback(cb);
15
17
  }
16
18
 
17
19
  if (typeof window.requestAnimationFrame === 'function') {
@@ -35,6 +37,7 @@ export var fireEvent = function fireEvent(createAnalyticsEvent, body) {
35
37
  /** Above lines are copied from teams common analytics */
36
38
 
37
39
  var TEAM_SUBJECT = 'teamProfileCard';
40
+ var USER_SUBJECT = 'profilecard';
38
41
 
39
42
  var createEvent = function createEvent(eventType, action, actionSubject, actionSubjectId) {
40
43
  var attributes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
@@ -45,29 +48,35 @@ var createEvent = function createEvent(eventType, action, actionSubject, actionS
45
48
  actionSubjectId: actionSubjectId,
46
49
  attributes: _objectSpread(_objectSpread({
47
50
  packageName: "@atlaskit/profilecard",
48
- packageVersion: "16.12.1"
51
+ packageVersion: "17.0.0"
49
52
  }, attributes), {}, {
50
- firedAt: getPageTime()
53
+ firedAt: Math.round(getPageTime())
51
54
  })
52
55
  };
53
56
  };
54
57
 
55
- export var teamCardTriggered = function teamCardTriggered(method) {
56
- return createEvent('ui', 'triggered', TEAM_SUBJECT, undefined, {
58
+ export var cardTriggered = function cardTriggered(type, method) {
59
+ return createEvent('ui', 'triggered', type === 'user' ? USER_SUBJECT : TEAM_SUBJECT, undefined, {
57
60
  method: method
58
61
  });
59
62
  };
60
63
  export var teamRequestAnalytics = function teamRequestAnalytics(action, attributes) {
61
64
  return createEvent('operational', action, TEAM_SUBJECT, 'request', attributes);
62
65
  };
63
- export var teamProfileCardRendered = function teamProfileCardRendered(actionSubjectId, attributes) {
64
- return createEvent('ui', 'rendered', TEAM_SUBJECT, actionSubjectId, attributes);
66
+ export var userRequestAnalytics = function userRequestAnalytics(action, attributes) {
67
+ return createEvent('operational', action, USER_SUBJECT, 'request', attributes);
68
+ };
69
+ export var profileCardRendered = function profileCardRendered(type, actionSubjectId, attributes) {
70
+ return createEvent('ui', 'rendered', type === 'user' ? USER_SUBJECT : TEAM_SUBJECT, actionSubjectId, attributes);
71
+ };
72
+ export var actionClicked = function actionClicked(type, attributes) {
73
+ return createEvent('ui', 'clicked', type === 'user' ? USER_SUBJECT : TEAM_SUBJECT, 'action', attributes);
65
74
  };
66
- export var teamActionClicked = function teamActionClicked(attributes) {
67
- return createEvent('ui', 'clicked', TEAM_SUBJECT, 'action', attributes);
75
+ export var reportingLinesClicked = function reportingLinesClicked(attributes) {
76
+ return createEvent('ui', 'clicked', USER_SUBJECT, 'reportingLines', attributes);
68
77
  };
69
- export var moreActionsClicked = function moreActionsClicked(attributes) {
70
- return createEvent('ui', 'clicked', TEAM_SUBJECT, 'moreActions', attributes);
78
+ export var moreActionsClicked = function moreActionsClicked(type, attributes) {
79
+ return createEvent('ui', 'clicked', type === 'user' ? USER_SUBJECT : TEAM_SUBJECT, 'moreActions', attributes);
71
80
  };
72
81
  export var teamAvatarClicked = function teamAvatarClicked(attributes) {
73
82
  return createEvent('ui', 'clicked', TEAM_SUBJECT, 'avatar', attributes);
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/profilecard",
3
- "version": "16.12.1"
3
+ "version": "17.0.0"
4
4
  }
@@ -1,3 +1,4 @@
1
+ import { AnalyticsEventPayload } from '@atlaskit/analytics-next';
1
2
  import { ClientOverrides, ProfileClientOptions, TeamCentralReportingLinesData } from '../types';
2
3
  import TeamCentralCardClient from './TeamCentralCardClient';
3
4
  import TeamProfileCardClient from './TeamProfileCardClient';
@@ -8,8 +9,8 @@ declare class ProfileCardClient {
8
9
  tcClient?: TeamCentralCardClient;
9
10
  constructor(config: ProfileClientOptions, clients?: ClientOverrides);
10
11
  flushCache(): void;
11
- getProfile(cloudId: string, userId: string): Promise<any>;
12
- getTeamProfile(teamId: string, orgId?: string, analytics?: (event: Record<string, any>) => void): Promise<import("../types").Team>;
12
+ getProfile(cloudId: string, userId: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<any>;
13
+ getTeamProfile(teamId: string, orgId?: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<import("../types").Team>;
13
14
  getReportingLines(userId: string): Promise<TeamCentralReportingLinesData>;
14
15
  getTeamCentralBaseUrl(): string | undefined;
15
16
  shouldShowGiveKudos(): Promise<boolean>;
@@ -1,3 +1,4 @@
1
+ import { AnalyticsEventPayload } from '@atlaskit/analytics-next';
1
2
  import type { ProfileClientOptions, Team } from '../types';
2
3
  import CachingClient from './CachingClient';
3
4
  export default class TeamProfileCardClient extends CachingClient<Team> {
@@ -5,5 +6,5 @@ export default class TeamProfileCardClient extends CachingClient<Team> {
5
6
  constructor(options: ProfileClientOptions);
6
7
  makeRequestViaGateway(teamId: string, _orgId: string | undefined): Promise<Team>;
7
8
  makeRequest(teamId: string, orgId: string | undefined): Promise<Team>;
8
- getProfile(teamId: string, orgId: string | undefined, analytics?: (event: Record<string, any>) => void): Promise<Team>;
9
+ getProfile(teamId: string, orgId: string | undefined, analytics?: (event: AnalyticsEventPayload) => void): Promise<Team>;
9
10
  }
@@ -1,3 +1,4 @@
1
+ import { AnalyticsEventPayload } from '@atlaskit/analytics-next';
1
2
  import { ApiClientResponse, ProfileCardClientData, ProfileClientOptions } from '../types';
2
3
  import CachingClient from './CachingClient';
3
4
  /**
@@ -13,5 +14,5 @@ export default class UserProfileCardClient extends CachingClient<any> {
13
14
  options: ProfileClientOptions;
14
15
  constructor(options: ProfileClientOptions);
15
16
  makeRequest(cloudId: string, userId: string): Promise<ProfileCardClientData>;
16
- getProfile(cloudId: string, userId: string): Promise<any>;
17
+ getProfile(cloudId: string, userId: string, analytics?: (event: AnalyticsEventPayload) => void): Promise<any>;
17
18
  }
@@ -0,0 +1,6 @@
1
+ export declare const getErrorAttributes: (error?: any) => {
2
+ errorStatus: any;
3
+ errorReason: any;
4
+ isSLOFailure: boolean;
5
+ traceId: string | undefined;
6
+ };
@@ -1,19 +1,10 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
+ import { AnalyticsEventPayload } from '@atlaskit/analytics-next';
2
3
  import { ProfileCardErrorType } from '../../types';
3
- declare type Props = {
4
+ interface Props {
4
5
  reload?: () => void | undefined;
5
6
  errorType?: ProfileCardErrorType;
6
- };
7
- export default class ErrorMessage extends React.PureComponent<Props> {
8
- static defaultProps: {
9
- errorType: {
10
- reason: string;
11
- };
12
- };
13
- renderNotFound: () => JSX.Element;
14
- renderDefault: () => JSX.Element;
15
- renderRetryButton: () => JSX.Element | null;
16
- renderErrorContent(): JSX.Element;
17
- render(): JSX.Element;
7
+ fireAnalytics: (payload: AnalyticsEventPayload) => void;
18
8
  }
19
- export {};
9
+ declare const ErrorMessage: (props: Props) => JSX.Element;
10
+ export default ErrorMessage;
@@ -1,17 +1,15 @@
1
1
  import React from 'react';
2
- import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
+ import { AnalyticsEventPayload } from '@atlaskit/analytics-next';
3
3
  import { TriggerProps } from '@atlaskit/popup/types';
4
- import type { AnalyticsFromDuration, ProfileCardAction, Team, TeamProfileCardTriggerProps, TeamProfileCardTriggerState } from '../../types';
5
- export declare class TeamProfileCardTriggerInternal extends React.PureComponent<TeamProfileCardTriggerProps & {
6
- createAnalyticsEvent?: CreateUIAnalyticsEvent;
7
- }, TeamProfileCardTriggerState> {
4
+ import type { AnalyticsFromDuration, AnalyticsProps, ProfileCardAction, Team, TeamProfileCardTriggerProps, TeamProfileCardTriggerState } from '../../types';
5
+ export declare class TeamProfileCardTriggerInternal extends React.PureComponent<TeamProfileCardTriggerProps & AnalyticsProps, TeamProfileCardTriggerState> {
8
6
  static defaultProps: Partial<TeamProfileCardTriggerProps>;
9
7
  _isMounted: boolean;
10
8
  showTimer: number;
11
9
  hideTimer: number;
12
10
  openedByHover: boolean;
13
11
  openTime: number;
14
- fireAnalytics: (payload: Record<string, any>) => void;
12
+ fireAnalytics: (payload: AnalyticsEventPayload) => void;
15
13
  fireAnalyticsWithDuration: (generator: AnalyticsFromDuration) => void;
16
14
  hideProfilecard: (delay?: number) => void;
17
15
  showProfilecard: (delay?: number) => void;
@@ -48,9 +46,5 @@ export declare class TeamProfileCardTriggerInternal extends React.PureComponent<
48
46
  renderPopup(): React.ReactNode;
49
47
  render(): React.ReactNode;
50
48
  }
51
- declare const _default: React.ForwardRefExoticComponent<Pick<Omit<TeamProfileCardTriggerProps & {
52
- createAnalyticsEvent?: CreateUIAnalyticsEvent | undefined;
53
- }, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & Partial<Pick<Omit<TeamProfileCardTriggerProps & {
54
- createAnalyticsEvent?: CreateUIAnalyticsEvent | undefined;
55
- }, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, keyof TeamProfileCardTriggerProps>> & Partial<Pick<Partial<TeamProfileCardTriggerProps>, never>> & React.RefAttributes<any>>;
49
+ declare const _default: React.ForwardRefExoticComponent<Pick<Omit<TeamProfileCardTriggerProps & AnalyticsProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & Partial<Pick<Omit<TeamProfileCardTriggerProps & AnalyticsProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, keyof TeamProfileCardTriggerProps>> & Partial<Pick<Partial<TeamProfileCardTriggerProps>, never>> & React.RefAttributes<any>>;
56
50
  export default _default;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
- import { ProfileCardAction } from '../../types';
2
+ import { AnalyticsWithDurationProps, ProfileCardAction } from '../../types';
3
3
  declare type OverflowButtonsProps = {
4
4
  actions: ProfileCardAction[];
5
- onItemClick: (action: ProfileCardAction, args: any, event: React.MouseEvent | React.KeyboardEvent) => void;
6
- };
5
+ onItemClick: (action: ProfileCardAction, args: any, event: React.MouseEvent | React.KeyboardEvent, index: number) => void;
6
+ } & AnalyticsWithDurationProps;
7
+ export declare const ACTION_OVERFLOW_THRESHOLD = 2;
7
8
  export declare const OverflowProfileCardButtons: (props: OverflowButtonsProps) => JSX.Element;
8
9
  export {};
@@ -1,29 +1,5 @@
1
- import React, { ReactElement } from 'react';
2
- import { LozengeProps, ProfileCardAction, ProfilecardProps } from '../../types';
3
- export default class Profilecard extends React.PureComponent<ProfilecardProps> {
4
- static defaultProps: ProfilecardProps;
5
- GIVE_KUDOS_ACTION_ID: string;
6
- private timeOpen;
7
- clientFetchProfile: () => void;
8
- constructor(props: ProfilecardProps);
9
- private durationSince;
10
- callClientFetchProfile: (...args: any) => void;
11
- callAnalytics: (id: string, options: any) => void;
12
- componentDidMount(): void;
13
- renderErrorMessage(): JSX.Element;
14
- kudosUrl: () => string;
15
- kudosButtonCallback: () => void;
16
- getActions(): ProfileCardAction[];
17
- renderButton: (action: ProfileCardAction, idx: number) => ReactElement;
18
- renderActionsButtons(): JSX.Element | null;
19
- private onActionClick;
20
- renderCardDetailsDefault(): JSX.Element;
21
- renderCardDetailsForDisabledAccount(): JSX.Element;
22
- getDisabledAccountName(): string | JSX.Element | null | undefined;
23
- getDisabledAccountDesc(): {};
24
- private renderFullNameAndPublicName;
25
- renderCustomLozenges(lozenges: LozengeProps[]): JSX.Element | null;
26
- renderCardDetailsApp(): JSX.Element;
27
- renderCardDetails(): JSX.Element;
28
- render(): JSX.Element;
29
- }
1
+ import React from 'react';
2
+ import { AnalyticsProps, ProfilecardProps } from '../../types';
3
+ export declare const ProfilecardInternal: (props: ProfilecardProps & AnalyticsProps) => JSX.Element | null;
4
+ declare const _default: React.ForwardRefExoticComponent<Omit<ProfilecardProps & AnalyticsProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any>>;
5
+ export default _default;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { AnalyticsWithDurationProps, ProfilecardProps } from '../../types';
3
+ export declare const ProfileCardDetails: (props: ProfilecardProps & AnalyticsWithDurationProps) => JSX.Element;