( options: Pick<CoreOptions, 'defaultIntegrations' | 'integrations'>, )
| 44 | |
| 45 | /** Gets integrations to install */ |
| 46 | export function getIntegrationsToSetup( |
| 47 | options: Pick<CoreOptions, 'defaultIntegrations' | 'integrations'>, |
| 48 | ): Integration[] { |
| 49 | const defaultIntegrations = options.defaultIntegrations || []; |
| 50 | const userIntegrations = options.integrations; |
| 51 | |
| 52 | // We flag default instances, so that later we can tell them apart from any user-created instances of the same class |
| 53 | defaultIntegrations.forEach((integration: IntegrationWithDefaultInstance) => { |
| 54 | integration.isDefaultInstance = true; |
| 55 | }); |
| 56 | |
| 57 | let integrations: Integration[]; |
| 58 | |
| 59 | if (Array.isArray(userIntegrations)) { |
| 60 | integrations = [...defaultIntegrations, ...userIntegrations]; |
| 61 | } else if (typeof userIntegrations === 'function') { |
| 62 | const resolvedUserIntegrations = userIntegrations(defaultIntegrations); |
| 63 | integrations = Array.isArray(resolvedUserIntegrations) ? resolvedUserIntegrations : [resolvedUserIntegrations]; |
| 64 | } else { |
| 65 | integrations = defaultIntegrations; |
| 66 | } |
| 67 | |
| 68 | return filterDuplicates(integrations); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default |
no test coverage detected