Skip to content

Commit 7a62d02

Browse files
committed
feat: Export integrations on Sentry.Integrations
1 parent a764dac commit 7a62d02

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

packages/browser/test/integration/common.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ function initSDK() {
117117
Sentry.init({
118118
dsn: 'https://public@example.com/1',
119119
// debug: true,
120-
integrations: [new SentryIntegration.Dedupe()],
120+
integrations: [
121+
(Sentry.Integrations && Sentry.Integrations.Dedupe && new Sentry.Integrations.Dedupe()) ||
122+
(SentryIntegrations && new SentryIntegrations.Dedupe()),
123+
],
121124
attachStacktrace: true,
122125
transport: DummyTransport,
123126
ignoreErrors: ['ignoreErrorTest'],

packages/browser/test/integration/frame.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<title></title>
77
<script src="polyfills/es6-promise-4.2.5.auto.js"></script>
88
<script src="polyfills/whatwg-fetch-3.0.0.js"></script>
9-
<script src="dedupe.js"></script>
109
<script src="common.js"></script>
1110
<script src="../../build/bundle.js"></script>
11+
<script src="dedupe.js"></script>
1212
<script src="init.js"></script>
1313
</head>
1414

packages/browser/test/manual/test-code.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const Sentry = require('../../dist/index.js');
2+
const Integrations = require('../../../integrations/dist/dedupe.js');
23

34
// Init
45
Sentry.init({
56
dsn: 'https://completelyrandom@dsn.asdf/42',
7+
integrations: [new Integrations.Dedupe()],
68
beforeSend(event) {
79
console.log('Got an event');
810
return null;

packages/integrations/rollup.config.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,27 @@ function toPascalCase(string) {
5353
}
5454

5555
function mergeIntoSentry(name) {
56-
return `window.SentryIntegration = window.SentryIntegration || {}; \n
57-
window.SentryIntegration.${name} = exports.${name};`;
56+
return `
57+
if (window.Sentry && window.Sentry.Integrations) {
58+
window.Sentry.Integrations['${name}'] = exports.${name};
59+
} else {
60+
if ((typeof __SENTRY_INTEGRATIONS_LOG === 'undefined')) {
61+
console.warn('Sentry.Integrations is not defined, make sure you included this script after the SDK.');
62+
console.warn('In case you were using the loader, we added the Integration is now available under SentryIntegrations.${name}');
63+
console.warn('To disable these warning set __SENTRY_INTEGRATIONS_LOG = true; somewhere before loading this script.');
64+
}
65+
window.SentryIntegrations = window.SentryIntegrations || {};
66+
window.SentryIntegrations['${name}'] = exports.${name};
67+
}
68+
`;
69+
}
70+
71+
function allIntegrations() {
72+
return fs.readdirSync('./src').filter(file => file != 'modules.ts');
5873
}
5974

6075
function loadAllIntegrations() {
61-
return fs.readdirSync('./src').map(file => ({
76+
return allIntegrations().map(file => ({
6277
input: `src/${file}`,
6378
output: {
6479
banner: '(function (window) {',

0 commit comments

Comments
 (0)