Skip to content

Commit a909d94

Browse files
committed
feat: Make sure that Debug integration is always setup as the last one
1 parent 22a2a4e commit a909d94

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

packages/core/src/integration.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ export function getIntegrationsToSetup(options: Options): Integration[] {
4040
integrations = userIntegrations(defaultIntegrations);
4141
integrations = Array.isArray(integrations) ? integrations : [integrations];
4242
} else {
43-
return [...defaultIntegrations];
43+
integrations = [...defaultIntegrations];
44+
}
45+
46+
// Make sure that if present, `Debug` integration will always run last
47+
const integrationsNames = integrations.map(i => i.name);
48+
const alwaysLastToRun = 'Debug';
49+
if (integrationsNames.indexOf(alwaysLastToRun) !== -1) {
50+
integrations.push(...integrations.splice(integrationsNames.indexOf(alwaysLastToRun), 1));
4451
}
4552

4653
return integrations;

packages/core/test/lib/integration.test.ts

+23
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,27 @@ describe('getIntegrationsToSetup', () => {
122122
expect((integrations[0] as any).order).toEqual('firstUser');
123123
expect((integrations[1] as any).order).toEqual('secondUser');
124124
});
125+
126+
it('always moves Debug integration to the end of the list', () => {
127+
let integrations = getIntegrationsToSetup({
128+
defaultIntegrations: [new MockIntegration('Debug'), new MockIntegration('foo')],
129+
integrations: [new MockIntegration('bar')],
130+
});
131+
132+
expect(integrations.map(i => i.name)).toEqual(['foo', 'bar', 'Debug']);
133+
134+
integrations = getIntegrationsToSetup({
135+
defaultIntegrations: [new MockIntegration('foo')],
136+
integrations: [new MockIntegration('Debug'), new MockIntegration('bar')],
137+
});
138+
139+
expect(integrations.map(i => i.name)).toEqual(['foo', 'bar', 'Debug']);
140+
141+
integrations = getIntegrationsToSetup({
142+
defaultIntegrations: [new MockIntegration('Debug')],
143+
integrations: [new MockIntegration('foo')],
144+
});
145+
146+
expect(integrations.map(i => i.name)).toEqual(['foo', 'Debug']);
147+
});
125148
});

0 commit comments

Comments
 (0)