Skip to content

Commit f7f18d7

Browse files
committed
feat: Add helper for old api
1 parent ace2651 commit f7f18d7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/apm/src/hubextensions.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ function traceHeaders(this: Hub): { [key: string]: string } {
2727
* @param context Properties with which the span should be created
2828
*/
2929
function startSpan(this: Hub, context: SpanContext | TransactionContext): Transaction | Span {
30+
/**
31+
* @deprecated
32+
* We have this here as a fallback to not break users upgrading to the new API
33+
*/
34+
if ((context as any).transaction) {
35+
logger.warn(
36+
`Please use \`Sentry.startTransaction({name: ${(context as any).transaction}})\` to start a Transaction.`,
37+
);
38+
(context as TransactionContext).name = (context as any).transaction as string;
39+
(context as TransactionContext)._isTransaction = true;
40+
}
41+
3042
// This is our safeguard so people always get a Transaction in return.
3143
// We set `_isTransaction: true` in {@link Sentry.startTransaction} to have a runtime check
3244
// if the user really wanted to create a Transaction.

0 commit comments

Comments
 (0)