diff --git a/MIGRATION.md b/MIGRATION.md index 101f9de4469d..7f4c04044bf2 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -8,6 +8,13 @@ npx @sentry/migr8@latest This will let you select which updates to run, and automatically update your code. Make sure to still review all code changes! +## Deprecated fields on `Span` and `Transaction` + +In v8, the Span class is heavily reworked. The following properties & methods are thus deprecated: + +* `span.toContext()`: Access the fields directly instead. +* `span.updateWithContext(newSpanContext)`: Update the fields directly instead. + ## Deprecate `pushScope` & `popScope` in favor of `withScope` Instead of manually pushing/popping a scope, you should use `Sentry.withScope(callback: (scope: Scope))` instead. diff --git a/packages/core/src/tracing/transaction.ts b/packages/core/src/tracing/transaction.ts index 59591971d24e..d16a15d7db41 100644 --- a/packages/core/src/tracing/transaction.ts +++ b/packages/core/src/tracing/transaction.ts @@ -149,6 +149,7 @@ export class Transaction extends SpanClass implements TransactionInterface { * @inheritDoc */ public toContext(): TransactionContext { + // eslint-disable-next-line deprecation/deprecation const spanContext = super.toContext(); return dropUndefinedKeys({ @@ -162,6 +163,7 @@ export class Transaction extends SpanClass implements TransactionInterface { * @inheritDoc */ public updateWithContext(transactionContext: TransactionContext): this { + // eslint-disable-next-line deprecation/deprecation super.updateWithContext(transactionContext); this.name = transactionContext.name || ''; diff --git a/packages/types/src/span.ts b/packages/types/src/span.ts index e8dcc92d9d4a..6a639b4fcab5 100644 --- a/packages/types/src/span.ts +++ b/packages/types/src/span.ts @@ -221,10 +221,16 @@ export interface Span extends SpanContext { /** Return a traceparent compatible header string */ toTraceparent(): string; - /** Returns the current span properties as a `SpanContext` */ + /** + * Returns the current span properties as a `SpanContext`. + * @deprecated Use `toJSON()` or access the fields directly instead. + */ toContext(): SpanContext; - /** Updates the current span with a new `SpanContext` */ + /** + * Updates the current span with a new `SpanContext`. + * @deprecated Update the fields directly instead. + */ updateWithContext(spanContext: SpanContext): this; /** Convert the object to JSON for w. spans array info only */ diff --git a/packages/types/src/transaction.ts b/packages/types/src/transaction.ts index fc682dc0b16a..a4bee40983a5 100644 --- a/packages/types/src/transaction.ts +++ b/packages/types/src/transaction.ts @@ -102,10 +102,16 @@ export interface Transaction extends TransactionContext, Omit