Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/astro/src/index.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export declare function init(options: Options | clientSdk.BrowserOptions | NodeO

export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
export declare const spanStreamingIntegration: typeof clientSdk.spanStreamingIntegration;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Types drop public integration export

Medium Severity

Removing the explicit spanStreamingIntegration re-export from framework index.types.ts files drops it from the public type surface. TypeScript export * from both client and server omits colliding names, so consumers of packages such as @sentry/astro and @sentry/nextjs can no longer import it. This is flagged because the review rules treat removal of a publicly exported function without a deprecation notice as a breaking change. The same explicit re-export is still required for other shared core symbols such as withStaticSpan.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 5f6ffb5. Configure here.

export declare const startSpan: typeof clientSdk.startSpan;
export declare const startSpanManual: typeof clientSdk.startSpanManual;
export declare const startInactiveSpan: typeof clientSdk.startInactiveSpan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
startSpan,
startSpanManual,
withActiveSpan,
spanStreamingIntegration,
} from '@sentry/core/browser';

export {
Expand All @@ -29,7 +30,6 @@ export { elementTimingIntegration } from '@sentry/browser-utils';
export { reportPageLoaded } from './tracing/reportPageLoaded';
export { setActiveSpanInBrowser } from './tracing/setActiveSpan';

export { spanStreamingIntegration } from '@sentry/core/browser';
export { fetchStreamPerformanceIntegration } from './integrations/fetchStreamPerformance';
export { webVitalsIntegration } from './integrations/webVitals';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export {
logger,
consoleLoggingIntegration,
metrics,
spanStreamingIntegration,
} from '@sentry/core/browser';

export {
Expand All @@ -30,7 +31,6 @@ export { elementTimingIntegration } from '@sentry/browser-utils';
export { reportPageLoaded } from './tracing/reportPageLoaded';
export { setActiveSpanInBrowser } from './tracing/setActiveSpan';

export { spanStreamingIntegration } from '@sentry/core/browser';
export { fetchStreamPerformanceIntegration } from './integrations/fetchStreamPerformance';
export { webVitalsIntegration } from './integrations/webVitals';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export {
withActiveSpan,
getSpanDescendants,
setMeasurement,
spanStreamingIntegration,
} from '@sentry/core/browser';

export {
Expand All @@ -36,7 +37,6 @@ export { setActiveSpanInBrowser } from './tracing/setActiveSpan';

export { reportPageLoaded } from './tracing/reportPageLoaded';

export { spanStreamingIntegration } from '@sentry/core/browser';
export { fetchStreamPerformanceIntegration } from './integrations/fetchStreamPerformance';
export { webVitalsIntegration } from './integrations/webVitals';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
startSpan,
startSpanManual,
withActiveSpan,
spanStreamingIntegration,
} from '@sentry/core/browser';

export {
Expand All @@ -29,7 +30,6 @@ export { elementTimingIntegration } from '@sentry/browser-utils';
export { reportPageLoaded } from './tracing/reportPageLoaded';
export { setActiveSpanInBrowser } from './tracing/setActiveSpan';

export { spanStreamingIntegration } from '@sentry/core/browser';
export { fetchStreamPerformanceIntegration } from './integrations/fetchStreamPerformance';
export { webVitalsIntegration } from './integrations/webVitals';

Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/index.bundle.tracing.replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export {
withActiveSpan,
getSpanDescendants,
setMeasurement,
spanStreamingIntegration,
} from '@sentry/core/browser';

export {
Expand All @@ -35,7 +36,6 @@ export { elementTimingIntegrationShim as elementTimingIntegration };
export { reportPageLoaded } from './tracing/reportPageLoaded';
export { setActiveSpanInBrowser } from './tracing/setActiveSpan';

export { spanStreamingIntegration } from '@sentry/core/browser';
export { fetchStreamPerformanceIntegration } from './integrations/fetchStreamPerformance';
export { webVitalsIntegration } from './integrations/webVitals';

Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/index.bundle.tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export {
withActiveSpan,
getSpanDescendants,
setMeasurement,
spanStreamingIntegration,
} from '@sentry/core/browser';

export {
Expand All @@ -37,7 +38,6 @@ export { setActiveSpanInBrowser } from './tracing/setActiveSpan';

export { reportPageLoaded } from './tracing/reportPageLoaded';

export { spanStreamingIntegration } from '@sentry/core/browser';
export { fetchStreamPerformanceIntegration } from './integrations/fetchStreamPerformance';
export { webVitalsIntegration } from './integrations/webVitals';

Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export { elementTimingIntegration, getAbsoluteUrl, isBotUserAgent } from '@sentr
export { normalizeStringifyValue } from './normalizeStringifyValue';
export { reportPageLoaded } from './tracing/reportPageLoaded';
export { setActiveSpanInBrowser } from './tracing/setActiveSpan';
export { spanStreamingIntegration } from '@sentry/core/browser';
export { fetchStreamPerformanceIntegration } from './integrations/fetchStreamPerformance';
export { webVitalsIntegration } from './integrations/webVitals';
export { userTimingIntegration } from './integrations/usertiming';
Expand Down Expand Up @@ -73,6 +72,7 @@ export {
featureFlagsIntegration,
logger,
metrics,
spanStreamingIntegration,
} from '@sentry/core/browser';
export type { Span, FeatureFlagsIntegration } from '@sentry/core/browser';
export { makeBrowserOfflineTransport } from './transports/offline';
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/browser-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export {

export { startIdleSpan } from './tracing/idleSpan';

export { spanStreamingIntegration } from './integrations/browserSpanStreaming';

export { supportsNativeFetch } from './utils/supports';
export type { XhrBreadcrumbData, XhrBreadcrumbHint } from './types/breadcrumb';
export type { BrowserClientReplayOptions } from './types/browseroptions';
1 change: 0 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ export * from './browser-exports';
// We need to re-export them here to disambiguate the exports for anyone importing
// from `@sentry/core`. Server exports win over browser exports.
export { startSpan, startInactiveSpan, startSpanManual } from './server-exports';
export { spanStreamingIntegration } from './server-exports';
44 changes: 0 additions & 44 deletions packages/core/src/integrations/browserSpanStreaming.ts

This file was deleted.

30 changes: 29 additions & 1 deletion packages/core/src/integrations/spanStreaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@ import { hasSpanStreamingEnabled } from '../tracing/spans/hasSpanStreamingEnable
import { SpanBuffer } from '../tracing/spans/spanBuffer';
import { debug } from '../utils/debug-logger';
import { spanIsSampled } from '../utils/spanUtils';
import { safeUnref } from '../utils/timer';

export const INTEGRATION_NAME = 'SpanStreaming' as const;

export const spanStreamingIntegration = defineIntegration(() => {
interface SpanStreamingOptions {
/**
* When enabled, a trace is flushed shortly after its segment span ends, rather than relying solely
* on the buffer's timeout/size thresholds or an explicit `flushTraceSpans` emission.
*
*
* @default true
*/
flushOnSegmentEnd?: boolean;
}

export const spanStreamingIntegration = defineIntegration((options: SpanStreamingOptions = {}) => {
Comment thread
cursor[bot] marked this conversation as resolved.
const flushOnSegmentEnd = options.flushOnSegmentEnd ?? true;
Comment thread
sentry[bot] marked this conversation as resolved.

return {
name: INTEGRATION_NAME,

Expand All @@ -33,6 +47,20 @@ export const spanStreamingIntegration = defineIntegration(() => {
client.on('flushTraceSpans', traceId => {
buffer.flush(traceId);
});

if (flushOnSegmentEnd) {
// Also flush the trace when the segment span ends to ensure things are sent timely.
client.on('afterSegmentSpanEnd', segmentSpan => {
const traceId = segmentSpan.spanContext().traceId;
// `safeUnref` so an enabled `flushOnSegmentEnd` on a server runtime can't keep the
// process alive until the timer fires (no-op in the browser, where it's the default path).
safeUnref(
setTimeout(() => {
buffer.flush(traceId);
}, 500),
);
});
}
Comment thread
cursor[bot] marked this conversation as resolved.
},
};
}) satisfies IntegrationFn;
1 change: 0 additions & 1 deletion packages/core/src/server-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

export { startSpan, startInactiveSpan, startSpanManual } from './tracing/trace';
export { spanStreamingIntegration } from './integrations/spanStreaming';

export type { ServerRuntimeClientOptions } from './server-runtime-client';
export { ServerRuntimeClient } from './server-runtime-client';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/shared-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export type { FeatureFlagsIntegration } from './integrations/featureFlags';
export { featureFlagsIntegration } from './integrations/featureFlags';
export { growthbookIntegration } from './integrations/featureFlags';
export { conversationIdIntegration } from './integrations/conversationId';
export { spanStreamingIntegration } from './integrations/spanStreaming';
export { profiler } from './profiling';
// eslint thinks the entire function is deprecated (while only one overload is actually deprecated)
// Therefore:
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tracing/browserSpanApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Client } from '../client';
import { getClient } from '../currentScopes';
import { spanStreamingIntegration } from '../integrations/browserSpanStreaming';
import { spanStreamingIntegration } from '../integrations/spanStreaming';
import type { Span } from '../types/span';
import type { StartSpanOptions } from '../types/startSpanOptions';
import { hasSpanStreamingEnabled } from './spans/hasSpanStreamingEnabled';
Expand Down
13 changes: 10 additions & 3 deletions packages/core/test/exports.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { describe, expect, it } from 'vitest';
import * as browserEntry from '../src/browser';
import * as rootEntry from '../src/index';
import { spanStreamingIntegration as browserSpanStreamingIntegration } from '../src/integrations/browserSpanStreaming';
import { spanStreamingIntegration as plainSpanStreamingIntegration } from '../src/integrations/spanStreaming';
import { spanStreamingIntegration } from '../src/integrations/spanStreaming';
import * as serverEntry from '../src/server';
import * as browserSpanApi from '../src/tracing/browserSpanApi';
import {
Expand All @@ -20,7 +19,6 @@ describe('entry point resolution', () => {
['startSpan', plainStartSpan, browserSpanApi.startSpan],
['startInactiveSpan', plainStartInactiveSpan, browserSpanApi.startInactiveSpan],
['startSpanManual', plainStartSpanManual, browserSpanApi.startSpanManual],
['spanStreamingIntegration', plainSpanStreamingIntegration, browserSpanStreamingIntegration],
] as const;

it.each(cases)('`%s`: the root entry serves the plain variant', (name, plain) => {
Expand All @@ -35,4 +33,13 @@ describe('entry point resolution', () => {
expect(browserEntry[name]).toBe(browser);
expect(browserEntry[name]).not.toBe(plain);
});

// `spanStreamingIntegration` is a single shared implementation, exported from both
// `browser-exports` and `server-exports`. Because both re-export the identical binding, it is not
// an ambiguous star export and needs no explicit disambiguation in `index.ts` — every entry
// resolves to the exact same function.
it.each(['index', 'server', 'browser'] as const)('`spanStreamingIntegration`: the %s entry serves it', entry => {
const entries = { index: rootEntry, server: serverEntry, browser: browserEntry };
expect(entries[entry].spanStreamingIntegration).toBe(spanStreamingIntegration);
});
});
Loading
Loading