<commit_before>import Ember  from 'ember';
import config from '../config/environment';
import { getContext, generateError } from 'ember-cli-bugsnag/utils/errors';

var currentEnv = config.environment;

export default {
  name: 'bugsnag-error-service',

  initialize: function(container) {
    if (typeof Bugsnag === 'undefined') { return; }

    if (currentEnv !== 'test' && Bugsnag.notifyReleaseStages.indexOf(currentEnv) !== -1) {
      Ember.onerror = function (error) {
        Bugsnag.context = getContext(container.lookup('router:main'));
        Bugsnag.notifyException(error);
        console.error(error.stack);
      };

      Ember.RSVP.on('error', function(error) {
        Bugsnag.context = getContext(container.lookup('router:main'));
        Bugsnag.notifyException(error);
        console.error(error.stack);
      });

      Ember.Logger.error = function (message, cause, stack) {
        Bugsnag.context = getContext(container.lookup('router:main'));
        Bugsnag.notifyException(generateError(cause, stack), message);
        console.error(stack);
      };<commit_msg>Refresh Bugsnag's rate limit on each transition<commit_after>import Ember  from 'ember';
import config from '../config/environment';
import { getContext, generateError } from 'ember-cli-bugsnag/utils/errors';

var currentEnv = config.environment;

export default {
  name: 'bugsnag-error-service',

  initialize: function(container) {
    if (typeof Bugsnag === 'undefined') { return; }

    if (currentEnv !== 'test' && Bugsnag.notifyReleaseStages.indexOf(currentEnv) !== -1) {
      Ember.onerror = function (error) {
        Bugsnag.context = getContext(container.lookup('router:main'));
        Bugsnag.notifyException(error);
        console.error(error.stack);
      };

      Ember.RSVP.on('error', function(error) {
        Bugsnag.context = getContext(container.lookup('router:main'));
        Bugsnag.notifyException(error);
        console.error(error.stack);
      });

      Ember.Logger.error = function (message, cause, stack) {
        Bugsnag.context = getContext(container.lookup('router:main'));
        Bugsnag.notifyException(generateError(cause, stack), message);
        console.error(stack);
      };

      const router = container.lookup('router:main');
      const originalDidTransition = router.didTransition || Ember.K;
      router.didTransition = function() {
        Bugsnag.refresh();
        return originalDidTransition.apply(this, arguments);
      };
{'fraction_non_alphanumeric': 0.13928138877674606, 'fraction_numerical': 0.0008074283407347598, 'mean_word_length': 3.5136612021857925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6785361', 'n_tokens_mistral': 712, 'n_tokens_neox': 699, 'n_words': 131}