Skip to content

Commit efada28

Browse files
committed
test: remove circular dep
1 parent b95becd commit efada28

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

packages/browser/src/profiling/hubextensions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import type { Transaction } from '@sentry/types';
44
import { logger, uuid4 } from '@sentry/utils';
55

66
import { WINDOW } from '../helpers';
7-
import { addToProfileQueue } from './integration';
87
import type {
98
JSSelfProfile,
109
JSSelfProfiler,
1110
JSSelfProfilerConstructor,
1211
ProcessedJSSelfProfile,
1312
} from './jsSelfProfiling';
14-
import { isValidSampleRate } from './utils';
13+
import { addToProfileQueue , isValidSampleRate } from './utils';
14+
1515

1616
export const MAX_PROFILE_DURATION_MS = 30_000;
1717
// Keep a flag value to avoid re-initializing the profiler constructor. If it fails
@@ -270,3 +270,5 @@ export function wrapTransactionWithProfiling(transaction: Transaction): Transact
270270
transaction.finish = profilingWrappedTransactionFinish;
271271
return transaction;
272272
}
273+
274+

packages/browser/src/profiling/integration.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,8 @@ import { logger } from '@sentry/utils';
44

55
import type { BrowserClient } from './../client';
66
import { wrapTransactionWithProfiling } from './hubextensions';
7-
import type { ProcessedJSSelfProfile } from './jsSelfProfiling';
87
import type { ProfiledEvent } from './utils';
9-
import { addProfilesToEnvelope, createProfilingEvent, findProfiledTransactionsFromEnvelope } from './utils';
10-
11-
const MAX_PROFILE_QUEUE_SIZE = 50;
12-
const PROFILE_QUEUE: ProcessedJSSelfProfile[] = [];
13-
14-
/**
15-
* Adds the profile to the queue of profiles to be sent
16-
*/
17-
export function addToProfileQueue(profile: ProcessedJSSelfProfile): void {
18-
PROFILE_QUEUE.push(profile);
19-
20-
// We only want to keep the last n profiles in the queue.
21-
if (PROFILE_QUEUE.length > MAX_PROFILE_QUEUE_SIZE) {
22-
PROFILE_QUEUE.shift();
23-
}
24-
}
8+
import { addProfilesToEnvelope, createProfilingEvent, findProfiledTransactionsFromEnvelope,PROFILE_QUEUE } from './utils';
259

2610
/**
2711
* Browser profiling integration. Stores any event that has contexts["profile"]["profile_id"]

packages/browser/src/profiling/utils.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,17 @@ export function createProfilingEvent(profile: ProcessedJSSelfProfile, event: Pro
450450

451451
return createProfilePayload(event, profile);
452452
}
453+
454+
const MAX_PROFILE_QUEUE_SIZE = 50;
455+
export const PROFILE_QUEUE: ProcessedJSSelfProfile[] = [];
456+
/**
457+
* Adds the profile to the queue of profiles to be sent
458+
*/
459+
export function addToProfileQueue(profile: ProcessedJSSelfProfile): void {
460+
PROFILE_QUEUE.push(profile);
461+
462+
// We only want to keep the last n profiles in the queue.
463+
if (PROFILE_QUEUE.length > MAX_PROFILE_QUEUE_SIZE) {
464+
PROFILE_QUEUE.shift();
465+
}
466+
}

0 commit comments

Comments
 (0)