File tree Expand file tree Collapse file tree 8 files changed +65
-11
lines changed Expand file tree Collapse file tree 8 files changed +65
-11
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import { gt, readOnly } from '@ember/object/computed';
3
3
import { inject as service } from '@ember/service' ;
4
4
import Component from '@glimmer/component' ;
5
5
6
- import * as Sentry from '@sentry/browser' ;
7
6
import { didCancel } from 'ember-concurrency' ;
8
7
9
8
import { simplifyUrl } from './crate-sidebar/link' ;
@@ -12,6 +11,7 @@ const NUM_VERSIONS = 5;
12
11
13
12
export default class DownloadGraph extends Component {
14
13
@service playground ;
14
+ @service sentry ;
15
15
16
16
@readOnly ( 'args.crate.versions' ) sortedVersions ;
17
17
@@ -53,7 +53,7 @@ export default class DownloadGraph extends Component {
53
53
this . playground . loadCratesTask . perform ( ) . catch ( error => {
54
54
if ( ! ( didCancel ( error ) || error . isServerError || error . isNetworkError ) ) {
55
55
// report unexpected errors to Sentry
56
- Sentry . captureException ( error ) ;
56
+ this . sentry . captureException ( error ) ;
57
57
}
58
58
} ) ;
59
59
}
Original file line number Diff line number Diff line change @@ -2,18 +2,18 @@ import { action } from '@ember/object';
2
2
import Route from '@ember/routing/route' ;
3
3
import { inject as service } from '@ember/service' ;
4
4
5
- import * as Sentry from '@sentry/browser' ;
6
5
import { rawTimeout , task } from 'ember-concurrency' ;
7
6
8
7
export default class ApplicationRoute extends Route {
9
8
@service progress ;
10
9
@service router ;
11
10
@service session ;
12
11
@service playground ;
12
+ @service sentry ;
13
13
14
14
beforeModel ( ) {
15
15
this . router . on ( 'routeDidChange' , ( ) => {
16
- Sentry . configureScope ( scope => {
16
+ this . sentry . configureScope ( scope => {
17
17
scope . setTag ( 'routeName' , this . router . currentRouteName ) ;
18
18
} ) ;
19
19
} ) ;
Original file line number Diff line number Diff line change 1
1
import Route from '@ember/routing/route' ;
2
2
import { inject as service } from '@ember/service' ;
3
3
4
- import * as Sentry from '@sentry/browser' ;
5
4
import { didCancel } from 'ember-concurrency' ;
6
5
7
6
import { AjaxError } from '../../utils/ajax' ;
8
7
9
8
export default class VersionRoute extends Route {
10
9
@service notifications ;
10
+ @service sentry ;
11
11
12
12
async model ( params ) {
13
13
let crate = this . modelFor ( 'crate' ) ;
@@ -41,7 +41,7 @@ export default class VersionRoute extends Route {
41
41
version . loadDocsBuildsTask . perform ( ) . catch ( error => {
42
42
// report unexpected errors to Sentry and ignore `ajax()` errors
43
43
if ( ! didCancel ( error ) && ! ( error instanceof AjaxError ) ) {
44
- Sentry . captureException ( error ) ;
44
+ this . sentry . captureException ( error ) ;
45
45
}
46
46
} ) ;
47
47
}
Original file line number Diff line number Diff line change @@ -3,13 +3,13 @@ import { htmlSafe } from '@ember/template';
3
3
import { tracked } from '@glimmer/tracking' ;
4
4
import Ember from 'ember' ;
5
5
6
- import * as Sentry from '@sentry/browser' ;
7
6
import { didCancel , rawTimeout , task } from 'ember-concurrency' ;
8
7
9
8
const SPEED = 200 ;
10
9
11
10
export default class ProgressService extends Service {
12
11
@service router ;
12
+ @service sentry ;
13
13
14
14
@tracked _style = '' ;
15
15
@@ -28,7 +28,7 @@ export default class ProgressService extends Service {
28
28
this . updateTask . perform ( ) . catch ( error => {
29
29
if ( ! didCancel ( error ) ) {
30
30
// this task shouldn't be able to fail, but if it does we'll let Sentry know
31
- Sentry . captureException ( error ) ;
31
+ this . sentry . captureException ( error ) ;
32
32
}
33
33
} ) ;
34
34
Original file line number Diff line number Diff line change
1
+ import Service from '@ember/service' ;
2
+
3
+ import * as Sentry from '@sentry/browser' ;
4
+
5
+ export default class SentryService extends Service {
6
+ captureException ( error , captureContext ) {
7
+ Sentry . captureException ( error , captureContext ) ;
8
+ }
9
+
10
+ configureScope ( callback ) {
11
+ Sentry . configureScope ( callback ) ;
12
+ }
13
+
14
+ setUser ( user ) {
15
+ Sentry . setUser ( user ) ;
16
+ }
17
+ }
Original file line number Diff line number Diff line change 1
1
import { alias } from '@ember/object/computed' ;
2
2
import Service , { inject as service } from '@ember/service' ;
3
3
4
- import * as Sentry from '@sentry/browser' ;
5
4
import { race , rawTimeout , task , waitForEvent } from 'ember-concurrency' ;
6
5
import window from 'ember-window-mock' ;
7
6
@@ -12,6 +11,7 @@ export default class SessionService extends Service {
12
11
@service store ;
13
12
@service notifications ;
14
13
@service router ;
14
+ @service sentry ;
15
15
16
16
savedTransition = null ;
17
17
@@ -129,7 +129,7 @@ export default class SessionService extends Service {
129
129
this . isLoggedIn = false ;
130
130
131
131
yield this . loadUserTask . cancelAll ( { resetState : true } ) ;
132
- Sentry . setUser ( null ) ;
132
+ this . sentry . setUser ( null ) ;
133
133
134
134
this . router . transitionTo ( 'index' ) ;
135
135
} )
@@ -149,7 +149,7 @@ export default class SessionService extends Service {
149
149
let ownedCrates = response . owned_crates . map ( c => this . store . push ( this . store . normalize ( 'owned-crate' , c ) ) ) ;
150
150
151
151
let { id } = currentUser ;
152
- Sentry . setUser ( { id } ) ;
152
+ this . sentry . setUser ( { id } ) ;
153
153
154
154
return { currentUser, ownedCrates } ;
155
155
} ) . drop ( ) )
Original file line number Diff line number Diff line change 1
1
import { setupApplicationTest as upstreamSetupApplicationTest } from 'ember-qunit' ;
2
2
3
+ import { setupSentryMock } from './sentry' ;
3
4
import setupMirage from './setup-mirage' ;
4
5
5
6
export { setupTest , setupRenderingTest } from 'ember-qunit' ;
@@ -8,4 +9,5 @@ export { setupTest, setupRenderingTest } from 'ember-qunit';
8
9
export function setupApplicationTest ( hooks , options ) {
9
10
upstreamSetupApplicationTest ( hooks , options ) ;
10
11
setupMirage ( hooks ) ;
12
+ setupSentryMock ( hooks ) ;
11
13
}
Original file line number Diff line number Diff line change
1
+ import Service from '@ember/service' ;
2
+
3
+ class MockSentryService extends Service {
4
+ events = [ ] ;
5
+ scope = new MockScope ( ) ;
6
+
7
+ captureException ( error ) {
8
+ let { scope, user } = this ;
9
+ let { tags } = scope ;
10
+ let event = { error, tags, user } ;
11
+ this . events . push ( event ) ;
12
+ }
13
+
14
+ configureScope ( callback ) {
15
+ callback ( this . scope ) ;
16
+ }
17
+
18
+ setUser ( user ) {
19
+ this . user = user ;
20
+ }
21
+ }
22
+
23
+ class MockScope {
24
+ tags = { } ;
25
+
26
+ setTag ( key , value ) {
27
+ this . tags [ key ] = value ;
28
+ }
29
+ }
30
+
31
+ export function setupSentryMock ( hooks ) {
32
+ hooks . beforeEach ( function ( ) {
33
+ this . owner . register ( 'service:sentry' , MockSentryService ) ;
34
+ } ) ;
35
+ }
You can’t perform that action at this time.
0 commit comments