An open API service indexing awesome lists of open source software.

https://github.com/souravion/ng-route-logger


https://github.com/souravion/ng-route-logger

Last synced: 6 days ago
JSON representation

Awesome Lists containing this project

README

        

# πŸ“¦ ng-route-logger

**ng-route-logger** is a simple and powerful Angular library that helps you **track page navigation times** inside your Angular application.

Whenever a user switches from one route (page) to another, this library records:
- πŸ“ The new page’s URL (like `/home`, `/about`)
- ⏱️ How many milliseconds it took to load that page

This is super useful if you're building a fast Angular app and want to know which routes take longer to load.

---

## 🎯 Why Should You Use It?

βœ… Simple to set up
βœ… Works with Angular's built-in router
βœ… Uses **RxJS Observables**, so you can subscribe to live logs
βœ… Helpful for developers, testers, and learners

---

## πŸ“¦ Installation

Run this command in your Angular project folder:

```bash
npm install ng-route-logger
```
## 🧰 Having Trouble Installing?

If you're facing issues while installing (like cache or permission problems), you can force the install using:

```bash
npm install ng-route-logger --force
```
## πŸ› οΈ How to Use

### 1. Import the Module

In your `app.module.ts`, import the logger module:

```ts
import { NgRouteLoggerModule } from 'ng-route-logger';

@NgModule({
imports: [
NgRouteLoggerModule, // Add this line
...
],
})
export class AppModule {}
```
### 2. Use the Logger Service

You can inject the logger service into any component or service like this:

```ts
import { NgRouteLoggerService } from 'ng-route-logger';

constructor(private logger: NgRouteLoggerService) {
this.logger.getLogs()
}
```
## πŸ“š Example Log Output

```ts
[
{ route: '/home', loadTime: 96.3 },
{ route: '/about', loadTime: 201.7 },
{ route: '/contact', loadTime: 87.2 }
]
```
## πŸ“š Example Use Cases
- Show a "page load time" chart for users

- Find out which pages take longest to load

- Log page transitions for debugging or performance testing

## πŸ” What’s Happening in the Background?

- ⏱️ Starts timer when route navigation begins (`NavigationStart`)
- πŸ›‘ Stops timer when navigation ends (`NavigationEnd`)
- 🧾 Logs the route and time taken
- πŸ“‘ Streams the logs using **RxJS Observable**

## πŸ“¬ Contribute or Report Issues
Found a bug or have an idea? Create an issue or PR at:

πŸ‘‰ [https://github.com/souravion/ng-route-logger](https://github.com/souravion/ng-route-logger)

## πŸš€ Planned Features (Coming Soon)

Here are some awesome features we plan to add in future updates:

| Feature | Description |
|------------------------------------|-----------------------------------------------------------------------------|
| πŸ“Š Route Load Time Charts | Visualize navigation performance using simple charts (e.g., bar or line) |
| πŸ’Ύ Export Logs | Export route logs as JSON or CSV files for performance audits |
| πŸŽ›οΈ Configurable Logging Options | Enable/disable specific logs or exclude certain routes |
| 🧹 Auto-Cleanup | Automatically limit stored logs to the last N entries |
| πŸ”₯ DevTools Panel Integration | Optional integration with browser devtools extension for real-time viewing |
| πŸ§ͺ Unit Test Utilities | Helpers to test routing performance in unit/e2e test suites |
| 🌐 Multi-Tab Session Awareness | Detect and separate logs from different browser tabs |

> ✨ Have an idea or feature request? Feel free to [open an issue](https://github.com/souravion/ng-route-logger/issues) or [start a discussion](https://github.com/souravion/ng-route-logger/discussions)!

## ✨ Made with ❀️ by Souravion
For Angular developers who want to know how fast their app really is.