@@ -5,26 +5,33 @@ import { next } from '@ember/runloop';
55import { assert , warn } from '@ember/debug' ;
66import Ember from 'ember' ;
77import { timestampWithMs } from '@sentry/utils' ;
8- import { OwnConfig } from './types' ;
8+ import { GlobalConfig , OwnConfig } from './types' ;
9+ import { getGlobalObject } from '@sentry/utils' ;
910
1011declare module '@ember/debug' {
1112 export function assert ( desc : string , test : unknown ) : void ;
1213}
1314
15+ function _getSentryInitConfig ( ) {
16+ const _global = getGlobalObject < GlobalConfig > ( ) ;
17+ _global . __sentryEmberConfig = _global . __sentryEmberConfig ?? { } ;
18+ return _global . __sentryEmberConfig ;
19+ }
20+
1421export function InitSentryForEmber ( _runtimeConfig : BrowserOptions | undefined ) {
15- const config = getOwnConfig < OwnConfig > ( ) . sentryConfig ;
22+ const environmentConfig = getOwnConfig < OwnConfig > ( ) . sentryConfig ;
1623
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 ) ;
1926
20- if ( ! config . sentry ) {
27+ if ( ! environmentConfig . sentry ) {
2128 // 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 ;
2330 }
2431
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 ) ;
2835
2936 initConfig . _metadata = initConfig . _metadata || { } ;
3037 initConfig . _metadata . sdk = {
@@ -38,10 +45,14 @@ export function InitSentryForEmber(_runtimeConfig: BrowserOptions | undefined) {
3845 version : SDK_VERSION ,
3946 } ;
4047
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+
4152 Sentry . init ( initConfig ) ;
4253
4354 if ( macroCondition ( isDevelopingApp ( ) ) ) {
44- if ( config . ignoreEmberOnErrorWarning ) {
55+ if ( environmentConfig . ignoreEmberOnErrorWarning ) {
4556 return ;
4657 }
4758 next ( null , function ( ) {
0 commit comments