Skip to content

Commit fb9317b

Browse files
committed
ref: use weakmap
1 parent ad6e167 commit fb9317b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/integrations/src/reportingobserver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { captureMessage, convertIntegrationFnToClass, getClient, withScope } from '@sentry/core';
2-
import type { Client, EventProcessor, Hub, Integration, IntegrationFn } from '@sentry/types';
2+
import type { Client, IntegrationFn } from '@sentry/types';
33
import { GLOBAL_OBJ, supportsReportingObserver } from '@sentry/utils';
44

55
const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;
@@ -46,13 +46,13 @@ interface ReportingObserverOptions {
4646
types?: ReportTypes[];
4747
}
4848

49-
const SETUP_CLIENTS: Client[] = [];
49+
const SETUP_CLIENTS = new WeakMap<Client, boolean>();
5050

5151
const reportingObserverIntegration = ((options: ReportingObserverOptions = {}) => {
5252
const types = options.types || ['crash', 'deprecation', 'intervention'];
5353

5454
function handler(reports: Report[]): void {
55-
if (!SETUP_CLIENTS.includes(getClient() as Client)) {
55+
if (!SETUP_CLIENTS.has(getClient() as Client)) {
5656
return;
5757
}
5858

@@ -109,7 +109,7 @@ const reportingObserverIntegration = ((options: ReportingObserverOptions = {}) =
109109
},
110110

111111
setup(client): void {
112-
SETUP_CLIENTS.push(client);
112+
SETUP_CLIENTS.set(client, true);
113113
},
114114
};
115115
}) satisfies IntegrationFn;

0 commit comments

Comments
 (0)