@atlaskit/profilecard 24.13.7 → 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 (87) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/afm-cc/tsconfig.json +6 -0
  3. package/afm-dev-agents/tsconfig.json +6 -0
  4. package/afm-jira/tsconfig.json +6 -0
  5. package/afm-passionfruit/tsconfig.json +6 -0
  6. package/afm-post-office/tsconfig.json +6 -0
  7. package/afm-rovo-extension/tsconfig.json +6 -0
  8. package/afm-townsquare/tsconfig.json +6 -0
  9. package/dist/cjs/client/ProfileCardClient.js +2 -2
  10. package/dist/cjs/client/UserProfileCardClient.js +45 -11
  11. package/dist/cjs/client/getOrgIdForCloudIdFromAGG.js +1 -1
  12. package/dist/cjs/client/getTeamFromAGG.js +1 -1
  13. package/dist/cjs/components/Agent/AgentProfileCard.js +3 -0
  14. package/dist/cjs/components/Agent/AgentProfileCardResourced.js +2 -1
  15. package/dist/cjs/components/Error/ErrorMessage.js +18 -7
  16. package/dist/cjs/components/User/OverflowProfileCardButtons.js +22 -7
  17. package/dist/cjs/components/User/ProfileCard.js +80 -28
  18. package/dist/cjs/components/User/ProfileCardDetails.js +2 -1
  19. package/dist/cjs/components/User/ProfileCardResourced.js +40 -16
  20. package/dist/cjs/components/User/ProfileCardTrigger.js +52 -12
  21. package/dist/cjs/components/User/ReportingLinesDetails.js +36 -11
  22. package/dist/cjs/components/User/UserLoadingState.js +15 -3
  23. package/dist/cjs/components/common/LoadingState.js +17 -3
  24. package/dist/cjs/components/common/ProfileCardTrigger.js +29 -7
  25. package/dist/cjs/components/common/ProfileCardWrapper.js +4 -2
  26. package/dist/cjs/util/analytics.js +7 -3
  27. package/dist/es2019/client/ProfileCardClient.js +2 -2
  28. package/dist/es2019/client/UserProfileCardClient.js +50 -13
  29. package/dist/es2019/client/getOrgIdForCloudIdFromAGG.js +1 -1
  30. package/dist/es2019/client/getTeamFromAGG.js +1 -1
  31. package/dist/es2019/components/Agent/AgentProfileCard.js +3 -0
  32. package/dist/es2019/components/Agent/AgentProfileCardResourced.js +2 -1
  33. package/dist/es2019/components/Error/ErrorMessage.js +17 -6
  34. package/dist/es2019/components/User/OverflowProfileCardButtons.js +18 -7
  35. package/dist/es2019/components/User/ProfileCard.js +72 -25
  36. package/dist/es2019/components/User/ProfileCardDetails.js +2 -1
  37. package/dist/es2019/components/User/ProfileCardResourced.js +25 -4
  38. package/dist/es2019/components/User/ProfileCardTrigger.js +54 -13
  39. package/dist/es2019/components/User/ReportingLinesDetails.js +30 -9
  40. package/dist/es2019/components/User/UserLoadingState.js +14 -4
  41. package/dist/es2019/components/common/LoadingState.js +16 -4
  42. package/dist/es2019/components/common/ProfileCardTrigger.js +26 -7
  43. package/dist/es2019/components/common/ProfileCardWrapper.js +4 -2
  44. package/dist/es2019/util/analytics.js +6 -2
  45. package/dist/esm/client/ProfileCardClient.js +2 -2
  46. package/dist/esm/client/UserProfileCardClient.js +46 -12
  47. package/dist/esm/client/getOrgIdForCloudIdFromAGG.js +1 -1
  48. package/dist/esm/client/getTeamFromAGG.js +1 -1
  49. package/dist/esm/components/Agent/AgentProfileCard.js +3 -0
  50. package/dist/esm/components/Agent/AgentProfileCardResourced.js +2 -1
  51. package/dist/esm/components/Error/ErrorMessage.js +19 -6
  52. package/dist/esm/components/User/OverflowProfileCardButtons.js +23 -8
  53. package/dist/esm/components/User/ProfileCard.js +80 -28
  54. package/dist/esm/components/User/ProfileCardDetails.js +2 -1
  55. package/dist/esm/components/User/ProfileCardResourced.js +40 -16
  56. package/dist/esm/components/User/ProfileCardTrigger.js +53 -13
  57. package/dist/esm/components/User/ReportingLinesDetails.js +37 -11
  58. package/dist/esm/components/User/UserLoadingState.js +16 -4
  59. package/dist/esm/components/common/LoadingState.js +18 -4
  60. package/dist/esm/components/common/ProfileCardTrigger.js +30 -8
  61. package/dist/esm/components/common/ProfileCardWrapper.js +4 -2
  62. package/dist/esm/util/analytics.js +6 -2
  63. package/dist/types/client/ProfileCardClient.d.ts +2 -1
  64. package/dist/types/client/UserProfileCardClient.d.ts +2 -1
  65. package/dist/types/components/Error/ErrorMessage.d.ts +2 -0
  66. package/dist/types/components/User/ProfileCard.d.ts +3 -2
  67. package/dist/types/components/User/ProfileCardResourced.d.ts +4 -2
  68. package/dist/types/components/User/UserLoadingState.d.ts +3 -1
  69. package/dist/types/components/User/lazyProfileCard.d.ts +1 -1
  70. package/dist/types/components/common/LoadingState.d.ts +3 -1
  71. package/dist/types/components/common/ProfileCardWrapper.d.ts +2 -1
  72. package/dist/types/components/common/types.d.ts +3 -0
  73. package/dist/types/types.d.ts +13 -6
  74. package/dist/types/util/analytics.d.ts +5 -0
  75. package/dist/types-ts4.5/client/ProfileCardClient.d.ts +2 -1
  76. package/dist/types-ts4.5/client/UserProfileCardClient.d.ts +2 -1
  77. package/dist/types-ts4.5/components/Error/ErrorMessage.d.ts +2 -0
  78. package/dist/types-ts4.5/components/User/ProfileCard.d.ts +3 -2
  79. package/dist/types-ts4.5/components/User/ProfileCardResourced.d.ts +4 -2
  80. package/dist/types-ts4.5/components/User/UserLoadingState.d.ts +3 -1
  81. package/dist/types-ts4.5/components/User/lazyProfileCard.d.ts +1 -1
  82. package/dist/types-ts4.5/components/common/LoadingState.d.ts +3 -1
  83. package/dist/types-ts4.5/components/common/ProfileCardWrapper.d.ts +2 -1
  84. package/dist/types-ts4.5/components/common/types.d.ts +3 -0
  85. package/dist/types-ts4.5/types.d.ts +13 -6
  86. package/dist/types-ts4.5/util/analytics.d.ts +5 -0
  87. package/package.json +10 -5
@@ -1,7 +1,7 @@
1
1
  import { print } from 'graphql';
2
2
  import gql from 'graphql-tag';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
- import { userRequestAnalytics } from '../util/analytics';
4
+ import { PACKAGE_META_DATA, userRequestAnalytics } from '../util/analytics';
5
5
  import { localTime } from '../util/date';
6
6
  import { getPageTime } from '../util/performance';
7
7
  import CachingClient from './CachingClient';
@@ -149,7 +149,7 @@ export default class UserProfileCardClient extends CachingClient {
149
149
  timestring: timestring
150
150
  };
151
151
  }
152
- getProfile(cloudId, userId, analytics) {
152
+ getProfile(cloudId, userId, analytics, analyticsNext) {
153
153
  if (!userId) {
154
154
  return Promise.reject(new Error('userId missing'));
155
155
  }
@@ -160,25 +160,62 @@ export default class UserProfileCardClient extends CachingClient {
160
160
  }
161
161
  return new Promise((resolve, reject) => {
162
162
  const startTime = getPageTime();
163
- if (analytics) {
164
- analytics(userRequestAnalytics('triggered'));
163
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
164
+ if (analyticsNext) {
165
+ analyticsNext('operational.profilecard.triggered.request', {
166
+ firedAt: Math.round(getPageTime()),
167
+ ...PACKAGE_META_DATA
168
+ });
169
+ }
170
+ } else {
171
+ if (analytics) {
172
+ analytics(userRequestAnalytics('triggered'));
173
+ }
165
174
  }
166
175
  this.makeRequest(cloudId, userId).then(data => {
167
176
  if (this.cache) {
168
177
  this.setCachedProfile(cacheIdentifier, data);
169
178
  }
170
- if (analytics) {
171
- analytics(userRequestAnalytics('succeeded', {
172
- duration: getPageTime() - startTime
173
- }));
179
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
180
+ if (analyticsNext) {
181
+ analyticsNext('operational.profilecard.succeeded.request', {
182
+ duration: getPageTime() - startTime,
183
+ firedAt: Math.round(getPageTime()),
184
+ ...PACKAGE_META_DATA
185
+ });
186
+ }
187
+ } else {
188
+ if (analytics) {
189
+ analytics(userRequestAnalytics('succeeded', {
190
+ duration: getPageTime() - startTime
191
+ }));
192
+ }
174
193
  }
175
194
  resolve(data);
176
195
  }).catch(error => {
177
- if (analytics) {
178
- analytics(userRequestAnalytics('failed', {
179
- duration: getPageTime() - startTime,
180
- ...getErrorAttributes(error)
181
- }));
196
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
197
+ if (analyticsNext) {
198
+ const errorAttributes = getErrorAttributes(error);
199
+ analyticsNext('operational.profilecard.failed.request', {
200
+ duration: getPageTime() - startTime,
201
+ ...errorAttributes,
202
+ traceId: errorAttributes.traceId || null,
203
+ errorCategory: errorAttributes.errorCategory || null,
204
+ errorType: errorAttributes.errorType || null,
205
+ errorPath: errorAttributes.errorPath || null,
206
+ errorNumber: errorAttributes.errorNumber || null,
207
+ errorStatusCode: errorAttributes.errorStatusCode || null,
208
+ firedAt: Math.round(getPageTime()),
209
+ ...PACKAGE_META_DATA
210
+ });
211
+ }
212
+ } else {
213
+ if (analytics) {
214
+ analytics(userRequestAnalytics('failed', {
215
+ duration: getPageTime() - startTime,
216
+ ...getErrorAttributes(error)
217
+ }));
218
+ }
182
219
  }
183
220
  reject(error);
184
221
  });
@@ -6,7 +6,7 @@ const ORG_ID_FROM_CLOUD_ID_QUERY = `query OrgIdFromCloudId($cloudId: ID!) {
6
6
  }`;
7
7
  const addHeaders = headers => {
8
8
  headers.append('atl-client-name', "@atlaskit/profilecard");
9
- headers.append('atl-client-version', "24.13.6");
9
+ headers.append('atl-client-version', "24.13.7");
10
10
  return headers;
11
11
  };
12
12
  export async function getOrgIdForCloudIdFromAGG(url, cloudId) {
@@ -77,7 +77,7 @@ export const addHeaders = headers => {
77
77
  headers.append('X-ExperimentalApi', 'teams-beta');
78
78
  headers.append('X-ExperimentalApi', 'team-members-beta');
79
79
  headers.append('atl-client-name', "@atlaskit/profilecard");
80
- headers.append('atl-client-version', "24.13.6");
80
+ headers.append('atl-client-version', "24.13.7");
81
81
  return headers;
82
82
  };
83
83
  export async function getTeamFromAGG(url, teamId, siteId) {
@@ -129,6 +129,9 @@ const AgentProfileCard = ({
129
129
  return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
130
130
  errorType: errorType,
131
131
  fireAnalytics: fireAnalytics
132
+ // TODO: Add fireAnalyticsNext
133
+ ,
134
+ fireAnalyticsNext: () => {}
132
135
  }));
133
136
  }
134
137
  return /*#__PURE__*/React.createElement(AgentProfileCardWrapper, null, /*#__PURE__*/React.createElement(Box, {
@@ -89,7 +89,8 @@ export const AgentProfileCardResourced = props => {
89
89
  fetchData();
90
90
  },
91
91
  errorType: error || null,
92
- fireAnalytics: () => {}
92
+ fireAnalytics: () => {},
93
+ fireAnalyticsNext: () => {}
93
94
  }));
94
95
  }
95
96
  return /*#__PURE__*/React.createElement(Suspense, {
@@ -2,10 +2,11 @@ import React, { useEffect } from 'react';
2
2
  import Button from '@atlaskit/button/new';
3
3
  import CrossCircleIcon from '@atlaskit/icon/core/cross-circle';
4
4
  import IconError from '@atlaskit/icon/glyph/cross-circle';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
6
7
  import { Text } from '@atlaskit/primitives';
7
8
  import { ErrorTitle, ErrorWrapper } from '../../styled/Error';
8
- import { profileCardRendered } from '../../util/analytics';
9
+ import { PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
9
10
  const ErrorMessage = props => {
10
11
  const errorType = props.errorType || {
11
12
  reason: 'default'
@@ -13,15 +14,25 @@ const ErrorMessage = props => {
13
14
  const errorReason = errorType.reason;
14
15
  const {
15
16
  fireAnalytics,
17
+ fireAnalyticsNext,
16
18
  reload
17
19
  } = props;
18
20
  const hasRetry = !!reload;
19
21
  useEffect(() => {
20
- fireAnalytics(profileCardRendered('user', 'error', {
21
- hasRetry,
22
- errorType: errorReason
23
- }));
24
- }, [errorReason, fireAnalytics, hasRetry]);
22
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
23
+ fireAnalyticsNext('ui.profilecard.rendered.error', {
24
+ hasRetry,
25
+ errorType: errorReason,
26
+ firedAt: Math.round(performance.now()),
27
+ ...PACKAGE_META_DATA
28
+ });
29
+ } else {
30
+ fireAnalytics(profileCardRendered('user', 'error', {
31
+ hasRetry,
32
+ errorType: errorReason
33
+ }));
34
+ }
35
+ }, [errorReason, fireAnalytics, fireAnalyticsNext, hasRetry]);
25
36
  const errorContent = () => {
26
37
  if (errorReason === 'NotFound') {
27
38
  return /*#__PURE__*/React.createElement(ErrorTitle, null, "The user is no longer available for the site");
@@ -7,7 +7,8 @@ import MoreIcon from '@atlaskit/icon/core/migration/show-more-horizontal--more';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
8
  import messages from '../../messages';
9
9
  import { OverflowActionButtonsWrapper } from '../../styled/Card';
10
- import { moreActionsClicked } from '../../util/analytics';
10
+ import { moreActionsClicked, PACKAGE_META_DATA } from '../../util/analytics';
11
+ import { getPageTime } from '../../util/performance';
11
12
  export const ACTION_OVERFLOW_THRESHOLD = 2;
12
13
  export const OverflowProfileCardButtons = props => {
13
14
  const intl = useIntl();
@@ -15,7 +16,8 @@ export const OverflowProfileCardButtons = props => {
15
16
  const {
16
17
  actions,
17
18
  onItemClick,
18
- fireAnalyticsWithDuration
19
+ fireAnalyticsWithDuration,
20
+ fireAnalyticsWithDurationNext
19
21
  } = props;
20
22
  const numActions = actions.length + ACTION_OVERFLOW_THRESHOLD;
21
23
  const onOpenChange = useCallback(({
@@ -23,14 +25,23 @@ export const OverflowProfileCardButtons = props => {
23
25
  }) => {
24
26
  setOpen(prevOpen => {
25
27
  if (nextOpen && !prevOpen) {
26
- fireAnalyticsWithDuration(duration => moreActionsClicked('user', {
27
- duration,
28
- numActions
29
- }));
28
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
29
+ fireAnalyticsWithDurationNext('ui.profilecard.clicked.moreActions', duration => ({
30
+ duration,
31
+ numActions,
32
+ firedAt: Math.round(getPageTime()),
33
+ ...PACKAGE_META_DATA
34
+ }));
35
+ } else {
36
+ fireAnalyticsWithDuration(duration => moreActionsClicked('user', {
37
+ duration,
38
+ numActions
39
+ }));
40
+ }
30
41
  }
31
42
  return nextOpen;
32
43
  });
33
- }, [numActions, fireAnalyticsWithDuration]);
44
+ }, [numActions, fireAnalyticsWithDuration, fireAnalyticsWithDurationNext]);
34
45
  return /*#__PURE__*/React.createElement(OverflowActionButtonsWrapper, {
35
46
  testId: "profilecard-actions-overflow"
36
47
  }, /*#__PURE__*/React.createElement(DropdownMenu, {
@@ -5,12 +5,14 @@ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
5
5
  import Avatar from '@atlaskit/avatar';
6
6
  import { LinkButton } from '@atlaskit/button/new';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
+ import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
8
9
  import Spinner from '@atlaskit/spinner';
10
+ import { useAnalyticsEvents } from '@atlaskit/teams-app-internal-analytics';
9
11
  import { N0 } from '@atlaskit/theme/colors';
10
12
  import messages from '../../messages';
11
13
  import { ActionButtonGroup, ActionsFlexSpacer, AnimatedKudosButton, AnimationWrapper, CardContainer, CardContent, KudosBlobAnimation, ProfileImage } from '../../styled/Card';
12
14
  import { CardWrapper, SpinnerContainer } from '../../styled/UserTrigger';
13
- import { actionClicked, fireEvent, profileCardRendered } from '../../util/analytics';
15
+ import { actionClicked, fireEvent, PACKAGE_META_DATA, profileCardRendered } from '../../util/analytics';
14
16
  import { isBasicClick } from '../../util/click';
15
17
  import { getPageTime } from '../../util/performance';
16
18
  import { ErrorMessage } from '../Error';
@@ -54,6 +56,9 @@ export const ProfilecardInternal = props => {
54
56
  const {
55
57
  createAnalyticsEvent
56
58
  } = props;
59
+ const {
60
+ fireEvent: fireEventNext
61
+ } = useAnalyticsEvents();
57
62
  const fireAnalytics = useCallback(payload => {
58
63
  if (createAnalyticsEvent) {
59
64
  fireEvent(createAnalyticsEvent, payload);
@@ -64,6 +69,11 @@ export const ProfilecardInternal = props => {
64
69
  const event = generator(elapsed);
65
70
  fireAnalytics(event);
66
71
  }, [fireAnalytics, openTime]);
72
+ const fireAnalyticsWithDurationNext = useCallback((eventKey, generator) => {
73
+ const duration = getPageTime() - openTime;
74
+ const attributes = generator(duration);
75
+ fireEventNext(eventKey, attributes);
76
+ }, [openTime, fireEventNext]);
67
77
  const {
68
78
  kudosAction
69
79
  } = useKudos(props.cloudId, props.userId, props.teamCentralBaseUrl, props.openKudosDrawer);
@@ -87,22 +97,33 @@ export const ProfilecardInternal = props => {
87
97
  const canRender = !hasError && !isLoading && !!(fullName || status === 'closed');
88
98
  useEffect(() => {
89
99
  if (canRender) {
90
- fireAnalyticsWithDuration(duration => profileCardRendered('user', 'content', {
91
- duration,
92
- numActions: realActions.length
93
- }));
100
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
101
+ fireAnalyticsWithDurationNext('ui.profilecard.rendered.content', duration => ({
102
+ duration,
103
+ numActions: realActions.length,
104
+ firedAt: Math.round(getPageTime()),
105
+ ...PACKAGE_META_DATA
106
+ }));
107
+ } else {
108
+ fireAnalyticsWithDuration(duration => profileCardRendered('user', 'content', {
109
+ duration,
110
+ numActions: realActions.length
111
+ }));
112
+ }
94
113
  }
95
- }, [canRender, fireAnalyticsWithDuration, realActions]);
114
+ }, [canRender, fireAnalyticsWithDuration, fireAnalyticsWithDurationNext, realActions]);
96
115
  if (hasError) {
97
116
  return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(ErrorMessage, {
98
117
  reload: props.clientFetchProfile,
99
118
  errorType: props.errorType || null,
100
- fireAnalytics: fireAnalytics
119
+ fireAnalytics: fireAnalytics,
120
+ fireAnalyticsNext: fireEventNext
101
121
  }));
102
122
  }
103
123
  if (isLoading) {
104
124
  return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement(LoadingView, {
105
- fireAnalyticsWithDuration: fireAnalyticsWithDuration
125
+ fireAnalyticsWithDuration: fireAnalyticsWithDuration,
126
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext
106
127
  }));
107
128
  }
108
129
  if (!canRender) {
@@ -118,35 +139,51 @@ export const ProfilecardInternal = props => {
118
139
  borderColor: `var(--ds-shadow-overlay, ${N0})`
119
140
  })), /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(ProfileCardDetails, _extends({}, props, {
120
141
  status: status,
121
- fireAnalyticsWithDuration: fireAnalyticsWithDuration
142
+ fireAnalyticsWithDuration: fireAnalyticsWithDuration,
143
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext
122
144
  })), 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') && {
123
145
  fullName
124
146
  }, {
125
147
  fullName: fullName,
126
148
  actions: realActions,
127
149
  fireAnalyticsWithDuration: fireAnalyticsWithDuration,
128
- isTriggeredUsingKeyboard: props.isTriggeredUsingKeyboard
150
+ isTriggeredUsingKeyboard: props.isTriggeredUsingKeyboard,
151
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext
129
152
  }))))));
130
153
  };
131
154
  const Actions = ({
132
155
  actions,
133
156
  fireAnalyticsWithDuration,
157
+ fireAnalyticsWithDurationNext,
134
158
  isTriggeredUsingKeyboard,
135
159
  fullName
136
160
  }) => {
137
161
  const onActionClick = useCallback((action, args, event, index) => {
138
- fireAnalyticsWithDuration(duration => actionClicked('user', {
139
- duration,
140
- hasHref: !!action.link,
141
- hasOnClick: !!action.callback,
142
- index,
143
- actionId: action.id || 'no-id-specified'
144
- }));
162
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
163
+ fireAnalyticsWithDurationNext('ui.profilecard.clicked.action', duration => ({
164
+ method: 'click',
165
+ firedAt: Math.round(getPageTime()),
166
+ duration,
167
+ hasHref: !!action.link,
168
+ hasOnClick: !!action.callback,
169
+ index,
170
+ actionId: action.id || 'no-id-specified',
171
+ ...PACKAGE_META_DATA
172
+ }));
173
+ } else {
174
+ fireAnalyticsWithDuration(duration => actionClicked('user', {
175
+ duration,
176
+ hasHref: !!action.link,
177
+ hasOnClick: !!action.callback,
178
+ index,
179
+ actionId: action.id || 'no-id-specified'
180
+ }));
181
+ }
145
182
  if (action.callback && isBasicClick(event)) {
146
183
  event.preventDefault();
147
184
  action.callback(event, ...args);
148
185
  }
149
- }, [fireAnalyticsWithDuration]);
186
+ }, [fireAnalyticsWithDuration, fireAnalyticsWithDurationNext]);
150
187
  if (!actions || actions.length === 0) {
151
188
  return null;
152
189
  }
@@ -175,21 +212,31 @@ const Actions = ({
175
212
  }), overflowActions && /*#__PURE__*/React.createElement(OverflowProfileCardButtons, _extends({
176
213
  actions: overflowActions,
177
214
  fireAnalyticsWithDuration: fireAnalyticsWithDuration,
215
+ fireAnalyticsWithDurationNext: fireAnalyticsWithDurationNext,
178
216
  onItemClick: (action, args, event, index) => onActionClick(action, args, event, index + ACTION_OVERFLOW_THRESHOLD)
179
217
  }, fg('jfp_a11y_team_profile_card_actions_label') && {
180
218
  fullName
181
219
  })));
182
220
  };
183
- const LoadingView = ({
184
- fireAnalyticsWithDuration
221
+ export const LoadingView = ({
222
+ fireAnalyticsWithDuration,
223
+ fireAnalyticsWithDurationNext
185
224
  }) => {
186
225
  useEffect(() => {
187
- fireAnalyticsWithDuration(duration => profileCardRendered('user', 'spinner', {
188
- duration
189
- }));
190
- }, [fireAnalyticsWithDuration]);
226
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
227
+ fireAnalyticsWithDurationNext('ui.profilecard.rendered.spinner', duration => ({
228
+ firedAt: Math.round(getPageTime()),
229
+ duration,
230
+ ...PACKAGE_META_DATA
231
+ }));
232
+ } else {
233
+ fireAnalyticsWithDuration(duration => profileCardRendered('user', 'spinner', {
234
+ duration
235
+ }));
236
+ }
237
+ }, [fireAnalyticsWithDuration, fireAnalyticsWithDurationNext]);
191
238
  return /*#__PURE__*/React.createElement(SpinnerContainer, {
192
239
  testId: "profilecard-spinner-container"
193
240
  }, /*#__PURE__*/React.createElement(Spinner, null));
194
241
  };
195
- export default withAnalyticsEvents()(ProfilecardInternal);
242
+ export default componentWithFG('ptc-enable-profile-card-analytics-refactor', ProfilecardInternal, withAnalyticsEvents()(ProfilecardInternal));
@@ -137,6 +137,7 @@ export const ProfileCardDetails = props => {
137
137
  reportingLines: props.reportingLines,
138
138
  reportingLinesProfileUrl: props.reportingLinesProfileUrl,
139
139
  onReportingLinesClick: props.onReportingLinesClick,
140
- fireAnalyticsWithDuration: props.fireAnalyticsWithDuration
140
+ fireAnalyticsWithDuration: props.fireAnalyticsWithDuration,
141
+ fireAnalyticsWithDurationNext: props.fireAnalyticsWithDurationNext
141
142
  }));
142
143
  };
@@ -3,6 +3,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import React, { Suspense } from 'react';
4
4
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
5
5
  import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
6
+ import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
7
+ import { useAnalyticsEvents } from '@atlaskit/teams-app-internal-analytics';
6
8
  import filterActions from '../../internal/filterActions';
7
9
  import { CardWrapper } from '../../styled/UserTrigger';
8
10
  import { fireEvent } from '../../util/analytics';
@@ -33,6 +35,15 @@ class ProfileCardResourced extends React.PureComponent {
33
35
  fireEvent(this.props.createAnalyticsEvent, payload);
34
36
  }
35
37
  });
38
+ _defineProperty(this, "fireAnalyticsNext", (eventKey, ...attributes) => {
39
+ // Don't fire analytics if the component is unmounted
40
+ if (!this._isMounted) {
41
+ return;
42
+ }
43
+ if (this.props.fireEvent) {
44
+ this.props.fireEvent(eventKey, ...attributes);
45
+ }
46
+ });
36
47
  _defineProperty(this, "clientFetchProfile", () => {
37
48
  const {
38
49
  cloudId,
@@ -50,7 +61,7 @@ class ProfileCardResourced extends React.PureComponent {
50
61
  hasError: false,
51
62
  data: null
52
63
  }, () => {
53
- const requests = Promise.all([this.props.resourceClient.getProfile(cloudId, userId, this.fireAnalytics), this.props.resourceClient.getReportingLines(userId), this.props.resourceClient.shouldShowGiveKudos(), this.props.resourceClient.getTeamCentralBaseUrl({
64
+ const 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({
54
65
  withOrgContext: true,
55
66
  withSiteContext: true
56
67
  })]);
@@ -130,7 +141,8 @@ class ProfileCardResourced extends React.PureComponent {
130
141
  const isFetchingOrNotStartToFetchYet = isLoading === true || isLoading === undefined;
131
142
  if (isFetchingOrNotStartToFetchYet) {
132
143
  return /*#__PURE__*/React.createElement(CardWrapper, null, /*#__PURE__*/React.createElement(UserLoadingState, {
133
- fireAnalytics: this.fireAnalytics
144
+ fireAnalytics: this.fireAnalytics,
145
+ fireAnalyticsNext: this.fireAnalyticsNext
134
146
  }));
135
147
  } else if (hasError) {
136
148
  return /*#__PURE__*/React.createElement(CardWrapper, {
@@ -138,7 +150,8 @@ class ProfileCardResourced extends React.PureComponent {
138
150
  }, /*#__PURE__*/React.createElement(ErrorMessage, {
139
151
  errorType: error,
140
152
  reload: this.clientFetchProfile,
141
- fireAnalytics: this.fireAnalytics
153
+ fireAnalytics: this.fireAnalytics,
154
+ fireAnalyticsNext: this.fireAnalyticsNext
142
155
  }));
143
156
  }
144
157
  const newProps = {
@@ -177,4 +190,12 @@ _defineProperty(ProfileCardResourced, "defaultProps", {
177
190
  actions: []
178
191
  });
179
192
  export const ProfileCardResourcedInternal = ProfileCardResourced;
180
- export default withAnalyticsEvents()(ProfileCardResourced);
193
+ const ProfileCardResourcedWithAnalytics = props => {
194
+ const {
195
+ fireEvent
196
+ } = useAnalyticsEvents();
197
+ return /*#__PURE__*/React.createElement(ProfileCardResourced, _extends({
198
+ fireEvent: fireEvent
199
+ }, props));
200
+ };
201
+ export default componentWithFG('ptc-enable-profile-card-analytics-refactor', ProfileCardResourcedWithAnalytics, withAnalyticsEvents()(ProfileCardResourced));
@@ -9,12 +9,14 @@ import { GiveKudosLauncherLazy, KudosType } from '@atlaskit/give-kudos';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
10
  import Popup from '@atlaskit/popup';
11
11
  import { Box } from '@atlaskit/primitives/compiled';
12
+ import { useAnalyticsEvents as useAnalyticsEventsNext } from '@atlaskit/teams-app-internal-analytics';
12
13
  import { layers } from '@atlaskit/theme/constants';
13
14
  import filterActionsInner from '../../internal/filterActions';
14
15
  import getLabelMessage from '../../internal/getLabelMessage';
15
16
  import { CardWrapper } from '../../styled/UserTrigger';
16
- import { cardTriggered, fireEvent } from '../../util/analytics';
17
+ import { cardTriggered, fireEvent, PACKAGE_META_DATA } from '../../util/analytics';
17
18
  import { DELAY_MS_HIDE, DELAY_MS_SHOW } from '../../util/config';
19
+ import { getPageTime } from '../../util/performance';
18
20
  import { AgentProfileCardResourced } from '../Agent/AgentProfileCardResourced';
19
21
  import { ProfileCardLazy } from './lazyProfileCard';
20
22
  import UserLoadingState from './UserLoadingState';
@@ -105,6 +107,9 @@ export default function ProfilecardTriggerNext({
105
107
  const [kudosDrawerOpen, setKudosDrawerOpen] = useState(false);
106
108
  const [isTriggeredUsingKeyboard, setTriggeredUsingKeyboard] = useState(false);
107
109
  const triggerRef = useRef(null);
110
+ const {
111
+ fireEvent: fireEventNext
112
+ } = useAnalyticsEventsNext();
108
113
  useEffect(() => {
109
114
  isMounted.current = true;
110
115
  return () => {
@@ -123,6 +128,14 @@ export default function ProfilecardTriggerNext({
123
128
  setShouldShowGiveKudos(false);
124
129
  setTeamCentralBaseUrl(undefined);
125
130
  }, [userId]);
131
+
132
+ // Create a wrapper function that has the same interface as fireEventNext but includes isMounted check
133
+ const fireAnalyticsNext = useCallback((eventKey, ...attributes) => {
134
+ if (!isMounted.current) {
135
+ return;
136
+ }
137
+ fireEventNext(eventKey, ...attributes);
138
+ }, [fireEventNext]);
126
139
  const fireAnalytics = useCallback(payload => {
127
140
  // Don't fire any analytics if the component is unmounted
128
141
  if (!isMounted.current) {
@@ -180,7 +193,7 @@ export default function ProfilecardTriggerNext({
180
193
  setError(null);
181
194
  setData(null);
182
195
  try {
183
- const requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos(), resourceClient.getTeamCentralBaseUrl({
196
+ const requests = Promise.all([resourceClient.getProfile(cloudId || '', userId, fireAnalytics, fireAnalyticsNext), resourceClient.getReportingLines(userId), resourceClient.shouldShowGiveKudos(), resourceClient.getTeamCentralBaseUrl({
184
197
  withOrgContext: true,
185
198
  withSiteContext: true
186
199
  })]);
@@ -189,7 +202,7 @@ export default function ProfilecardTriggerNext({
189
202
  } catch (err) {
190
203
  handleClientError(err);
191
204
  }
192
- }, [cloudId, fireAnalytics, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
205
+ }, [cloudId, fireAnalytics, fireAnalyticsNext, isLoading, resourceClient, userId, handleClientSuccess, handleClientError]);
193
206
  const showProfilecard = useCallback(() => {
194
207
  clearTimeout(hideTimer.current);
195
208
  clearTimeout(showTimer.current);
@@ -208,25 +221,49 @@ export default function ProfilecardTriggerNext({
208
221
  event.stopPropagation();
209
222
  showProfilecard();
210
223
  if (!visible) {
211
- fireAnalytics(cardTriggered('user', 'click'));
224
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
225
+ fireAnalyticsNext('ui.profilecard.triggered', {
226
+ method: 'click',
227
+ firedAt: Math.round(getPageTime()),
228
+ ...PACKAGE_META_DATA
229
+ });
230
+ } else {
231
+ fireAnalytics(cardTriggered('user', 'click'));
232
+ }
212
233
  }
213
- }, [fireAnalytics, showProfilecard, visible]);
234
+ }, [fireAnalytics, fireAnalyticsNext, showProfilecard, visible]);
214
235
  const onMouseEnter = useCallback(() => {
215
236
  showProfilecard();
216
237
  if (!visible) {
217
- fireAnalytics(cardTriggered('user', 'hover'));
238
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
239
+ fireAnalyticsNext('ui.profilecard.triggered', {
240
+ method: 'hover',
241
+ firedAt: Math.round(getPageTime()),
242
+ ...PACKAGE_META_DATA
243
+ });
244
+ } else {
245
+ fireAnalytics(cardTriggered('user', 'hover'));
246
+ }
218
247
  }
219
- }, [fireAnalytics, showProfilecard, visible]);
248
+ }, [fireAnalytics, fireAnalyticsNext, showProfilecard, visible]);
220
249
  const onKeyPress = useCallback(event => {
221
250
  if (event.key === 'Enter' || event.key === ' ') {
222
251
  event.preventDefault();
223
252
  setTriggeredUsingKeyboard(true);
224
253
  showProfilecard();
225
254
  if (!visible) {
226
- fireAnalytics(cardTriggered('user', 'click'));
255
+ if (fg('ptc-enable-profile-card-analytics-refactor')) {
256
+ fireAnalyticsNext('ui.profilecard.triggered', {
257
+ method: 'click',
258
+ firedAt: Math.round(getPageTime()),
259
+ ...PACKAGE_META_DATA
260
+ });
261
+ } else {
262
+ fireAnalytics(cardTriggered('user', 'click'));
263
+ }
227
264
  }
228
265
  }
229
- }, [fireAnalytics, showProfilecard, visible]);
266
+ }, [fireAnalytics, fireAnalyticsNext, showProfilecard, visible]);
230
267
  const onFocus = useCallback(() => {
231
268
  showProfilecard();
232
269
  }, [showProfilecard]);
@@ -301,7 +338,8 @@ export default function ProfilecardTriggerNext({
301
338
  placement: position,
302
339
  offset: offset !== null && offset !== void 0 ? offset : [0, 8],
303
340
  content: () => /*#__PURE__*/React.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
304
- fireAnalytics: fireAnalytics
341
+ fireAnalytics: fireAnalytics,
342
+ fireAnalyticsNext: fireAnalyticsNext
305
343
  }) : visible && /*#__PURE__*/React.createElement(ProfileCardContent, {
306
344
  profilecardProps: profilecardProps,
307
345
  isAgent: !!(data !== null && data !== void 0 && data.isAgent),
@@ -378,7 +416,8 @@ export default function ProfilecardTriggerNext({
378
416
  placement: position,
379
417
  offset: offset !== null && offset !== void 0 ? offset : [0, 8],
380
418
  content: () => /*#__PURE__*/React.createElement("div", wrapperProps, showLoading ? /*#__PURE__*/React.createElement(LoadingView, {
381
- fireAnalytics: fireAnalytics
419
+ fireAnalytics: fireAnalytics,
420
+ fireAnalyticsNext: fireAnalyticsNext
382
421
  }) : visible && /*#__PURE__*/React.createElement(ProfileCardContent, {
383
422
  profilecardProps: profilecardProps,
384
423
  isAgent: !!(data !== null && data !== void 0 && data.isAgent),
@@ -447,9 +486,11 @@ export default function ProfilecardTriggerNext({
447
486
  })));
448
487
  }
449
488
  const LoadingView = ({
450
- fireAnalytics
489
+ fireAnalytics,
490
+ fireAnalyticsNext
451
491
  }) => /*#__PURE__*/React.createElement(CardWrapper, {
452
492
  testId: "profilecard.profilecardtrigger.loading"
453
493
  }, /*#__PURE__*/React.createElement(UserLoadingState, {
454
- fireAnalytics: fireAnalytics
494
+ fireAnalytics: fireAnalytics,
495
+ fireAnalyticsNext: fireAnalyticsNext
455
496
  }));