Skip to content

Commit aba990d

Browse files
author
Luca Forstner
committed
.
1 parent 2173db2 commit aba990d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/core/src/integration.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export type IntegrationIndex = {
1111
[key: string]: Integration;
1212
};
1313

14+
type IntegrationWithDefaultInstance = Integration & { isDefaultInstance?: true };
15+
1416
/**
1517
* Remove duplicates from the given array, preferring the last instance of any duplicate. Not guaranteed to
1618
* preserve the order of integrations in the array.
@@ -20,10 +22,10 @@ export type IntegrationIndex = {
2022
function filterDuplicates(integrations: Integration[]): Integration[] {
2123
const integrationsByName: { [key: string]: Integration } = {};
2224

23-
integrations.forEach(currentInstance => {
25+
integrations.forEach((currentInstance: IntegrationWithDefaultInstance) => {
2426
const { name } = currentInstance;
2527

26-
const existingInstance = integrationsByName[name];
28+
const existingInstance: IntegrationWithDefaultInstance | undefined = integrationsByName[name];
2729

2830
// We want integrations later in the array to overwrite earlier ones of the same type, except that we never want a
2931
// default instance to overwrite an existing user instance
@@ -43,7 +45,7 @@ export function getIntegrationsToSetup(options: Pick<Options, 'defaultIntegratio
4345
const userIntegrations = options.integrations;
4446

4547
// We flag default instances, so that later we can tell them apart from any user-created instances of the same class
46-
defaultIntegrations.forEach(integration => {
48+
defaultIntegrations.forEach((integration: IntegrationWithDefaultInstance) => {
4749
integration.isDefaultInstance = true;
4850
});
4951

packages/solidstart/test/client/sdk.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ describe('browserTracingIntegration', () => {
4646
?.getOptions()
4747
.integrations.find(integration => integration.name === 'BrowserTracing');
4848
expect(browserTracingIntegration).toBeDefined();
49+
// @ts-expect-error Non public field
4950
expect(browserTracingIntegration!.isDefaultInstance).toEqual(true);
5051
});
5152

@@ -76,6 +77,7 @@ describe('browserTracingIntegration', () => {
7677
?.getOptions()
7778
.integrations.find(integration => integration.name === 'BrowserTracing');
7879
expect(browserTracingIntegration).toBeDefined();
80+
// @ts-expect-error Non public field
7981
expect(browserTracingIntegration!.isDefaultInstance).toBeUndefined();
8082
});
8183
});

0 commit comments

Comments
 (0)