@@ -22,7 +22,8 @@ import {getQuartzMe as apiGetQuartzMe} from 'src/me/actions/thunks'
2222import RouteToOrg from 'src/shared/containers/RouteToOrg'
2323
2424// Selectors
25- import { getQuartzMe } from 'src/me/selectors'
25+ import { getAllOrgs } from 'src/resources/selectors'
26+ import { getMe , getQuartzMe } from 'src/me/selectors'
2627
2728// Constants
2829import { CLOUD } from 'src/shared/constants'
@@ -42,12 +43,14 @@ const canAccessCheckout = (me: Me): boolean => {
4243}
4344
4445const GetOrganizations : FunctionComponent = ( ) => {
45- const status = useSelector ( ( state : AppState ) => state . resources . orgs . status )
46+ const { status, org } = useSelector ( getAllOrgs )
4647 const quartzMeStatus = useSelector (
4748 ( state : AppState ) => state . me . quartzMeStatus
4849 )
49- const me = useSelector ( getQuartzMe )
50+ const quartzMe = useSelector ( getQuartzMe )
51+ const { id : meId = '' , name : email = '' } = useSelector ( getMe )
5052 const dispatch = useDispatch ( )
53+
5154 useEffect ( ( ) => {
5255 if ( status === RemoteDataState . NotStarted ) {
5356 dispatch ( getOrganizations ( ) )
@@ -61,16 +64,31 @@ const GetOrganizations: FunctionComponent = () => {
6164 ) {
6265 dispatch ( apiGetQuartzMe ( ) )
6366 }
67+ } , [ dispatch , quartzMeStatus ] )
6468
69+ useEffect ( ( ) => {
6570 if (
6671 isFlagEnabled ( 'credit250Experiment' ) &&
67- quartzMeStatus === RemoteDataState . Done
72+ quartzMeStatus === RemoteDataState . Done &&
73+ status === RemoteDataState . Done
6874 ) {
69- const { accountCreatedAt = '' } = me
75+ const {
76+ accountType : account_type ,
77+ accountCreatedAt : account_created_at = '' ,
78+ } = quartzMe
79+ const { id : orgId = '' } = org
7080 window . dataLayer = window . dataLayer ?? [ ]
71- window . dataLayer . push ( { accountCreatedAt} )
81+ window . dataLayer . push ( {
82+ identity : {
83+ account_type,
84+ account_created_at,
85+ id : meId ,
86+ email,
87+ organization_id : orgId ,
88+ } ,
89+ } )
7290 }
73- } , [ dispatch , me , quartzMeStatus ] )
91+ } , [ quartzMeStatus , status ] ) // eslint-disable-line react-hooks/exhaustive-deps
7492
7593 return (
7694 < PageSpinner loading = { status } >
@@ -89,10 +107,10 @@ const GetOrganizations: FunctionComponent = () => {
89107 />
90108 < Route path = "/orgs" component = { App } />
91109 < Route exact path = "/" component = { RouteToOrg } />
92- { CLOUD && canAccessCheckout ( me ) && (
110+ { CLOUD && canAccessCheckout ( quartzMe ) && (
93111 < Route path = "/checkout" component = { CheckoutPage } />
94112 ) }
95- { CLOUD && me ?. isOperator && (
113+ { CLOUD && quartzMe ?. isOperator && (
96114 < Route path = "/operator" component = { OperatorPage } />
97115 ) }
98116 < Route component = { NotFound } />
0 commit comments