File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import * as amplitude from '@amplitude/analytics-browser'
12import { createApi , fetchBaseQuery } from '@reduxjs/toolkit/dist/query/react'
23
34import { FetchBaseQueryArgs } from '@reduxjs/toolkit/dist/query/fetchBaseQuery'
@@ -36,6 +37,17 @@ const baseApiOptions = (queryArgs?: Partial<FetchBaseQueryArgs>) => {
3637 } catch ( e ) { }
3738 }
3839
40+ const deviceId = amplitude . getDeviceId ( )
41+ const sessionId = amplitude . getSessionId ( )
42+ const userId = amplitude . getUserId ( )
43+ if ( deviceId || sessionId || userId ) {
44+ const entries : string [ ] = [ ]
45+ if ( deviceId ) entries . push ( `amplitude.device_id=${ deviceId } ` )
46+ if ( sessionId ) entries . push ( `amplitude.session_id=${ sessionId } ` )
47+ if ( userId ) entries . push ( `amplitude.user_id=${ userId } ` )
48+ headers . set ( 'baggage' , entries . join ( ',' ) )
49+ }
50+
3951 return headers
4052 } ,
4153 ...queryArgs ,
Original file line number Diff line number Diff line change @@ -694,6 +694,7 @@ export type Account = {
694694 pylon_email_signature : string
695695 sign_up_type : SignupType
696696 id : number
697+ uuid : string
697698 email : string
698699 auth_type : AuthType
699700 is_superuser : boolean
Original file line number Diff line number Diff line change @@ -112,7 +112,8 @@ const API = {
112112 }
113113
114114 if ( Project . amplitude ) {
115- amplitude . setUserId ( id )
115+ const amplitudeUserId = user . uuid || id
116+ amplitude . setUserId ( amplitudeUserId )
116117 API . trackTraits ( { email : id } )
117118 if ( window . engagement ) {
118119 window . engagement . boot ( {
@@ -122,7 +123,7 @@ const API = {
122123 amplitude . track ( event . event_type , event . event_properties ) ,
123124 } ,
124125 ] ,
125- user : { user_id : id , user_properties : { } } ,
126+ user : { user_id : amplitudeUserId , user_properties : { } } ,
126127 } )
127128 }
128129 }
You can’t perform that action at this time.
0 commit comments