Skip to content

Commit 56e2c62

Browse files
committed
plz
1 parent 9fc9d6d commit 56e2c62

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

packages/apm/src/integrations/tracing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ export class Tracing implements Integration {
853853
Tracing._log(`[Tracing] Transaction: ${SpanStatus.Cancelled} since it maxed out maxTransactionDuration`);
854854
if (event.contexts && event.contexts.trace) {
855855
event.contexts.trace = {
856-
...event.contexts.trace,
856+
...(typeof event.contexts.trace === 'object' && event.contexts.trace),
857857
status: SpanStatus.DeadlineExceeded,
858858
};
859859
event.tags = {

packages/hub/src/scope.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import {
33
Breadcrumb,
44
CaptureContext,
5+
Context,
6+
Contexts,
57
Event,
68
EventHint,
79
EventProcessor,
@@ -43,7 +45,7 @@ export class Scope implements ScopeInterface {
4345
protected _extra: Extras = {};
4446

4547
/** Contexts */
46-
protected _contexts: { [key: string]: Record<string, unknown> } = {};
48+
protected _contexts: Contexts = {};
4749

4850
/** Fingerprint */
4951
protected _fingerprint?: string[];
@@ -183,7 +185,7 @@ export class Scope implements ScopeInterface {
183185
/**
184186
* @inheritDoc
185187
*/
186-
public setContext(key: string, context: Record<string, unknown> | null): this {
188+
public setContext(key: string, context: Context | null): this {
187189
if (context === null) {
188190
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
189191
delete this._contexts[key];

packages/types/src/context.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export type Context = unknown;
2+
export type Contexts = Record<string, Context>;

packages/types/src/event.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Breadcrumb } from './breadcrumb';
2+
import { Contexts } from './context';
23
import { Exception } from './exception';
4+
import { Extras } from './extra';
35
import { Request } from './request';
46
import { CaptureContext } from './scope';
57
import { SdkInfo } from './sdkinfo';
@@ -31,11 +33,9 @@ export interface Event {
3133
};
3234
stacktrace?: Stacktrace;
3335
breadcrumbs?: Breadcrumb[];
34-
contexts?: {
35-
[key: string]: Record<any, any>;
36-
};
36+
contexts?: Contexts;
3737
tags?: { [key: string]: string };
38-
extra?: { [key: string]: any };
38+
extra?: Extras;
3939
user?: User;
4040
type?: EventType;
4141
spans?: Span[];

packages/types/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export { Breadcrumb, BreadcrumbHint } from './breadcrumb';
22
export { Client } from './client';
3+
export { Context, Contexts } from './context';
34
export { Dsn, DsnComponents, DsnLike, DsnProtocol } from './dsn';
45
export { ExtendedError } from './error';
56
export { Event, EventHint } from './event';

packages/types/src/scope.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Breadcrumb } from './breadcrumb';
2+
import { Context, Contexts } from './context';
23
import { EventProcessor } from './eventprocessor';
34
import { Extra, Extras } from './extra';
45
import { Severity } from './severity';
@@ -14,7 +15,7 @@ export interface ScopeContext {
1415
user: User;
1516
level: Severity;
1617
extra: Extras;
17-
contexts: { [key: string]: Record<string, unknown> };
18+
contexts: Contexts;
1819
tags: { [key: string]: string };
1920
fingerprint: string[];
2021
}
@@ -82,7 +83,7 @@ export interface Scope {
8283
* @param name of the context
8384
* @param context Any kind of data. This data will be normailzed.
8485
*/
85-
setContext(name: string, context: Record<string, unknown> | null): this;
86+
setContext(name: string, context: Context | null): this;
8687

8788
/**
8889
* Sets the Span on the scope.

0 commit comments

Comments
 (0)