Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

244
Views
Rollbar evita que el origen del registro original se muestre en la consola del navegador

Rollbar, todas las llamadas regulares de console.log se muestran como originadas en rollbar.min.js:2251:82. Sin embargo, me gustaría poder ver de dónde provino el registro, por ejemplo, de header.ts:25, esto puede ser útil en algunos casos.

aplicación.módulo.ts

 import { BrowserModule } from '@angular/platform-browser'; import { NgModule, ErrorHandler } from '@angular/core'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { RollbarService, rollbarFactory, RollbarErrorHandler } from './rollbar'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, AppRoutingModule ], providers: [ { provide: ErrorHandler, useClass: RollbarErrorHandler }, { provide: RollbarService, useFactory: rollbarFactory } ], bootstrap: [AppComponent] }) export class AppModule {}

rollbar.ts

 import * as Rollbar from 'rollbar'; import { Injectable, Inject, InjectionToken, ErrorHandler } from '@angular/core'; const rollbarConfig = { accessToken: 'CLIENT_ITEM_TOKEN', captureUncaught: true, captureUnhandledRejections: true, autoInstrument: { log: false }, }; export const RollbarService = new InjectionToken<Rollbar>('rollbar'); @Injectable() export class RollbarErrorHandler implements ErrorHandler { constructor(@Inject(RollbarService) private rollbar: Rollbar) {} handleError(err:any) : void { this.rollbar.error(err.originalError || err); } } export function rollbarFactory() { return new Rollbar(rollbarConfig); }

¿Cómo habilitar solo el registro de errores si está en un entorno de producción? El uso de la clase angular ErrorHandler en un entorno local parece resolver mi problema. ¿Cómo puedo hacer esto?

Ejemplo:

 if (!environment.production) { return new ErrorHandler() }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!