1
1
import { addGlobalEventProcessor , getCurrentHub } from '@sentry/hub' ;
2
- import { ClientOptions , Integration , Options } from '@sentry/types' ;
3
- import { addNonEnumerableProperty , logger } from '@sentry/utils' ;
2
+ import { Integration , Options } from '@sentry/types' ;
3
+ import { logger } from '@sentry/utils' ;
4
4
5
5
import { IS_DEBUG_BUILD } from './flags' ;
6
6
@@ -9,7 +9,7 @@ export const installedIntegrations: string[] = [];
9
9
/** Map of integrations assigned to a client */
10
10
export type IntegrationIndex = {
11
11
[ key : string ] : Integration ;
12
- } & { initialized ?: boolean } ;
12
+ } ;
13
13
14
14
/**
15
15
* @private
@@ -54,31 +54,24 @@ export function getIntegrationsToSetup(options: Options): Integration[] {
54
54
return integrations ;
55
55
}
56
56
57
- /** Setup given integration */
58
- export function setupIntegration ( integration : Integration ) : void {
59
- if ( installedIntegrations . indexOf ( integration . name ) !== - 1 ) {
60
- return ;
61
- }
62
- integration . setupOnce ( addGlobalEventProcessor , getCurrentHub ) ;
63
- installedIntegrations . push ( integration . name ) ;
64
- IS_DEBUG_BUILD && logger . log ( `Integration installed: ${ integration . name } ` ) ;
65
- }
66
-
67
57
/**
68
58
* Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default
69
59
* integrations are added unless they were already provided before.
70
60
* @param integrations array of integration instances
71
61
* @param withDefault should enable default integrations
72
62
*/
73
- export function setupIntegrations < O extends ClientOptions > ( options : O ) : IntegrationIndex {
74
- const integrations : IntegrationIndex = { } ;
75
- options . integrations . forEach ( integration => {
76
- integrations [ integration . name ] = integration ;
77
- setupIntegration ( integration ) ;
63
+ export function setupIntegrations ( integrations : Integration [ ] ) : IntegrationIndex {
64
+ const integrationIndex : IntegrationIndex = { } ;
65
+
66
+ integrations . forEach ( integration => {
67
+ integrationIndex [ integration . name ] = integration ;
68
+
69
+ if ( installedIntegrations . indexOf ( integration . name ) === - 1 ) {
70
+ integration . setupOnce ( addGlobalEventProcessor , getCurrentHub ) ;
71
+ installedIntegrations . push ( integration . name ) ;
72
+ IS_DEBUG_BUILD && logger . log ( `Integration installed: ${ integration . name } ` ) ;
73
+ }
78
74
} ) ;
79
- // set the `initialized` flag so we don't run through the process again unecessarily; use `Object.defineProperty`
80
- // because by default it creates a property which is nonenumerable, which we want since `initialized` shouldn't be
81
- // considered a member of the index the way the actual integrations are
82
- addNonEnumerableProperty ( integrations , 'initialized' , true ) ;
83
- return integrations ;
75
+
76
+ return integrationIndex ;
84
77
}
0 commit comments