@@ -5,26 +5,33 @@ import { next } from '@ember/runloop';
5
5
import { assert , warn } from '@ember/debug' ;
6
6
import Ember from 'ember' ;
7
7
import { timestampWithMs } from '@sentry/utils' ;
8
- import { OwnConfig } from './types' ;
8
+ import { GlobalConfig , OwnConfig } from './types' ;
9
+ import { getGlobalObject } from '@sentry/utils' ;
9
10
10
11
declare module '@ember/debug' {
11
12
export function assert ( desc : string , test : unknown ) : void ;
12
13
}
13
14
15
+ function _getSentryInitConfig ( ) {
16
+ const _global = getGlobalObject < GlobalConfig > ( ) ;
17
+ _global . __sentryEmberConfig = _global . __sentryEmberConfig ?? { } ;
18
+ return _global . __sentryEmberConfig ;
19
+ }
20
+
14
21
export function InitSentryForEmber ( _runtimeConfig : BrowserOptions | undefined ) {
15
- const config = getOwnConfig < OwnConfig > ( ) . sentryConfig ;
22
+ const environmentConfig = getOwnConfig < OwnConfig > ( ) . sentryConfig ;
16
23
17
- assert ( 'Missing configuration.' , config ) ;
18
- assert ( 'Missing configuration for Sentry.' , config . sentry || _runtimeConfig ) ;
24
+ assert ( 'Missing configuration.' , environmentConfig ) ;
25
+ assert ( 'Missing configuration for Sentry.' , environmentConfig . sentry || _runtimeConfig ) ;
19
26
20
- if ( ! config . sentry ) {
27
+ if ( ! environmentConfig . sentry ) {
21
28
// If environment config is not specified but the above assertion passes, use runtime config.
22
- config . sentry = { ..._runtimeConfig } as any ;
29
+ environmentConfig . sentry = { ..._runtimeConfig } as any ;
23
30
}
24
31
25
- // Permanently merge options into config, preferring runtime config
26
- Object . assign ( config . sentry , _runtimeConfig || { } ) ;
27
- const initConfig = Object . assign ( { } , config . sentry ) ;
32
+ // Merge runtime config into environment config, preferring runtime.
33
+ Object . assign ( environmentConfig . sentry , _runtimeConfig || { } ) ;
34
+ const initConfig = Object . assign ( { } , environmentConfig . sentry ) ;
28
35
29
36
initConfig . _metadata = initConfig . _metadata || { } ;
30
37
initConfig . _metadata . sdk = {
@@ -38,10 +45,14 @@ export function InitSentryForEmber(_runtimeConfig: BrowserOptions | undefined) {
38
45
version : SDK_VERSION ,
39
46
} ;
40
47
48
+ // Persist Sentry init options so they are identical when performance initializers call init again.
49
+ const sentryInitConfig = _getSentryInitConfig ( ) ;
50
+ Object . assign ( sentryInitConfig , initConfig ) ;
51
+
41
52
Sentry . init ( initConfig ) ;
42
53
43
54
if ( macroCondition ( isDevelopingApp ( ) ) ) {
44
- if ( config . ignoreEmberOnErrorWarning ) {
55
+ if ( environmentConfig . ignoreEmberOnErrorWarning ) {
45
56
return ;
46
57
}
47
58
next ( null , function ( ) {
0 commit comments