Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9c0e75a
[WIP] feat: Add @sentry/ember
k-fish Jul 13, 2020
b8948b0
Fix license to be MIT
k-fish Jul 14, 2020
0254fb1
Remove side-effect and only create the Ember event processor when Sen…
k-fish Jul 14, 2020
e838aec
Add acceptance tests that assert calls to Sentry are being made
k-fish Jul 20, 2020
36ddff7
Add warning for onerror to explain how it interacts with Sentry errors
k-fish Jul 20, 2020
0fb3711
Allow addon-specific config to turn off warn message about Ember.oner…
k-fish Jul 20, 2020
a5bfa53
Merge remote-tracking branch 'origin/master' into feat/sentry/ember
k-fish Jul 21, 2020
20466eb
Update package.json for @sentry/browser 5.20.0
k-fish Jul 21, 2020
4c22bc0
Add changelog entry
k-fish Jul 21, 2020
6e489e3
Add to lerna packages
k-fish Jul 21, 2020
4a03dc5
Use a custom transport so that acceptance tests work in both CI and D…
k-fish Jul 21, 2020
7441988
Switch components back to pre-octane so that they are compatible with…
k-fish Jul 21, 2020
f0779dd
Cleanup template lint / eslint
k-fish Jul 21, 2020
55f35fe
Ignore ember in additional node.js checks
k-fish Jul 22, 2020
2b7134d
Ignore @sentry/ember in build phase as well as node > 10 is required
k-fish Jul 22, 2020
98aaecb
Fix typing around passing config at runtime, so that all options are …
k-fish Jul 22, 2020
6adacee
Use Github Actions
k-fish Jul 22, 2020
fcd2391
Remove extra click / console log call
k-fish Jul 22, 2020
2b50a53
Address some PR feedback
k-fish Jul 23, 2020
db0354f
Switch naming of init function for clarity
k-fish Jul 27, 2020
adba304
Extend base tsconfig and remove overlapping config
k-fish Jul 27, 2020
06a1e8f
Remove GHA package-specific workflow
k-fish Jul 27, 2020
967c60e
Update to 5.20.1
k-fish Jul 27, 2020
29c8ea5
Merge remote-tracking branch 'origin/master' into feat/sentry/ember
k-fish Jul 27, 2020
7e8a175
Added note about previous integration
k-fish Jul 27, 2020
565189f
Add supported versions
k-fish Jul 27, 2020
3984198
Merge remote-tracking branch 'origin/master' into feat/sentry/ember
k-fish Jul 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

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

## 5.20.1

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"packages/apm",
"packages/browser",
"packages/core",
"packages/ember",
"packages/gatsby",
"packages/hub",
"packages/integrations",
Expand Down
9 changes: 9 additions & 0 deletions packages/ember/.ember-cli
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
Copy link
Member

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).

Copy link
Contributor

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?

Copy link
Member

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 😅

Copy link
Member Author

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.

}
20 changes: 20 additions & 0 deletions packages/ember/.eslintignore
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
57 changes: 57 additions & 0 deletions packages/ember/.eslintrc.js
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',
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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']
}
]
};
25 changes: 25 additions & 0 deletions packages/ember/.gitignore
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
32 changes: 32 additions & 0 deletions packages/ember/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# compiled output
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of nitpicking but all our other npmignore files look something like:

*
!/dist/**/*
!/esm/**/*

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?

Copy link
Member Author

Choose a reason for hiding this comment

The 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
5 changes: 5 additions & 0 deletions packages/ember/.template-lintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
extends: 'octane'
};
3 changes: 3 additions & 0 deletions packages/ember/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
}
9 changes: 9 additions & 0 deletions packages/ember/LICENSE
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.
82 changes: 82 additions & 0 deletions packages/ember/README.md
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`

```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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention something here about our existing ember integration in @sentry/intergrations?
Like this package is the successor or something.

Copy link
Member Author

Choose a reason for hiding this comment

The 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
```
Empty file added packages/ember/addon/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions packages/ember/addon/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module 'ember-get-config' {
export default object;
}
57 changes: 57 additions & 0 deletions packages/ember/addon/index.ts
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.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. So we ask users to instrument Ember.onError theirselves? Any reason we didn't opt for automatic instrumentation of Ember.onError?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite, Ember.onerror doesn't fully cover all error, just some of the errors within Ember. If someone doesn't have Ember.onerror declared, then all errors will naturally forward to Sentry. If they do have onerror declared and are doing something with those errors, then a subset of errors might be getting ignored and not forwarded to Sentry, hence the warning.

Copy link
Member

Choose a reason for hiding this comment

The 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 {
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';
Loading