Skip to content

Commit c72641c

Browse files
committed
ref(browser): Move browserTracing into browser pkg
1 parent 481debb commit c72641c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+255
-249
lines changed

dev-packages/browser-integration-tests/suites/tracing/metrics/pageload-browser-spans/test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ sentryTest('should add browser-related spans to pageload transaction', async ({
1414
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
1515
const browserSpans = eventData.spans?.filter(({ op }) => op === 'browser');
1616

17-
// Spans `connect`, `cache` and `DNS` are not always inside `pageload` transaction.
17+
// Spans `domContentLoadedEvent`, `connect`, `cache` and `DNS` are not
18+
// always inside `pageload` transaction.
1819
expect(browserSpans?.length).toBeGreaterThanOrEqual(4);
1920

20-
['domContentLoadedEvent', 'loadEvent', 'request', 'response'].forEach(eventDesc =>
21+
['loadEvent', 'request', 'response'].forEach(eventDesc =>
2122
expect(browserSpans).toContainEqual(
2223
expect.objectContaining({
2324
description: eventDesc,

packages/browser-utils/.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ module.exports = {
1111
},
1212
},
1313
{
14-
files: ['src/browser/web-vitals/**'],
14+
files: ['src/metrics/**'],
1515
rules: {
1616
'@typescript-eslint/explicit-function-return-type': 'off',
17+
'@typescript-eslint/no-non-null-assertion': 'off',
1718
},
1819
},
1920
],

packages/browser-utils/src/browser/index.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/browser-utils/src/index.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
export {
2-
browserTracingIntegration,
3-
startBrowserTracingNavigationSpan,
4-
startBrowserTracingPageLoadSpan,
5-
BROWSER_TRACING_INTEGRATION_ID,
6-
instrumentOutgoingRequests,
7-
defaultRequestInstrumentationOptions,
82
addPerformanceInstrumentationHandler,
93
addClsInstrumentationHandler,
104
addFidInstrumentationHandler,
115
addTtfbInstrumentationHandler,
126
addLcpInstrumentationHandler,
13-
} from './browser';
7+
} from './metrics/instrument';
8+
9+
export {
10+
addPerformanceEntries,
11+
startTrackingInteractions,
12+
startTrackingLongTasks,
13+
startTrackingWebVitals,
14+
} from './metrics/browserMetrics';
1415

1516
export { addClickKeypressInstrumentationHandler } from './instrument/dom';
1617

@@ -20,5 +21,3 @@ export {
2021
addXhrInstrumentationHandler,
2122
SENTRY_XHR_DATA_KEY,
2223
} from './instrument/xhr';
23-
24-
export type { RequestInstrumentationOptions } from './browser';

packages/browser-utils/src/instrument/dom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { HandlerDataDom } from '@sentry/types';
22

33
import { addHandler, addNonEnumerableProperty, fill, maybeInstrument, triggerHandlers, uuid4 } from '@sentry/utils';
4-
import { WINDOW } from '../browser/types';
4+
import { WINDOW } from '../metrics/types';
55

66
type SentryWrappedTarget = HTMLElement & { _sentryId?: string };
77

packages/browser-utils/src/instrument/history.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { HandlerDataHistory } from '@sentry/types';
22
import { addHandler, fill, maybeInstrument, supportsHistory, triggerHandlers } from '@sentry/utils';
3-
import { WINDOW } from '../browser/types';
3+
import { WINDOW } from '../metrics/types';
44

55
let lastHref: string | undefined;
66

packages/browser-utils/src/instrument/xhr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { HandlerDataXhr, SentryWrappedXMLHttpRequest, WrappedFunction } from '@sentry/types';
22

33
import { addHandler, fill, isString, maybeInstrument, triggerHandlers } from '@sentry/utils';
4-
import { WINDOW } from '../browser/types';
4+
import { WINDOW } from '../metrics/types';
55

66
export const SENTRY_XHR_DATA_KEY = '__sentry_xhr_v3__';
77

packages/browser-utils/src/browser/metrics/index.ts renamed to packages/browser-utils/src/metrics/browserMetrics.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ import type { Measurements, Span, SpanAttributes, StartSpanOptions } from '@sent
55
import { browserPerformanceTimeOrigin, getComponentName, htmlTreeAsString, logger, parseUrl } from '@sentry/utils';
66

77
import { spanToJSON } from '@sentry/core';
8-
import { DEBUG_BUILD } from '../../debug-build';
8+
import { DEBUG_BUILD } from '../debug-build';
99
import {
1010
addClsInstrumentationHandler,
1111
addFidInstrumentationHandler,
1212
addLcpInstrumentationHandler,
1313
addPerformanceInstrumentationHandler,
1414
addTtfbInstrumentationHandler,
15-
} from '../instrument';
16-
import { WINDOW } from '../types';
17-
import { getNavigationEntry } from '../web-vitals/lib/getNavigationEntry';
18-
import { getVisibilityWatcher } from '../web-vitals/lib/getVisibilityWatcher';
15+
} from './instrument';
16+
import { WINDOW } from './types';
1917
import { isMeasurementValue, startAndEndSpan } from './utils';
18+
import { getNavigationEntry } from './web-vitals/lib/getNavigationEntry';
19+
import { getVisibilityWatcher } from './web-vitals/lib/getVisibilityWatcher';
2020

2121
interface NavigatorNetworkInformation {
2222
readonly connection?: NetworkInformation;

packages/browser-utils/src/browser/web-vitals/getFID.ts renamed to packages/browser-utils/src/metrics/web-vitals/getFID.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ export const FIDThresholds: MetricRatingThresholds = [100, 300];
3535
* _**Important:** since FID is only reported after the user interacts with the
3636
* page, it's possible that it will not be reported for some page loads._
3737
*/
38-
export const onFID = (onReport: FIDReportCallback, opts: ReportOpts = {}): void => {
38+
export const onFID = (onReport: FIDReportCallback, opts: ReportOpts = {}) => {
3939
whenActivated(() => {
4040
const visibilityWatcher = getVisibilityWatcher();
4141
const metric = initMetric('FID');
4242
// eslint-disable-next-line prefer-const
4343
let report: ReturnType<typeof bindReporter>;
4444

45-
const handleEntry = (entry: PerformanceEventTiming) => {
45+
const handleEntry = (entry: PerformanceEventTiming): void => {
4646
// Only report if the page wasn't hidden prior to the first input.
4747
if (entry.startTime < visibilityWatcher.firstHiddenTime) {
4848
metric.value = entry.processingStart - entry.startTime;

packages/browser-utils/test/browser/backgroundtab.test.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.

packages/browser-utils/test/browser/metrics/index.test.ts renamed to packages/browser-utils/test/browser/browserMetrics.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import {
99
spanToJSON,
1010
} from '@sentry/core';
1111
import type { Span } from '@sentry/types';
12-
import type { ResourceEntry } from '../../../src/browser/metrics';
13-
import { _addMeasureSpans, _addResourceSpans } from '../../../src/browser/metrics';
14-
import { WINDOW } from '../../../src/browser/types';
15-
import { TestClient, getDefaultClientOptions } from '../../utils/TestClient';
12+
import type { ResourceEntry } from '../../src/metrics/browserMetrics';
13+
import { _addMeasureSpans, _addResourceSpans } from '../../src/metrics/browserMetrics';
14+
import { WINDOW } from '../../src/metrics/types';
15+
import { TestClient, getDefaultClientOptions } from '../utils/TestClient';
1616

1717
const mockWindowLocation = {
1818
ancestorOrigins: {},

packages/browser-utils/test/browser/metrics/utils.test.ts renamed to packages/browser-utils/test/browser/utils.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
setCurrentClient,
77
spanToJSON,
88
} from '@sentry/core';
9-
import { startAndEndSpan } from '../../../src/browser/metrics/utils';
10-
import { TestClient, getDefaultClientOptions } from '../../utils/TestClient';
9+
import { startAndEndSpan } from '../../src/metrics/utils';
10+
import { TestClient, getDefaultClientOptions } from '../utils/TestClient';
1111

1212
describe('startAndEndSpan()', () => {
1313
beforeEach(() => {

packages/browser/src/index.bundle.tracing.replay.feedback.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import {
2-
browserTracingIntegration,
3-
startBrowserTracingNavigationSpan,
4-
startBrowserTracingPageLoadSpan,
5-
} from '@sentry-internal/browser-utils';
61
import { feedbackIntegration, getFeedback } from '@sentry-internal/feedback';
72
import { feedbackModalIntegration } from '@sentry-internal/feedback-modal';
83
import { feedbackScreenshotIntegration } from '@sentry-internal/feedback-screenshot';
94
import { replayIntegration } from '@sentry-internal/replay';
105
import { addTracingExtensions } from '@sentry/core';
6+
import {
7+
browserTracingIntegration,
8+
startBrowserTracingNavigationSpan,
9+
startBrowserTracingPageLoadSpan,
10+
} from './tracing/browserTracingIntegration';
1111

1212
// We are patching the global object with our hub extension methods
1313
addTracingExtensions();

packages/browser/src/index.bundle.tracing.replay.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import {
2-
browserTracingIntegration,
3-
startBrowserTracingNavigationSpan,
4-
startBrowserTracingPageLoadSpan,
5-
} from '@sentry-internal/browser-utils';
61
import {
72
feedbackIntegrationShim,
83
feedbackModalIntegrationShim,
94
feedbackScreenshotIntegrationShim,
105
} from '@sentry-internal/integration-shims';
116
import { replayIntegration } from '@sentry-internal/replay';
127
import { addTracingExtensions } from '@sentry/core';
8+
import {
9+
browserTracingIntegration,
10+
startBrowserTracingNavigationSpan,
11+
startBrowserTracingPageLoadSpan,
12+
} from './tracing/browserTracingIntegration';
1313

1414
// We are patching the global object with our hub extension methods
1515
addTracingExtensions();

packages/browser/src/index.bundle.tracing.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import {
2-
browserTracingIntegration,
3-
startBrowserTracingNavigationSpan,
4-
startBrowserTracingPageLoadSpan,
5-
} from '@sentry-internal/browser-utils';
61
// This is exported so the loader does not fail when switching off Replay
72
import {
83
feedbackIntegrationShim,
@@ -11,6 +6,11 @@ import {
116
replayIntegrationShim,
127
} from '@sentry-internal/integration-shims';
138
import { addTracingExtensions } from '@sentry/core';
9+
import {
10+
browserTracingIntegration,
11+
startBrowserTracingNavigationSpan,
12+
startBrowserTracingPageLoadSpan,
13+
} from './tracing/browserTracingIntegration';
1414

1515
// We are patching the global object with our hub extension methods
1616
addTracingExtensions();

packages/browser/src/index.ts

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,47 @@
11
export * from './exports';
22

3-
export { reportingObserverIntegration } from './integrations/reportingobserver';
4-
export { httpClientIntegration } from './integrations/httpclient';
5-
export { contextLinesIntegration } from './integrations/contextlines';
6-
73
export {
4+
addTracingExtensions,
5+
getActiveSpan,
6+
getRootSpan,
7+
startSpan,
8+
startInactiveSpan,
9+
startSpanManual,
10+
withActiveSpan,
11+
getSpanDescendants,
12+
setMeasurement,
13+
getSpanStatusFromHttpCode,
14+
setHttpStatus,
15+
makeMultiplexedTransport,
16+
moduleMetadataIntegration,
817
captureConsoleIntegration,
918
debugIntegration,
1019
extraErrorDataIntegration,
1120
rewriteFramesIntegration,
1221
sessionTimingIntegration,
1322
} from '@sentry/core';
1423

24+
export type { Span } from '@sentry/types';
25+
26+
export { reportingObserverIntegration } from './integrations/reportingobserver';
27+
export { httpClientIntegration } from './integrations/httpclient';
28+
export { contextLinesIntegration } from './integrations/contextlines';
29+
30+
export { makeBrowserOfflineTransport } from './transports/offline';
31+
32+
export {
33+
browserTracingIntegration,
34+
startBrowserTracingNavigationSpan,
35+
startBrowserTracingPageLoadSpan,
36+
} from './tracing/browserTracingIntegration';
37+
export {
38+
instrumentOutgoingRequests,
39+
defaultRequestInstrumentationOptions,
40+
} from './tracing/request';
41+
export type { RequestInstrumentationOptions } from './tracing/request';
42+
43+
export { browserProfilingIntegration } from './profiling/integration';
44+
1545
export {
1646
replayIntegration,
1747
getReplay,
@@ -27,7 +57,6 @@ export type {
2757
ReplaySpanFrame,
2858
ReplaySpanFrameEvent,
2959
} from '@sentry-internal/replay';
30-
3160
export { replayCanvasIntegration } from '@sentry-internal/replay-canvas';
3261

3362
export {
@@ -37,30 +66,3 @@ export {
3766
} from '@sentry-internal/feedback';
3867
export { feedbackModalIntegration } from '@sentry-internal/feedback-modal';
3968
export { feedbackScreenshotIntegration } from '@sentry-internal/feedback-screenshot';
40-
41-
export {
42-
defaultRequestInstrumentationOptions,
43-
instrumentOutgoingRequests,
44-
browserTracingIntegration,
45-
startBrowserTracingNavigationSpan,
46-
startBrowserTracingPageLoadSpan,
47-
} from '@sentry-internal/browser-utils';
48-
export type { RequestInstrumentationOptions } from '@sentry-internal/browser-utils';
49-
export {
50-
addTracingExtensions,
51-
getActiveSpan,
52-
getRootSpan,
53-
startSpan,
54-
startInactiveSpan,
55-
startSpanManual,
56-
withActiveSpan,
57-
getSpanDescendants,
58-
setMeasurement,
59-
getSpanStatusFromHttpCode,
60-
setHttpStatus,
61-
makeMultiplexedTransport,
62-
moduleMetadataIntegration,
63-
} from '@sentry/core';
64-
export type { Span } from '@sentry/types';
65-
export { makeBrowserOfflineTransport } from './transports/offline';
66-
export { browserProfilingIntegration } from './profiling/integration';

packages/browser-utils/src/browser/backgroundtab.ts renamed to packages/browser/src/tracing/backgroundtab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { spanToJSON } from '@sentry/core';
33
import { logger } from '@sentry/utils';
44

55
import { DEBUG_BUILD } from '../debug-build';
6-
import { WINDOW } from './types';
6+
import { WINDOW } from '../helpers';
77

88
/**
99
* Add a listener that cancels and finishes a transaction when the global

0 commit comments

Comments
 (0)