@@ -51,18 +51,23 @@ function startTransaction(this: Hub, context: TransactionContext): Transaction {
5151function startSpan ( this : Hub , context : SpanContext ) : Transaction | Span {
5252 /**
5353 * @deprecated
54- * This is here to make sure we don't break users that relied on calling startSpan to create a transaction
55- * with the transaction poperty set.
54+ * TODO: consider removing this in a future release.
55+ *
56+ * This is for backwards compatibility with releases before startTransaction
57+ * existed, to allow for a smoother transition.
5658 */
57- if ( ( context as any ) . transaction !== undefined ) {
58- logger . warn ( `Use \`Sentry.startTransaction({name: ${ ( context as any ) . transaction } })\` to start a Transaction.` ) ;
59- ( context as TransactionContext ) . name = ( context as any ) . transaction as string ;
60- }
61-
62- // We have the check of not undefined since we defined it's ok to start a transaction with an empty name
63- // tslint:disable-next-line: strict-type-predicates
64- if ( ( context as TransactionContext ) . name !== undefined ) {
65- return this . startTransaction ( context as TransactionContext ) ;
59+ {
60+ // The `TransactionContext.name` field used to be called `transaction`.
61+ const transactionContext = context as Partial < TransactionContext & { transaction : string } > ;
62+ if ( transactionContext . transaction !== undefined ) {
63+ transactionContext . name = transactionContext . transaction ;
64+ }
65+ // Check for not undefined since we defined it's ok to start a transaction
66+ // with an empty name.
67+ if ( transactionContext . name !== undefined ) {
68+ logger . warn ( 'Deprecated: Use startTransaction to start transactions and Transaction.startChild to start spans.' ) ;
69+ return this . startTransaction ( transactionContext as TransactionContext ) ;
70+ }
6671 }
6772
6873 const scope = this . getScope ( ) ;
0 commit comments