-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Add @sentry/ember #2739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add @sentry/ember #2739
Changes from all commits
9c0e75a
b8948b0
0254fb1
e838aec
36ddff7
0fb3711
a5bfa53
20466eb
4c22bc0
6e489e3
4a03dc5
7441988
f0779dd
55f35fe
2b7134d
98aaecb
6adacee
fcd2391
2b50a53
db0354f
adba304
06a1e8f
967c60e
29c8ea5
7e8a175
565189f
3984198
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
/** | ||
Ember CLI sends analytics information by default. The data is completely | ||
anonymous, but there are times when you might want to disable this behavior. | ||
|
||
Setting `disableAnalytics` to true will prevent any data from being sent. | ||
*/ | ||
"disableAnalytics": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# unconventional js | ||
/blueprints/*/files/ | ||
/vendor/ | ||
|
||
# compiled output | ||
/dist/ | ||
/tmp/ | ||
|
||
# dependencies | ||
/bower_components/ | ||
/node_modules/ | ||
|
||
# misc | ||
/coverage/ | ||
!.* | ||
|
||
# ember-try | ||
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/package.json.ember-try |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
root: true, | ||
parser: 'babel-eslint', | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
legacyDecorators: true | ||
} | ||
}, | ||
plugins: [ | ||
'ember' | ||
], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:ember/recommended' | ||
], | ||
env: { | ||
browser: true | ||
}, | ||
globals: { | ||
"QUnit": true | ||
}, | ||
rules: {}, | ||
overrides: [ | ||
// node files | ||
{ | ||
files: [ | ||
'.eslintrc.js', | ||
'.template-lintrc.js', | ||
'ember-cli-build.js', | ||
'index.js', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait why the eslint config? is it just autogenerated? I know tslint sucks, and we are looking to update to eslint soon. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of this is auto-generated for Ember addons, it's IMO best to leave addon settings as they are all built the same, which encourages community support. Upgrading for changes to ts/es linting rules in the future is simpler too as there are usually simple migration paths for most things if you follow Ember conventions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha lets keep it then. |
||
'testem.js', | ||
'blueprints/*/index.js', | ||
'config/**/*.js', | ||
'tests/dummy/config/**/*.js' | ||
], | ||
excludedFiles: [ | ||
'addon/**', | ||
'addon-test-support/**', | ||
'app/**', | ||
'tests/dummy/app/**' | ||
], | ||
parserOptions: { | ||
sourceType: 'script' | ||
}, | ||
env: { | ||
browser: false, | ||
node: true | ||
}, | ||
plugins: ['node'], | ||
extends: ['plugin:node/recommended'] | ||
} | ||
] | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# compiled output | ||
/dist/ | ||
/tmp/ | ||
|
||
# dependencies | ||
/bower_components/ | ||
/node_modules/ | ||
|
||
# misc | ||
/.env* | ||
/.pnp* | ||
/.sass-cache | ||
/connect.lock | ||
/coverage/ | ||
/libpeerconnection.log | ||
/npm-debug.log* | ||
/testem.log | ||
/yarn-error.log | ||
|
||
# ember-try | ||
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/package.json.ember-try |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# compiled output | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kind of nitpicking but all our other
which is far easier to understand and also less error prone. So instead of adding everything and ignoring specific things, we do the opposite of, first ignore everything and then we pick what we actually want. I guess this is some kind of ember boilerplate, but are we may be able to come up with something similar? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No problem, I don't mind going through the effort of changing it, but the npmignore is generated by the blueprint for Ember addons, which gets updated if the file layout ever changes (which it might soon enough). Every other Ember addon uses the same .npmignore. If any updates to the file structure happen we can simply just run the blueprint command again and use the new npmignore without having to go in to determine which of the files may or may not be used by the addon ecosystem in some way. tldr; leaving as is is more maintainable, as the file structure for Ember addons is convention based. |
||
/dist/ | ||
/tmp/ | ||
|
||
# dependencies | ||
/bower_components/ | ||
|
||
# misc | ||
/.bowerrc | ||
/.editorconfig | ||
/.ember-cli | ||
/.env* | ||
/.eslintignore | ||
/.eslintrc.js | ||
/.git/ | ||
/.gitignore | ||
/.template-lintrc.js | ||
/.travis.yml | ||
/.watchmanconfig | ||
/bower.json | ||
/config/ember-try.js | ||
/CONTRIBUTING.md | ||
/ember-cli-build.js | ||
/testem.js | ||
/tests/ | ||
/yarn.lock | ||
.gitkeep | ||
|
||
# ember-try | ||
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/package.json.ember-try |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
extends: 'octane' | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"ignore_dirs": ["tmp", "dist"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2020, Sentry | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<p align="center"> | ||
<a href="https://sentry.io" target="_blank" align="center"> | ||
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280"> | ||
</a> | ||
<br /> | ||
</p> | ||
|
||
# Official Sentry SDK for Ember.js | ||
|
||
## Links | ||
|
||
- [Official SDK Docs](https://docs.sentry.io/quickstart/) | ||
- [TypeDoc](http://getsentry.github.io/sentry-javascript/) | ||
|
||
## General | ||
|
||
This package is an Ember addon that wraps `@sentry/browser`, with added functionality related to Ember. All methods available in | ||
`@sentry/browser` can be imported from `@sentry/ember`. | ||
|
||
### Installation | ||
|
||
As with other Ember addons, run: | ||
`ember install @sentry/ember` | ||
|
||
Then add the following config to `config/environment.js` | ||
AbhiPrasad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```javascript | ||
ENV['@sentry/ember'] = { | ||
sentry: { | ||
dsn: '__DSN__' // replace __DSN__ with your DSN | ||
} | ||
}; | ||
``` | ||
|
||
### Usage | ||
|
||
To use this SDK, call `InitSentryForEmber` before the application is initialized, in `app.js`. This will load Sentry config from `environment.js` for you. | ||
|
||
```javascript | ||
import Application from '@ember/application'; | ||
import Resolver from 'ember-resolver'; | ||
import loadInitializers from 'ember-load-initializers'; | ||
import config from './config/environment'; | ||
import { InitSentryForEmber } from '@sentry/ember'; | ||
|
||
InitSentryForEmber(); | ||
|
||
export default class App extends Application { | ||
modulePrefix = config.modulePrefix; | ||
podModulePrefix = config.podModulePrefix; | ||
Resolver = Resolver; | ||
} | ||
``` | ||
|
||
### Additional Configuration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we mention something here about our existing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it be here in additional configuration or above under general? |
||
|
||
Aside from configuration passed from this addon into `@sentry/browser` via the `sentry` property, there is also the following Ember specific configuration. | ||
|
||
```javascript | ||
ENV['@sentry/ember'] = { | ||
ignoreEmberOnErrorWarning: false, // Will silence Ember.onError warning without the need of using Ember debugging tools. False by default. | ||
sentry: ... // See sentry-javascript configuration https://docs.sentry.io/error-reporting/configuration/?platform=javascript | ||
}; | ||
``` | ||
|
||
### Supported Versions | ||
|
||
`@sentry/ember` currently supports Ember **3.8+** for error monitoring. | ||
|
||
### Previous Integration | ||
|
||
Previously we've recommended using the Ember integration from `@sentry/integrations` but moving forward we will be using | ||
this Ember addon to offer more Ember-specific error and performancing monitoring. | ||
|
||
## Testing | ||
|
||
You can find example instrumentation in the `dummy` application, which is also used for testing. To test with the dummy | ||
application, you must pass the dsn as an environment variable. | ||
|
||
```javascript | ||
SENTRY_DSN=__DSN__ ember serve | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare module 'ember-get-config' { | ||
export default object; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
import { addGlobalEventProcessor, SDK_VERSION, BrowserOptions } from '@sentry/browser'; | ||
import environmentConfig from 'ember-get-config'; | ||
|
||
import { next } from '@ember/runloop'; | ||
import { assert, warn, runInDebug } from '@ember/debug'; | ||
import Ember from 'ember'; | ||
|
||
export function InitSentryForEmber(_runtimeConfig: BrowserOptions | undefined) { | ||
const config = environmentConfig['@sentry/ember']; | ||
assert('Missing configuration', config); | ||
assert('Missing configuration for Sentry.', config.sentry); | ||
|
||
const initConfig = Object.assign({}, config.sentry, _runtimeConfig || {}); | ||
|
||
createEmberEventProcessor(); | ||
|
||
Sentry.init(initConfig); | ||
|
||
runInDebug(() => { | ||
if (config.ignoreEmberOnErrorWarning) { | ||
return; | ||
} | ||
next(null, function () { | ||
warn( | ||
'Ember.onerror found. Using Ember.onerror can hide some errors (such as flushed runloop errors) from Sentry. Use Sentry.captureException to capture errors within Ember.onError or remove it to have errors caught by Sentry directly. This error can be silenced via addon configuration.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. So we ask users to instrument There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not quite, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I misunderstood, that makes much more sense. Cool 👍 |
||
!Ember.onerror, | ||
{ | ||
id: '@sentry/ember.ember-onerror-detected', | ||
}, | ||
); | ||
}); | ||
}); | ||
} | ||
|
||
function createEmberEventProcessor(): void { | ||
AbhiPrasad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (addGlobalEventProcessor) { | ||
addGlobalEventProcessor((event) => { | ||
event.sdk = { | ||
...event.sdk, | ||
name: 'sentry.javascript.ember', | ||
packages: [ | ||
...((event.sdk && event.sdk.packages) || []), | ||
{ | ||
name: 'npm:@sentry/ember', | ||
version: SDK_VERSION, | ||
}, | ||
], | ||
version: SDK_VERSION, | ||
}; | ||
|
||
return event; | ||
}); | ||
} | ||
} | ||
|
||
export * from '@sentry/browser'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool TIL. Maybe we should do something similar for
sentry-cli
@kamilogorek (unless this already exists).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't send any analytics in sentry-cli afaik?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore my previous comment then 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last I remember it uses
leek
to send build metrics to GA. It lets the Ember team know how addons and apps are being built and issues with the pipeline so they can design against actual usage vs. theoretical.