Skip to content

Commit 8e38516

Browse files
committed
Merge branch 'develop' into feat-replay-add-more-dom-attributes-on-click
2 parents eb89070 + 3269a06 commit 8e38516

File tree

5 files changed

+84
-33
lines changed

5 files changed

+84
-33
lines changed

packages/core/src/tracing/idletransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ export class IdleTransaction extends Transaction {
239239
restartOnChildSpanChange: true,
240240
},
241241
): void {
242+
this._idleTimeoutCanceledPermanently = restartOnChildSpanChange === false;
242243
if (this._idleTimeoutID) {
243244
clearTimeout(this._idleTimeoutID);
244245
this._idleTimeoutID = undefined;
245-
this._idleTimeoutCanceledPermanently = restartOnChildSpanChange === false;
246246

247247
if (Object.keys(this.activities).length === 0 && this._idleTimeoutCanceledPermanently) {
248248
this._finishReason = IDLE_TRANSACTION_FINISH_REASONS[5];
@@ -269,7 +269,7 @@ export class IdleTransaction extends Transaction {
269269
* @param spanId The span id that represents the activity
270270
*/
271271
private _pushActivity(spanId: string): void {
272-
this.cancelIdleTimeout();
272+
this.cancelIdleTimeout(undefined, { restartOnChildSpanChange: !this._idleTimeoutCanceledPermanently });
273273
__DEBUG_BUILD__ && logger.log(`[Tracing] pushActivity: ${spanId}`);
274274
this.activities[spanId] = true;
275275
__DEBUG_BUILD__ && logger.log('[Tracing] new activities count', Object.keys(this.activities).length);
Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,14 @@
11
export * from './exports';
22

3-
import { addExtensionMethods } from './extensions';
4-
import * as Integrations from './node/integrations';
5-
6-
export { Integrations };
7-
8-
// BrowserTracing is already exported as part of `Integrations` above (and for the moment will remain so for
9-
// backwards compatibility), but that interferes with treeshaking, so we also export it separately
10-
// here.
11-
//
12-
// Previously we expected users to import tracing integrations like
13-
//
14-
// import { Integrations } from '@sentry/tracing';
15-
// const instance = new Integrations.BrowserTracing();
16-
//
17-
// This makes the integrations unable to be treeshaken though. To address this, we now have
18-
// this individual export. We now expect users to consume BrowserTracing like so:
19-
//
20-
// import { BrowserTracing } from '@sentry/tracing';
21-
// const instance = new BrowserTracing();
22-
//
23-
// For an example of of the new usage of BrowserTracing, see @sentry/nextjs index.client.ts
24-
export { BrowserTracing } from './browser';
3+
export { Apollo, Express, GraphQL, Mongo, Mysql, Postgres, Prisma } from './node/integrations';
254

265
export {
6+
BrowserTracing,
277
BROWSER_TRACING_INTEGRATION_ID,
288
instrumentOutgoingRequests,
299
defaultRequestInstrumentationOptions,
3010
} from './browser';
3111

3212
export type { RequestInstrumentationOptions } from './browser';
3313

34-
export { addExtensionMethods };
14+
export { addExtensionMethods } from './extensions';

packages/tracing-internal/src/node/integrations/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,3 @@ export { Mongo } from './mongo';
55
export { Prisma } from './prisma';
66
export { GraphQL } from './graphql';
77
export { Apollo } from './apollo';
8-
9-
// TODO(v8): Remove this export
10-
// Please see `src/index.ts` for more details.
11-
export { BrowserTracing } from '../../browser';

packages/tracing/src/index.ts

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,49 @@
1-
export * from '@sentry-internal/tracing';
1+
export {
2+
// BrowserTracing is already exported as part of `Integrations` below (and for the moment will remain so for
3+
// backwards compatibility), but that interferes with treeshaking, so we also export it separately
4+
// here.
5+
BrowserTracing,
6+
BROWSER_TRACING_INTEGRATION_ID,
7+
IdleTransaction,
8+
Span,
9+
// eslint-disable-next-line deprecation/deprecation
10+
SpanStatus,
11+
TRACEPARENT_REGEXP,
12+
Transaction,
13+
addExtensionMethods,
14+
defaultRequestInstrumentationOptions,
15+
extractTraceparentData,
16+
instrumentOutgoingRequests,
17+
getActiveTransaction,
18+
hasTracingEnabled,
19+
spanStatusfromHttpCode,
20+
startIdleTransaction,
21+
stripUrlQueryAndFragment,
22+
} from '@sentry-internal/tracing';
23+
export type { RequestInstrumentationOptions, SpanStatusType } from '@sentry-internal/tracing';
224

3-
import { addExtensionMethods } from '@sentry-internal/tracing';
25+
import {
26+
addExtensionMethods,
27+
Apollo,
28+
BrowserTracing,
29+
Express,
30+
GraphQL,
31+
Mongo,
32+
Mysql,
33+
Postgres,
34+
Prisma,
35+
} from '@sentry-internal/tracing';
36+
37+
export const Integrations = {
38+
BrowserTracing: BrowserTracing,
39+
Apollo: Apollo,
40+
Express: Express,
41+
GraphQL: GraphQL,
42+
Mongo: Mongo,
43+
Mysql: Mysql,
44+
Postgres: Postgres,
45+
Prisma: Prisma,
46+
};
447

548
// Treeshakable guard to remove all code related to tracing
649
declare const __SENTRY_TRACING__: boolean;
@@ -10,5 +53,3 @@ if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
1053
// We are patching the global object with our hub extension methods
1154
addExtensionMethods();
1255
}
13-
14-
export { addExtensionMethods };

packages/tracing/test/idletransaction.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,40 @@ describe('IdleTransaction', () => {
248248
});
249249

250250
describe('cancelIdleTimeout', () => {
251+
it('permanent idle timeout cancel is not restarted by child span start', () => {
252+
const idleTimeout = 10;
253+
const transaction = new IdleTransaction({ name: 'foo', startTimestamp: 1234 }, hub, idleTimeout);
254+
transaction.initSpanRecorder(10);
255+
256+
const firstSpan = transaction.startChild({});
257+
transaction.cancelIdleTimeout(undefined, { restartOnChildSpanChange: false });
258+
const secondSpan = transaction.startChild({});
259+
firstSpan.finish();
260+
secondSpan.finish();
261+
262+
expect(transaction.endTimestamp).toBeDefined();
263+
});
264+
265+
it('permanent idle timeout cancel finished the transaction with the last child', () => {
266+
const idleTimeout = 10;
267+
const transaction = new IdleTransaction({ name: 'foo', startTimestamp: 1234 }, hub, idleTimeout);
268+
transaction.initSpanRecorder(10);
269+
270+
const firstSpan = transaction.startChild({});
271+
transaction.cancelIdleTimeout(undefined, { restartOnChildSpanChange: false });
272+
const secondSpan = transaction.startChild({});
273+
const thirdSpan = transaction.startChild({});
274+
275+
firstSpan.finish();
276+
expect(transaction.endTimestamp).toBeUndefined();
277+
278+
secondSpan.finish();
279+
expect(transaction.endTimestamp).toBeUndefined();
280+
281+
thirdSpan.finish();
282+
expect(transaction.endTimestamp).toBeDefined();
283+
});
284+
251285
it('permanent idle timeout cancel finishes transaction if there are no activities', () => {
252286
const idleTimeout = 10;
253287
const transaction = new IdleTransaction({ name: 'foo', startTimestamp: 1234 }, hub, idleTimeout);

0 commit comments

Comments
 (0)