0

I installed Sentry on my Angular application by following their tutorial, given that parts of it are outdated so I kept fixing them up in my code and ended up with this:

        // My module.ts

        // modules
        import { NgModule, Injector, ErrorHandler } from '@angular/core';
        import { CommonModule } from '@angular/common';
        import { FormsModule, ReactiveFormsModule } from '@angular/forms';
        import { HttpModule } from '@angular/http';
        import { RouterModule, Routes } from '@angular/router';
        import { HttpClientModule } from '@angular/common/http';

        // import Raven from 'raven-js/src/raven';
        import * as Raven from 'raven-js';

        Raven.config('https://mypublicDSN@sentry.io/omitted').install();

        class RavenExceptionHandler {
            call(err:any) {
              Raven.captureException(err.originalException);
            }
        }

        // components
        import { MyComponent } from './components/my.component';

        // services
        import { ApiService } from './services/api';

        // configuration
        import { environment } from 'environments/environment';

        // instance
        @NgModule({
            providers: [
                ApiService,
                { 
                    provide: ErrorHandler, 
                    useClass: RavenExceptionHandler 
                }
            ],
            declarations: [
                MyComponent,
            ],
            imports: [
                CommonModule,
                FormsModule,
                ReactiveFormsModule,
                HttpModule,
                HttpClientModule,

                // material design components:
                MatButtonModule,
                MatCardModule,
                MatCheckboxModule,
                MatChipsModule,
                MatDatepickerModule,
                MatDialogModule,
                MatExpansionModule,
                MatFormFieldModule,
                MatGridListModule,
                MatIconModule,
                MatInputModule,
                MatListModule,
                MatNativeDateModule,
                MatProgressBarModule,
                MatRadioModule,
                MatSelectModule,
                MatSidenavModule,
                MatSlideToggleModule,
                MatStepperModule,
                MatTableModule,
                MatToolbarModule,
                MatTooltipModule,
            ],
            exports: [
                MyComponent,
            ],
        })
        export class MyModule {
            constructor(private injector: Injector) { }
        }

I imported Raven, configured it with my public DSN, initalised the RavenExceptionHandler, imported ErrorHandler and added the provider that uses both handlers.

Now that's setup I went to my component and did threw an error in the constructor:

        // my.component.ts
        import { Component, Input, ElementRef, ViewChild } from '@angular/core';
        import { CommonModule } from '@angular/common';
        import { DataService } from './data.service';

        @Component({
            selector: 'my-selector',
            templateUrl: './my-selector.template.html',
            styleUrls: ['./my-selector.styles.css']
        })
        export class DataPrepComponent {
            @Input() public projectId: string;
            @Input() public documentId: string;

            constructor(public dataService: DataService) {
                console.log("Throwing error");
                throw new Error('Throwing error for Sentry');
            }

        }

I can see the errors coming up on my log but I can't see anything logged in my Sentry dashboard:

enter image description here enter image description here

I am running this on my localhost. but I couldn't find any documentation that would say that this prevents the logs from coming up, and I also am allowing any domain to send logs: enter image description here

What am I doing wrong or not doing?

Naguib Ihab
  • 4,259
  • 7
  • 44
  • 80
  • Thanks for the comment @Ginkoid. The filter is unchecked but there are no requests going out to sentry.io that I can see in the network tab. Could there be something wrong with the configuration itself? – Naguib Ihab Feb 11 '18 at 23:45
  • @NaguibIhab I'm having the same issue, now in 2019 :) Have you found a solution? – Demven Weir Jan 14 '19 at 05:12
  • @DemvenWeir sorry I can't remember, but I probably didn't find a solution since I didn't add an answer here – Naguib Ihab Jan 14 '19 at 22:42

1 Answers1

0

Sentry has a new SDK for angular apps.

You can find your app dsn link by searching for "Client Keys DSN" on sentry.io navbar search input.

golfadas
  • 5,351
  • 3
  • 32
  • 39