Skip to content

Commit eb5f3d4

Browse files
authored
fix: use honeybadger over toast for identity error reporting (#5068)
1 parent e040548 commit eb5f3d4

File tree

3 files changed

+42
-45
lines changed

3 files changed

+42
-45
lines changed

src/identity/actions/thunks/index.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import {
66
setQuartzIdentity,
77
setQuartzIdentityStatus,
88
} from 'src/identity/actions/creators'
9-
import {notify} from 'src/shared/actions/notifications'
10-
import {
11-
updateBillingFailed,
12-
updateIdentityFailed,
13-
updateOrgFailed,
14-
} from 'src/shared/copy/notifications'
159

1610
// Types
1711
import {RemoteDataState, GetState, NotificationAction} from 'src/types'
@@ -33,7 +27,13 @@ import {isFlagEnabled} from 'src/shared/utils/featureFlag'
3327
// Thunks
3428
import {getQuartzMeThunk} from 'src/me/actions/thunks'
3529

36-
export const getQuartzIdentityThunk = () => async dispatch => {
30+
// Error Reporting
31+
import {reportErrorThroughHoneyBadger} from 'src/shared/utils/errors'
32+
33+
export const getQuartzIdentityThunk = () => async (
34+
dispatch: Dispatch<any>,
35+
getState: GetState
36+
) => {
3737
if (!isFlagEnabled('quartzIdentity')) {
3838
dispatch(getQuartzMeThunk())
3939
return
@@ -50,10 +50,14 @@ export const getQuartzIdentityThunk = () => async dispatch => {
5050
const legacyMe = convertIdentityToMe(quartzIdentity)
5151
dispatch(setQuartzMe(legacyMe, RemoteDataState.Done))
5252
dispatch(setQuartzMeStatus(RemoteDataState.Done))
53-
} catch (error) {
53+
} catch (err) {
5454
dispatch(setQuartzIdentityStatus(RemoteDataState.Error))
5555
dispatch(setQuartzMeStatus(RemoteDataState.Error))
56-
dispatch(notify(updateIdentityFailed()))
56+
57+
reportErrorThroughHoneyBadger(err, {
58+
name: 'Failed to fetch /quartz/identity',
59+
context: {state: getState()},
60+
})
5761
}
5862
}
5963

@@ -75,10 +79,14 @@ export const getBillingProviderThunk = () => async (
7579
const legacyMe = convertIdentityToMe(updatedState.identity.currentIdentity)
7680
dispatch(setQuartzMe(legacyMe, RemoteDataState.Done))
7781
dispatch(setQuartzMeStatus(RemoteDataState.Done))
78-
} catch (error) {
82+
} catch (err) {
7983
dispatch(setQuartzIdentityStatus(RemoteDataState.Error))
8084
dispatch(setQuartzMeStatus(RemoteDataState.Error))
81-
dispatch(notify(updateBillingFailed()))
85+
86+
reportErrorThroughHoneyBadger(err, {
87+
name: 'Failed to fetch /quartz/accounts/',
88+
context: {state: getState()},
89+
})
8290
}
8391
}
8492

@@ -101,9 +109,13 @@ export const getCurrentOrgDetailsThunk = () => async (
101109
const legacyMe = convertIdentityToMe(updatedState.identity.currentIdentity)
102110
dispatch(setQuartzMe(legacyMe, RemoteDataState.Done))
103111
dispatch(setQuartzMeStatus(RemoteDataState.Done))
104-
} catch (error) {
112+
} catch (err) {
105113
dispatch(setQuartzIdentityStatus(RemoteDataState.Error))
106114
dispatch(setQuartzMeStatus(RemoteDataState.Error))
107-
dispatch(notify(updateOrgFailed()))
115+
116+
reportErrorThroughHoneyBadger(err, {
117+
name: 'Failed to fetch /quartz/orgs/:orgId',
118+
context: {state: getState()},
119+
})
108120
}
109121
}

src/identity/quartzOrganizations/actions/thunks/index.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,39 @@ import {
1313
import {PublishNotificationAction} from 'src/shared/actions/notifications'
1414

1515
// Types
16-
import {RemoteDataState} from 'src/types'
16+
import {GetState, RemoteDataState} from 'src/types'
1717
import {OrganizationSummaries} from 'src/client/unityRoutes'
1818

1919
type Actions = QuartzOrganizationActions | PublishNotificationAction
2020
type DefaultOrg = OrganizationSummaries[number]
2121

22-
// Notifications
23-
import {notify} from 'src/shared/actions/notifications'
24-
import {updateQuartzOrganizationsFailed} from 'src/shared/copy/notifications'
22+
// Error Reporting
23+
import {reportErrorThroughHoneyBadger} from 'src/shared/utils/errors'
2524

2625
export const getQuartzOrganizationsThunk = () => async (
27-
dispatch: Dispatch<Actions>
26+
dispatch: Dispatch<Actions>,
27+
getState: GetState
2828
) => {
2929
try {
3030
dispatch(setQuartzOrganizationsStatus(RemoteDataState.Loading))
3131
const quartzOrganizations = await fetchQuartzOrgs()
3232

3333
dispatch(setQuartzOrganizations(quartzOrganizations))
3434
dispatch(setQuartzOrganizationsStatus(RemoteDataState.Done))
35-
} catch (error) {
35+
} catch (err) {
3636
dispatch(setQuartzOrganizationsStatus(RemoteDataState.Error))
37-
dispatch(notify(updateQuartzOrganizationsFailed()))
37+
38+
reportErrorThroughHoneyBadger(err, {
39+
name: 'Failed to fetch /quartz/orgs/',
40+
context: {state: getState()},
41+
})
3842
}
3943
}
4044

4145
export const updateDefaultOrgThunk = (
4246
oldDefaultOrg: DefaultOrg,
4347
newDefaultOrg: DefaultOrg
44-
) => async (dispatch: Dispatch<Actions>) => {
48+
) => async (dispatch: Dispatch<Actions>, getState: GetState) => {
4549
try {
4650
dispatch(setQuartzOrganizationsStatus(RemoteDataState.Loading))
4751

@@ -52,6 +56,10 @@ export const updateDefaultOrgThunk = (
5256
dispatch(setQuartzOrganizationsStatus(RemoteDataState.Done))
5357
} catch (err) {
5458
dispatch(setQuartzOrganizationsStatus(RemoteDataState.Error))
55-
throw Error(err)
59+
60+
reportErrorThroughHoneyBadger(err, {
61+
name: 'Failed to update /quartz/orgs/default',
62+
context: {state: getState()},
63+
})
5664
}
5765
}

src/shared/copy/notifications/categories/accounts-users-orgs.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,3 @@ export const removeUserSuccessful = (): Notification => ({
130130
...defaultSuccessNotification,
131131
message: `User Removed`,
132132
})
133-
134-
export const updateBillingFailed = (): Notification => ({
135-
...defaultErrorNotification,
136-
message:
137-
'Error retrieving account billing provider. Please refresh this page.',
138-
})
139-
140-
export const updateIdentityFailed = (): Notification => ({
141-
...defaultErrorNotification,
142-
message: 'Error retrieving user identity. Please refresh this page.',
143-
})
144-
145-
export const updateOrgFailed = (): Notification => ({
146-
...defaultErrorNotification,
147-
message:
148-
'Error retrieving new organization information. Please refresh this page.',
149-
})
150-
151-
export const updateQuartzOrganizationsFailed = (): Notification => ({
152-
...defaultErrorNotification,
153-
message:
154-
'We were unable to retrieve the list of your InfluxData organizations. Please refresh this page.',
155-
})

0 commit comments

Comments
 (0)