Skip to content

Commit e35f29c

Browse files
committed
[WIP] feat: Add @sentry/ember
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. Once #2736 and other tracing PR's have landed, we can add Ember specific performance instrumentation.
1 parent 98993a1 commit e35f29c

Some content is hidden

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

49 files changed

+1109
-0
lines changed

packages/ember/.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
indent_style = space
13+
indent_size = 2
14+
15+
[*.hbs]
16+
insert_final_newline = false
17+
18+
[*.{diff,md}]
19+
trim_trailing_whitespace = false

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: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
rules: {},
24+
overrides: [
25+
// node files
26+
{
27+
files: [
28+
'.eslintrc.js',
29+
'.template-lintrc.js',
30+
'ember-cli-build.js',
31+
'index.js',
32+
'testem.js',
33+
'blueprints/*/index.js',
34+
'config/**/*.js',
35+
'tests/dummy/config/**/*.js'
36+
],
37+
excludedFiles: [
38+
'addon/**',
39+
'addon-test-support/**',
40+
'app/**',
41+
'tests/dummy/app/**'
42+
],
43+
parserOptions: {
44+
sourceType: 'script'
45+
},
46+
env: {
47+
browser: false,
48+
node: true
49+
},
50+
plugins: ['node'],
51+
extends: ['plugin:node/recommended']
52+
}
53+
]
54+
};

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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2019, Sentry
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

packages/ember/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 config to `config/environment.js`
26+
27+
```javascript
28+
ENV['@sentry/ember'] = {
29+
dsn: '__DSN__'
30+
};
31+
```
32+
33+
### Usage
34+
35+
To use this SDK, call `SentryForEmber` before the application is initialized, in `app.js`. This will load Sentry config from `environment.js` for you.
36+
37+
```javascript
38+
import Application from '@ember/application';
39+
import Resolver from 'ember-resolver';
40+
import loadInitializers from 'ember-load-initializers';
41+
import config from './config/environment';
42+
import { SentryForEmber } from '@sentry/ember';
43+
44+
SentryForEmber();
45+
46+
export default class App extends Application {
47+
modulePrefix = config.modulePrefix;
48+
podModulePrefix = config.podModulePrefix;
49+
Resolver = Resolver;
50+
}
51+
```
52+
53+
## Testing
54+
55+
You can find example instrumentation in the `dummy` application, which is also used for testing. To test with the dummy
56+
application, you must pass the dsn as an environment variable.
57+
58+
```javascript
59+
SENTRY_DSN=__DSN__ ember serve
60+
```

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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as Sentry from '@sentry/browser';
2+
import { addGlobalEventProcessor, SDK_VERSION } from '@sentry/browser';
3+
import environmentConfig from 'ember-get-config';
4+
5+
import { assert } from '@ember/debug';
6+
7+
export function SentryForEmber() {
8+
const config = environmentConfig['@sentry/ember'];
9+
assert('Missing configuration for Sentry', config);
10+
11+
const initConfig = Object.assign({}, config);
12+
Sentry.init(initConfig);
13+
}
14+
15+
function createEmberEventProcessor(): void {
16+
if (addGlobalEventProcessor) {
17+
addGlobalEventProcessor(event => {
18+
event.sdk = {
19+
...event.sdk,
20+
name: 'sentry.javascript.ember',
21+
packages: [
22+
...((event.sdk && event.sdk.packages) || []),
23+
{
24+
name: 'npm:@sentry/ember',
25+
version: SDK_VERSION,
26+
},
27+
],
28+
version: SDK_VERSION,
29+
};
30+
31+
return event;
32+
});
33+
}
34+
}
35+
36+
export * from '@sentry/browser';
37+
38+
createEmberEventProcessor();

packages/ember/addon/profiler.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
import { subscribe } from '@ember/instrumentation';
3+
4+
export function profileRender(object, property, desc) {
5+
return {
6+
get() {
7+
console.log('get');
8+
return () => {
9+
return desc.value;
10+
};
11+
},
12+
valued: (hello) => {
13+
console.log(hello);
14+
},
15+
valuel() {
16+
if (typeof desc.initializer === 'function') {
17+
return desc.initializer.call(undefined);
18+
}
19+
20+
if (typeof desc.get === 'function') {
21+
return desc.get.call(undefined);
22+
}
23+
24+
if (desc.value) {
25+
return desc.value;
26+
}
27+
28+
return undefined;
29+
}
30+
}
31+
}
32+
33+
function instrumentRender() {
34+
subscribe('render', {
35+
before(name, timestamp, payload) {
36+
console.log(name, timestamp, payload);
37+
},
38+
after(name, timestamp, payload) {
39+
console.log(name, timestamp, payload);
40+
}
41+
});
42+
}
43+
*/

0 commit comments

Comments
 (0)