# Changelog

## [1.1.14] - 2025-03-19

### **🛠 Fixes & Improvements**
- **Fixed:** Resolved a circular dependency issue when `ErrorLoggerService` was set as the global `ErrorHandler`.

## [1.1.13] - 2025-03-19

### **🛠 Fixes & Improvements**
- **Fixed:** Resolved a circular dependency issue when `ErrorLoggerService` was set as the global `ErrorHandler`.
  - Now using `Injector` to retrieve the default `ErrorHandler` dynamically, preventing dependency loops.
  - Ensured proper error propagation without interfering with other handlers.
- **Improved:** Stability of the logging service by refining error handling and dependency resolution.

## [1.1.12] - 2025-03-19

### 🛠 Fixes & Enhancements
- **Remove CORS detection in the HTTP interceptor.**

## [1.1.11] - 2025-03-19

### 🛠 Fixes & Enhancements
- **Fixed CORS detection in the HTTP interceptor.**

## [1.1.10] - 2025-03-19

### 🛠 Fixes & Enhancements
- **Fixed CORS detection in the HTTP interceptor.**

## [1.1.9] - 2025-03-19

### 🛠 Fixes & Enhancements
- **Fixed CORS detection in the HTTP interceptor.**

## [1.1.8] - 2025-03-19

### 🛠 Fixes & Enhancements
- **Fixed CORS detection in the HTTP interceptor.**

## [1.1.7] - 2025-03-19

### 🛠 Fixes & Enhancements
- **Fixed error in ErrorLoggerService.**

## [1.1.6] - 2025-03-19

### 🛠 Fixes & Enhancements
- **Implemented a more precise detection of errors in the HTTP interceptor, differentiating them from network connectivity issues.**
- **Improved error propagation in ErrorLoggerService to ensure that logged errors continue to be handled by other global error handlers.**

## [1.1.5] - 2025-03-19

### 🔄 Improvements
- **Improving console debugging messages**
- **The seconds elapsed before sending the logs were adjusted**

## [1.1.4] - 2025-03-19

### 🔄 Improvements
- **Improving console debugging messages**

## [1.1.3] - 2025-03-19

### 🔄 Improvements
- **Improving console debugging messages**

## [1.1.2] - 2025-03-19

### 🔄 Improvements
- **Improving console debugging messages**

## [1.1.1] - 2025-03-18

### 🛠 Fixes & Enhancements
- **Fixing the console message after resolving the app build identifier: `Signing logs with App Build ID: undefined`**

## [1.1.0] - 2025-03-18

### 🚀 New Features
- **Added automatic `appBuildId` generation:**
  - If `appBuildId` is not explicitly set in the logger configuration, the system will attempt to generate it dynamically.
  - The `BuildIdService` was introduced to extract a unique identifier from main file via optimized streaming.

### 🔄 Improvements
- **Optimized main file hashing process:**
  - Instead of loading the entire main file into memory, a **streaming approach** is used, reducing performance overhead.
  - The script attempts to fetch main file from **document**.

### 🛠 Fixes & Enhancements
- **Ensured that the logger does not generate unintended errors.**

## [1.0.15] - 2025-03-17

### 🔄 Changes
- **Fixed:** Resolved an issue where the `Authorization` header was not being added to HTTP requests due to the immutability of Angular's `HttpHeaders`. The fix now reassigns the headers after setting the `Authorization` key, ensuring that the API key is correctly included in outgoing log requests.
- **Added:** Introduced a unique SHA-256 hash generation for each log entry to improve deduplication and tracking.
- **Updated:** The generated hash is now used in `errorSet` to prevent duplicate logs and is also included when sending logs to the server.

### ✨ New Implementation
```typescript
private async generateHash(logData: any): Promise<string> {
  const encoder = new TextEncoder();
  const data = encoder.encode(
    `${logData.appName}-${logData.appEnv}-${logData.appBuildId}-${logData.message || 'Unknown error'}-${logData.stack || ''}`
  );
  const hashBuffer = await window.crypto.subtle.digest('SHA-256', data);
  return this.arrayBufferToHex(hashBuffer);
}

private arrayBufferToHex(buffer: ArrayBuffer): string {
  return Array.from(new Uint8Array(buffer))
    .map((b) => b.toString(16).padStart(2, '0'))
    .join('');
}
```

## [1.0.14] - 2025-03-17

### 🔄 Changes
- Improved the initialization and loading process of the `ErrorLoggerService` to ensure better stability and performance.
- Delayed log submission attempts by **10 seconds** after a navigation event to reduce redundant requests and optimize API calls.

### 🛠 Fixes & Enhancements
- Optimized the handling of navigation events to ensure logs are sent efficiently.
- Minor refactoring to improve the readability and maintainability of the logging service.

---

### 📌 How to Update
To update to the latest version, run:
```sh
npm update ng-safelogger
