How to serialize navigation state


I am trying to figure out how a way to serialize the current navigation state of my Ionic app for the purpose of remote error logging using Sentry.

For example, say my appPage has a Tabs component, and clicking on a <button ion-item> pushes another page onto the nav stack with some navParams, then another button on that page pushes another page onto the nav stack, and a button on that page opens a modal using modalCtrl.create().present().

An exception occurs within that modal. I capture the error and call a service function to log the exception to Sentry. I would like to add additional data describing the navigation state of the app when the error occurred… basically I want an array of component by name AppComponent,TabsComponent,TabPage,OtherPageComponent1, OtherPageComponent2, ModalComponent, along with any navParams that were passed to each of these pages.

I am finding it difficult to figure out how to do this and cannot find much documentation to help me out. Any help would be appreciated.