Skip to content

[Angular] Init of rg4js doesn't work correctly if it's in constructor #383

@DownloadHelper

Description

@DownloadHelper

Hi !

The standard init of rg4js for Angular ErrorHandler working good :

import * as rg4js from 'raygun4js';
import { ErrorHandler } from '@angular/core';

const VERSION_NUMBER = '1.0.0.0';
rg4js('apiKey', "apiKey");
rg4js('setVersion', VERSION_NUMBER);
rg4js('enableCrashReporting', true);
export class RaygunErrorHandler implements ErrorHandler {
  handleError(e: any) {
    rg4js('send', {
      error: e,
    });
  }
}

But that doesn't work correctly if we move the init into a constructor :

import * as rg4js from 'raygun4js';
import { ErrorHandler } from '@angular/core';

export class RaygunErrorHandler implements ErrorHandler {

  constructor() {
    const VERSION_NUMBER = '1.0.0.0';
    rg4js('apiKey', "apiKey");
    rg4js('setVersion', VERSION_NUMBER);
    rg4js('enableCrashReporting', true);
  }

  handleError(e: any) {
    rg4js('send', {
      error: e,
    });
  }
}

Do you have an idea? I would need this to get my configuration and my apiKey from an Angular service.

Thank you !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions