1 | Object.defineProperty(exports, '__esModule', { value: true });
|
2 |
|
3 | var hub = require('@sentry/hub');
|
4 | var utils = require('@sentry/utils');
|
5 |
|
6 | var installedIntegrations = [];
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | function filterDuplicates(integrations) {
|
14 | return integrations.reduce((acc, integrations) => {
|
15 | if (acc.every(accIntegration => integrations.name !== accIntegration.name)) {
|
16 | acc.push(integrations);
|
17 | }
|
18 | return acc;
|
19 | }, [] );
|
20 | }
|
21 |
|
22 |
|
23 | function getIntegrationsToSetup(options) {
|
24 | var defaultIntegrations = (options.defaultIntegrations && [...options.defaultIntegrations]) || [];
|
25 | var userIntegrations = options.integrations;
|
26 |
|
27 | let integrations = [...filterDuplicates(defaultIntegrations)];
|
28 |
|
29 | if (Array.isArray(userIntegrations)) {
|
30 |
|
31 | integrations = [
|
32 | ...integrations.filter(integrations =>
|
33 | userIntegrations.every(userIntegration => userIntegration.name !== integrations.name),
|
34 | ),
|
35 |
|
36 | ...filterDuplicates(userIntegrations),
|
37 | ];
|
38 | } else if (typeof userIntegrations === 'function') {
|
39 | integrations = userIntegrations(integrations);
|
40 | integrations = Array.isArray(integrations) ? integrations : [integrations];
|
41 | }
|
42 |
|
43 |
|
44 | var integrationsNames = integrations.map(i => i.name);
|
45 | var alwaysLastToRun = 'Debug';
|
46 | if (integrationsNames.indexOf(alwaysLastToRun) !== -1) {
|
47 | integrations.push(...integrations.splice(integrationsNames.indexOf(alwaysLastToRun), 1));
|
48 | }
|
49 |
|
50 | return integrations;
|
51 | }
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | function setupIntegrations(integrations) {
|
60 | var integrationIndex = {};
|
61 |
|
62 | integrations.forEach(integration => {
|
63 | integrationIndex[integration.name] = integration;
|
64 |
|
65 | if (installedIntegrations.indexOf(integration.name) === -1) {
|
66 | integration.setupOnce(hub.addGlobalEventProcessor, hub.getCurrentHub);
|
67 | installedIntegrations.push(integration.name);
|
68 | (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.log(`Integration installed: ${integration.name}`);
|
69 | }
|
70 | });
|
71 |
|
72 | return integrationIndex;
|
73 | }
|
74 |
|
75 | exports.getIntegrationsToSetup = getIntegrationsToSetup;
|
76 | exports.installedIntegrations = installedIntegrations;
|
77 | exports.setupIntegrations = setupIntegrations;
|
78 |
|