Skip to content

Commit 73aae9b

Browse files
committed
ref(core): Remove startTransaction & finishTransaction hooks
They are no longer needed/used.
1 parent 5d76558 commit 73aae9b

File tree

5 files changed

+10
-61
lines changed

5 files changed

+10
-61
lines changed

packages/core/src/baseclient.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -417,12 +417,6 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
417417
// Keep on() & emit() signatures in sync with types' client.ts interface
418418
/* eslint-disable @typescript-eslint/unified-signatures */
419419

420-
/** @inheritdoc */
421-
public on(hook: 'startTransaction', callback: (transaction: Transaction) => void): void;
422-
423-
/** @inheritdoc */
424-
public on(hook: 'finishTransaction', callback: (transaction: Transaction) => void): void;
425-
426420
/** @inheritdoc */
427421
public on(hook: 'spanStart', callback: (span: Span) => void): void;
428422

@@ -476,12 +470,6 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
476470
this._hooks[hook].push(callback);
477471
}
478472

479-
/** @inheritdoc */
480-
public emit(hook: 'startTransaction', transaction: Transaction): void;
481-
482-
/** @inheritdoc */
483-
public emit(hook: 'finishTransaction', transaction: Transaction): void;
484-
485473
/** @inheritdoc */
486474
public emit(hook: 'spanStart', span: Span): void;
487475

packages/core/src/tracing/transaction.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,6 @@ export class Transaction extends SentrySpan implements TransactionInterface {
224224

225225
// eslint-disable-next-line deprecation/deprecation
226226
const client = this._hub.getClient();
227-
if (client) {
228-
client.emit('finishTransaction', this);
229-
}
230227

231228
if (this._sampled !== true) {
232229
// At this point if `sampled !== true` we want to discard the transaction.

packages/core/test/lib/base.test.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,20 +1935,6 @@ describe('BaseClient', () => {
19351935
] as const;
19361936

19371937
describe.each(scenarios)('with client %s', (_, client) => {
1938-
it('should call a startTransaction hook', () => {
1939-
expect.assertions(1);
1940-
1941-
const mockTransaction = {
1942-
traceId: '86f39e84263a4de99c326acab3bfe3bd',
1943-
} as Transaction;
1944-
1945-
client.on('startTransaction', transaction => {
1946-
expect(transaction).toEqual(mockTransaction);
1947-
});
1948-
1949-
client.emit('startTransaction', mockTransaction);
1950-
});
1951-
19521938
it('should call a beforeEnvelope hook', () => {
19531939
expect.assertions(1);
19541940

packages/replay/src/replay.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { EventType, record } from '@sentry-internal/rrweb';
33
import {
44
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
55
captureException,
6+
getActiveSpan,
67
getClient,
78
getCurrentScope,
9+
getRootSpan,
810
spanToJSON,
911
} from '@sentry/core';
10-
import type { ReplayRecordingMode, Transaction } from '@sentry/types';
12+
import type { ReplayRecordingMode, Span, Transaction } from '@sentry/types';
1113
import { logger } from '@sentry/utils';
1214

1315
import {
@@ -87,10 +89,10 @@ export class ReplayContainer implements ReplayContainerInterface {
8789
public recordingMode: ReplayRecordingMode;
8890

8991
/**
90-
* The current or last active transcation.
92+
* The current or last active span.
9193
* This is only available when performance is enabled.
9294
*/
93-
public lastTransaction?: Transaction;
95+
public lastActiveSpan?: Span;
9496

9597
/**
9698
* These are here so we can overwrite them in tests etc.
@@ -720,16 +722,16 @@ export class ReplayContainer implements ReplayContainerInterface {
720722
* This is only available if performance is enabled, and if an instrumented router is used.
721723
*/
722724
public getCurrentRoute(): string | undefined {
723-
// eslint-disable-next-line deprecation/deprecation
724-
const lastTransaction = this.lastTransaction || getCurrentScope().getTransaction();
725+
const lastActiveSpan = this.lastActiveSpan || getActiveSpan();
726+
const lastRootSpan = lastActiveSpan && getRootSpan(lastActiveSpan);
725727

726-
const attributes = (lastTransaction && spanToJSON(lastTransaction).data) || {};
728+
const attributes = (lastRootSpan && spanToJSON(lastRootSpan).data) || {};
727729
const source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
728-
if (!lastTransaction || !source || !['route', 'custom'].includes(source)) {
730+
if (!lastRootSpan || !source || !['route', 'custom'].includes(source)) {
729731
return undefined;
730732
}
731733

732-
return spanToJSON(lastTransaction).description;
734+
return spanToJSON(lastRootSpan).description;
733735
}
734736

735737
/**

packages/types/src/client.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,6 @@ export interface Client<O extends ClientOptions = ClientOptions> {
185185
// HOOKS
186186
/* eslint-disable @typescript-eslint/unified-signatures */
187187

188-
/**
189-
* Register a callback for transaction start.
190-
* Receives the transaction as argument.
191-
*/
192-
on(hook: 'startTransaction', callback: (transaction: Transaction) => void): void;
193-
194-
/**
195-
* Register a callback for transaction finish.
196-
* Receives the transaction as argument.
197-
*/
198-
on(hook: 'finishTransaction', callback: (transaction: Transaction) => void): void;
199-
200188
/**
201189
* Register a callback for whenever a span is started.
202190
* Receives the span as argument.
@@ -278,18 +266,6 @@ export interface Client<O extends ClientOptions = ClientOptions> {
278266
*/
279267
on(hook: 'close', callback: () => void): void;
280268

281-
/**
282-
* Fire a hook event for transaction start.
283-
* Expects to be given a transaction as the second argument.
284-
*/
285-
emit(hook: 'startTransaction', transaction: Transaction): void;
286-
287-
/**
288-
* Fire a hook event for transaction finish.
289-
* Expects to be given a transaction as the second argument.
290-
*/
291-
emit(hook: 'finishTransaction', transaction: Transaction): void;
292-
293269
/** Fire a hook whener a span starts. */
294270
emit(hook: 'spanStart', span: Span): void;
295271

0 commit comments

Comments
 (0)