1 | Object.defineProperty(exports, "__esModule", { value: true });
|
2 | var tslib_1 = require("tslib");
|
3 | var hub_1 = require("@sentry/hub");
|
4 | var utils_1 = require("@sentry/utils");
|
5 | exports.installedIntegrations = [];
|
6 |
|
7 |
|
8 |
|
9 | function filterDuplicates(integrations) {
|
10 | return integrations.reduce(function (acc, integrations) {
|
11 | if (acc.every(function (accIntegration) { return integrations.name !== accIntegration.name; })) {
|
12 | acc.push(integrations);
|
13 | }
|
14 | return acc;
|
15 | }, []);
|
16 | }
|
17 |
|
18 | function getIntegrationsToSetup(options) {
|
19 | var defaultIntegrations = (options.defaultIntegrations && tslib_1.__spread(options.defaultIntegrations)) || [];
|
20 | var userIntegrations = options.integrations;
|
21 | var integrations = tslib_1.__spread(filterDuplicates(defaultIntegrations));
|
22 | if (Array.isArray(userIntegrations)) {
|
23 |
|
24 | integrations = tslib_1.__spread(integrations.filter(function (integrations) {
|
25 | return userIntegrations.every(function (userIntegration) { return userIntegration.name !== integrations.name; });
|
26 | }), filterDuplicates(userIntegrations));
|
27 | }
|
28 | else if (typeof userIntegrations === 'function') {
|
29 | integrations = userIntegrations(integrations);
|
30 | integrations = Array.isArray(integrations) ? integrations : [integrations];
|
31 | }
|
32 |
|
33 | var integrationsNames = integrations.map(function (i) { return i.name; });
|
34 | var alwaysLastToRun = 'Debug';
|
35 | if (integrationsNames.indexOf(alwaysLastToRun) !== -1) {
|
36 | integrations.push.apply(integrations, tslib_1.__spread(integrations.splice(integrationsNames.indexOf(alwaysLastToRun), 1)));
|
37 | }
|
38 | return integrations;
|
39 | }
|
40 | exports.getIntegrationsToSetup = getIntegrationsToSetup;
|
41 |
|
42 | function setupIntegration(integration) {
|
43 | if (exports.installedIntegrations.indexOf(integration.name) !== -1) {
|
44 | return;
|
45 | }
|
46 | integration.setupOnce(hub_1.addGlobalEventProcessor, hub_1.getCurrentHub);
|
47 | exports.installedIntegrations.push(integration.name);
|
48 | utils_1.logger.log("Integration installed: " + integration.name);
|
49 | }
|
50 | exports.setupIntegration = setupIntegration;
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | function setupIntegrations(options) {
|
58 | var integrations = {};
|
59 | getIntegrationsToSetup(options).forEach(function (integration) {
|
60 | integrations[integration.name] = integration;
|
61 | setupIntegration(integration);
|
62 | });
|
63 | return integrations;
|
64 | }
|
65 | exports.setupIntegrations = setupIntegrations;
|
66 |
|
\ | No newline at end of file |