Skip to content

Commit

Permalink
Merge pull request #53 from MindscapeHQ/version-2.0.0
Browse files Browse the repository at this point in the history
Version 2.0.0
  • Loading branch information
redJ4y authored Sep 24, 2023
2 parents 0ab094c + a794412 commit d39844f
Show file tree
Hide file tree
Showing 12 changed files with 17,079 additions and 13,963 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ jobs:

# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- env: EMBER_TRY_SCENARIO=ember-lts-3.12
- env: EMBER_TRY_SCENARIO=ember-lts-3.16
- env: EMBER_TRY_SCENARIO=ember-lts-3.20
- env: EMBER_TRY_SCENARIO=ember-lts-4.4.5
- env: EMBER_TRY_SCENARIO=ember-lts-4.8.6
- env: EMBER_TRY_SCENARIO=ember-lts-4.12.3
- env: EMBER_TRY_SCENARIO=ember-release
- env: EMBER_TRY_SCENARIO=ember-beta
- env: EMBER_TRY_SCENARIO=ember-canary
Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@

This addon will allow you to report errors to [Raygun](https://raygun.com) from your Ember CLI app using [raygun4js](https://github.com/MindscapeHQ/raygun4js).

# Legacy Provider Notice

There is a known issue that prevents this provider from working with Ember.js versions greater than 3.1, see [deprecation of Ember.Logger](https://rfcs.emberjs.com/id/0297-deprecate-ember-logger).

An update is planned. In the meantime, a workaround can be made by adding a `Logger` object back into Ember which delegates to the equivalent `console` methods.

:heart: Please [open an issue](https://github.com/MindscapeHQ/ember-cli-raygun/issues/new) if you run into any troubles, thanks for testing!
:heart: Please [open an issue](https://github.com/MindscapeHQ/ember-cli-raygun/issues/new) if you run into any troubles!

---

Expand Down Expand Up @@ -130,7 +124,7 @@ For your contributions on the previous version of this addon :)
Pull requests are welcome!
* `git clone` this repository
* `yarn install`
* `npm install`
## Running tests
Expand Down
5 changes: 2 additions & 3 deletions addon/instance-initializers/raygun.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import RSVP from 'rsvp';
import { getOwnConfig } from '@embroider/macros';
import Ember from 'ember';

export function initialize(applicationInstance) {
const raygunConfig = getOwnConfig().raygunConfig;
Expand All @@ -26,8 +25,8 @@ export function initialize(applicationInstance) {
});
});

const existingOnError = Ember.onerror;
Ember.onerror = function (error) {
const existingOnError = applicationInstance.onerror;
applicationInstance.onerror = function (error) {
if (existingOnError) existingOnError(error);
raygunService.send(error);
};
Expand Down
62 changes: 51 additions & 11 deletions addon/services/raygun.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import Service from '@ember/service';

export default class RaygunService extends Service {

_isRaygunAvailable() {
return typeof rg4js === 'function';
}

init() {
super.init(...arguments);
if (typeof rg4js !== "function") {
console.warn("ember-cli-raygun: Unable to see raygun4js - has the bootstrap script been correctly injected into your <head> section? Check your CSP too!")
return
if (!this._isRaygunAvailable()) {
console.warn("ember-cli-raygun: Unable to see rg4js - has the bootstrap script been correctly injected into your <head> section? Check your CSP too!");
return;
}
}

Expand All @@ -16,28 +20,64 @@ export default class RaygunService extends Service {
}

set apiKey(newKey) {
this._apiKey = newKey;
rg4js('apiKey', newKey)
if (this._isRaygunAvailable()) {
this._apiKey = newKey;
rg4js('apiKey', newKey);
} else {
console.warn("ember-cli-raygun: Unable to set apiKey, rg4js is not available.");
}
}

get enableCrashReporting() {
return this._enableCrashReporting;
}

set enableCrashReporting(value) {
rg4js('enableCrashReporting', value)
if (this._isRaygunAvailable()) {
this._enableCrashReporting = value;
rg4js('enableCrashReporting', value);
} else {
console.warn("ember-cli-raygun: Unable to enable crash reporting, rg4js is not available.");
}
}

get enablePulse() {
return this._enablePulse;
}

set enablePulse(value) {
rg4js('enablePulse', value)
if (this._isRaygunAvailable()) {
this._enablePulse = value;
rg4js('enablePulse', value);
} else {
console.warn("ember-cli-raygun: Unable to enable Pulse, rg4js is not available.");
}
}

send() {
return rg4js('send', ...arguments);
if (this._isRaygunAvailable()) {
return rg4js('send', ...arguments);
} else {
console.warn("ember-cli-raygun: Unable to send data, rg4js is not available.");
return null;
}
}

setUser() {
return rg4js('setUser', ...arguments);
if (this._isRaygunAvailable()) {
return rg4js('setUser', ...arguments);
} else {
console.warn("ember-cli-raygun: Unable to set user, rg4js is not available.");
return null;
}
}

trackEvent() {
return rg4js('trackEvent', ...arguments);
if (this._isRaygunAvailable()) {
return rg4js('trackEvent', ...arguments);
} else {
console.warn("ember-cli-raygun: Unable to track event, rg4js is not available.");
return null;
}
}

}
14 changes: 7 additions & 7 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@

const getChannelURL = require('ember-source-channel-url');

module.exports = async function() {
module.exports = async function () {
return {
scenarios: [
{
name: 'ember-lts-3.12',
name: 'ember-lts-4.4.5',
npm: {
devDependencies: {
'ember-source': '~3.12.0'
'ember-source': '~4.4.5'
}
}
},
{
name: 'ember-lts-3.16',
name: 'ember-lts-4.8.6',
npm: {
devDependencies: {
'ember-source': '~3.16.0'
'ember-source': '~4.8.6'
}
}
},
{
name: 'ember-lts-3.20',
name: 'ember-lts-4.12.3',
npm: {
devDependencies: {
'ember-source': '~3.20.5'
'ember-source': '~4.12.3'
}
}
},
Expand Down
Loading

0 comments on commit d39844f

Please sign in to comment.