Skip to content

Commit 933f399

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

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/hub/src/scope.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class Scope implements ScopeInterface {
4545

4646
/** Contexts */
4747
// eslint-disable-next-line @typescript-eslint/no-explicit-any
48-
protected _contexts: { [key: string]: any } = {};
48+
protected _contexts: { [key: string]: Record<any, any> } = {};
4949

5050
/** Fingerprint */
5151
protected _fingerprint?: string[];
@@ -185,9 +185,14 @@ export class Scope implements ScopeInterface {
185185
/**
186186
* @inheritDoc
187187
*/
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 };
188+
public setContext(key: string, context: { [key: string]: Record<any, any> } | null): this {
189+
if (context === null) {
190+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
191+
delete this._contexts[key];
192+
} else {
193+
this._contexts = { ...this._contexts, [key]: context };
194+
}
195+
191196
this._notifyScopeListeners();
192197
return this;
193198
}

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)