ember-cli-raygun

A Raygun.com integration add on for Ember CLI

Usage no npm install needed!

<script type="module">
  import emberCliRaygun from 'https://cdn.skypack.dev/ember-cli-raygun';
</script>

README

Ember CLI Raygun

Build Status Ember Observer Score

This addon will allow you to report errors to Raygun from your Ember CLI app using raygun4js

Ember Octane Upgrade

This Add-On has recently been rewritten in order to be compatible with the latest Ember versions.

The most recent stable version is 1.3.0, and you can see the previous code in the pre-octane branch

:heart: Please open an issue if you run into any troubles, thanks for testing!

Installation

It's as easy as:

$ ember install ember-cli-raygun

Optionally you can pass your Raygun API Key:

$ ember install ember-cli-raygun --api_key='YOUR-RAYGUN-API-KEY'

Otherwise, you’ll need to set your Raygun API Key (available under "Application Settings" in your Raygun Account) in config/environment.js

// config/environment.js
var ENV = {
  // ...
  raygun: {
    apiKey:  "YOUR-RAYGUN-API-KEY",
    enableCrashReporting: (environment === "production")
  }
  // ...

The default blueprint (which runs during ember install ember-cli-raygun) will add the above config in your app's config/environment.js file.

Congratulations! You can now track and fix your errors once you deploy your app. (By default Ember CLI Raygun is disabled unless your environment is set to "production" - you can configure that behaviour in config/environment.js)

CORS

ember-cli-raygun will automatically inject the raygun4js bootstrap script into the head of your Ember app. This is the most reliable way to catch errors (even during app initialization).

If you’re using CORS without unsafe-inline, you’ll need to add the following directives to ensure rg4js and Raygun load correctly:

  • script-src

    • 'sha256-kOJzCjwwBHVC6EAEX5M+ovfu9sE7JG0G9LcYssttn6I='
    • 'http://cdn.raygun.io'
  • connect-src

Accessing Raygun

Functions you might need on rg4js are exposed as an Ember Service, for instance tracking custom events:

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class IndexRoute extends Route {
  @service raygun;

  beforeModel() {
    this.get('raygun').trackEvent({
      type: 'customTiming',
      name: 'IndexRouteBeforeModel',
      duration: 1200
    })
  }

}

Affected User Tracking

Check out the Affected User Tracking section in the raygun4js documentation for full details.

You potentially want something like the following in your application route:

// app/routes/application.js
// ...

  @service user;
  @service raygun;

  beforeModel: () {
    this.setRaygunUser();
  },

  setRaygunUser: () {
    this.get("raygun").setUser({
      identifier: this.get("user.id"),
      isAnonymous: false,
      email: this.get("user.email"),
      firstName: this.get("user.firstName"),
      fullName: this.get("user.fullName")
    });    
  },
// ...

Thanks! :heart:

Thanks to:

For your contributions on the previous version of this addon :)

Contributing

Pull requests are welcome!

  • git clone this repository
  • yarn install

Running tests

  • ember test OR
  • ember test --server

There’s a detailed test harness in the dummy app so please check that your changes work end-to-end by running that.