Skip to content

Commit 38d173d

Browse files
fix(rudderstack): move identify call later where org.id will exist (#5476)
1 parent f624a8d commit 38d173d

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

src/me/actions/thunks/index.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Libraries
22
import HoneyBadger from 'honeybadger-js'
3-
import {identify} from 'rudder-sdk-js'
43
import {Dispatch} from 'react'
54

65
// Functions making API calls
@@ -10,8 +9,6 @@ import {getAccounts} from 'src/client/unityRoutes'
109
// Utils
1110
import {gaEvent, updateReportingContext} from 'src/cloud/utils/reporting'
1211
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
13-
import {CLOUD} from 'src/shared/constants'
14-
import {getOrg} from 'src/organizations/selectors'
1512

1613
// Actions
1714
import {
@@ -25,14 +22,11 @@ import {
2522
import {MeState} from 'src/me/reducers'
2623

2724
// Types
28-
import {RemoteDataState, GetState} from 'src/types'
25+
import {RemoteDataState} from 'src/types'
2926
import {Actions} from 'src/me/actions/creators'
3027
import {fetchQuartzMe} from 'src/identity/apis/auth'
3128

32-
export const getIdpeMeThunk = () => async (
33-
dispatch: Dispatch<Actions>,
34-
getState: GetState
35-
) => {
29+
export const getIdpeMeThunk = () => async (dispatch: Dispatch<Actions>) => {
3630
try {
3731
let user
3832

@@ -61,20 +55,10 @@ export const getIdpeMeThunk = () => async (
6155
},
6256
})
6357

64-
updateReportingContext({
65-
userID: user.id,
66-
})
67-
6858
HoneyBadger.setContext({
6959
user_id: user.id,
7060
})
7161

72-
if (CLOUD && isFlagEnabled('rudderstackReporting')) {
73-
const state = getState()
74-
const org = getOrg(state)
75-
identify(user.id, {email: user.name, orgID: org.id})
76-
}
77-
7862
dispatch(setMe(user as MeState))
7963
} catch (error) {
8064
console.error(error)

src/shared/containers/GetOrganizations.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React, {useEffect, FunctionComponent, lazy, Suspense} from 'react'
33
import {useDispatch, useSelector} from 'react-redux'
44
import {Route, Switch} from 'react-router-dom'
5+
import {identify} from 'rudder-sdk-js'
56

67
// Components
78
import PageSpinner from 'src/perf/components/PageSpinner'
@@ -77,6 +78,12 @@ const GetOrganizations: FunctionComponent = () => {
7778
}
7879
}, [dispatch, status]) // eslint-disable-line react-hooks/exhaustive-deps
7980

81+
useEffect(() => {
82+
if (CLOUD && org?.id && isFlagEnabled('rudderstackReporting')) {
83+
identify(meId, {email, orgID: org.id})
84+
}
85+
}, [org?.id, identify])
86+
8087
useEffect(() => {
8188
if (
8289
CLOUD &&

0 commit comments

Comments
 (0)