@atlaskit/profilecard 24.13.6 → 24.14.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 (142) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/__tests__/vr-tests/__snapshots__/agent-profilecard/agent-profile-card-example--default.png +0 -0
  3. package/__tests__/vr-tests/__snapshots__/user-profilecard/alternate-actions--default.png +0 -0
  4. package/__tests__/vr-tests/__snapshots__/user-profilecard/best-case-profile--default.png +0 -0
  5. package/__tests__/vr-tests/__snapshots__/user-profilecard/bot-case-profile--default.png +0 -0
  6. package/__tests__/vr-tests/__snapshots__/user-profilecard/error-state--default.png +0 -0
  7. package/__tests__/vr-tests/__snapshots__/user-profilecard/error-state-not-found--default.png +0 -0
  8. package/__tests__/vr-tests/__snapshots__/user-profilecard/worst-case-profile--default.png +0 -0
  9. package/__tests__/vr-tests/agent-profilecard.vr.tsx +5 -0
  10. package/__tests__/vr-tests/user-profilecard.vr.tsx +17 -0
  11. package/afm-cc/tsconfig.json +6 -0
  12. package/afm-dev-agents/tsconfig.json +6 -0
  13. package/afm-jira/tsconfig.json +6 -0
  14. package/afm-passionfruit/tsconfig.json +6 -0
  15. package/afm-post-office/tsconfig.json +6 -0
  16. package/afm-rovo-extension/tsconfig.json +6 -0
  17. package/afm-townsquare/tsconfig.json +6 -0
  18. package/dist/cjs/client/ProfileCardClient.js +2 -2
  19. package/dist/cjs/client/UserProfileCardClient.js +45 -11
  20. package/dist/cjs/client/getOrgIdForCloudIdFromAGG.js +1 -1
  21. package/dist/cjs/client/getTeamFromAGG.js +1 -1
  22. package/dist/cjs/components/Agent/AgentProfileCard.js +3 -0
  23. package/dist/cjs/components/Agent/AgentProfileCardResourced.js +2 -1
  24. package/dist/cjs/components/Error/ErrorMessage.js +18 -7
  25. package/dist/cjs/components/User/OverflowProfileCardButtons.js +22 -7
  26. package/dist/cjs/components/User/ProfileCard.js +80 -28
  27. package/dist/cjs/components/User/ProfileCardDetails.js +3 -2
  28. package/dist/cjs/components/User/ProfileCardResourced.js +40 -16
  29. package/dist/cjs/components/User/ProfileCardTrigger.js +53 -13
  30. package/dist/cjs/components/User/ReportingLinesDetails.js +37 -12
  31. package/dist/cjs/components/User/UserLoadingState.js +15 -3
  32. package/dist/cjs/components/common/LoadingState.js +17 -3
  33. package/dist/cjs/components/common/ProfileCardTrigger.js +29 -7
  34. package/dist/cjs/components/common/ProfileCardWrapper.js +4 -2
  35. package/dist/cjs/components/team-profile-card/main.js +1 -1
  36. package/dist/cjs/components/team-profile-card/team-connections/main.js +3 -19
  37. package/dist/cjs/components/team-profile-card/team-containers-skeleton/index.js +1 -1
  38. package/dist/cjs/components/team-profile-card/team-containers-skeleton/linked-container-card-skeleton/index.js +1 -1
  39. package/dist/cjs/mocks/mock-profile-client.js +10 -0
  40. package/dist/cjs/mocks/profile-data.js +2 -2
  41. package/dist/cjs/mocks/reporting-lines-data.js +4 -3
  42. package/dist/cjs/styled/Card.js +1 -1
  43. package/dist/cjs/styled/CoverImage.js +1 -1
  44. package/dist/cjs/styled/Error.js +1 -1
  45. package/dist/cjs/styled/ReportingLines.js +1 -1
  46. package/dist/cjs/styled/TeamCard.js +1 -1
  47. package/dist/cjs/styled/TeamTrigger.js +1 -1
  48. package/dist/cjs/styled/UserTrigger.js +1 -1
  49. package/dist/cjs/util/analytics.js +7 -3
  50. package/dist/es2019/client/ProfileCardClient.js +2 -2
  51. package/dist/es2019/client/UserProfileCardClient.js +50 -13
  52. package/dist/es2019/client/getOrgIdForCloudIdFromAGG.js +1 -1
  53. package/dist/es2019/client/getTeamFromAGG.js +1 -1
  54. package/dist/es2019/components/Agent/AgentProfileCard.js +3 -0
  55. package/dist/es2019/components/Agent/AgentProfileCardResourced.js +2 -1
  56. package/dist/es2019/components/Error/ErrorMessage.js +17 -6
  57. package/dist/es2019/components/User/OverflowProfileCardButtons.js +18 -7
  58. package/dist/es2019/components/User/ProfileCard.js +72 -25
  59. package/dist/es2019/components/User/ProfileCardDetails.js +3 -2
  60. package/dist/es2019/components/User/ProfileCardResourced.js +25 -4
  61. package/dist/es2019/components/User/ProfileCardTrigger.js +55 -14
  62. package/dist/es2019/components/User/ReportingLinesDetails.js +31 -10
  63. package/dist/es2019/components/User/UserLoadingState.js +14 -4
  64. package/dist/es2019/components/common/LoadingState.js +16 -4
  65. package/dist/es2019/components/common/ProfileCardTrigger.js +26 -7
  66. package/dist/es2019/components/common/ProfileCardWrapper.js +4 -2
  67. package/dist/es2019/components/team-profile-card/main.js +1 -1
  68. package/dist/es2019/components/team-profile-card/team-connections/main.js +3 -18
  69. package/dist/es2019/components/team-profile-card/team-containers-skeleton/index.js +1 -1
  70. package/dist/es2019/components/team-profile-card/team-containers-skeleton/linked-container-card-skeleton/index.js +1 -1
  71. package/dist/es2019/mocks/mock-profile-client.js +6 -0
  72. package/dist/es2019/mocks/profile-data.js +1 -1
  73. package/dist/es2019/mocks/reporting-lines-data.js +2 -2
  74. package/dist/es2019/styled/Card.js +1 -1
  75. package/dist/es2019/styled/CoverImage.js +1 -1
  76. package/dist/es2019/styled/Error.js +1 -1
  77. package/dist/es2019/styled/ReportingLines.js +1 -1
  78. package/dist/es2019/styled/TeamCard.js +1 -1
  79. package/dist/es2019/styled/TeamTrigger.js +1 -1
  80. package/dist/es2019/styled/UserTrigger.js +1 -1
  81. package/dist/es2019/util/analytics.js +6 -2
  82. package/dist/esm/client/ProfileCardClient.js +2 -2
  83. package/dist/esm/client/UserProfileCardClient.js +46 -12
  84. package/dist/esm/client/getOrgIdForCloudIdFromAGG.js +1 -1
  85. package/dist/esm/client/getTeamFromAGG.js +1 -1
  86. package/dist/esm/components/Agent/AgentProfileCard.js +3 -0
  87. package/dist/esm/components/Agent/AgentProfileCardResourced.js +2 -1
  88. package/dist/esm/components/Error/ErrorMessage.js +19 -6
  89. package/dist/esm/components/User/OverflowProfileCardButtons.js +23 -8
  90. package/dist/esm/components/User/ProfileCard.js +80 -28
  91. package/dist/esm/components/User/ProfileCardDetails.js +3 -2
  92. package/dist/esm/components/User/ProfileCardResourced.js +40 -16
  93. package/dist/esm/components/User/ProfileCardTrigger.js +54 -14
  94. package/dist/esm/components/User/ReportingLinesDetails.js +38 -12
  95. package/dist/esm/components/User/UserLoadingState.js +16 -4
  96. package/dist/esm/components/common/LoadingState.js +18 -4
  97. package/dist/esm/components/common/ProfileCardTrigger.js +30 -8
  98. package/dist/esm/components/common/ProfileCardWrapper.js +4 -2
  99. package/dist/esm/components/team-profile-card/main.js +1 -1
  100. package/dist/esm/components/team-profile-card/team-connections/main.js +3 -18
  101. package/dist/esm/components/team-profile-card/team-containers-skeleton/index.js +1 -1
  102. package/dist/esm/components/team-profile-card/team-containers-skeleton/linked-container-card-skeleton/index.js +1 -1
  103. package/dist/esm/mocks/mock-profile-client.js +10 -0
  104. package/dist/esm/mocks/profile-data.js +1 -1
  105. package/dist/esm/mocks/reporting-lines-data.js +2 -2
  106. package/dist/esm/styled/Card.js +1 -1
  107. package/dist/esm/styled/CoverImage.js +1 -1
  108. package/dist/esm/styled/Error.js +1 -1
  109. package/dist/esm/styled/ReportingLines.js +1 -1
  110. package/dist/esm/styled/TeamCard.js +1 -1
  111. package/dist/esm/styled/TeamTrigger.js +1 -1
  112. package/dist/esm/styled/UserTrigger.js +1 -1
  113. package/dist/esm/util/analytics.js +6 -2
  114. package/dist/types/client/ProfileCardClient.d.ts +2 -1
  115. package/dist/types/client/TeamCentralCardClient.d.ts +2 -2
  116. package/dist/types/client/UserProfileCardClient.d.ts +2 -1
  117. package/dist/types/components/Error/ErrorMessage.d.ts +2 -0
  118. package/dist/types/components/User/ProfileCard.d.ts +3 -2
  119. package/dist/types/components/User/ProfileCardResourced.d.ts +4 -2
  120. package/dist/types/components/User/UserLoadingState.d.ts +3 -1
  121. package/dist/types/components/User/lazyProfileCard.d.ts +1 -1
  122. package/dist/types/components/common/LoadingState.d.ts +3 -1
  123. package/dist/types/components/common/ProfileCardWrapper.d.ts +2 -1
  124. package/dist/types/components/common/types.d.ts +3 -0
  125. package/dist/types/mocks/profile-data.d.ts +1 -0
  126. package/dist/types/types.d.ts +13 -6
  127. package/dist/types/util/analytics.d.ts +5 -0
  128. package/dist/types-ts4.5/client/ProfileCardClient.d.ts +2 -1
  129. package/dist/types-ts4.5/client/TeamCentralCardClient.d.ts +2 -2
  130. package/dist/types-ts4.5/client/UserProfileCardClient.d.ts +2 -1
  131. package/dist/types-ts4.5/components/Error/ErrorMessage.d.ts +2 -0
  132. package/dist/types-ts4.5/components/User/ProfileCard.d.ts +3 -2
  133. package/dist/types-ts4.5/components/User/ProfileCardResourced.d.ts +4 -2
  134. package/dist/types-ts4.5/components/User/UserLoadingState.d.ts +3 -1
  135. package/dist/types-ts4.5/components/User/lazyProfileCard.d.ts +1 -1
  136. package/dist/types-ts4.5/components/common/LoadingState.d.ts +3 -1
  137. package/dist/types-ts4.5/components/common/ProfileCardWrapper.d.ts +2 -1
  138. package/dist/types-ts4.5/components/common/types.d.ts +3 -0
  139. package/dist/types-ts4.5/mocks/profile-data.d.ts +1 -0
  140. package/dist/types-ts4.5/types.d.ts +13 -6
  141. package/dist/types-ts4.5/util/analytics.d.ts +5 -0
  142. package/package.json +12 -10
@@ -1,18 +1,23 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
+ 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; }
6
+ 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
7
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
5
8
  import { FormattedMessage } from 'react-intl-next';
6
9
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
7
10
  import Avatar from '@atlaskit/avatar';
8
11
  import { LinkButton } from '@atlaskit/button/new';
9
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
+ import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
10
14
  import Spinner from '@atlaskit/spinner';
15
+ import { useAnalyticsEvents } from '@atlaskit/teams-app-internal-analytics';
11
16
  import { N0 } from '@atlaskit/theme/colors';
12
17
  import messages from '../../messages';
13
18
  import { ActionButtonGroup, ActionsFlexSpacer, AnimatedKudosButton, AnimationWrapper, CardContainer, CardContent, KudosBlobAnimation, ProfileImage } from '../../styled/Card';
14
19
  import { CardWrapper, SpinnerContainer } from '../../styled/UserTrigger';
15
- import { actionClicked, fireEvent, profileCardRendered } from '../../util/analytics';
20
+ import { actionClicked, fireEvent, PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
16
21
  import { isBasicClick } from '../../util/click';
17
22
  import { getPageTime } from '../../util/performance';
18
23
  import { ErrorMessage } from '../Error';
@@ -58,6 +63,8 @@ export var ProfilecardInternal = function ProfilecardInternal(props) {
58
63
  _useState2 = _slicedToArray(_useState, 1),
59
64
  openTime = _useState2[0];
60
65
  var createAnalyticsEvent = props.createAnalyticsEvent;
66
+ var _useAnalyticsEvents = useAnalyticsEvents(),
67
+ fireEventNext = _useAnalyticsEvents.fireEvent;
61
68
  var fireAnalytics = useCallback(function (payload) {
62
69
  if (createAnalyticsEvent) {
63
70
  fireEvent(createAnalyticsEvent, payload);
@@ -68,6 +75,11 @@ export var ProfilecardInternal = function ProfilecardInternal(props) {
68
75
  var event = generator(elapsed);
69
76
  fireAnalytics(event);
70
77
  }, [fireAnalytics, openTime]);
78
+ var fireAnalyticsWithDurationNext = useCallback(function (eventKey, generator) {
79
+ var duration = getPageTime() - openTime;
80
+ var attributes = generator(duration);
81
+ fireEventNext(eventKey, attributes);
82
+ }, [openTime, fireEventNext]);
71
83
  var _useKudos = useKudos(props.cloudId, props.userId, props.teamCentralBaseUrl, props.openKudosDrawer),
72
84
  kudosAction = _useKudos.kudosAction;
73
85
  var _props$actions = props.actions,
@@ -88,24 +100,36 @@ export var ProfilecardInternal = function ProfilecardInternal(props) {
88
100
  var canRender = !hasError && !isLoading && !!(fullName || status === 'closed');
89
101
  useEffect(function () {
90
102
  if (canRender) {
91
- fireAnalyticsWithDuration(function (duration) {
92
- return profileCardRendered('user', 'content', {
93
- duration: duration,
94
- numActions: realActions.length
103
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
104
+ fireAnalyticsWithDurationNext('ui.profilecard.rendered.content', function (duration) {
105
+ return _objectSpread({
106
+ duration: duration,
107
+ numActions: realActions.length,
108
+ firedAt: Math.round(getPageTime())
109
+ }, PACKAGE_META_DATA);
95
110
  });
96
- });
111
+ } else {
112
+ fireAnalyticsWithDuration(function (duration) {
113
+ return profileCardRendered('user', 'content', {
114
+ duration: duration,
115
+ numActions: realActions.length
116
+ });
117
+ });
118
+ }
97
119
  }
98
- }, [canRender, fireAnalyticsWithDuration, realActions]);
120
+ }, [canRender, fireAnalyticsWithDuration, fireAnalyticsWithDurationNext, realActions]);
99
121
  if (hasError) {
100
122
  return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
101
123
  reload: props.clientFetchProfile,
102
124
  errorType: props.errorType || null,
103
- fireAnalytics: fireAnalytics
125
+ fireAnalytics: fireAnalytics,
126
+ fireAnalyticsNext: fireEventNext
104
127
  }));
105
128
  }
106
129
  if (isLoading) {
107
130
  return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(LoadingView, {
108
- fireAnalyticsWithDuration: fireAnalyticsWithDuration
131
+ fireAnalyticsWithDuration: fireAnalyticsWithDuration,
132
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext
109
133
  }));
110
134
  }
111
135
  if (!canRender) {
@@ -121,36 +145,53 @@ export var ProfilecardInternal = function ProfilecardInternal(props) {
121
145
  borderColor: "var(--ds-shadow-overlay, ".concat(N0, ")")
122
146
  })), /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(ProfileCardDetails, _extends({}, props, {
123
147
  status: status,
124
- fireAnalyticsWithDuration: fireAnalyticsWithDuration
148
+ fireAnalyticsWithDuration: fireAnalyticsWithDuration,
149
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext
125
150
  })), realActions && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ActionsFlexSpacer, null), /*#__PURE__*/React.createElement(Actions, _extends({}, fg('jfp_a11y_team_profile_card_actions_label') && {
126
151
  fullName: fullName
127
152
  }, {
128
153
  fullName: fullName,
129
154
  actions: realActions,
130
155
  fireAnalyticsWithDuration: fireAnalyticsWithDuration,
131
- isTriggeredUsingKeyboard: props.isTriggeredUsingKeyboard
156
+ isTriggeredUsingKeyboard: props.isTriggeredUsingKeyboard,
157
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext
132
158
  }))))));
133
159
  };
134
160
  var Actions = function Actions(_ref) {
135
161
  var actions = _ref.actions,
136
162
  fireAnalyticsWithDuration = _ref.fireAnalyticsWithDuration,
163
+ fireAnalyticsWithDurationNext = _ref.fireAnalyticsWithDurationNext,
137
164
  isTriggeredUsingKeyboard = _ref.isTriggeredUsingKeyboard,
138
165
  fullName = _ref.fullName;
139
166
  var onActionClick = useCallback(function (action, args, event, index) {
140
- fireAnalyticsWithDuration(function (duration) {
141
- return actionClicked('user', {
142
- duration: duration,
143
- hasHref: !!action.link,
144
- hasOnClick: !!action.callback,
145
- index: index,
146
- actionId: action.id || 'no-id-specified'
167
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
168
+ fireAnalyticsWithDurationNext('ui.profilecard.clicked.action', function (duration) {
169
+ return _objectSpread({
170
+ method: 'click',
171
+ firedAt: Math.round(getPageTime()),
172
+ duration: duration,
173
+ hasHref: !!action.link,
174
+ hasOnClick: !!action.callback,
175
+ index: index,
176
+ actionId: action.id || 'no-id-specified'
177
+ }, PACKAGE_META_DATA);
147
178
  });
148
- });
179
+ } else {
180
+ fireAnalyticsWithDuration(function (duration) {
181
+ return actionClicked('user', {
182
+ duration: duration,
183
+ hasHref: !!action.link,
184
+ hasOnClick: !!action.callback,
185
+ index: index,
186
+ actionId: action.id || 'no-id-specified'
187
+ });
188
+ });
189
+ }
149
190
  if (action.callback && isBasicClick(event)) {
150
191
  event.preventDefault();
151
192
  action.callback.apply(action, [event].concat(_toConsumableArray(args)));
152
193
  }
153
- }, [fireAnalyticsWithDuration]);
194
+ }, [fireAnalyticsWithDuration, fireAnalyticsWithDurationNext]);
154
195
  if (!actions || actions.length === 0) {
155
196
  return null;
156
197
  }
@@ -184,6 +225,7 @@ var Actions = function Actions(_ref) {
184
225
  }), overflowActions && /*#__PURE__*/React.createElement(OverflowProfileCardButtons, _extends({
185
226
  actions: overflowActions,
186
227
  fireAnalyticsWithDuration: fireAnalyticsWithDuration,
228
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext,
187
229
  onItemClick: function onItemClick(action, args, event, index) {
188
230
  return onActionClick(action, args, event, index + ACTION_OVERFLOW_THRESHOLD);
189
231
  }
@@ -191,17 +233,27 @@ var Actions = function Actions(_ref) {
191
233
  fullName: fullName
192
234
  })));
193
235
  };
194
- var LoadingView = function LoadingView(_ref2) {
195
- var fireAnalyticsWithDuration = _ref2.fireAnalyticsWithDuration;
236
+ export var LoadingView = function LoadingView(_ref2) {
237
+ var fireAnalyticsWithDuration = _ref2.fireAnalyticsWithDuration,
238
+ fireAnalyticsWithDurationNext = _ref2.fireAnalyticsWithDurationNext;
196
239
  useEffect(function () {
197
- fireAnalyticsWithDuration(function (duration) {
198
- return profileCardRendered('user', 'spinner', {
199
- duration: duration
240
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
241
+ fireAnalyticsWithDurationNext('ui.profilecard.rendered.spinner', function (duration) {
242
+ return _objectSpread({
243
+ firedAt: Math.round(getPageTime()),
244
+ duration: duration
245
+ }, PACKAGE_META_DATA);
246
+ });
247
+ } else {
248
+ fireAnalyticsWithDuration(function (duration) {
249
+ return profileCardRendered('user', 'spinner', {
250
+ duration: duration
251
+ });
200
252
  });
201
- });
202
- }, [fireAnalyticsWithDuration]);
253
+ }
254
+ }, [fireAnalyticsWithDuration, fireAnalyticsWithDurationNext]);
203
255
  return /*#__PURE__*/React.createElement(SpinnerContainer, {
204
256
  testId: "profilecard-spinner-container"
205
257
  }, /*#__PURE__*/React.createElement(Spinner, null));
206
258
  };
207
- export default withAnalyticsEvents()(ProfilecardInternal);
259
+ export default componentWithFG('ptc-enable-profile-card-analytics-refactor', ProfilecardInternal, withAnalyticsEvents()(ProfilecardInternal));
@@ -1,4 +1,4 @@
1
- /* ProfileCardDetails.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* ProfileCardDetails.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _excluded = ["text"];
@@ -134,6 +134,7 @@ export var ProfileCardDetails = function ProfileCardDetails(props) {
134
134
  reportingLines: props.reportingLines,
135
135
  reportingLinesProfileUrl: props.reportingLinesProfileUrl,
136
136
  onReportingLinesClick: props.onReportingLinesClick,
137
- fireAnalyticsWithDuration: props.fireAnalyticsWithDuration
137
+ fireAnalyticsWithDuration: props.fireAnalyticsWithDuration,
138
+ fireAnalyticsWithDurationNext: props.fireAnalyticsWithDurationNext
138
139
  }));
139
140
  };
@@ -13,6 +13,8 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
13
13
  import React, { Suspense } from 'react';
14
14
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
15
15
  import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
16
+ import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
17
+ import { useAnalyticsEvents } from '@atlaskit/teams-app-internal-analytics';
16
18
  import filterActions from '../../internal/filterActions';
17
19
  import { CardWrapper } from '../../styled/UserTrigger';
18
20
  import { fireEvent } from '../../util/analytics';
@@ -48,10 +50,23 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
48
50
  fireEvent(_this.props.createAnalyticsEvent, payload);
49
51
  }
50
52
  });
53
+ _defineProperty(_this, "fireAnalyticsNext", function (eventKey) {
54
+ // Don't fire analytics if the component is unmounted
55
+ if (!_this._isMounted) {
56
+ return;
57
+ }
58
+ if (_this.props.fireEvent) {
59
+ var _this$props;
60
+ for (var _len2 = arguments.length, attributes = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
61
+ attributes[_key2 - 1] = arguments[_key2];
62
+ }
63
+ (_this$props = _this.props).fireEvent.apply(_this$props, [eventKey].concat(attributes));
64
+ }
65
+ });
51
66
  _defineProperty(_this, "clientFetchProfile", function () {
52
- var _this$props = _this.props,
53
- cloudId = _this$props.cloudId,
54
- userId = _this$props.userId;
67
+ var _this$props2 = _this.props,
68
+ cloudId = _this$props2.cloudId,
69
+ userId = _this$props2.userId;
55
70
  var isLoading = _this.state.isLoading;
56
71
  if (isLoading === true) {
57
72
  // don't fetch data when fetching is in process
@@ -62,7 +77,7 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
62
77
  hasError: false,
63
78
  data: null
64
79
  }, function () {
65
- var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId, userId, _this.fireAnalytics), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos(), _this.props.resourceClient.getTeamCentralBaseUrl({
80
+ var requests = Promise.all([_this.props.resourceClient.getProfile(cloudId, userId, _this.fireAnalytics, _this.fireAnalyticsNext), _this.props.resourceClient.getReportingLines(userId), _this.props.resourceClient.shouldShowGiveKudos(), _this.props.resourceClient.getTeamCentralBaseUrl({
66
81
  withOrgContext: true,
67
82
  withSiteContext: true
68
83
  })]);
@@ -101,10 +116,10 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
101
116
  }, {
102
117
  key: "componentDidUpdate",
103
118
  value: function componentDidUpdate(prevProps) {
104
- var _this$props2 = this.props,
105
- userId = _this$props2.userId,
106
- cloudId = _this$props2.cloudId,
107
- resourceClient = _this$props2.resourceClient;
119
+ var _this$props3 = this.props,
120
+ userId = _this$props3.userId,
121
+ cloudId = _this$props3.cloudId,
122
+ resourceClient = _this$props3.resourceClient;
108
123
  if (userId !== prevProps.userId || cloudId !== prevProps.cloudId || resourceClient !== prevProps.resourceClient) {
109
124
  this.setState({
110
125
  isLoading: undefined
@@ -154,15 +169,16 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
154
169
  reportingLinesData = _this$state.reportingLinesData,
155
170
  isKudosEnabled = _this$state.isKudosEnabled,
156
171
  teamCentralBaseUrl = _this$state.teamCentralBaseUrl;
157
- var _this$props3 = this.props,
158
- onReportingLinesClick = _this$props3.onReportingLinesClick,
159
- cloudId = _this$props3.cloudId,
160
- userId = _this$props3.userId,
161
- addFlag = _this$props3.addFlag;
172
+ var _this$props4 = this.props,
173
+ onReportingLinesClick = _this$props4.onReportingLinesClick,
174
+ cloudId = _this$props4.cloudId,
175
+ userId = _this$props4.userId,
176
+ addFlag = _this$props4.addFlag;
162
177
  var isFetchingOrNotStartToFetchYet = isLoading === true || isLoading === undefined;
163
178
  if (isFetchingOrNotStartToFetchYet) {
164
179
  return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(UserLoadingState, {
165
- fireAnalytics: this.fireAnalytics
180
+ fireAnalytics: this.fireAnalytics,
181
+ fireAnalyticsNext: this.fireAnalyticsNext
166
182
  }));
167
183
  } else if (hasError) {
168
184
  return /*#__PURE__*/React.createElement(CardWrapper, {
@@ -170,7 +186,8 @@ var ProfileCardResourced = /*#__PURE__*/function (_React$PureComponent) {
170
186
  }, /*#__PURE__*/React.createElement(ErrorMessage, {
171
187
  errorType: error,
172
188
  reload: this.clientFetchProfile,
173
- fireAnalytics: this.fireAnalytics
189
+ fireAnalytics: this.fireAnalytics,
190
+ fireAnalyticsNext: this.fireAnalyticsNext
174
191
  }));
175
192
  }
176
193
  var newProps = _objectSpread(_objectSpread({
@@ -210,4 +227,11 @@ _defineProperty(ProfileCardResourced, "defaultProps", {
210
227
  actions: []
211
228
  });
212
229
  export var ProfileCardResourcedInternal = ProfileCardResourced;
213
- export default withAnalyticsEvents()(ProfileCardResourced);
230
+ var ProfileCardResourcedWithAnalytics = function ProfileCardResourcedWithAnalytics(props) {
231
+ var _useAnalyticsEvents = useAnalyticsEvents(),
232
+ fireEvent = _useAnalyticsEvents.fireEvent;
233
+ return /*#__PURE__*/React.createElement(ProfileCardResourced, _extends({
234
+ fireEvent: fireEvent
235
+ }, props));
236
+ };
237
+ export default componentWithFG('ptc-enable-profile-card-analytics-refactor', ProfileCardResourcedWithAnalytics, withAnalyticsEvents()(ProfileCardResourced));
@@ -1,4 +1,4 @@
1
- /* ProfileCardTrigger.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* ProfileCardTrigger.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
@@ -21,12 +21,14 @@ import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
21
21
  import { fg } from '@atlaskit/platform-feature-flags';
22
22
  import Popup from '@atlaskit/popup';
23
23
  import { Box } from '@atlaskit/primitives/compiled';
24
+ import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/teams-app-internal-analytics';
24
25
  import { layers } from '@atlaskit/theme/constants';
25
26
  import filterActionsInner from '../../internal/filterActions';
26
27
  import getLabelMessage from '../../internal/getLabelMessage';
27
28
  import { CardWrapper } from '../../styled/UserTrigger';
28
- import { cardTriggered, fireEvent } from '../../util/analytics';
29
+ import { cardTriggered, fireEvent, PACKAGE_META_DATA } from '../../util/analytics';
29
30
  import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
31
+ import { getPageTime } from '../../util/performance';
30
32
  import { AgentProfileCardResourced } from '../Agent/AgentProfileCardResourced';
31
33
  import { ProfileCardLazy } from './lazyProfileCard';
32
34
  import UserLoadingState from './UserLoadingState';
@@ -147,6 +149,8 @@ export default function ProfilecardTriggerNext(_ref2) {
147
149
  isTriggeredUsingKeyboard = _useState18[0],
148
150
  setTriggeredUsingKeyboard = _useState18[1];
149
151
  var triggerRef = useRef(null);
152
+ var _useAnalyticsEventsNe = useAnalyticsEventsNext(),
153
+ fireEventNext = _useAnalyticsEventsNe.fireEvent;
150
154
  useEffect(function () {
151
155
  isMounted.current = true;
152
156
  return function () {
@@ -165,6 +169,17 @@ export default function ProfilecardTriggerNext(_ref2) {
165
169
  setShouldShowGiveKudos(false);
166
170
  setTeamCentralBaseUrl(undefined);
167
171
  }, [userId]);
172
+
173
+ // Create a wrapper function that has the same interface as fireEventNext but includes isMounted check
174
+ var fireAnalyticsNext = useCallback(function (eventKey) {
175
+ if (!isMounted.current) {
176
+ return;
177
+ }
178
+ for (var _len = arguments.length, attributes = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
179
+ attributes[_key - 1] = arguments[_key];
180
+ }
181
+ fireEventNext.apply(void 0, [eventKey].concat(attributes));
182
+ }, [fireEventNext]);
168
183
  var fireAnalytics = useCallback(function (payload) {
169
184
  // Don't fire any analytics if the component is unmounted
170
185
  if (!isMounted.current) {
@@ -228,7 +243,7 @@ export default function ProfilecardTriggerNext(_ref2) {
228
243
  setError(null);
229
244
  setData(null);
230
245
  _context.prev = 6;
231
- requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos(), resourceClient.getTeamCentralBaseUrl({
246
+ requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics, fireAnalyticsNext), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos(), resourceClient.getTeamCentralBaseUrl({
232
247
  withOrgContext: true,
233
248
  withSiteContext: true
234
249
  })]);
@@ -248,7 +263,7 @@ export default function ProfilecardTriggerNext(_ref2) {
248
263
  return _context.stop();
249
264
  }
250
265
  }, _callee, null, [[6, 14]]);
251
- })), [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
266
+ })), [cloudId, fireAnalytics, fireAnalyticsNext, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
252
267
  var showProfilecard = useCallback(function () {
253
268
  clearTimeout(hideTimer.current);
254
269
  clearTimeout(showTimer.current);
@@ -267,25 +282,46 @@ export default function ProfilecardTriggerNext(_ref2) {
267
282
  event.stopPropagation();
268
283
  showProfilecard();
269
284
  if (!visible) {
270
- fireAnalytics(cardTriggered('user', 'click'));
285
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
286
+ fireAnalyticsNext('ui.profilecard.triggered', _objectSpread({
287
+ method: 'click',
288
+ firedAt: Math.round(getPageTime())
289
+ }, PACKAGE_META_DATA));
290
+ } else {
291
+ fireAnalytics(cardTriggered('user', 'click'));
292
+ }
271
293
  }
272
- }, [fireAnalytics, showProfilecard, visible]);
294
+ }, [fireAnalytics, fireAnalyticsNext, showProfilecard, visible]);
273
295
  var onMouseEnter = useCallback(function () {
274
296
  showProfilecard();
275
297
  if (!visible) {
276
- fireAnalytics(cardTriggered('user', 'hover'));
298
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
299
+ fireAnalyticsNext('ui.profilecard.triggered', _objectSpread({
300
+ method: 'hover',
301
+ firedAt: Math.round(getPageTime())
302
+ }, PACKAGE_META_DATA));
303
+ } else {
304
+ fireAnalytics(cardTriggered('user', 'hover'));
305
+ }
277
306
  }
278
- }, [fireAnalytics, showProfilecard, visible]);
307
+ }, [fireAnalytics, fireAnalyticsNext, showProfilecard, visible]);
279
308
  var onKeyPress = useCallback(function (event) {
280
309
  if (event.key === 'Enter' || event.key === ' ') {
281
310
  event.preventDefault();
282
311
  setTriggeredUsingKeyboard(true);
283
312
  showProfilecard();
284
313
  if (!visible) {
285
- fireAnalytics(cardTriggered('user', 'click'));
314
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
315
+ fireAnalyticsNext('ui.profilecard.triggered', _objectSpread({
316
+ method: 'click',
317
+ firedAt: Math.round(getPageTime())
318
+ }, PACKAGE_META_DATA));
319
+ } else {
320
+ fireAnalytics(cardTriggered('user', 'click'));
321
+ }
286
322
  }
287
323
  }
288
- }, [fireAnalytics, showProfilecard, visible]);
324
+ }, [fireAnalytics, fireAnalyticsNext, showProfilecard, visible]);
289
325
  var onFocus = useCallback(function () {
290
326
  showProfilecard();
291
327
  }, [showProfilecard]);
@@ -365,7 +401,8 @@ export default function ProfilecardTriggerNext(_ref2) {
365
401
  offset: offset !== null && offset !== void 0 ? offset : [0, 8],
366
402
  content: function content() {
367
403
  return /*#__PURE__*/React.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
368
- fireAnalytics: fireAnalytics
404
+ fireAnalytics: fireAnalytics,
405
+ fireAnalyticsNext: fireAnalyticsNext
369
406
  }) : visible && /*#__PURE__*/React.createElement(ProfileCardContent, {
370
407
  profilecardProps: profilecardProps,
371
408
  isAgent: !!(data !== null && data !== void 0 && data.isAgent),
@@ -440,7 +477,8 @@ export default function ProfilecardTriggerNext(_ref2) {
440
477
  offset: offset !== null && offset !== void 0 ? offset : [0, 8],
441
478
  content: function content() {
442
479
  return /*#__PURE__*/React.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
443
- fireAnalytics: fireAnalytics
480
+ fireAnalytics: fireAnalytics,
481
+ fireAnalyticsNext: fireAnalyticsNext
444
482
  }) : visible && /*#__PURE__*/React.createElement(ProfileCardContent, {
445
483
  profilecardProps: profilecardProps,
446
484
  isAgent: !!(data !== null && data !== void 0 && data.isAgent),
@@ -506,10 +544,12 @@ export default function ProfilecardTriggerNext(_ref2) {
506
544
  })));
507
545
  }
508
546
  var LoadingView = function LoadingView(_ref4) {
509
- var fireAnalytics = _ref4.fireAnalytics;
547
+ var fireAnalytics = _ref4.fireAnalytics,
548
+ fireAnalyticsNext = _ref4.fireAnalyticsNext;
510
549
  return /*#__PURE__*/React.createElement(CardWrapper, {
511
550
  testId: "profilecard.profilecardtrigger.loading"
512
551
  }, /*#__PURE__*/React.createElement(UserLoadingState, {
513
- fireAnalytics: fireAnalytics
552
+ fireAnalytics: fireAnalytics,
553
+ fireAnalyticsNext: fireAnalyticsNext
514
554
  }));
515
555
  };
@@ -1,16 +1,21 @@
1
- /* ReportingLinesDetails.tsx generated by @compiled/babel-plugin v0.36.1 */
1
+ /* ReportingLinesDetails.tsx generated by @compiled/babel-plugin v0.38.1 */
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import "./ReportingLinesDetails.compiled.css";
3
4
  import { ax, ix } from "@compiled/react/runtime";
5
+ 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; }
6
+ 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
7
  import React from 'react';
5
8
  import { FormattedMessage, useIntl } from 'react-intl-next';
6
9
  import Avatar from '@atlaskit/avatar';
7
10
  import AvatarGroup from '@atlaskit/avatar-group';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
8
12
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
9
13
  import { Box, xcss } from '@atlaskit/primitives';
10
14
  import { Pressable } from '@atlaskit/primitives/compiled';
11
15
  import messages from '../../messages';
12
16
  import { ManagerName, ManagerSection, OffsetWrapper, ReportingLinesSection } from '../../styled/ReportingLines';
13
- import { reportingLinesClicked } from '../../util/analytics';
17
+ import { PACKAGE_META_DATA, reportingLinesClicked } from '../../util/analytics';
18
+ import { getPageTime } from '../../util/performance';
14
19
  function getProfileHref(userId, profileUrl) {
15
20
  return profileUrl ? profileUrl + userId : undefined;
16
21
  }
@@ -32,6 +37,7 @@ var ReportingLinesDetails = function ReportingLinesDetails(props) {
32
37
  var _useIntl = useIntl(),
33
38
  formatMessage = _useIntl.formatMessage;
34
39
  var fireAnalyticsWithDuration = props.fireAnalyticsWithDuration,
40
+ fireAnalyticsWithDurationNext = props.fireAnalyticsWithDurationNext,
35
41
  _props$reportingLines = props.reportingLines,
36
42
  reportingLines = _props$reportingLines === void 0 ? {} : _props$reportingLines,
37
43
  reportingLinesProfileUrl = props.reportingLinesProfileUrl,
@@ -44,12 +50,22 @@ var ReportingLinesDetails = function ReportingLinesDetails(props) {
44
50
  var hasReports = reports.length > 0;
45
51
  var getReportingLinesOnClick = function getReportingLinesOnClick(user, userType) {
46
52
  return onReportingLinesClick ? function () {
47
- fireAnalyticsWithDuration(function (duration) {
48
- return reportingLinesClicked({
49
- duration: duration,
50
- userType: userType
53
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
54
+ fireAnalyticsWithDurationNext('ui.profilecard.clicked.reportingLines', function (duration) {
55
+ return _objectSpread({
56
+ duration: duration,
57
+ userType: userType,
58
+ firedAt: Math.round(getPageTime())
59
+ }, PACKAGE_META_DATA);
51
60
  });
52
- });
61
+ } else {
62
+ fireAnalyticsWithDuration(function (duration) {
63
+ return reportingLinesClicked({
64
+ duration: duration,
65
+ userType: userType
66
+ });
67
+ });
68
+ }
53
69
  onReportingLinesClick(user);
54
70
  } : undefined;
55
71
  };
@@ -58,12 +74,22 @@ var ReportingLinesDetails = function ReportingLinesDetails(props) {
58
74
  if (onReportingLinesClick) {
59
75
  shouldPreventDefault = onReportingLinesClick(user) === false;
60
76
  }
61
- fireAnalyticsWithDuration(function (duration) {
62
- return reportingLinesClicked({
63
- duration: duration,
64
- userType: userType
77
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
78
+ fireAnalyticsWithDurationNext('ui.profilecard.clicked.reportingLines', function (duration) {
79
+ return _objectSpread({
80
+ duration: duration,
81
+ userType: userType,
82
+ firedAt: Math.round(getPageTime())
83
+ }, PACKAGE_META_DATA);
65
84
  });
66
- });
85
+ } else {
86
+ fireAnalyticsWithDuration(function (duration) {
87
+ return reportingLinesClicked({
88
+ duration: duration,
89
+ userType: userType
90
+ });
91
+ });
92
+ }
67
93
  if (shouldPreventDefault) {
68
94
  return;
69
95
  }
@@ -1,12 +1,24 @@
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
  import React, { useEffect } from 'react';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
2
6
  import AkSpinner from '@atlaskit/spinner';
3
7
  import { SpinnerContainer } from '../../styled/UserTrigger';
4
- import { profileCardRendered } from '../../util/analytics';
8
+ import { PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
9
+ import { getPageTime } from '../../util/performance';
5
10
  var UserLoadingState = function UserLoadingState(_ref) {
6
- var fireAnalytics = _ref.fireAnalytics;
11
+ var fireAnalytics = _ref.fireAnalytics,
12
+ fireAnalyticsNext = _ref.fireAnalyticsNext;
7
13
  useEffect(function () {
8
- fireAnalytics(profileCardRendered('user', 'spinner'));
9
- }, [fireAnalytics]);
14
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
15
+ fireAnalyticsNext('ui.profilecard.rendered.spinner', _objectSpread({
16
+ firedAt: Math.round(getPageTime())
17
+ }, PACKAGE_META_DATA));
18
+ } else {
19
+ fireAnalytics(profileCardRendered('user', 'spinner'));
20
+ }
21
+ }, [fireAnalytics, fireAnalyticsNext]);
10
22
  return /*#__PURE__*/React.createElement(SpinnerContainer, null, /*#__PURE__*/React.createElement(AkSpinner, null));
11
23
  };
12
24
  export default UserLoadingState;
@@ -1,14 +1,28 @@
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
  import React, { useEffect } from 'react';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
2
6
  import AkSpinner from '@atlaskit/spinner';
3
7
  import { SpinnerContainer } from '../../styled/UserTrigger';
4
- import { profileCardRendered } from '../../util/analytics';
8
+ import { getActionSubject, PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
9
+ import { getPageTime } from '../../util/performance';
5
10
  export var LoadingState = function LoadingState(_ref) {
6
11
  var fireAnalytics = _ref.fireAnalytics,
12
+ fireAnalyticsNext = _ref.fireAnalyticsNext,
7
13
  profileType = _ref.profileType;
8
14
  useEffect(function () {
9
- if (fireAnalytics) {
10
- fireAnalytics(profileCardRendered(profileType, 'spinner'));
15
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
16
+ if (fireAnalyticsNext) {
17
+ fireAnalyticsNext("ui.".concat(getActionSubject(profileType), ".rendered.spinner"), _objectSpread({
18
+ firedAt: Math.round(getPageTime())
19
+ }, PACKAGE_META_DATA));
20
+ }
21
+ } else {
22
+ if (fireAnalytics) {
23
+ fireAnalytics(profileCardRendered(profileType, 'spinner'));
24
+ }
11
25
  }
12
- }, [fireAnalytics, profileType]);
26
+ }, [fireAnalytics, fireAnalyticsNext, profileType]);
13
27
  return /*#__PURE__*/React.createElement(SpinnerContainer, null, /*#__PURE__*/React.createElement(AkSpinner, null));
14
28
  };