Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/telemetry/src/angular/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ErrorHandler, inject } from '@angular/core';
import { ActivatedRouteSnapshot, Router } from '@angular/router';
import { registerTelemetry } from '../register';
import { captureError, getTelemetry } from '../api';
import { TelemetryOptions } from '../public-types';
import { Telemetry, TelemetryOptions } from '../public-types';
import { FirebaseApp } from '@firebase/app';

registerTelemetry();
Expand Down Expand Up @@ -79,20 +79,21 @@ export * from '../public-types';
*/
export class FirebaseErrorHandler implements ErrorHandler {
private readonly router = inject(Router);
private readonly telemetry: Telemetry;

constructor(
private app: FirebaseApp,
private telemetryOptions?: TelemetryOptions
) {}
) {
this.telemetry = getTelemetry(this.app, this.telemetryOptions);
Comment on lines 85 to +88
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The constructor parameters app and telemetryOptions are only used within the constructor to initialize the telemetry property. They don't need to be stored as class properties. You can remove the private modifier from them and adjust the call to getTelemetry accordingly. This improves encapsulation by not exposing these properties on the class instance when they are not needed.

Suggested change
private app: FirebaseApp,
private telemetryOptions?: TelemetryOptions
) {}
) {
this.telemetry = getTelemetry(this.app, this.telemetryOptions);
app: FirebaseApp,
telemetryOptions?: TelemetryOptions
) {
this.telemetry = getTelemetry(app, telemetryOptions);

}

handleError(error: unknown): void {
const telemetry = getTelemetry(this.app, this.telemetryOptions);

const attributes = {
'angular_route_path': this.getSafeRoutePath(this.router)
};

captureError(telemetry, error, attributes);
captureError(this.telemetry, error, attributes);
}

/**
Expand Down
Loading