From 150f7f27033b146374bcb183c930b500dfff3086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Wed, 16 Sep 2020 11:40:22 +0200 Subject: [PATCH] fix: Use correct types for event context data --- packages/hub/src/scope.ts | 17 ++++++++++------- packages/types/src/scope.ts | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/hub/src/scope.ts b/packages/hub/src/scope.ts index 82d470a265db..0f3e86fc6d0c 100644 --- a/packages/hub/src/scope.ts +++ b/packages/hub/src/scope.ts @@ -40,12 +40,10 @@ export class Scope implements ScopeInterface { protected _tags: { [key: string]: string } = {}; /** Extra */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - protected _extra: { [key: string]: any } = {}; + protected _extra: { [key: string]: unknown } = {}; /** Contexts */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - protected _contexts: { [key: string]: any } = {}; + protected _contexts: { [key: string]: Record } = {}; /** Fingerprint */ protected _fingerprint?: string[]; @@ -185,9 +183,14 @@ export class Scope implements ScopeInterface { /** * @inheritDoc */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public setContext(key: string, context: { [key: string]: any } | null): this { - this._contexts = { ...this._contexts, [key]: context }; + public setContext(key: string, context: Record | null): this { + if (context === null) { + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete this._contexts[key]; + } else { + this._contexts = { ...this._contexts, [key]: context }; + } + this._notifyScopeListeners(); return this; } diff --git a/packages/types/src/scope.ts b/packages/types/src/scope.ts index 973d45fd7b4e..d53d525d8af8 100644 --- a/packages/types/src/scope.ts +++ b/packages/types/src/scope.ts @@ -14,7 +14,7 @@ export interface ScopeContext { user: User; level: Severity; extra: { [key: string]: any }; - contexts: { [key: string]: any }; + contexts: { [key: string]: Record }; tags: { [key: string]: string }; fingerprint: string[]; }