File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ STUDIO_BASE_URL=http://localhost:18010
1414MARKETING_SITE_BASE_URL = http://localhost:18000
1515ORDER_HISTORY_URL = http://localhost:1996/orders
1616REFRESH_ACCESS_TOKEN_ENDPOINT = http://localhost:18000/login_refresh
17- SEGMENT_KEY = ul
17+ SEGMENT_KEY = null
1818SITE_NAME = Open edX
1919USER_INFO_COOKIE_NAME = edx-user-info
2020LOGO_URL = https://edx-cdn.org/v3/default/logo.svg
Original file line number Diff line number Diff line change 55dist
66node_modules
77/docs /api
8+ .env.private
Original file line number Diff line number Diff line change @@ -158,28 +158,17 @@ class SegmentAnalyticsService {
158158 identifyAnonymousUser ( traits ) {
159159 // if we do not have an authenticated user (indicated by being in this method),
160160 // but we still have a user id associated in segment, reset the local segment state
161- // This has to be wrapped in the document.readyState logic because the analytics.user()
161+ // This has to be wrapped in the analytics.ready() callback because the analytics.user()
162162 // function isn't available until the analytics.js package has finished initializing.
163163 return new Promise ( ( resolve , reject ) => { // eslint-disable-line no-unused-vars
164- if ( document . readyState === 'complete' ) {
164+ global . analytics . ready ( ( ) => {
165165 if ( global . analytics . user ( ) . id ( ) ) {
166166 global . analytics . reset ( ) ;
167167 }
168168 global . analytics . identify ( traits ) ;
169169 this . hasIdentifyBeenCalled = true ;
170170 resolve ( ) ;
171- } else {
172- document . addEventListener ( 'readystatechange' , event => {
173- if ( event . target . readyState === 'complete' ) {
174- if ( global . analytics . user ( ) . id ( ) ) {
175- global . analytics . reset ( ) ;
176- }
177- global . analytics . identify ( traits ) ;
178- this . hasIdentifyBeenCalled = true ;
179- resolve ( ) ;
180- }
181- } ) ;
182- }
171+ } ) ;
183172 } ) ;
184173 }
185174
Original file line number Diff line number Diff line change @@ -46,6 +46,11 @@ beforeEach(() => {
4646 window . analytics . page = jest . fn ( ) ;
4747 window . analytics . track = jest . fn ( ) ;
4848 window . analytics . reset = jest . fn ( ) ;
49+ window . analytics . ready = jest . fn ( ( callback ) => {
50+ if ( callback ) {
51+ callback ( ) ;
52+ }
53+ } ) ;
4954} ) ;
5055
5156describe ( 'analytics sendTrackingLogEvent' , ( ) => {
You can’t perform that action at this time.
0 commit comments