Skip to content

Commit 9428c9a

Browse files
authored
feat: Add @sentry/ember (#2739)
This will add the `@sentry/ember` package. This will provide an Ember addon that fits into the Ember ecosystem and will in the future offer custom framework specific functionality.
1 parent 18db201 commit 9428c9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1245
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
6+
- [ember] feat: Add `@sentry/ember` (#2739)
67

78
## 5.20.1
89

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"packages/apm",
2323
"packages/browser",
2424
"packages/core",
25+
"packages/ember",
2526
"packages/gatsby",
2627
"packages/hub",
2728
"packages/integrations",

packages/ember/.ember-cli

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
/**
3+
Ember CLI sends analytics information by default. The data is completely
4+
anonymous, but there are times when you might want to disable this behavior.
5+
6+
Setting `disableAnalytics` to true will prevent any data from being sent.
7+
*/
8+
"disableAnalytics": false
9+
}

packages/ember/.eslintignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# unconventional js
2+
/blueprints/*/files/
3+
/vendor/
4+
5+
# compiled output
6+
/dist/
7+
/tmp/
8+
9+
# dependencies
10+
/bower_components/
11+
/node_modules/
12+
13+
# misc
14+
/coverage/
15+
!.*
16+
17+
# ember-try
18+
/.node_modules.ember-try/
19+
/bower.json.ember-try
20+
/package.json.ember-try

packages/ember/.eslintrc.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
'use strict';
2+
3+
module.exports = {
4+
root: true,
5+
parser: 'babel-eslint',
6+
parserOptions: {
7+
ecmaVersion: 2018,
8+
sourceType: 'module',
9+
ecmaFeatures: {
10+
legacyDecorators: true
11+
}
12+
},
13+
plugins: [
14+
'ember'
15+
],
16+
extends: [
17+
'eslint:recommended',
18+
'plugin:ember/recommended'
19+
],
20+
env: {
21+
browser: true
22+
},
23+
globals: {
24+
"QUnit": true
25+
},
26+
rules: {},
27+
overrides: [
28+
// node files
29+
{
30+
files: [
31+
'.eslintrc.js',
32+
'.template-lintrc.js',
33+
'ember-cli-build.js',
34+
'index.js',
35+
'testem.js',
36+
'blueprints/*/index.js',
37+
'config/**/*.js',
38+
'tests/dummy/config/**/*.js'
39+
],
40+
excludedFiles: [
41+
'addon/**',
42+
'addon-test-support/**',
43+
'app/**',
44+
'tests/dummy/app/**'
45+
],
46+
parserOptions: {
47+
sourceType: 'script'
48+
},
49+
env: {
50+
browser: false,
51+
node: true
52+
},
53+
plugins: ['node'],
54+
extends: ['plugin:node/recommended']
55+
}
56+
]
57+
};

packages/ember/.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist/
5+
/tmp/
6+
7+
# dependencies
8+
/bower_components/
9+
/node_modules/
10+
11+
# misc
12+
/.env*
13+
/.pnp*
14+
/.sass-cache
15+
/connect.lock
16+
/coverage/
17+
/libpeerconnection.log
18+
/npm-debug.log*
19+
/testem.log
20+
/yarn-error.log
21+
22+
# ember-try
23+
/.node_modules.ember-try/
24+
/bower.json.ember-try
25+
/package.json.ember-try

packages/ember/.npmignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# compiled output
2+
/dist/
3+
/tmp/
4+
5+
# dependencies
6+
/bower_components/
7+
8+
# misc
9+
/.bowerrc
10+
/.editorconfig
11+
/.ember-cli
12+
/.env*
13+
/.eslintignore
14+
/.eslintrc.js
15+
/.git/
16+
/.gitignore
17+
/.template-lintrc.js
18+
/.travis.yml
19+
/.watchmanconfig
20+
/bower.json
21+
/config/ember-try.js
22+
/CONTRIBUTING.md
23+
/ember-cli-build.js
24+
/testem.js
25+
/tests/
26+
/yarn.lock
27+
.gitkeep
28+
29+
# ember-try
30+
/.node_modules.ember-try/
31+
/bower.json.ember-try
32+
/package.json.ember-try

packages/ember/.template-lintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = {
4+
extends: 'octane'
5+
};

packages/ember/.watchmanconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ignore_dirs": ["tmp", "dist"]
3+
}

packages/ember/LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020, Sentry
4+
5+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
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.

packages/ember/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<p align="center">
2+
<a href="https://sentry.io" target="_blank" align="center">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
4+
</a>
5+
<br />
6+
</p>
7+
8+
# Official Sentry SDK for Ember.js
9+
10+
## Links
11+
12+
- [Official SDK Docs](https://docs.sentry.io/quickstart/)
13+
- [TypeDoc](http://getsentry.github.io/sentry-javascript/)
14+
15+
## General
16+
17+
This package is an Ember addon that wraps `@sentry/browser`, with added functionality related to Ember. All methods available in
18+
`@sentry/browser` can be imported from `@sentry/ember`.
19+
20+
### Installation
21+
22+
As with other Ember addons, run:
23+
`ember install @sentry/ember`
24+
25+
Then add the following config to `config/environment.js`
26+
27+
```javascript
28+
ENV['@sentry/ember'] = {
29+
sentry: {
30+
dsn: '__DSN__' // replace __DSN__ with your DSN
31+
}
32+
};
33+
```
34+
35+
### Usage
36+
37+
To use this SDK, call `InitSentryForEmber` before the application is initialized, in `app.js`. This will load Sentry config from `environment.js` for you.
38+
39+
```javascript
40+
import Application from '@ember/application';
41+
import Resolver from 'ember-resolver';
42+
import loadInitializers from 'ember-load-initializers';
43+
import config from './config/environment';
44+
import { InitSentryForEmber } from '@sentry/ember';
45+
46+
InitSentryForEmber();
47+
48+
export default class App extends Application {
49+
modulePrefix = config.modulePrefix;
50+
podModulePrefix = config.podModulePrefix;
51+
Resolver = Resolver;
52+
}
53+
```
54+
55+
### Additional Configuration
56+
57+
Aside from configuration passed from this addon into `@sentry/browser` via the `sentry` property, there is also the following Ember specific configuration.
58+
59+
```javascript
60+
ENV['@sentry/ember'] = {
61+
ignoreEmberOnErrorWarning: false, // Will silence Ember.onError warning without the need of using Ember debugging tools. False by default.
62+
sentry: ... // See sentry-javascript configuration https://docs.sentry.io/error-reporting/configuration/?platform=javascript
63+
};
64+
```
65+
66+
### Supported Versions
67+
68+
`@sentry/ember` currently supports Ember **3.8+** for error monitoring.
69+
70+
### Previous Integration
71+
72+
Previously we've recommended using the Ember integration from `@sentry/integrations` but moving forward we will be using
73+
this Ember addon to offer more Ember-specific error and performancing monitoring.
74+
75+
## Testing
76+
77+
You can find example instrumentation in the `dummy` application, which is also used for testing. To test with the dummy
78+
application, you must pass the dsn as an environment variable.
79+
80+
```javascript
81+
SENTRY_DSN=__DSN__ ember serve
82+
```

packages/ember/addon/.gitkeep

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'ember-get-config' {
2+
export default object;
3+
}

packages/ember/addon/index.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import * as Sentry from '@sentry/browser';
2+
import { addGlobalEventProcessor, SDK_VERSION, BrowserOptions } from '@sentry/browser';
3+
import environmentConfig from 'ember-get-config';
4+
5+
import { next } from '@ember/runloop';
6+
import { assert, warn, runInDebug } from '@ember/debug';
7+
import Ember from 'ember';
8+
9+
export function InitSentryForEmber(_runtimeConfig: BrowserOptions | undefined) {
10+
const config = environmentConfig['@sentry/ember'];
11+
assert('Missing configuration', config);
12+
assert('Missing configuration for Sentry.', config.sentry);
13+
14+
const initConfig = Object.assign({}, config.sentry, _runtimeConfig || {});
15+
16+
createEmberEventProcessor();
17+
18+
Sentry.init(initConfig);
19+
20+
runInDebug(() => {
21+
if (config.ignoreEmberOnErrorWarning) {
22+
return;
23+
}
24+
next(null, function () {
25+
warn(
26+
'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.',
27+
!Ember.onerror,
28+
{
29+
id: '@sentry/ember.ember-onerror-detected',
30+
},
31+
);
32+
});
33+
});
34+
}
35+
36+
function createEmberEventProcessor(): void {
37+
if (addGlobalEventProcessor) {
38+
addGlobalEventProcessor((event) => {
39+
event.sdk = {
40+
...event.sdk,
41+
name: 'sentry.javascript.ember',
42+
packages: [
43+
...((event.sdk && event.sdk.packages) || []),
44+
{
45+
name: 'npm:@sentry/ember',
46+
version: SDK_VERSION,
47+
},
48+
],
49+
version: SDK_VERSION,
50+
};
51+
52+
return event;
53+
});
54+
}
55+
}
56+
57+
export * from '@sentry/browser';

0 commit comments

Comments
 (0)