0

I am Working on angular 4 project using angular-cli 1.2.6, So here I want to use Raygun in my application for error logging. I could not able to find any documentation on installing for angular-cli projects as angular 4 does not a system.config.js.

Can someone guide me on Raygun integration on angular 4 apps?

Aakash N
  • 61
  • 1
  • 7

2 Answers2

0

you have to install this library : https://github.com/LiberisLabs/raygun-angular2 . angular4 uses webpack.

sancelot
  • 1,905
  • 12
  • 31
0

run npm install raygun4js --save

then create app.raygun.setup.ts file

import * as rg4js from 'raygun4js';
import { ErrorHandler } from '@angular/core';
const VERSION_NUMBER = '1.0.0.0';
rg4js('apiKey', 'Your_API_Key');
rg4js('setVersion', VERSION_NUMBER);
rg4js('enableCrashReporting', true);
export class RaygunErrorHandler implements ErrorHandler {
  handleError(e: any) {
    rg4js('send', {
      error: e,
    });
  }
}

include raygun dependencies in app.module.ts

@NgModule({
  imports: [...],
  declarations: [...],
  providers: [{...}, { 
    provide: ErrorHandler, 
    useClass: RaygunErrorHandler 
  }],
Aakash N
  • 61
  • 1
  • 7