question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sentry on Angular working in localhost (serve) but not on a server (build)

See original GitHub issue

I’m trying to work with Sentry for Angular 8.

it’s working great and capturing the error events when served in localhost, but not on a build on the server.

Would love any help to understand why/what’s the difference I’m missing ?

//app.module.ts
Sentry.init({
    integrations: [new Sentry.Integrations.Breadcrumbs({
        console: false
    })],
  dsn: "https://somecode@o386725.ingest.sentry.io/sometoken"
});

@Injectable()
export class SentryErrorHandler implements ErrorHandler {
  constructor() {}
  handleError(error) {
    const eventId = Sentry.captureException(error.originalError || error);
    Sentry.showReportDialog({ eventId });
  }
}
//later added to providers
{ provide: ErrorHandler, useClass: SentryErrorHandler }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
khanyuriycommented, Jun 5, 2020

Ok, that was my fault.

Sentry.init() was called in separate file, that contained only const provider declaration, although it was imported and used in app.module . It seems that it was a victim of angular tree shaking.

Moving Sentry.init(…) to a file with injectable service (SentryErrorHandler) declaration, as in Sentry angular integration docs, fixed an issue.

0reactions
AbhiPrasadcommented, Sep 30, 2021

Closing this issue for repo cleanup, but if you are still encountering this issue, please let us know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sentry on Angular working in localhost (serve) but not on a ...
I'm trying to work with Sentry for Angular 8. it's working great and capturing the error events when served in localhost, but not...
Read more >
Troubleshooting for Angular
Cross-Origin Resource Sharing (CORS) is a set of APIs (mostly HTTP headers) that dictate how files ought to be downloaded and served across...
Read more >
Angular with Sentry — A Step-by-Step Guide
When you create a production build, source maps are not generated for you. This means, you WILL NOT see original files associated with...
Read more >
Configuration
This document describes configuration available to the Sentry server itself. First Install During a new install, Sentry prompts first for a walkthrough of ......
Read more >
Application Monitoring and Error Tracking - Sentry - YouTube
Will Capozzoli (Solutions Engineer at Sentry ) walks you through how to get the most out of Sentry application monitoring and error tracking ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found