Skip to content

Commit 150f7f2

Browse files
committed
fix: Use correct types for event context data
1 parent a575c83 commit 150f7f2

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

packages/hub/src/scope.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ export class Scope implements ScopeInterface {
4040
protected _tags: { [key: string]: string } = {};
4141

4242
/** Extra */
43-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
44-
protected _extra: { [key: string]: any } = {};
43+
protected _extra: { [key: string]: unknown } = {};
4544

4645
/** Contexts */
47-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
48-
protected _contexts: { [key: string]: any } = {};
46+
protected _contexts: { [key: string]: Record<string, unknown> } = {};
4947

5048
/** Fingerprint */
5149
protected _fingerprint?: string[];
@@ -185,9 +183,14 @@ export class Scope implements ScopeInterface {
185183
/**
186184
* @inheritDoc
187185
*/
188-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
189-
public setContext(key: string, context: { [key: string]: any } | null): this {
190-
this._contexts = { ...this._contexts, [key]: context };
186+
public setContext(key: string, context: Record<string, unknown> | null): this {
187+
if (context === null) {
188+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
189+
delete this._contexts[key];
190+
} else {
191+
this._contexts = { ...this._contexts, [key]: context };
192+
}
193+
191194
this._notifyScopeListeners();
192195
return this;
193196
}

packages/types/src/scope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface ScopeContext {
1414
user: User;
1515
level: Severity;
1616
extra: { [key: string]: any };
17-
contexts: { [key: string]: any };
17+
contexts: { [key: string]: Record<any, any> };
1818
tags: { [key: string]: string };
1919
fingerprint: string[];
2020
}

0 commit comments

Comments
 (0)