Skip to content

Commit 11de1ad

Browse files
committed
[v7] Allow for passing scope internally during client creation
1 parent aad5aa9 commit 11de1ad

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/core/src/baseclient.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ import { collectIntegrations } from './integrations';
6262
* // ...
6363
* }
6464
*/
65-
// TODO: Allow for passing scope during construction for explicit `this._scope`
6665
export abstract class BaseClient<O extends Options> implements ClientLike<O> {
6766
/** Options passed to the SDK. */
6867
public readonly options: O;
@@ -79,7 +78,7 @@ export abstract class BaseClient<O extends Options> implements ClientLike<O> {
7978

8079
protected _lastEventId?: string;
8180

82-
protected _scope: ScopeLike = new Scope();
81+
protected _scope: ScopeLike;
8382

8483
protected _eventProcessors: EventProcessor[] = [];
8584

@@ -101,6 +100,7 @@ export abstract class BaseClient<O extends Options> implements ClientLike<O> {
101100
this.logger.enabled = true;
102101
}
103102

103+
this._scope = this.options._internal?.scope || new Scope();
104104
this._transport = this._setupTransport();
105105
this._integrations = this._setupIntegrations();
106106
}

packages/integration-common-inboundfilters/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ export class InboundFilters implements Integration {
9494
return false;
9595
}
9696

97+
const { ignoreErrors } = options;
9798
return this._getPossibleEventMessages(event).some(message =>
98-
// Not sure why TypeScript complains here...
99-
(options.ignoreErrors as Array<RegExp | string>).some(pattern => isMatchingPattern(message, pattern)),
99+
ignoreErrors.some(pattern => isMatchingPattern(message, pattern)),
100100
);
101101
}
102102

packages/types/src/options.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Breadcrumb, BreadcrumbHint } from './breadcrumb';
22
import { SentryEvent, EventHint } from './event';
33
import { Integration } from './integration';
44
import { LogLevel } from './loglevel';
5+
import { ScopeLike } from './scope';
56
import { SdkInfo } from './sdkinfo';
67
import { SamplingContext } from './transaction';
78
import { Transport, TransportOptions } from './transport';
@@ -130,6 +131,7 @@ export interface Options {
130131

131132
_internal?: {
132133
sdk?: SdkInfo;
134+
scope?: ScopeLike;
133135
defaultIntegrations?: Integration[];
134136
discoveredIntegrations?: Integration[];
135137
};

0 commit comments

Comments
 (0)