@@ -79,6 +79,10 @@ const PER_COMPONENT_PATH_CALLBACKS = new Map<string, TabbedPageNavigationCallbac
7979export function useTabbedPageNav ( ) {
8080 return {
8181 triggerTabbedPageNavigate : function ( url : string , routerDirection : RouteDirection , routerAction : RouteAction , onEventCaught ?: TypedCustomEventData < typeof NavigationEvent > [ 'onEventCaught' ] | undefined ) {
82+ window . trackTabbedPageNavigationEvent ( {
83+ type : 'tabbed-page-custom-dispatch-event:navigation' ,
84+ params : { url, routerDirection, routerAction }
85+ } )
8286 // Using standard event dispatching through ionic's $emit is pointless here, as I didn't find
8387 // how to bubble these event from <ion-router-outlet> placed into _BaseEventPages
8488 // => I'm using a crappy global event (type unsafe) hack here
@@ -88,6 +92,10 @@ export function useTabbedPageNav() {
8892 } ) )
8993 } ,
9094 triggerTabbedPageExitOrNavigate : function ( url : string , routerDirection ?: RouteDirection , onEventCaught ?: TypedCustomEventData < typeof NavigationEvent > [ 'onEventCaught' ] | undefined ) {
95+ window . trackTabbedPageNavigationEvent ( {
96+ type : 'tabbed-page-custom-dispatch-event:tabExitOrNavigate' ,
97+ params : { url, routerDirection }
98+ } )
9199 // Using standard event dispatching through ionic's $emit is pointless here, as I didn't find
92100 // how to bubble these event from <ion-router-outlet> placed into _BaseEventPages
93101 // => I'm using a crappy global event (type unsafe) hack here
@@ -104,12 +112,22 @@ export function useTabbedPageNav() {
104112 const ionRouter = useIonRouter ( ) ;
105113 const startingHistoryPosition = history . state . position ;
106114
115+ window . trackTabbedPageNavigationEvent ( {
116+ type : 'tabbed-page-nag-listeners:registration' , params : { currentComponentInstancePath, startingHistoryPosition }
117+ } ) ;
118+
107119 const navCallback = async ( event : Event ) => {
108120 const perComponentPathCallbacks = PER_COMPONENT_PATH_CALLBACKS . get ( currentComponentInstancePath ) ;
109121 if ( ! perComponentPathCallbacks ) {
122+ window . trackTabbedPageNavigationEvent ( {
123+ type : 'nav-callback:no-op' , params : { reason : `no PER_COMPONENT_PATH_CALLBACKS found for path: ${ currentComponentInstancePath } ` }
124+ } )
110125 return ;
111126 }
112127 if ( perComponentPathCallbacks [ perComponentPathCallbacks . length - 1 ] . navCallback !== navCallback ) {
128+ window . trackTabbedPageNavigationEvent ( {
129+ type : 'nav-callback:no-op' , params : { reason : `last registered navCallback not matching current navCallback for path: ${ currentComponentInstancePath } ` }
130+ } )
113131 return ;
114132 }
115133
@@ -118,14 +136,21 @@ export function useTabbedPageNav() {
118136 await event . detail . onEventCaught ( ) ;
119137 }
120138
139+ window . trackTabbedPageNavigationEvent ( {
140+ type : 'ionRouter:navigate' , params : event . detail
141+ } )
121142 // This navigate() call will happen inside tabbed page context
122143 ionRouter . navigate ( event . detail . url , event . detail . routerDirection , event . detail . routerAction ) ;
123144
124145 perComponentPathCallbacks . pop ( ) ;
125146 if ( perComponentPathCallbacks . length ) {
147+ window . trackTabbedPageNavigationEvent ( {
148+ type : 'otherNavCallbackDelegation' , params : { perComponentPathCallbacksSize : perComponentPathCallbacks . length }
149+ } )
150+ const nextCallback = perComponentPathCallbacks [ perComponentPathCallbacks . length - 1 ] ;
126151 await new Promise ( ( resolve ) => {
127152 setTimeout ( async ( ) => {
128- await perComponentPathCallbacks [ perComponentPathCallbacks . length - 1 ] . navCallback ( event ) ;
153+ await nextCallback . navCallback ( event ) ;
129154 resolve ( null ) ;
130155 } , 0 ) ;
131156 } ) ;
@@ -139,20 +164,39 @@ export function useTabbedPageNav() {
139164 const tabExitOrNavigateCallback = async ( event : Event ) => {
140165 const perComponentPathCallbacks = PER_COMPONENT_PATH_CALLBACKS . get ( currentComponentInstancePath ) ;
141166 if ( ! perComponentPathCallbacks ) {
167+ window . trackTabbedPageNavigationEvent ( {
168+ type : "tab-exit-or-navigate-callback:no-op" , params : { reason : `no PER_COMPONENT_PATH_CALLBACKS found for path: ${ currentComponentInstancePath } ` }
169+ } )
142170 return ;
143171 }
144172 if ( perComponentPathCallbacks [ perComponentPathCallbacks . length - 1 ] . tabExitOrNavigateCallback !== tabExitOrNavigateCallback ) {
173+ window . trackTabbedPageNavigationEvent ( {
174+ type : 'tab-exit-or-navigate-callback:no-op' , params : { reason : `last registered tabExitOrNavigateCallback not matching current tabExitOrNavigateCallback for path: ${ currentComponentInstancePath } ` }
175+ } )
145176 return ;
146177 }
147178
148179 if ( isTabExitOrNavigateEvent ( event ) ) {
149180 const routerGoBacks = startingHistoryPosition - history . state . position ;
181+
182+ window . trackTabbedPageNavigationEvent ( {
183+ type : 'goBackOrNavigateTo' , params : {
184+ url : event . detail . url , routerGoBacks, startingHistoryPosition,
185+ historyPosition : history . state . position , routerDirection : event . detail . routerDirection
186+ }
187+ } )
188+
150189 await goBackOrNavigateTo ( ionRouter , event . detail . url , routerGoBacks , event . detail . routerDirection , event . detail . onEventCaught ) ;
151190
152191 perComponentPathCallbacks . pop ( ) ;
153192 if ( perComponentPathCallbacks . length ) {
193+ window . trackTabbedPageNavigationEvent ( {
194+ type : 'otherNavCallbackDelegation' , params : { perComponentPathCallbacksSize : perComponentPathCallbacks . length }
195+ } )
196+
197+ const nextCallback = perComponentPathCallbacks [ perComponentPathCallbacks . length - 1 ] ;
154198 await new Promise ( async ( resolve ) => {
155- await perComponentPathCallbacks [ perComponentPathCallbacks . length - 1 ] . tabExitOrNavigateCallback ( event ) ;
199+ await nextCallback . tabExitOrNavigateCallback ( event ) ;
156200 setTimeout ( ( ) => resolve ( null ) , 0 ) ;
157201 } ) ;
158202 } else {
0 commit comments